From 2a7090728b8ef897a523712f89c917302f2c6532 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Tue, 3 Jan 2017 09:45:33 +0100 Subject: [PATCH 1/2] [DolphinView] Update view palette on palette change 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 | 35 ++++++++++++++++++++++------------- src/views/dolphinview.h | 2 ++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 4105628ee1..7d85fa240c 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -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(event); diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 0b0d8196d6..fbe3a6376f 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -762,6 +762,8 @@ private: QUrl viewPropertiesUrl() const; private: + void updatePalette(); + bool m_active; bool m_tabsForFiles; bool m_assureVisibleCurrentIndex; From 996f8520e7003326ade6ea96929dd41958ba308d Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Tue, 3 Jan 2017 09:46:43 +0100 Subject: [PATCH 2/2] Explicitly pass iconNameForUrl when creating new places entry Once KIO::iconNameForUrl returns special icons for standard paths (e.g. Video folder) this will ensure when adding such a folder to places it will automatically get the proper icon. Since KIO already depends on KBookmarks it can't depend the other way round, otherwise this would have been fixed in KBookmarks directly. Differential Revision: https://phabricator.kde.org/D3896 --- src/dolphincontextmenu.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index ed3f64379e..666b81c8d6 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -307,7 +307,7 @@ void DolphinContextMenu::openItemContextMenu() if (selectedUrl.isValid()) { PlacesItemModel model; const QString text = selectedUrl.fileName(); - PlacesItem* item = model.createPlacesItem(text, selectedUrl); + PlacesItem* item = model.createPlacesItem(text, selectedUrl, KIO::iconNameForUrl(selectedUrl)); model.appendItemToGroup(item); model.saveBookmarks(); } @@ -373,7 +373,8 @@ void DolphinContextMenu::openViewportContextMenu() if (container->url().isValid()) { PlacesItemModel model; PlacesItem* item = model.createPlacesItem(container->placesText(), - container->url()); + container->url(), + KIO::iconNameForUrl(container->url())); model.appendItemToGroup(item); model.saveBookmarks(); }