diff --git a/applet.cpp b/applet.cpp index 4a454ed10..47396cdc3 100644 --- a/applet.cpp +++ b/applet.cpp @@ -56,10 +56,11 @@ class Applet::Private QStringList loadedEngines; }; -Applet::Applet(QWidget* parent, +Applet::Applet(QGraphicsItem *parent, KService::Ptr appletDescription, int id) - : QWidget(parent), + : QWidget(0), + QGraphicsItemGroup(parent), d(new Private(appletDescription, id)) { } @@ -124,12 +125,10 @@ QString Applet::instanceName() const return d->appletDescription->library() + QString::number(d->id); } -void Applet::watchForFocus(QWidget* widget, bool watch) +void Applet::watchForFocus(QObject *widget, bool watch) { if (!widget) - { return; - } int index = d->watchedForFocus.indexOf(widget); if (watch) @@ -149,10 +148,8 @@ void Applet::watchForFocus(QWidget* widget, bool watch) void Applet::needsFocus(bool focus) { - if (focus == hasFocus()) - { + if (focus == QWidget::hasFocus() || focus == QGraphicsItem::hasFocus()) return; - } emit requestFocus(focus); } diff --git a/applet.h b/applet.h index 27d0c28f4..d6e67ce91 100644 --- a/applet.h +++ b/applet.h @@ -19,6 +19,7 @@ #ifndef PLASMA_APPLET_H #define PLASMA_APPLET_H +#include #include #include @@ -29,14 +30,14 @@ namespace Plasma { -class KDE_EXPORT Applet : public QWidget +class KDE_EXPORT Applet : public QWidget, public QGraphicsItemGroup { Q_OBJECT public: typedef QList List; - Applet(QWidget* parent, + Applet(QGraphicsItem* parent, KService::Ptr appletDescription, int id); ~Applet(); @@ -89,7 +90,7 @@ class KDE_EXPORT Applet : public QWidget * @param widget the widget to watch for keyboard focus * @param watch whether to start watching the widget, or to stop doing so */ - void watchForFocus(QWidget* widget, bool watch = true); + void watchForFocus(QObject *widget, bool watch = true); /** * Call this whenever focus is needed or not needed. You do not have to