From 1ba6b61e7ef8e9019dd91fe6b50f1a367ce9f4e6 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 11 Nov 2024 13:40:23 +0800 Subject: [PATCH 1/3] Emit a signal on wizard close Signed-off-by: Claudio Cambra --- src/gui/wizard/owncloudwizard.cpp | 6 ++++++ src/gui/wizard/owncloudwizard.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp index f09c52fcaf155..1f4fd9b313c55 100644 --- a/src/gui/wizard/owncloudwizard.cpp +++ b/src/gui/wizard/owncloudwizard.cpp @@ -408,6 +408,12 @@ void OwncloudWizard::changeEvent(QEvent *e) QWizard::changeEvent(e); } +void OwncloudWizard::closeEvent(QCloseEvent *event) +{ + emit wizardClosed(); + QWizard::closeEvent(event); +} + void OwncloudWizard::customizeStyle() { // HINT: Customize wizard's own style here, if necessary in the future (Dark-/Light-Mode switching) diff --git a/src/gui/wizard/owncloudwizard.h b/src/gui/wizard/owncloudwizard.h index 7f69587a45da7..d184d9978911d 100644 --- a/src/gui/wizard/owncloudwizard.h +++ b/src/gui/wizard/owncloudwizard.h @@ -110,9 +110,11 @@ public slots: void needCertificate(); void styleChanged(); void onActivate(); + void wizardClosed(); protected: void changeEvent(QEvent *) override; + void closeEvent(QCloseEvent *) override; private: void customizeStyle(); From 6820e1a7178645915d0c9bb9875731f36e7d1b9c Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 11 Nov 2024 13:41:23 +0800 Subject: [PATCH 2/3] Also emit close signal on window hide (i.e. user close) on macOS Signed-off-by: Claudio Cambra --- src/gui/wizard/owncloudwizard.cpp | 9 +++++++++ src/gui/wizard/owncloudwizard.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp index 1f4fd9b313c55..9368b3d162800 100644 --- a/src/gui/wizard/owncloudwizard.cpp +++ b/src/gui/wizard/owncloudwizard.cpp @@ -408,6 +408,15 @@ void OwncloudWizard::changeEvent(QEvent *e) QWizard::changeEvent(e); } +void OwncloudWizard::hideEvent(QHideEvent *event) +{ + QWizard::hideEvent(event); +#ifdef Q_OS_MACOS + // Closing the window on macOS hides it rather than closes it, so emit a wizardClosed here + emit wizardClosed(); +#endif +} + void OwncloudWizard::closeEvent(QCloseEvent *event) { emit wizardClosed(); diff --git a/src/gui/wizard/owncloudwizard.h b/src/gui/wizard/owncloudwizard.h index d184d9978911d..da614b92d7e5c 100644 --- a/src/gui/wizard/owncloudwizard.h +++ b/src/gui/wizard/owncloudwizard.h @@ -114,6 +114,7 @@ public slots: protected: void changeEvent(QEvent *) override; + void hideEvent(QHideEvent *) override; void closeEvent(QCloseEvent *) override; private: From fe7c12115656de7f848d9bca80abd7442b12c52e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 11 Nov 2024 13:41:35 +0800 Subject: [PATCH 3/3] Clear wizard static pointer on wizardClosed Signed-off-by: Claudio Cambra --- src/gui/owncloudsetupwizard.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index 40b88289a340d..09102f62429fc 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -85,6 +85,7 @@ void OwncloudSetupWizard::runWizard(QObject *obj, const char *amember, QWidget * wiz = new OwncloudSetupWizard(parent); connect(wiz, SIGNAL(ownCloudWizardDone(int)), obj, amember); + connect(wiz->_ocWizard, &OwncloudWizard::wizardClosed, obj, [] { wiz.clear(); }); FolderMan::instance()->setSyncEnabled(false); wiz->startWizard(); }