Added overlay support. To use it add to your theme overlay.svg.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=796088
This commit is contained in:
Davide Bettio 2008-04-12 14:07:44 +00:00
parent 382caec1f7
commit 8e45bf56db
2 changed files with 23 additions and 1 deletions

View File

@ -103,6 +103,7 @@ public:
package(0),
needsConfigOverlay(0),
background(0),
overlay(0),
failureText(0),
script(0),
configXml(0),
@ -132,6 +133,7 @@ public:
DataEngineManager::self()->unload( engine );
}
delete background;
delete overlay;
delete package;
delete configXml;
delete shadow;
@ -318,6 +320,7 @@ public:
QList<QGraphicsItem*> watchedForMouseMove;
QStringList loadedEngines;
Plasma::SvgPanel *background;
Plasma::SvgPanel *overlay;
Plasma::LineEdit *failureText;
AppletScript *script;
ConfigXml* configXml;
@ -641,6 +644,10 @@ void Applet::setDrawStandardBackground(bool drawBackground)
if (!d->background) {
d->background = new Plasma::SvgPanel("widgets/background");
if (!Plasma::Theme::self()->image("widgets/overlay").isEmpty()) {
d->overlay = new Plasma::SvgPanel("widgets/overlay");
}
int left, top, right, bottom;
d->getBorderSize(left, top, right, bottom);
setMargins(0, 0, right, bottom);
@ -649,7 +656,9 @@ void Applet::setDrawStandardBackground(bool drawBackground)
}
} else if (d->background) {
delete d->background;
delete d->overlay;
d->background = 0;
d->overlay = 0;
setMargins(0, 0, 0, 0);
updateGeometry();
update();
@ -977,6 +986,13 @@ void Applet::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *opti
paintInterface(painter, option, QRect(QPoint(0,0), d->contentSize(this).toSize()));
}
if (d->overlay &&
formFactor() != Plasma::Vertical &&
formFactor() != Plasma::Horizontal) {
//kDebug() << "option rect is" << option->rect;
d->overlay->paint(painter, option->rect);
}
painter->restore();
}
@ -1578,6 +1594,11 @@ void Applet::setGeometry(const QRectF& geometry)
d->background->resize(size());
}
if (d->overlay) {
//kDebug() << "setting overlay to" << size();
d->overlay->resize(size());
}
updateConstraints(Plasma::SizeConstraint);
emit geometryChanged();
} else if (p != pos()) {

View File

@ -93,7 +93,8 @@ class PLASMA_EXPORT Theme : public QObject
*
* @arg name the name of the file in the theme directory (without the
* ".svg" part or a leading slash)
* @return the full path to the requested file for the current theme
* @return the full path to the requested file for the current theme,
* or an empty string if the image is not available
*/
Q_INVOKABLE QString image( const QString& name ) const;