diff --git a/dialog.cpp b/dialog.cpp index 9bc154441..0bfb969da 100644 --- a/dialog.cpp +++ b/dialog.cpp @@ -35,6 +35,7 @@ #include #include +#include #ifdef Q_WS_X11 #include @@ -62,17 +63,23 @@ Dialog::Dialog( QWidget * parent, Qt::WindowFlags f ) d->background->setBorderFlags(SvgPanel::DrawAllBorders); d->background->resize(size()); + connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update())); + + connect(Plasma::Theme::self(), SIGNAL(changed()), this, SLOT(themeUpdated())); + themeUpdated(); +} + +Dialog::~Dialog() +{ +} + +void Dialog::themeUpdated() +{ const int topHeight = d->background->marginSize(Plasma::TopMargin); const int leftWidth = d->background->marginSize(Plasma::LeftMargin); const int rightWidth = d->background->marginSize(Plasma::RightMargin); const int bottomHeight = d->background->marginSize(Plasma::BottomMargin); setContentsMargins(leftWidth, topHeight, rightWidth, bottomHeight); - - connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update())); -} - -Dialog::~Dialog() -{ } void Dialog::paintEvent(QPaintEvent *e) diff --git a/dialog.h b/dialog.h index 9f3119447..f7a3a9019 100644 --- a/dialog.h +++ b/dialog.h @@ -75,6 +75,12 @@ class PLASMA_EXPORT Dialog : public QWidget void paintEvent(QPaintEvent *e); void resizeEvent(QResizeEvent *e); + private Q_SLOTS: + /** + * React to theme changes + */ + void themeUpdated(); + private: class Private; Private * const d; diff --git a/widgets/tooltip.cpp b/widgets/tooltip.cpp index fbbbdbb96..234b1f335 100644 --- a/widgets/tooltip.cpp +++ b/widgets/tooltip.cpp @@ -195,11 +195,6 @@ ToolTip::ToolTip() d->background = new SvgPanel("widgets/tooltip", this); d->background->setBorderFlags(SvgPanel::DrawAllBorders); - const int topHeight = d->background->marginSize(Plasma::TopMargin); - const int leftWidth = d->background->marginSize(Plasma::LeftMargin); - const int rightWidth = d->background->marginSize(Plasma::RightMargin); - const int bottomHeight = d->background->marginSize(Plasma::BottomMargin); - setContentsMargins(leftWidth, topHeight, rightWidth, bottomHeight); connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update())); @@ -216,8 +211,8 @@ ToolTip::ToolTip() connect(d->showTimer, SIGNAL(timeout()), SLOT(showToolTip())); connect(d->hideTimer, SIGNAL(timeout()), SLOT(resetShownState())); - connect(Plasma::Theme::self(), SIGNAL(changed()), this, SLOT(resetPalette())); - resetPalette(); + connect(Plasma::Theme::self(), SIGNAL(changed()), this, SLOT(themeUpdated())); + themeUpdated(); } ToolTip::~ToolTip() @@ -242,8 +237,14 @@ void ToolTip::setData(const Plasma::ToolTipData &data) } } -void ToolTip::resetPalette() +void ToolTip::themeUpdated() { + const int topHeight = d->background->marginSize(Plasma::TopMargin); + const int leftWidth = d->background->marginSize(Plasma::LeftMargin); + const int rightWidth = d->background->marginSize(Plasma::RightMargin); + const int bottomHeight = d->background->marginSize(Plasma::BottomMargin); + setContentsMargins(leftWidth, topHeight, rightWidth, bottomHeight); + // Make the tooltip use Plasma's colorscheme QPalette plasmaPalette = QPalette(); plasmaPalette.setColor(QPalette::Window, Plasma::Theme::self()->backgroundColor()); diff --git a/widgets/tooltip_p.h b/widgets/tooltip_p.h index d494f6a6b..90e76f498 100644 --- a/widgets/tooltip_p.h +++ b/widgets/tooltip_p.h @@ -60,7 +60,7 @@ protected: private Q_SLOTS: void resetShownState(); void showToolTip(); - void resetPalette(); + void themeUpdated(); private: void setData(const Plasma::ToolTipData &data);