diff --git a/applet.cpp b/applet.cpp index 87ae8a85d..6c41b6ccc 100644 --- a/applet.cpp +++ b/applet.cpp @@ -502,8 +502,8 @@ void Applet::setBackgroundHints(const BackgroundHints hints) d->background = new Plasma::PanelSvg(); d->background->setImagePath("widgets/background"); d->background->setEnabledBorders(Plasma::PanelSvg::AllBorders); - int left, top, right, bottom; - d->getBorderSize(left, top, right, bottom); + qreal left, top, right, bottom; + d->background->getMargins(left, top, right, bottom); setContentsMargins(left, right, top, bottom); QSizeF fitSize(left + right, top + bottom); @@ -513,8 +513,8 @@ void Applet::setBackgroundHints(const BackgroundHints hints) d->background->resizePanel(boundingRect().size()); } } else if (d->background) { - int left, top, right, bottom; - d->getBorderSize(left, top, right, bottom); + qreal left, top, right, bottom; + d->background->getMargins(left, top, right, bottom); //Setting a minimum size of 0,0 would result in the panel to be only //on the first virtual desktop setMinimumSize(qMax(minimumSize().width() - left - right, 1.0), @@ -1301,18 +1301,6 @@ QString Applet::Private::instanceName() return appletDescription.service()->library() + QString::number(appletId); } -void Applet::Private::getBorderSize(int& left , int& top, int &right, int& bottom) -{ - if (background) { - top = background->marginSize(Plasma::TopMargin); - left = background->marginSize(Plasma::LeftMargin); - right = background->marginSize(Plasma::RightMargin); - bottom = background->marginSize(Plasma::BottomMargin); - } else { - top = left = right = bottom = 0; - } -} - void Applet::Private::scheduleConstraintsUpdate(Plasma::Constraints c) { if (pendingConstraints == NoConstraint) { diff --git a/panelsvg.cpp b/panelsvg.cpp index c13607c5b..e2eb6f22a 100644 --- a/panelsvg.cpp +++ b/panelsvg.cpp @@ -231,6 +231,14 @@ qreal PanelSvg::marginSize(const Plasma::MarginEdge edge) const } } +void PanelSvg::getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const +{ + top = marginSize(Plasma::TopMargin); + left = marginSize(Plasma::LeftMargin); + right = marginSize(Plasma::RightMargin); + bottom = marginSize(Plasma::BottomMargin); +} + QBitmap PanelSvg::mask() const { PanelData *panel = d->panels[d->prefix]; diff --git a/panelsvg.h b/panelsvg.h index 18cc5501e..8b70812c0 100644 --- a/panelsvg.h +++ b/panelsvg.h @@ -100,6 +100,16 @@ class PLASMA_EXPORT PanelSvg : public Svg */ qreal marginSize(const Plasma::MarginEdge edge) const; + /** + * Convenience method that extracts the size of the four margins + * in the four output parameters + * @arg left left margin size + * @arg top top margin size + * @arg right right margin size + * @arg bottom bottom margin size + */ + void getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const; + /** * Sets the prefix (@see setElementPrefix) to 'north', 'south', 'west' and 'east' * when the location is TopEdge, BottomEdge, LeftEdge and RightEdge,