From 350bb8c48e54dbef8de2b880aee7f9243528138e Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Wed, 25 Jun 2008 00:33:46 +0000 Subject: [PATCH] AppletScript::shape() svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=824153 --- applet.cpp | 9 +++++++++ applet.h | 5 +++++ scripting/appletscript.cpp | 11 +++++++++++ scripting/appletscript.h | 5 +++++ 4 files changed, 30 insertions(+) diff --git a/applet.cpp b/applet.cpp index 63a98698a..1d7f8ca42 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1398,6 +1398,15 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value) return QGraphicsWidget::itemChange(change, value); } +QPainterPath Applet::shape() const +{ + if (d->script) { + return d->script->shape(); + } + + return QGraphicsWidget::shape(); +} + QSizeF Applet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const { QSizeF hint = QGraphicsWidget::sizeHint(which, constraint); diff --git a/applet.h b/applet.h index 47e479580..4932e5aba 100644 --- a/applet.h +++ b/applet.h @@ -727,6 +727,11 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget */ QVariant itemChange(GraphicsItemChange change, const QVariant &value); + /** + * Reimplemented from QGraphicsItem + */ + QPainterPath shape() const; + /** * Reimplemented from QGraphicsLayoutItem */ diff --git a/scripting/appletscript.cpp b/scripting/appletscript.cpp index cdc5b1beb..84e911f5c 100644 --- a/scripting/appletscript.cpp +++ b/scripting/appletscript.cpp @@ -80,6 +80,17 @@ QList AppletScript::contextualActions() return QList(); } +QPainterPath AppletScript::shape() const +{ + if (applet()) { + QPainterPath path; + path.addRect(applet()->boundingRect()); + return path; + } + + return QPainterPath(); +} + void AppletScript::showConfigurationInterface() { } diff --git a/scripting/appletscript.h b/scripting/appletscript.h index 3a8e2e745..dd6473585 100644 --- a/scripting/appletscript.h +++ b/scripting/appletscript.h @@ -98,6 +98,11 @@ public: */ virtual QList contextualActions(); + /** + * Returns the shape of the widget, defaults to the bounding rect + */ + virtual QPainterPath shape() const; + public Q_SLOTS: /**