diff --git a/applet.cpp b/applet.cpp index b4f1003c7..df4b3ba57 100644 --- a/applet.cpp +++ b/applet.cpp @@ -145,6 +145,7 @@ public: // WARNING: do not access config() OR globalConfig() in this method! // that requires a scene, which is not available at this point applet->setAcceptsHoverEvents(true); + applet->setFlag(QGraphicsItem::ItemIsFocusable, true); if (!appletDescription.isValid()) { applet->setFailedToLaunch(true, i18n("Invalid applet description")); @@ -1232,6 +1233,17 @@ void Applet::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } } +void Applet::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + setFocus(Qt::MouseFocusReason); + QGraphicsWidget::mousePressEvent(event); +} + +void Applet::focusInEvent(QFocusEvent * event) +{ + kDebug() << "FOCUS! FOCUS! FOCUS!"; + QGraphicsWidget::focusInEvent(event); +} void Applet::showConfigurationInterface() { diff --git a/applet.h b/applet.h index 8a23bf923..eee4eb079 100644 --- a/applet.h +++ b/applet.h @@ -384,10 +384,10 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget **/ QString name() const; - /** - * @return the font currently set for this widget - **/ - QFont font() const; + /** + * @return the font currently set for this widget + **/ + QFont font() const; /** * Returns the plugin name for the applet @@ -442,7 +442,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget **/ void setDrawStandardBackground(bool drawBackground); - void paintWindowFrame ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); + void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); /** * If for some reason, the applet fails to get up on its feet (the @@ -532,13 +532,13 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget */ bool isContainment() const; - /** + /** * Sets the geometry of this Plasma::Applet. Should not be used directly by * applet subclasses. * @param geometry the geometry to apply to this Plasma::Applet. */ void setGeometry(const QRectF &geometry); - + /** * Causes this applet to raise above all other applets. */ @@ -717,6 +717,11 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget */ void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + /** + * @internal manage the mouse movement to drag the applet around + */ + void mousePressEvent(QGraphicsSceneMouseEvent *event); + /** * Reimplemented from QGraphicsItem */ diff --git a/containment.cpp b/containment.cpp index 1dbbfcf30..a1d5c317a 100644 --- a/containment.cpp +++ b/containment.cpp @@ -1173,6 +1173,17 @@ void Containment::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event) } +void Containment::keyPressEvent(QKeyEvent *event) +{ + kDebug() << "keyPressEvent with" << event->key() << "and hoping and wishing for a" << Qt::Key_Tab; + if (event->key() == Qt::Key_Tab) { // && event->modifiers() == 0) { + kDebug() << "let's give focus to...." << (QObject*)d->applets.first(); + if (!d->applets.isEmpty()) { + d->applets.first()->setFocus(Qt::TabFocusReason); + } + } +} + bool Containment::sceneEventFilter(QGraphicsItem *watched, QEvent *event) { Applet *applet = qgraphicsitem_cast(watched); diff --git a/containment.h b/containment.h index 986961c3c..6f68b5940 100644 --- a/containment.h +++ b/containment.h @@ -414,6 +414,7 @@ class PLASMA_EXPORT Containment : public Applet void contextMenuEvent(QGraphicsSceneContextMenuEvent * event); void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); + void keyPressEvent(QKeyEvent *event); bool sceneEventFilter(QGraphicsItem *watched, QEvent *event); QVariant itemChange(GraphicsItemChange change, const QVariant &value);