From 35cd88ab4efadeaf458028c66b63d208b29c4562 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 20 Jan 2009 02:39:27 +0000 Subject: [PATCH] update() on icon config changes BUG:181298 svn path=/branches/KDE/4.2/kdelibs/; revision=913905 --- widgets/iconwidget.cpp | 19 +++++++++++++++++-- widgets/iconwidget.h | 3 ++- widgets/iconwidget_p.h | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/widgets/iconwidget.cpp b/widgets/iconwidget.cpp index c58fe02b0..6b0370e0f 100644 --- a/widgets/iconwidget.cpp +++ b/widgets/iconwidget.cpp @@ -88,6 +88,19 @@ void IconWidgetPrivate::readColors() shadowColor = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor); } +void IconWidgetPrivate::colorConfigChanged() +{ + readColors(); + q->update(); +} + +void IconWidgetPrivate::iconConfigChanged() +{ + if (!icon.isNull()) { + q->update(); + } +} + IconAction::IconAction(IconWidget *icon, QAction *action) : m_icon(icon), m_action(action), @@ -296,8 +309,9 @@ IconWidget::~IconWidget() void IconWidgetPrivate::init() { readColors(); - QObject::connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(readColors())); - QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(readColors())); + QObject::connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(colorConfigChanged())); + QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorConfigChanged())); + QObject::connect(KGlobalSettings::self(), SIGNAL(iconChanged(int)), q, SLOT(iconConfigChanged())); // setAcceptedMouseButtons(Qt::LeftButton); q->setAcceptsHoverEvents(true); @@ -517,6 +531,7 @@ void IconWidget::setSvg(const QString &svgFilePath, const QString &elementId) d->iconSvg->setContainsMultipleImages(!elementId.isNull()); d->iconSvgElement = elementId; d->iconSvgElementChanged = true; + d->icon = QIcon(); update(); } diff --git a/widgets/iconwidget.h b/widgets/iconwidget.h index 2b9537b7d..2033742da 100644 --- a/widgets/iconwidget.h +++ b/widgets/iconwidget.h @@ -281,8 +281,9 @@ private: Q_PRIVATE_SLOT(d, void clearAction()) Q_PRIVATE_SLOT(d, void svgChanged()) Q_PRIVATE_SLOT(d, void actionDestroyed(QObject *obj)) - Q_PRIVATE_SLOT(d, void readColors()) Q_PRIVATE_SLOT(d, void hoverAnimationUpdate(qreal progress)) + Q_PRIVATE_SLOT(d, void colorConfigChanged()) + Q_PRIVATE_SLOT(d, void iconConfigChanged()) IconWidgetPrivate * const d; friend class IconWidgetPrivate; diff --git a/widgets/iconwidget_p.h b/widgets/iconwidget_p.h index 1782dbd6f..20f7d442b 100644 --- a/widgets/iconwidget_p.h +++ b/widgets/iconwidget_p.h @@ -179,6 +179,8 @@ public: void actionDestroyed(QObject *obj); void readColors(); + void colorConfigChanged(); + void iconConfigChanged(); void hoverAnimationUpdate(qreal progress); void init(); void layoutIcons(const QStyleOptionGraphicsItem *option);