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
This commit is contained in:
parent
9dfd938d17
commit
5eb18a635b
@ -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<QObject> 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");
|
||||
|
@ -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 *);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user