Fix warn colour in dark mode
authorClaudio Cambra <claudio.cambra@gmail.com>
Tue, 15 Feb 2022 12:53:39 +0000 (13:53 +0100)
committerClaudio Cambra <claudio.cambra@gmail.com>
Fri, 18 Mar 2022 11:08:12 +0000 (12:08 +0100)
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
src/gui/folderwizard.cpp
src/gui/folderwizard.h

index b240d72355fac9ab9f86cb32f3e253b3249058e8..b10752621d4b730b9053170959ae01abf5ae1de4 100644 (file)
@@ -77,6 +77,8 @@ FolderWizardLocalPath::FolderWizardLocalPath(const AccountPtr &account)
 
     _ui.warnLabel->setTextFormat(Qt::RichText);
     _ui.warnLabel->hide();
+
+    changeStyle();
 }
 
 FolderWizardLocalPath::~FolderWizardLocalPath() = default;
@@ -141,6 +143,31 @@ void FolderWizardLocalPath::slotChooseLocalFolder()
     emit completeChanged();
 }
 
+
+void FolderWizardLocalPath::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 FolderWizardLocalPath::changeStyle()
+{
+    const auto warnYellow = Theme::isDarkColor(QGuiApplication::palette().base().color()) ? QColor(63, 63, 0) : QColor(255, 255, 192);
+    auto modifiedPalette = _ui.warnLabel->palette();
+    modifiedPalette.setColor(QPalette::Window, warnYellow);
+    _ui.warnLabel->setPalette(modifiedPalette);
+}
+
 // =================================================================================
 FolderWizardRemotePath::FolderWizardRemotePath(const AccountPtr &account)
     : FormatWarningsWizardPage()
index c6e7d48ce69ff30f40a2159f3ff4c8611f5812a0..72b83e3e3a1f248417bbf003b9d6e8d400766258 100644 (file)
@@ -60,10 +60,16 @@ public:
     void cleanupPage() override;
 
     void setFolderMap(const Folder::Map &fm) { _folderMap = fm; }
+
+protected:
+    void changeEvent(QEvent *) override;
+
 protected slots:
     void slotChooseLocalFolder();
 
 private:
+    void changeStyle();
+
     Ui_FolderWizardSourcePage _ui;
     Folder::Map _folderMap;
     AccountPtr _account;