From f78bcff4a928c8be1a736a6e261cd56d6cfe449a Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 11 Aug 2023 13:10:15 +0800 Subject: [PATCH 1/4] Ensure background colour for warn label in folder wizard is the correct colour Signed-off-by: Claudio Cambra --- src/gui/folderwizard.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 1c82938cb1bbd..98cd81d68fd26 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -162,9 +162,10 @@ void FolderWizardLocalPath::changeEvent(QEvent *e) void FolderWizardLocalPath::changeStyle() { - const auto warnYellow = Theme::isDarkColor(QGuiApplication::palette().base().color()) ? QColor(63, 63, 0) : QColor(255, 255, 192); + const auto warnYellow = Theme::instance()->darkMode() ? QColor(63, 63, 0) : QColor(255, 255, 192); auto modifiedPalette = _ui.warnLabel->palette(); modifiedPalette.setColor(QPalette::Window, warnYellow); + modifiedPalette.setColor(QPalette::Base, warnYellow); _ui.warnLabel->setPalette(modifiedPalette); } From fb5df562a1eb2b0e01a75d713b21e900c5125308 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 11 Aug 2023 13:10:44 +0800 Subject: [PATCH 2/4] Also provide remote path folder wizard page with correct warn colour Signed-off-by: Claudio Cambra --- src/gui/folderwizard.cpp | 27 +++++++++++++++++++++++++++ src/gui/folderwizard.h | 7 ++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 98cd81d68fd26..715e01a3a5f27 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -193,6 +193,8 @@ FolderWizardRemotePath::FolderWizardRemotePath(const AccountPtr &account) _ui.folderTreeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); // Make sure that there will be a scrollbar when the contents is too wide _ui.folderTreeWidget->header()->setStretchLastSection(false); + + changeStyle(); } void FolderWizardRemotePath::slotAddRemoteFolder() @@ -524,6 +526,31 @@ void FolderWizardRemotePath::showWarn(const QString &msg) const } } +void FolderWizardRemotePath::changeEvent(QEvent *e) +{ + switch (e->type()) { + case QEvent::StyleChange: + case QEvent::PaletteChange: + case QEvent::ThemeChange: + // Notify the other widgets (Dark-/Light-Mode switching) + changeStyle(); + break; + default: + break; + } + + FormatWarningsWizardPage::changeEvent(e); +} + +void FolderWizardRemotePath::changeStyle() +{ + const auto warnYellow = Theme::instance()->darkMode() ? QColor(63, 63, 0) : QColor(255, 255, 192); + auto modifiedPalette = _ui.warnLabel->palette(); + modifiedPalette.setColor(QPalette::Window, warnYellow); + modifiedPalette.setColor(QPalette::Base, warnYellow); + _ui.warnLabel->setPalette(modifiedPalette); +} + // ==================================================================================== FolderWizardSelectiveSync::FolderWizardSelectiveSync(const AccountPtr &account) diff --git a/src/gui/folderwizard.h b/src/gui/folderwizard.h index e0aeecc5c03a7..867a50ec7b967 100644 --- a/src/gui/folderwizard.h +++ b/src/gui/folderwizard.h @@ -94,7 +94,6 @@ class FolderWizardRemotePath : public FormatWarningsWizardPage void cleanupPage() override; protected slots: - void showWarn(const QString & = QString()) const; void slotAddRemoteFolder(); void slotCreateRemoteFolder(const QString &); @@ -110,6 +109,12 @@ protected slots: void slotLsColFolderEntry(); void slotTypedPathFound(const QStringList &subpaths); +protected: + void changeEvent(QEvent *) override; + +private slots: + void changeStyle(); + private: LsColJob *runLsColJob(const QString &path); void recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QString path); From 31808630f941adb9844e9300bc10ac8cac895b3f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 23 Aug 2023 09:06:42 +0800 Subject: [PATCH 3/4] Constexprify yellow warning colours in FolderWizard Signed-off-by: Claudio Cambra --- src/gui/folderwizard.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 715e01a3a5f27..d9332aca0c70c 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -41,6 +41,12 @@ #include +namespace +{ +constexpr QColor darkWarnYellow(63, 63, 0); +constexpr QColor lightWarnYellow(255, 255, 192); +} + namespace OCC { QString FormatWarningsWizardPage::formatWarnings(const QStringList &warnings) const @@ -162,7 +168,7 @@ void FolderWizardLocalPath::changeEvent(QEvent *e) void FolderWizardLocalPath::changeStyle() { - const auto warnYellow = Theme::instance()->darkMode() ? QColor(63, 63, 0) : QColor(255, 255, 192); + const auto warnYellow = Theme::instance()->darkMode() ? darkWarnYellow : lightWarnYellow; auto modifiedPalette = _ui.warnLabel->palette(); modifiedPalette.setColor(QPalette::Window, warnYellow); modifiedPalette.setColor(QPalette::Base, warnYellow); @@ -544,7 +550,7 @@ void FolderWizardRemotePath::changeEvent(QEvent *e) void FolderWizardRemotePath::changeStyle() { - const auto warnYellow = Theme::instance()->darkMode() ? QColor(63, 63, 0) : QColor(255, 255, 192); + const auto warnYellow = Theme::instance()->darkMode() ? darkWarnYellow : lightWarnYellow; auto modifiedPalette = _ui.warnLabel->palette(); modifiedPalette.setColor(QPalette::Window, warnYellow); modifiedPalette.setColor(QPalette::Base, warnYellow); From 68f2e2a053e8405d4ca28461d6304f60d949a65e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 23 Aug 2023 09:11:45 +0800 Subject: [PATCH 4/4] Move warning yellow palette generation for warn labels to anonymous namespace function Signed-off-by: Claudio Cambra --- src/gui/folderwizard.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index d9332aca0c70c..84fa76d0489e5 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -45,6 +45,15 @@ namespace { constexpr QColor darkWarnYellow(63, 63, 0); constexpr QColor lightWarnYellow(255, 255, 192); + +QPalette yellowWarnWidgetPalette(const QPalette &existingPalette) +{ + const auto warnYellow = OCC::Theme::instance()->darkMode() ? darkWarnYellow : lightWarnYellow; + auto modifiedPalette = existingPalette; + modifiedPalette.setColor(QPalette::Window, warnYellow); + modifiedPalette.setColor(QPalette::Base, warnYellow); + return modifiedPalette; +} } namespace OCC { @@ -168,11 +177,8 @@ void FolderWizardLocalPath::changeEvent(QEvent *e) void FolderWizardLocalPath::changeStyle() { - const auto warnYellow = Theme::instance()->darkMode() ? darkWarnYellow : lightWarnYellow; - auto modifiedPalette = _ui.warnLabel->palette(); - modifiedPalette.setColor(QPalette::Window, warnYellow); - modifiedPalette.setColor(QPalette::Base, warnYellow); - _ui.warnLabel->setPalette(modifiedPalette); + const auto yellowWarnPalette = yellowWarnWidgetPalette(_ui.warnLabel->palette()); + _ui.warnLabel->setPalette(yellowWarnPalette); } // ================================================================================= @@ -550,11 +556,8 @@ void FolderWizardRemotePath::changeEvent(QEvent *e) void FolderWizardRemotePath::changeStyle() { - const auto warnYellow = Theme::instance()->darkMode() ? darkWarnYellow : lightWarnYellow; - auto modifiedPalette = _ui.warnLabel->palette(); - modifiedPalette.setColor(QPalette::Window, warnYellow); - modifiedPalette.setColor(QPalette::Base, warnYellow); - _ui.warnLabel->setPalette(modifiedPalette); + const auto yellowWarnPalette = yellowWarnWidgetPalette(_ui.warnLabel->palette()); + _ui.warnLabel->setPalette(yellowWarnPalette); } // ====================================================================================