]> cloud.milkyroute.net Git - dolphin.git/commitdiff
[DolphinView] Update view palette on palette change
authorKai Uwe Broulik <kde@privat.broulik.de>
Tue, 3 Jan 2017 08:45:33 +0000 (09:45 +0100)
committerKai Uwe Broulik <kde@privat.broulik.de>
Tue, 3 Jan 2017 08:45:33 +0000 (09:45 +0100)
Everything was handling palette change already but for the visual distinction between
active and non-active view (in case of split view), a custom palette was set which was
then never updated. This could be seen by the label text color changing but not the view background.

Differential Revision: https://phabricator.kde.org/D3909

src/views/dolphinview.cpp
src/views/dolphinview.h

index 4105628ee1d2b9f220eaff355dc2b6d8a0ea2741..7d85fa240c36027e25ad9ff950ad4515695340bf 100644 (file)
@@ -211,19 +211,7 @@ void DolphinView::setActive(bool active)
 
     m_active = active;
 
-    QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
-    if (!active) {
-        color.setAlpha(150);
-    }
-
-    QWidget* viewport = m_container->viewport();
-    if (viewport) {
-        QPalette palette;
-        palette.setColor(viewport->backgroundRole(), color);
-        viewport->setPalette(palette);
-    }
-
-    update();
+    updatePalette();
 
     if (active) {
         m_container->setFocus();
@@ -721,9 +709,30 @@ void DolphinView::stopLoading()
     m_model->cancelDirectoryLoading();
 }
 
+void DolphinView::updatePalette()
+{
+    QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
+    if (!m_active) {
+        color.setAlpha(150);
+    }
+
+    QWidget* viewport = m_container->viewport();
+    if (viewport) {
+        QPalette palette;
+        palette.setColor(viewport->backgroundRole(), color);
+        viewport->setPalette(palette);
+    }
+
+    update();
+}
+
 bool DolphinView::eventFilter(QObject* watched, QEvent* event)
 {
     switch (event->type()) {
+    case QEvent::PaletteChange:
+        updatePalette();
+        break;
+
     case QEvent::KeyPress:
         if (GeneralSettings::useTabForSwitchingSplitView()) {
             QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
index 0b0d8196d68714042177829545e32593826c799b..fbe3a6376f965c9ae05a51a1580e4bbcd347accc 100644 (file)
@@ -762,6 +762,8 @@ private:
     QUrl viewPropertiesUrl() const;
 
 private:
+    void updatePalette();
+
     bool m_active;
     bool m_tabsForFiles;
     bool m_assureVisibleCurrentIndex;