summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <[email protected]>2016-05-13 11:48:30 +0200
committerMarco Martin <[email protected]>2016-05-13 11:48:30 +0200
commit4453d62f8b454a1f0d489bf7abde533d52e475e8 (patch)
treeaa77da6b2abcf694b240ea04e6ba2756478edafa
parent1649a0f890b04c98756d765f846ec394b4aa8920 (diff)
use selected icon state for selected sidebar item
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
-rw-r--r--src/kitemviews/kstandarditemlistwidget.cpp17
-rw-r--r--src/kitemviews/kstandarditemlistwidget.h3
2 files changed, 15 insertions, 5 deletions
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp
index 51c5bc8..8740cb7 100644
--- a/src/kitemviews/kstandarditemlistwidget.cpp
+++ b/src/kitemviews/kstandarditemlistwidget.cpp
@@ -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));
}
diff --git a/src/kitemviews/kstandarditemlistwidget.h b/src/kitemviews/kstandarditemlistwidget.h
index 9ab5d4c..e6ba4bb 100644
--- a/src/kitemviews/kstandarditemlistwidget.h
+++ b/src/kitemviews/kstandarditemlistwidget.h
@@ -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