mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
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
This commit is contained in:
parent
1649a0f890
commit
4453d62f8b
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue