diff --git a/toolbox.cpp b/toolbox.cpp index 2ce74f479..5fe84cf0e 100644 --- a/toolbox.cpp +++ b/toolbox.cpp @@ -154,6 +154,18 @@ void Toolbox::setOrientation( Qt::Orientation orient ) d->orientation = orient; } +void Toolbox::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + event->accept(); +} + +void Toolbox::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (boundingRect().contains(event->pos())) { + emit toggled(); + } +} + } // plasma namespace #include "toolbox_p.moc" diff --git a/toolbox_p.h b/toolbox_p.h index 9f6834bfc..867a8c4c6 100644 --- a/toolbox_p.h +++ b/toolbox_p.h @@ -55,9 +55,12 @@ public: virtual void showToolbox() = 0; virtual void hideToolbox() = 0; +Q_SIGNALS: + void toggled(); + protected: - virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) = 0; - virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) = 0; + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); private: class Private;