From fcff33a4305e986911ca53a7d0e310f1071cadd5 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 11 Aug 2023 13:10:44 +0800 Subject: [PATCH] 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);