]> cloud.milkyroute.net Git - dolphin.git/commitdiff
use selected icon state for selected sidebar item
authorMarco Martin <notmart@gmail.com>
Fri, 13 May 2016 09:48:30 +0000 (11:48 +0200)
committerMarco Martin <notmart@gmail.com>
Fri, 13 May 2016 09:48:30 +0000 (11:48 +0200)
Since now the breeze icons can be recolored by kiconloader
with svg stylesheets, use this feature to recolor the
currently selected icon in the sidebar and in the
details view (not the icon view)
look wouldn't change if used with icon themes that
don't support this feature
This makes it look more in line with the breeze style

REVIEW:127877

src/kitemviews/kstandarditemlistwidget.cpp
src/kitemviews/kstandarditemlistwidget.h

index 51c5bc896a588f03a450cee07dd4e69d1a6a1918..8740cb73fd59c6b55ea856bd2c011e504e6183aa 100644 (file)
@@ -850,6 +850,15 @@ void KStandardItemListWidget::hideEvent(QHideEvent* event)
     KItemListWidget::hideEvent(event);
 }
 
+bool KStandardItemListWidget::event(QEvent *event)
+{
+    if (event->type() == QEvent::WindowDeactivate || event->type() == QEvent::WindowActivate) {
+        m_dirtyContent = true;
+    }
+
+    return KItemListWidget::event(event);
+}
+
 void KStandardItemListWidget::slotCutItemsChanged()
 {
     const QUrl itemUrl = data().value("url").toUrl();
@@ -954,7 +963,7 @@ void KStandardItemListWidget::updatePixmapCache()
                 iconName = QStringLiteral("unknown");
             }
             const QStringList overlays = values["iconOverlays"].toStringList();
-            m_pixmap = pixmapForIcon(iconName, overlays, maxIconHeight);
+            m_pixmap = pixmapForIcon(iconName, overlays, maxIconHeight, isSelected() && isActiveWindow() ? QIcon::Selected : QIcon::Normal);
 
         } else if (m_pixmap.width() / m_pixmap.devicePixelRatio() != maxIconWidth || m_pixmap.height() / m_pixmap.devicePixelRatio() != maxIconHeight) {
             // A custom pixmap has been applied. Assure that the pixmap
@@ -1438,11 +1447,11 @@ void KStandardItemListWidget::closeRoleEditor()
     m_roleEditor = 0;
 }
 
-QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStringList& overlays, int size)
+QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStringList& overlays, int size, QIcon::Mode mode)
 {
     static const QIcon fallbackIcon = QIcon::fromTheme(QStringLiteral("unknown"));
     size *= qApp->devicePixelRatio();
-    const QString key = "KStandardItemListWidget:" % name % ":" % overlays.join(QStringLiteral(":")) % ":" % QString::number(size);
+    const QString key = "KStandardItemListWidget:" % name % ":" % overlays.join(QStringLiteral(":")) % ":" % QString::number(size) % ":" % QString::number(mode);
     QPixmap pixmap;
 
     if (!QPixmapCache::find(key, pixmap)) {
@@ -1467,7 +1476,7 @@ QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStrin
             requestedSize = size;
         }
 
-        pixmap = icon.pixmap(requestedSize / qApp->devicePixelRatio(), requestedSize / qApp->devicePixelRatio());
+        pixmap = icon.pixmap(requestedSize / qApp->devicePixelRatio(), requestedSize / qApp->devicePixelRatio(), mode);
         if (requestedSize != size) {
             KPixmapModifier::scale(pixmap, QSize(size, size));
         }
index 9ab5d4c8f776957323c540c2802bcbf47c852a91..e6ba4bb3f6d3d2098bdd4d86643be47d4a45251c 100644 (file)
@@ -183,6 +183,7 @@ protected:
     virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
     virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
     virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
+    bool event(QEvent *event) Q_DECL_OVERRIDE;
 
 private slots:
     void slotCutItemsChanged();
@@ -212,7 +213,7 @@ private:
      */
     void closeRoleEditor();
 
-    static QPixmap pixmapForIcon(const QString& name, const QStringList& overlays, int size);
+    static QPixmap pixmapForIcon(const QString& name, const QStringList& overlays, int size, QIcon::Mode mode);
 
     /**
      * @return Preferred size of the rating-image based on the given