Fix #2085 new tray menu.
authorCamila <hello@camila.codes>
Mon, 29 Jun 2020 17:41:51 +0000 (19:41 +0200)
committerKevin Ottens <ervin@ipsquad.net>
Thu, 2 Jul 2020 17:21:10 +0000 (19:21 +0200)
Update systray behavior and context menu:
- left click brings up the new QtQuick based dialogs on all latforms
- right click brings up the new QtQuick based dialog on Mac OS only
- right click brings up a context menu on all other platforms than Mac OS
- "Quit Nextcloud" => "Exit Nextcloud"
- Add "Open main dialog" option.

Signed-off-by: Camila <hello@camila.codes>
src/gui/owncloudgui.cpp
src/gui/systray.cpp
src/gui/systray.h
src/gui/tray/Window.qml

index 5dc280bdc8ed29ae93ac73c55df790dd269329ec..c6f3aa66e8f472b14a1ed852ee5349ab3ab81e6c 100644 (file)
@@ -85,6 +85,9 @@ ownCloudGui::ownCloudGui(Application *parent)
     connect(_tray.data(), &Systray::openHelp,
         this, &ownCloudGui::slotHelp);
 
+    connect(_tray.data(), &Systray::openMainDialog,
+        this, &ownCloudGui::slotOpenMainDialog);
+
     connect(_tray.data(), &Systray::openSettings,
         this, &ownCloudGui::slotShowSettings);
 
@@ -164,7 +167,7 @@ void ownCloudGui::slotOpenMainDialog()
 
 void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
 {
-    if (reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::Context) {
+    if (reason == QSystemTrayIcon::Trigger) {
         if (OwncloudSetupWizard::bringWizardToFrontIfVisible()) {
             // brought wizard to front
         } else if (_shareDialogs.size() > 0) {
index 93c0eba09e83f9d4e704f5f1221b9bdcef37bbaf..15f9d668e141e003fb3ab9c8cb71192395e68446 100644 (file)
@@ -25,6 +25,7 @@
 #include <QQmlContext>
 #include <QQuickWindow>
 #include <QScreen>
+#include <QMenu>
 
 #ifdef USE_FDO_NOTIFICATIONS
 #include <QDBusConnection>
@@ -79,6 +80,14 @@ Systray::Systray()
         }
     );
 
+#ifndef Q_OS_MAC
+    auto contextMenu = new QMenu();
+    contextMenu->addAction(tr("Open main dialog"), this, &Systray::openMainDialog);
+    contextMenu->addAction(tr("Settings"), this, &Systray::openSettings);
+    contextMenu->addAction(tr("Exit %1").arg(Theme::instance()->appNameGUI()), this, &Systray::shutdown);
+    setContextMenu(contextMenu);
+#endif
+
     connect(UserModel::instance(), &UserModel::newUserSelected,
         this, &Systray::slotNewUserSelected);
 
index 8f1612a2a2f498edc9d7b1d74143237c98a9bffd..e4d27c06583dd6e8bc60696e6bc40f7480ce34c1 100644 (file)
@@ -64,6 +64,7 @@ public:
 
 signals:
     void currentUserChanged();
+    void openMainDialog();
     void openSettings();
     void openHelp();
     void shutdown();
index 92183f59fe7649ee4001eae26538febbb7543ad1..d940b535e74f3963f8c652cc98b86f00aa5f68cd 100644 (file)
@@ -211,19 +211,13 @@ Window {
                             }\r
 \r
                             MenuItem {\r
-                                text: qsTr("Open settings")\r
+                                text: qsTr("Settings")\r
                                 font.pixelSize: Style.topLinePixelSize\r
                                 onClicked: Systray.openSettings()\r
                             }\r
 \r
                             MenuItem {\r
-                                text: qsTr("Help")\r
-                                font.pixelSize: Style.topLinePixelSize\r
-                                onClicked: Systray.openHelp()\r
-                            }\r
-\r
-                            MenuItem {\r
-                                text: qsTr("Quit Nextcloud")\r
+                                text: qsTr("Exit");\r
                                 font.pixelSize: Style.topLinePixelSize\r
                                 onClicked: Systray.shutdown()\r
                             }\r