* adds a new convenience method getMargins(&qreal,&qreal,&qreal,&qreal)

to fetch all the four margins at a time
* now applet uses it

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=802928
This commit is contained in:
Marco Martin 2008-05-01 09:49:30 +00:00
parent fa598a779a
commit 703b6c2ffa
3 changed files with 22 additions and 16 deletions

View File

@ -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) {

View File

@ -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];

View File

@ -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,