From eb3feb4a4e5fa4d8d23c9a2f0f6f4c63cefad276 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 26 Mar 2018 20:31:17 +0300 Subject: [PATCH] fix #934,change quit button to close button --exhausted to discuss this so often so in the end it may be my perspective wrong. Quit button in dock settings window changed to Close button and the Quit option moved to menu bar of the general Latte settings window with shortcut Ctrl+Q --- app/dock/dockview.cpp | 24 ------------------- app/dock/dockview.h | 2 -- app/dockcorona.cpp | 9 ++++++- app/layoutmanager.cpp | 8 +++++++ app/layoutmanager.h | 1 + app/settingsdialog.cpp | 17 +++++++++---- .../configuration/LatteDockConfiguration.qml | 10 ++++---- 7 files changed, 35 insertions(+), 36 deletions(-) diff --git a/app/dock/dockview.cpp b/app/dock/dockview.cpp index 6a364a377..61e532865 100644 --- a/app/dock/dockview.cpp +++ b/app/dock/dockview.cpp @@ -1722,30 +1722,6 @@ QList DockView::freeEdges() const return edgesInt; } -void DockView::closeApplication() -{ - //! this code must be called asynchronously because it is called - //! also from qml (Settings window). - QTimer::singleShot(50, [this]() { - DockCorona *dockCorona = qobject_cast(this->corona()); - - DockConfigView *configView = qobject_cast(m_configView); - - if (configView) { - configView->hideConfigWindow(); - } else if (m_configView) { - m_configView->close(); - } - - if (dockCorona) { - dockCorona->layoutManager()->hideAllDocks(); - } - - if (dockCorona) - dockCorona->closeApplication(); - }); -} - void DockView::deactivateApplets() { if (!containment()) { diff --git a/app/dock/dockview.h b/app/dock/dockview.h index 1b3c61795..99d82a498 100644 --- a/app/dock/dockview.h +++ b/app/dock/dockview.h @@ -230,8 +230,6 @@ public slots: Q_INVOKABLE bool tasksPresent(); Q_INVOKABLE bool latteTasksPresent(); - Q_INVOKABLE void closeApplication(); - void updateAbsDockGeometry(bool bypassChecks = false); protected slots: diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index 2a511df2c..18a84630b 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -626,8 +626,15 @@ int DockCorona::primaryScreenId() const void DockCorona::closeApplication() { + //! this code must be called asynchronously because it is called + //! also from qml (Settings window). + QTimer::singleShot(5, [this]() { + m_layoutManager->hideLatteSettingsDialog(); + m_layoutManager->hideAllDocks(); + }); + //! give the time for the docks to hide themselves - QTimer::singleShot(400, [this]() { + QTimer::singleShot(500, [this]() { qGuiApp->quit(); }); } diff --git a/app/layoutmanager.cpp b/app/layoutmanager.cpp index dc7eef1ca..ddd79532c 100644 --- a/app/layoutmanager.cpp +++ b/app/layoutmanager.cpp @@ -1160,6 +1160,14 @@ void LayoutManager::showLatteSettingsDialog(int page) m_latteSettingsDialog->activateWindow(); } +void LayoutManager::hideLatteSettingsDialog() +{ + if (m_latteSettingsDialog) { + m_latteSettingsDialog->deleteLater(); + m_latteSettingsDialog = nullptr; + } +} + void LayoutManager::showInfoWindow(QString info, int duration, QStringList activities) { foreach (auto screen, qGuiApp->screens()) { diff --git a/app/layoutmanager.h b/app/layoutmanager.h index 4fa5f3573..16d838e60 100644 --- a/app/layoutmanager.h +++ b/app/layoutmanager.h @@ -112,6 +112,7 @@ public slots: void showAboutDialog(); void updateColorizerSupport(); + void hideLatteSettingsDialog(); Q_INVOKABLE void showLatteSettingsDialog(int page = Latte::Dock::LayoutPage); //! switch to specified layout, default previousMemoryUsage means that it didnt change diff --git a/app/settingsdialog.cpp b/app/settingsdialog.cpp index b802c1990..84f809604 100644 --- a/app/settingsdialog.cpp +++ b/app/settingsdialog.cpp @@ -119,13 +119,21 @@ SettingsDialog::SettingsDialog(QWidget *parent, DockCorona *corona) //! About Menu QMenuBar *menuBar = new QMenuBar(this); - QMenuBar *rightAlignedMenuBar = new QMenuBar(menuBar); + // QMenuBar *rightAlignedMenuBar = new QMenuBar(menuBar); layout()->setMenuBar(menuBar); - menuBar->setCornerWidget(rightAlignedMenuBar); + //menuBar->setCornerWidget(rightAlignedMenuBar); - QMenu *helpMenu = new QMenu(i18n("Help"), rightAlignedMenuBar); - rightAlignedMenuBar->addMenu(helpMenu); + QMenu *fileMenu = new QMenu(i18n("File"), menuBar); + menuBar->addMenu(fileMenu); + + QMenu *helpMenu = new QMenu(i18n("Help"), menuBar); + //rightAlignedMenuBar->addMenu(helpMenu); + menuBar->addMenu(helpMenu); + + QAction *quitAction = fileMenu->addAction(i18n("Quit Latte")); + quitAction->setIcon(QIcon::fromTheme("application-exit")); + quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); QAction *aboutAction = helpMenu->addAction(i18n("About Latte")); aboutAction->setIcon(QIcon::fromTheme("latte-dock")); @@ -163,6 +171,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, DockCorona *corona) }); connect(aboutAction, &QAction::triggered, m_corona, &DockCorona::aboutApplication); + connect(quitAction, &QAction::triggered, m_corona, &DockCorona::closeApplication); //! update all layouts view when runningActivities changed. This way we update immediately //! the running Activities in Activities checkboxes which are shown as bold diff --git a/shell/package/contents/configuration/LatteDockConfiguration.qml b/shell/package/contents/configuration/LatteDockConfiguration.qml index e8082a270..e438cb88b 100644 --- a/shell/package/contents/configuration/LatteDockConfiguration.qml +++ b/shell/package/contents/configuration/LatteDockConfiguration.qml @@ -496,16 +496,16 @@ FocusScope { } PlasmaComponents.Button { - id: quit + id: closeButton Layout.fillWidth: true Layout.alignment: Qt.AlignRight - text: i18n("Quit") - iconSource: "application-exit" - tooltip: i18n("Quit Latte") + text: i18n("Close") + iconSource: "dialog-close" + tooltip: i18n("Close settings window") - onClicked: dock.closeApplication() + onClicked: dockConfig.hideConfigWindow(); } } }