Some Dialogs: Bring to top on tray click #5515 #5566 (#5664)
authorMarkus Goetz <markus@woboq.com>
Thu, 20 Apr 2017 06:55:44 +0000 (08:55 +0200)
committerGitHub <noreply@github.com>
Thu, 20 Apr 2017 06:55:44 +0000 (08:55 +0200)
On my OS X, it might get hidden under other apps while I opened it and then want to quickly
verify something in another app.

src/gui/owncloudgui.cpp
src/gui/owncloudsetupwizard.cpp
src/gui/owncloudsetupwizard.h

index 72d43ba26d7281d57102c8a74935e4297ad415b2..c80b34628fcc7a1c694d68c6c6487d8c4bc7d439 100644 (file)
@@ -174,22 +174,31 @@ void ownCloudGui::slotTrayClicked( QSystemTrayIcon::ActivationReason reason )
         last_click.start();
     }
 
-    // A click on the tray icon should only open the status window on Win and
-    // Linux, not on Mac. They want a menu entry.
-#if !defined Q_OS_MAC
+    // Left click
     if( reason == QSystemTrayIcon::Trigger ) {
-        // Start settings if config is existing.
-        slotOpenSettingsDialog();
-    }
+        if (OwncloudSetupWizard::bringWizardToFrontIfVisible()) {
+            // brought wizard to front
+        } else if (_shareDialogs.size() > 0) {
+            // Share dialog(s) be hidden by other apps, bring them back
+            Q_FOREACH(const QPointer<ShareDialog> &shareDialog, _shareDialogs) {
+                Q_ASSERT(shareDialog.data());
+                raiseDialog(shareDialog);
+            }
+        } else {
+#ifdef Q_OS_MAC
+            // on macOS, a left click always opens menu.
+            // However if the settings dialog is already visible but hidden
+            // by other applications, this will bring it to the front.
+            if (!_settingsDialog.isNull() && _settingsDialog->isVisible()) {
+                raiseDialog(_settingsDialog.data());
+            }
 #else
-    // On Mac, if the settings dialog is already visible but hidden
-    // by other applications, this will bring it to the front.
-    if( reason == QSystemTrayIcon::Trigger ) {
-        if (!_settingsDialog.isNull() && _settingsDialog->isVisible()) {
-            slotShowSettings();
+            slotOpenSettingsDialog();
+#endif
         }
     }
-#endif
+    // FIXME: Also make sure that any auto updater dialogue https://github.com/owncloud/client/issues/5613
+    // or SSL error dialog also comes to front.
 }
 
 void ownCloudGui::slotSyncStateChange( Folder* folder )
index 971ccf827b991e5e1596c2aed852934b8823ec66..651158536dd2b711a6d274a37eeaff475fda77e6 100644 (file)
@@ -32,6 +32,7 @@
 #include "accountmanager.h"
 #include "clientproxy.h"
 #include "filesystem.h"
+#include "owncloudgui.h"
 
 #include "creds/credentialsfactory.h"
 #include "creds/abstractcredentials.h"
@@ -64,10 +65,10 @@ OwncloudSetupWizard::~OwncloudSetupWizard()
     _ocWizard->deleteLater();
 }
 
+static QPointer<OwncloudSetupWizard> wiz = 0;
+
 void OwncloudSetupWizard::runWizard(QObject* obj, const char* amember, QWidget *parent)
 {
-    static QPointer<OwncloudSetupWizard> wiz;
-
     if (!wiz.isNull()) {
         return;
     }
@@ -78,6 +79,16 @@ void OwncloudSetupWizard::runWizard(QObject* obj, const char* amember, QWidget *
     wiz->startWizard();
 }
 
+bool OwncloudSetupWizard::bringWizardToFrontIfVisible()
+{
+    if (wiz.isNull()) {
+        return false;
+    }
+
+    ownCloudGui::raiseDialog(wiz->_ocWizard);
+    return true;
+}
+
 void OwncloudSetupWizard::startWizard()
 {
     AccountPtr account = AccountManager::createAccount();
index 8f172c8db3599a8d84a759d142f029de73cef8f8..c5ad99a2e9a44441423f0efa20b026936468b6a6 100644 (file)
@@ -60,6 +60,7 @@ class OwncloudSetupWizard : public QObject
 public:
     /** Run the wizard */
     static void runWizard(QObject *obj, const char* amember, QWidget *parent = 0 );
+    static bool bringWizardToFrontIfVisible();
 signals:
     // overall dialog close signal.
     void ownCloudWizardDone( int );