Add helper slots and signals to catch SettingsDialog's window activation events
authorMichael Schuster <michael@schuster.ms>
Sat, 21 Dec 2019 02:04:31 +0000 (03:04 +0100)
committerMichael Schuster <48932272+misch7@users.noreply.github.com>
Tue, 24 Dec 2019 06:46:57 +0000 (07:46 +0100)
Signal the SettingsDialog's window activation event down to ownCloudGui and Application,
so that other classes can hook in to get notified when the SettingsDialog is being shown
again.

This approach has been chosen because we otherwise would have to deal with new instance
pointers of the current SettingsWindow - but Application is already there ;-)

Purpose: The floating re-auth windows of the WebFlowCredentialsDialog often get hidden
behind the SettingsDialog, and the users have to minimize a lot of other windows to find
them again. This commit implements the preparation for the upcoming fix commit.

Signed-off-by: Michael Schuster <michael@schuster.ms>
src/gui/application.cpp
src/gui/application.h
src/gui/owncloudgui.cpp
src/gui/owncloudgui.h
src/gui/settingsdialog.cpp
src/gui/settingsdialog.h

index 18914159580182e8f61583dad61b5354fb412f98..51af86f923546f20128a1184545591dee71d0a85 100644 (file)
@@ -263,6 +263,9 @@ Application::Application(int &argc, char **argv)
 
     // Cleanup at Quit.
     connect(this, &QCoreApplication::aboutToQuit, this, &Application::slotCleanup);
+
+    // Allow other classes to hook into isShowingSettingsDialog() signals (re-auth widgets, for example)
+    connect(_gui.data(), &ownCloudGui::isShowingSettingsDialog, this, &Application::slotGuiIsShowingSettings);
 }
 
 Application::~Application()
@@ -655,5 +658,9 @@ void Application::showSettingsDialog()
     _gui->slotShowSettings();
 }
 
+void Application::slotGuiIsShowingSettings()
+{
+    emit isShowingSettingsDialog();
+}
 
 } // namespace OCC
index 77abd7a97e19827dcee5e9d57d7c2d301937dbd1..ac303cb4c2f44e76176f700cb20e2453e75b8e9b 100644 (file)
@@ -82,6 +82,7 @@ protected:
 signals:
     void folderRemoved();
     void folderStateChanged(Folder *);
+    void isShowingSettingsDialog();
 
 protected slots:
     void slotParseMessage(const QString &, QObject *);
@@ -91,6 +92,7 @@ protected slots:
     void slotAccountStateAdded(AccountState *accountState);
     void slotAccountStateRemoved(AccountState *accountState);
     void slotSystemOnlineConfigurationChanged(QNetworkConfiguration);
+    void slotGuiIsShowingSettings();
 
 private:
     void setHelp();
index ee30acf50942518c87ad438da42faa31075f8f71..828409f900f4c2cde432cfcd651580da239663ee 100644 (file)
@@ -1075,6 +1075,11 @@ void ownCloudGui::slotShowSettings()
     raiseDialog(_settingsDialog.data());
 }
 
+void ownCloudGui::slotSettingsDialogActivated()
+{
+    emit isShowingSettingsDialog();
+}
+
 void ownCloudGui::slotShowSyncProtocol()
 {
     slotShowSettings();
index 3df9582d87a6df297790b7da2deca857494639d4..98af71bb792a8dfd42e0fb8838ee63897dfac479 100644 (file)
@@ -70,6 +70,7 @@ public:
 signals:
     void setupProxy();
     void serverError(int code, const QString &message);
+    void isShowingSettingsDialog();
 
 public slots:
     void setupContextMenu();
@@ -93,6 +94,7 @@ public slots:
     void slotToggleLogBrowser();
     void slotOpenOwnCloud();
     void slotOpenSettingsDialog();
+    void slotSettingsDialogActivated();
     void slotHelp();
     void slotOpenPath(const QString &path);
     void slotAccountStateChanged();
index 0dc6480f681b1b639f81c741450e2f7fd5b4b2e7..0f5df7194d7b885523567fe118d701dba7f2fc82 100644 (file)
@@ -127,6 +127,8 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
     connect(showLogWindow, &QAction::triggered, gui, &ownCloudGui::slotToggleLogBrowser);
     addAction(showLogWindow);
 
+    connect(this, &SettingsDialog::onActivate, gui, &ownCloudGui::slotSettingsDialogActivated);
+
     customizeStyle();
 
     cfg.restoreGeometry(this);
@@ -163,6 +165,10 @@ void SettingsDialog::changeEvent(QEvent *e)
         // Notify the other widgets (Dark-/Light-Mode switching)
         emit styleChanged();
         break;
+    case QEvent::ActivationChange:
+        if(isActiveWindow())
+            emit onActivate();
+        break;
     default:
         break;
     }
index 67cf29e235127696133df9ef210c1030a8aa1a37..f5ec654d967f1c39db72db8d6704da5529ee5cbe 100644 (file)
@@ -65,6 +65,7 @@ public slots:
 
 signals:
     void styleChanged();
+    void onActivate();
 
 protected:
     void reject() override;