From dc83ea3bcbcfece8a0c5caeafcdd9f0854ffae6f Mon Sep 17 00:00:00 2001 From: Svetlana Abramenkova Date: Sun, 16 Dec 2018 10:46:35 +0300 Subject: Bench: Hide not .qml files from workspace view Added option into Preferences dialog that user can hide non QML files from workspace view Change-Id: Ib871edb8a322d710b69319c3b0f61a80c807a727 Fixes: AUTOSUITE-609 Reviewed-by: Nikolay Zamotaev --- src/bench/appearanceoptionpage.cpp | 55 ++++++++++++++++++++++++++++++++++ src/bench/appearanceoptionpage.h | 60 ++++++++++++++++++++++++++++++++++++++ src/bench/appearanceoptionpage.ui | 32 ++++++++++++++++++++ src/bench/bench.pro | 9 ++++-- src/bench/mainwindow.cpp | 3 ++ src/bench/optionsdialog.cpp | 10 +++++++ src/bench/optionsdialog.h | 5 ++++ src/widgets/workspaceview.cpp | 19 ++++++++++++ src/widgets/workspaceview.h | 2 ++ 9 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 src/bench/appearanceoptionpage.cpp create mode 100644 src/bench/appearanceoptionpage.h create mode 100644 src/bench/appearanceoptionpage.ui diff --git a/src/bench/appearanceoptionpage.cpp b/src/bench/appearanceoptionpage.cpp new file mode 100644 index 0000000..ab4da2f --- /dev/null +++ b/src/bench/appearanceoptionpage.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +#include "appearanceoptionpage.h" +#include "ui_appearanceoptionpage.h" + +AppearanceOptionPage::AppearanceOptionPage(QWidget *parent) + : QWidget(parent) + , ui(new Ui::AppearanceOptionPage) +{ + ui->setupUi(this); + QSettings s; + ui->fileFilter->setChecked(s.value("only_qml_files/enabled").toBool()); +} + +AppearanceOptionPage::~AppearanceOptionPage() +{ + delete ui; +} + +void AppearanceOptionPage::apply() +{ + bool enabled = ui->fileFilter->isChecked(); + QSettings s; + s.setValue("only_qml_files/enabled", enabled); + emit hideNonQMLFiles(enabled); +} diff --git a/src/bench/appearanceoptionpage.h b/src/bench/appearanceoptionpage.h new file mode 100644 index 0000000..f6cc39c --- /dev/null +++ b/src/bench/appearanceoptionpage.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +#ifndef APPEARANCEOPTIONSPAGE_H +#define APPEARANCEOPTIONSPAGE_H + +#include +#include + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { +class AppearanceOptionPage; +} +QT_END_NAMESPACE + +class AppearanceOptionPage : public QWidget +{ + Q_OBJECT +public: + explicit AppearanceOptionPage(QWidget *parent = nullptr); + ~AppearanceOptionPage(); + void apply(); + +signals: + void hideNonQMLFiles(bool hide); +private: + Ui::AppearanceOptionPage *ui; +}; + +#endif // APPEARANCEOPTIONSPAGE_H diff --git a/src/bench/appearanceoptionpage.ui b/src/bench/appearanceoptionpage.ui new file mode 100644 index 0000000..476fa99 --- /dev/null +++ b/src/bench/appearanceoptionpage.ui @@ -0,0 +1,32 @@ + + + AppearanceOptionPage + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + 10 + 10 + 271 + 20 + + + + Hide non QML files in workspace view + + + + + + diff --git a/src/bench/bench.pro b/src/bench/bench.pro index 038da41..df2b09a 100644 --- a/src/bench/bench.pro +++ b/src/bench/bench.pro @@ -28,7 +28,8 @@ SOURCES += \ hostdiscoverymanager.cpp \ autodiscoveryhostsdialog.cpp \ options.cpp \ - newprojectwizard.cpp + newprojectwizard.cpp \ + appearanceoptionpage.cpp HEADERS += \ aboutdialog.h \ @@ -50,14 +51,16 @@ HEADERS += \ hostdiscoverymanager.h \ autodiscoveryhostsdialog.h \ options.h \ - newprojectwizard.h + newprojectwizard.h \ + appearanceoptionpage.h FORMS += \ optionsdialog.ui \ hostsoptionpage.ui \ httpproxyoptionpage.ui \ importpathoptionpage.ui \ - autodiscoveryhostsdialog.ui + autodiscoveryhostsdialog.ui \ + appearanceoptionpage.ui include(../widgets/widgets.pri) include(../lib.pri) diff --git a/src/bench/mainwindow.cpp b/src/bench/mainwindow.cpp index dd0149d..9f41c38 100644 --- a/src/bench/mainwindow.cpp +++ b/src/bench/mainwindow.cpp @@ -393,6 +393,8 @@ void MainWindow::init() m_hostModel->restoreFromSettings(&s); restoreState(s.value("windowState").toByteArray()); + m_workspace->restoreFromSettings(&s); + m_initialized = true; } @@ -553,6 +555,7 @@ void MainWindow::updateWindowTitle() void MainWindow::openPreferences(Host *host) { OptionsDialog dialog; + connect(&dialog, &OptionsDialog::hideNonQMLFiles, m_workspace, &WorkspaceView::hideNonQMLFiles); dialog.setHostModel(m_hostModel); dialog.setDiscoveredHostsModel(m_discoveryManager->discoveredHostsModel()); diff --git a/src/bench/optionsdialog.cpp b/src/bench/optionsdialog.cpp index e131a0c..9ad1360 100644 --- a/src/bench/optionsdialog.cpp +++ b/src/bench/optionsdialog.cpp @@ -35,6 +35,7 @@ #include "httpproxyoptionpage.h" #include "importpathoptionpage.h" #include "hostsoptionpage.h" +#include "appearanceoptionpage.h" OptionsDialog::OptionsDialog(QWidget *parent) : QDialog(parent) @@ -42,6 +43,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) , m_httpProxyForm(new HttpProxyOptionPage(this)) , m_importPathsForm(new ImportPathOptionPage(this)) , m_hostsForm(new HostsOptionsPage(this)) + , m_appearanceForm(new AppearanceOptionPage(this)) { ui->setupUi(this); @@ -61,8 +63,14 @@ OptionsDialog::OptionsDialog(QWidget *parent) item->setData(Qt::UserRole, index); ui->optionsView->addItem(item); + item = new QListWidgetItem("Appearance"); + index = ui->optionsStack->addWidget(m_appearanceForm); + item->setData(Qt::UserRole, index); + ui->optionsView->addItem(item); + connect(ui->optionsView, &QListWidget::currentItemChanged, this, &OptionsDialog::optionSelected); + connect(m_appearanceForm, &AppearanceOptionPage::hideNonQMLFiles, this, &OptionsDialog::hideNonQMLFiles); } OptionsDialog::~OptionsDialog() @@ -97,6 +105,7 @@ void OptionsDialog::accept() m_httpProxyForm->apply(); m_importPathsForm->apply(); m_hostsForm->apply(); + m_appearanceForm->apply(); QDialog::accept(); } @@ -106,3 +115,4 @@ void OptionsDialog::reject() } + diff --git a/src/bench/optionsdialog.h b/src/bench/optionsdialog.h index 04cac0a..33e02bd 100644 --- a/src/bench/optionsdialog.h +++ b/src/bench/optionsdialog.h @@ -46,6 +46,7 @@ class ImportPathOptionPage; class HostsOptionsPage; class HostModel; class Host; +class AppearanceOptionPage; class OptionsDialog : public QDialog { @@ -60,6 +61,9 @@ public: void openHostConfig(Host* host); +signals: + void hideNonQMLFiles(bool hide); + private slots: void optionSelected(QListWidgetItem* current); void accept(); @@ -70,4 +74,5 @@ private: HttpProxyOptionPage *m_httpProxyForm; ImportPathOptionPage *m_importPathsForm; HostsOptionsPage *m_hostsForm; + AppearanceOptionPage *m_appearanceForm; }; diff --git a/src/widgets/workspaceview.cpp b/src/widgets/workspaceview.cpp index 5934c62..08eb9b4 100644 --- a/src/widgets/workspaceview.cpp +++ b/src/widgets/workspaceview.cpp @@ -169,3 +169,22 @@ void WorkspaceView::selectIndex(const QModelIndex &index) indexActivated(index); //m_view->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect); } + +void WorkspaceView::restoreFromSettings(QSettings *s) +{ + hideNonQMLFiles(s->value("only_qml_files/enabled").toBool()); +} + +void WorkspaceView::hideNonQMLFiles(bool hide) +{ + QStringList filters; + if (hide) { + filters << "*.qml"; + } + else { + filters << "*.*"; + } + m_model->setNameFilters(filters); + m_model->setNameFilterDisables(false); + m_view->setModel(m_model); +} diff --git a/src/widgets/workspaceview.h b/src/widgets/workspaceview.h index 3a7bb4d..aa0ef1d 100644 --- a/src/widgets/workspaceview.h +++ b/src/widgets/workspaceview.h @@ -49,12 +49,14 @@ public: QString rootPath() const; void setDirectoriesSelectable(bool enabled); bool directoriesSelectable() const; + void restoreFromSettings(QSettings *s); public Q_SLOTS: void setRootPath(const QString& dirPath); void activateDocument(const LiveDocument& path); void activateRootPath(); void goUp(); + void hideNonQMLFiles(bool hide); Q_SIGNALS: void pathActivated(const LiveDocument& path); -- cgit v1.2.3