recalculate all the margin sizes when the plasma theme changes

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=772465
This commit is contained in:
Marco Martin 2008-02-08 20:50:55 +00:00
parent 5f0afdd61c
commit 2f6a8de658
4 changed files with 29 additions and 15 deletions

View File

@ -35,6 +35,7 @@
#include <NETRootInfo> #include <NETRootInfo>
#include <plasma/svgpanel.h> #include <plasma/svgpanel.h>
#include <plasma/theme.h>
#ifdef Q_WS_X11 #ifdef Q_WS_X11
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -62,17 +63,23 @@ Dialog::Dialog( QWidget * parent, Qt::WindowFlags f )
d->background->setBorderFlags(SvgPanel::DrawAllBorders); d->background->setBorderFlags(SvgPanel::DrawAllBorders);
d->background->resize(size()); 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 topHeight = d->background->marginSize(Plasma::TopMargin);
const int leftWidth = d->background->marginSize(Plasma::LeftMargin); const int leftWidth = d->background->marginSize(Plasma::LeftMargin);
const int rightWidth = d->background->marginSize(Plasma::RightMargin); const int rightWidth = d->background->marginSize(Plasma::RightMargin);
const int bottomHeight = d->background->marginSize(Plasma::BottomMargin); const int bottomHeight = d->background->marginSize(Plasma::BottomMargin);
setContentsMargins(leftWidth, topHeight, rightWidth, bottomHeight); setContentsMargins(leftWidth, topHeight, rightWidth, bottomHeight);
connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update()));
}
Dialog::~Dialog()
{
} }
void Dialog::paintEvent(QPaintEvent *e) void Dialog::paintEvent(QPaintEvent *e)

View File

@ -75,6 +75,12 @@ class PLASMA_EXPORT Dialog : public QWidget
void paintEvent(QPaintEvent *e); void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e); void resizeEvent(QResizeEvent *e);
private Q_SLOTS:
/**
* React to theme changes
*/
void themeUpdated();
private: private:
class Private; class Private;
Private * const d; Private * const d;

View File

@ -195,11 +195,6 @@ ToolTip::ToolTip()
d->background = new SvgPanel("widgets/tooltip", this); d->background = new SvgPanel("widgets/tooltip", this);
d->background->setBorderFlags(SvgPanel::DrawAllBorders); 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())); connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update()));
@ -216,8 +211,8 @@ ToolTip::ToolTip()
connect(d->showTimer, SIGNAL(timeout()), SLOT(showToolTip())); connect(d->showTimer, SIGNAL(timeout()), SLOT(showToolTip()));
connect(d->hideTimer, SIGNAL(timeout()), SLOT(resetShownState())); connect(d->hideTimer, SIGNAL(timeout()), SLOT(resetShownState()));
connect(Plasma::Theme::self(), SIGNAL(changed()), this, SLOT(resetPalette())); connect(Plasma::Theme::self(), SIGNAL(changed()), this, SLOT(themeUpdated()));
resetPalette(); themeUpdated();
} }
ToolTip::~ToolTip() 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 // Make the tooltip use Plasma's colorscheme
QPalette plasmaPalette = QPalette(); QPalette plasmaPalette = QPalette();
plasmaPalette.setColor(QPalette::Window, Plasma::Theme::self()->backgroundColor()); plasmaPalette.setColor(QPalette::Window, Plasma::Theme::self()->backgroundColor());

View File

@ -60,7 +60,7 @@ protected:
private Q_SLOTS: private Q_SLOTS:
void resetShownState(); void resetShownState();
void showToolTip(); void showToolTip();
void resetPalette(); void themeUpdated();
private: private:
void setData(const Plasma::ToolTipData &data); void setData(const Plasma::ToolTipData &data);