From 2f6a8de658a215b6c5ae2fca1e290acaa5309155 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 8 Feb 2008 20:50:55 +0000 Subject: [PATCH] recalculate all the margin sizes when the plasma theme changes svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=772465 --- dialog.cpp | 19 +++++++++++++------ dialog.h | 6 ++++++ widgets/tooltip.cpp | 17 +++++++++-------- widgets/tooltip_p.h | 2 +- 4 files changed, 29 insertions(+), 15 deletions(-) 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);