From 404b0b74d11c8c26b5c607d8653f4bca7cdc9173 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Mon, 21 Jan 2008 15:10:19 +0000 Subject: [PATCH] open toolbox when the dashboard view starts (to show the user a way how to "Hide Dashboard" again) svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=764361 --- containment.cpp | 10 ++++++++++ containment.h | 10 ++++++++++ desktoptoolbox.cpp | 20 ++++++++++++++++++-- desktoptoolbox_p.h | 3 +++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/containment.cpp b/containment.cpp index 9ead8c57f..9038bb7ce 100644 --- a/containment.cpp +++ b/containment.cpp @@ -858,6 +858,16 @@ bool Containment::isToolboxToolEnabled(const QString &toolname) const return d->createToolbox()->isToolEnabled(toolname); } +void Containment::showToolbox() +{ + d->createToolbox()->showToolbox(); +} + +void Containment::hideToolbox() +{ + d->createToolbox()->hideToolbox(); +} + } // Plasma namespace #include "containment.moc" diff --git a/containment.h b/containment.h index ac3ab9464..911887fc5 100644 --- a/containment.h +++ b/containment.h @@ -248,6 +248,16 @@ class PLASMA_EXPORT Containment : public Applet */ void containmentConstraintsUpdated(Plasma::Constraints constraints); + /** + * Open the Plasma toolbox + */ + void showToolbox(); + + /** + * Close the Plasma toolbox + */ + void hideToolbox(); + Q_SIGNALS: /** * This signal is emitted when a new applet is created by the containment diff --git a/desktoptoolbox.cpp b/desktoptoolbox.cpp index 4e79e0963..792490a11 100644 --- a/desktoptoolbox.cpp +++ b/desktoptoolbox.cpp @@ -158,6 +158,15 @@ void DesktopToolbox::hoverEnterEvent(QGraphicsSceneHoverEvent *event) QGraphicsItem::hoverEnterEvent(event); return; } + showToolbox(); + QGraphicsItem::hoverEnterEvent(event); +} + +void DesktopToolbox::showToolbox() +{ + if (m_showing) { + return; + } int maxwidth = 0; foreach (QGraphicsItem* tool, QGraphicsItem::children()) { @@ -198,7 +207,6 @@ void DesktopToolbox::hoverEnterEvent(QGraphicsSceneHoverEvent *event) // TODO: 10 and 200 shouldn't be hardcoded here. There needs to be a way to // match whatever the time is that moveItem() takes. Same in hoverLeaveEvent(). m_animId = phase->customAnimation(10, 240, Plasma::Phase::EaseInCurve, this, "animate"); - QGraphicsItem::hoverEnterEvent(event); } void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) @@ -208,6 +216,15 @@ void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) QGraphicsItem::hoverLeaveEvent(event); return; } + hideToolbox(); + QGraphicsItem::hoverLeaveEvent(event); +} + +void DesktopToolbox::hideToolbox() +{ + if (!m_showing) { + return; + } int x = m_size*2; int y = 0; @@ -231,7 +248,6 @@ void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) if (m_toolBacker) { m_toolBacker->hide(); } - QGraphicsItem::hoverLeaveEvent(event); } void DesktopToolbox::animate(qreal progress) diff --git a/desktoptoolbox_p.h b/desktoptoolbox_p.h index 05337ec2b..af5d5ba1c 100644 --- a/desktoptoolbox_p.h +++ b/desktoptoolbox_p.h @@ -47,6 +47,9 @@ public: bool isToolEnabled(const QString &tool) const; QGraphicsItem* tool(const QString &tool) const; + void showToolbox(); + void hideToolbox(); + protected: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); void hoverEnterEvent(QGraphicsSceneHoverEvent *event);