From 8e45bf56db1f82914d0377c001cdb8b2f9aea0e2 Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Sat, 12 Apr 2008 14:07:44 +0000 Subject: [PATCH] Added overlay support. To use it add to your theme overlay.svg. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=796088 --- applet.cpp | 21 +++++++++++++++++++++ theme.h | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/applet.cpp b/applet.cpp index 60534e98e..597781438 100644 --- a/applet.cpp +++ b/applet.cpp @@ -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 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()) { diff --git a/theme.h b/theme.h index 6e5ceebbd..5c8eb04af 100644 --- a/theme.h +++ b/theme.h @@ -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;