From 5eb18a635b2fa4d4e77593eb395bf8d088de86de Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Sun, 26 Oct 2008 16:55:54 +0000 Subject: [PATCH] allow tips to autohide; having them just stay there forever and ever is an annoyance. some tips need to be permanent to be useful though (e.g. on the clock) so introduced a way to make that happen. needed to get this in before we go BC =) svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=876166 --- private/tooltip.cpp | 10 +++++++++- private/tooltip_p.h | 2 +- tooltipmanager.cpp | 11 +++++++++-- tooltipmanager.h | 2 ++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/private/tooltip.cpp b/private/tooltip.cpp index c059cefd8..f4fe5778f 100644 --- a/private/tooltip.cpp +++ b/private/tooltip.cpp @@ -45,7 +45,8 @@ class ToolTipPrivate imageLabel(0), preview(0), windowToPreview(0), - source(s) + source(s), + autohide(true) { } QLabel *label; @@ -54,6 +55,7 @@ class ToolTipPrivate WId windowToPreview; PanelSvg *background; QPointer source; + bool autohide; }; void ToolTip::showEvent(QShowEvent *e) @@ -115,6 +117,7 @@ void ToolTip::setContent(const ToolTipManager::Content &data) d->imageLabel->setPixmap(data.image); d->windowToPreview = data.windowToPreview; d->preview->setWindowId(d->windowToPreview); + d->autohide = data.autohide; if (isVisible()) { resize(sizeHint()); @@ -162,6 +165,11 @@ void ToolTip::sourceDestroyed() d->source = 0; } +bool ToolTip::autohide() const +{ + return d->autohide; +} + void ToolTip::updateTheme() { d->background->setImagePath("widgets/tooltip"); diff --git a/private/tooltip_p.h b/private/tooltip_p.h index 339426dd5..210c575cc 100644 --- a/private/tooltip_p.h +++ b/private/tooltip_p.h @@ -41,7 +41,7 @@ public: void setContent(const ToolTipManager::Content &data); void prepareShowing(bool cueUpdate); void setActivated(bool value); - bool isActivated(); + bool autohide() const; protected: void showEvent(QShowEvent *); diff --git a/tooltipmanager.cpp b/tooltipmanager.cpp index 5a70c47cc..cc5fd0d43 100644 --- a/tooltipmanager.cpp +++ b/tooltipmanager.cpp @@ -109,7 +109,8 @@ ToolTipManager *ToolTipManager::self() } ToolTipManager::Content::Content() - : windowToPreview(0) + : windowToPreview(0), + autohide(true) { } @@ -146,7 +147,7 @@ void ToolTipManager::show(QGraphicsWidget *widget) } if (d->currentWidget) { - hide(d->currentWidget); + //hide(d->currentWidget); } d->hideTimer->stop(); @@ -373,6 +374,12 @@ void ToolTipManagerPrivate::showToolTip() tooltip->move(popupPosition(currentWidget, tooltip->size())); isShown = true; //ToolTip is visible tooltip->setVisible(true); + + if (tooltip->autohide()) { + //kDebug() << "starting authoide"; + delayedHide = true; + hideTimer->start(3000); + } } bool ToolTipManager::eventFilter(QObject *watched, QEvent *event) diff --git a/tooltipmanager.h b/tooltipmanager.h index 5dffaf624..600ca6230 100644 --- a/tooltipmanager.h +++ b/tooltipmanager.h @@ -97,6 +97,8 @@ public: QPixmap image; /** Id of a window if you want to show a preview */ WId windowToPreview; + /** Whether or not to autohide the tooltip, defaults to true */ + bool autohide; }; /**