Procházet zdrojové kódy

Add helper slots and signals to catch SettingsDialog's window activation events

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>
Michael Schuster před 6 roky
rodič
revize
addb27a085

+ 7 - 0
src/gui/application.cpp

@@ -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

+ 2 - 0
src/gui/application.h

@@ -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();

+ 5 - 0
src/gui/owncloudgui.cpp

@@ -1075,6 +1075,11 @@ void ownCloudGui::slotShowSettings()
     raiseDialog(_settingsDialog.data());
 }
 
+void ownCloudGui::slotSettingsDialogActivated()
+{
+    emit isShowingSettingsDialog();
+}
+
 void ownCloudGui::slotShowSyncProtocol()
 {
     slotShowSettings();

+ 2 - 0
src/gui/owncloudgui.h

@@ -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();

+ 6 - 0
src/gui/settingsdialog.cpp

@@ -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;
     }

+ 1 - 0
src/gui/settingsdialog.h

@@ -65,6 +65,7 @@ public slots:
 
 signals:
     void styleChanged();
+    void onActivate();
 
 protected:
     void reject() override;