remove gratuitous "ToolTip"s
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=874244
This commit is contained in:
parent
70abf9ff86
commit
7abb5164a5
@ -300,7 +300,7 @@ void Applet::setFailedToLaunch(bool failed, const QString &reason)
|
|||||||
data.mainText = i18n("Unable to load the widget");
|
data.mainText = i18n("Unable to load the widget");
|
||||||
data.subText = reason;
|
data.subText = reason;
|
||||||
data.image = KIcon("dialog-error").pixmap(IconSize(KIconLoader::Desktop));
|
data.image = KIcon("dialog-error").pixmap(IconSize(KIconLoader::Desktop));
|
||||||
Plasma::ToolTipManager::self()->setToolTipContent(failureIcon, data);
|
Plasma::ToolTipManager::self()->setContent(failureIcon, data);
|
||||||
|
|
||||||
setLayout(failureLayout);
|
setLayout(failureLayout);
|
||||||
resize(300, 250);
|
resize(300, 250);
|
||||||
|
@ -45,8 +45,7 @@ class ToolTipPrivate
|
|||||||
imageLabel(0),
|
imageLabel(0),
|
||||||
preview(0),
|
preview(0),
|
||||||
windowToPreview(0),
|
windowToPreview(0),
|
||||||
source(s),
|
source(s)
|
||||||
isActivated(true)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
QLabel *label;
|
QLabel *label;
|
||||||
@ -55,7 +54,6 @@ class ToolTipPrivate
|
|||||||
WId windowToPreview;
|
WId windowToPreview;
|
||||||
PanelSvg *background;
|
PanelSvg *background;
|
||||||
QObject *source;
|
QObject *source;
|
||||||
bool isActivated;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void ToolTip::showEvent(QShowEvent *e)
|
void ToolTip::showEvent(QShowEvent *e)
|
||||||
@ -140,16 +138,6 @@ void ToolTip::prepareShowing(bool cueUpdate)
|
|||||||
resize(sizeHint());
|
resize(sizeHint());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::setActivated(bool value)
|
|
||||||
{
|
|
||||||
d->isActivated = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ToolTip::isActivated()
|
|
||||||
{
|
|
||||||
return d->isActivated;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolTip::resizeEvent(QResizeEvent *e)
|
void ToolTip::resizeEvent(QResizeEvent *e)
|
||||||
{
|
{
|
||||||
QWidget::resizeEvent(e);
|
QWidget::resizeEvent(e);
|
||||||
|
@ -132,14 +132,14 @@ ToolTipManager::~ToolTipManager()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTipManager::showToolTip(QGraphicsWidget *widget)
|
void ToolTipManager::show(QGraphicsWidget *widget)
|
||||||
{
|
{
|
||||||
if (!d->tooltips.contains(widget)) {
|
if (!d->tooltips.contains(widget)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->currentWidget) {
|
if (d->currentWidget) {
|
||||||
hideToolTip(d->currentWidget);
|
hide(d->currentWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->hideTimer->stop();
|
d->hideTimer->stop();
|
||||||
@ -156,7 +156,7 @@ void ToolTipManager::showToolTip(QGraphicsWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolTipManager::isToolTipVisible(QGraphicsWidget *widget) const
|
bool ToolTipManager::isVisible(QGraphicsWidget *widget) const
|
||||||
{
|
{
|
||||||
ToolTip *tooltip = d->tooltips.value(widget);
|
ToolTip *tooltip = d->tooltips.value(widget);
|
||||||
if (tooltip) {
|
if (tooltip) {
|
||||||
@ -166,14 +166,14 @@ bool ToolTipManager::isToolTipVisible(QGraphicsWidget *widget) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTipManager::delayedHideToolTip()
|
void ToolTipManager::delayedHide()
|
||||||
{
|
{
|
||||||
d->showTimer->stop(); // stop the timer to show the tooltip
|
d->showTimer->stop(); // stop the timer to show the tooltip
|
||||||
d->delayedHide = true;
|
d->delayedHide = true;
|
||||||
d->hideTimer->start(250);
|
d->hideTimer->start(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTipManager::hideToolTip(QGraphicsWidget *widget)
|
void ToolTipManager::hide(QGraphicsWidget *widget)
|
||||||
{
|
{
|
||||||
ToolTip *tooltip = d->tooltips.value(widget);
|
ToolTip *tooltip = d->tooltips.value(widget);
|
||||||
if (tooltip) {
|
if (tooltip) {
|
||||||
@ -210,7 +210,7 @@ void ToolTipManager::unregisterWidget(QGraphicsWidget *widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTipManager::setToolTipContent(QGraphicsWidget *widget, const ToolTipContent &data)
|
void ToolTipManager::setContent(QGraphicsWidget *widget, const ToolTipContent &data)
|
||||||
{
|
{
|
||||||
registerWidget(widget);
|
registerWidget(widget);
|
||||||
|
|
||||||
@ -309,6 +309,7 @@ void ToolTipManagerPrivate::showToolTip()
|
|||||||
// give the object a chance for delayed loading of the tip
|
// give the object a chance for delayed loading of the tip
|
||||||
QMetaObject::invokeMethod(currentWidget, "toolTipAboutToShow");
|
QMetaObject::invokeMethod(currentWidget, "toolTipAboutToShow");
|
||||||
tooltip = tooltips.value(currentWidget);
|
tooltip = tooltips.value(currentWidget);
|
||||||
|
kDebug() << "attempt to make one ... we gots" << tooltip;
|
||||||
if (tooltip) {
|
if (tooltip) {
|
||||||
justCreated = true;
|
justCreated = true;
|
||||||
} else {
|
} else {
|
||||||
@ -317,14 +318,12 @@ void ToolTipManagerPrivate::showToolTip()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tooltip->isActivated()) {
|
tooltip->setVisible(false);
|
||||||
tooltip->setVisible(false);
|
//kDebug() << "about to show" << justCreated;
|
||||||
//kDebug() << "about to show" << justCreated;
|
tooltip->prepareShowing(!justCreated);
|
||||||
tooltip->prepareShowing(!justCreated);
|
tooltip->move(popupPosition(currentWidget, tooltip->size()));
|
||||||
tooltip->move(popupPosition(currentWidget, tooltip->size()));
|
isShown = true; //ToolTip is visible
|
||||||
isShown = true; //ToolTip is visible
|
tooltip->setVisible(true);
|
||||||
tooltip->setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolTipManager::eventFilter(QObject *watched, QEvent *event)
|
bool ToolTipManager::eventFilter(QObject *watched, QEvent *event)
|
||||||
@ -338,7 +337,7 @@ bool ToolTipManager::eventFilter(QObject *watched, QEvent *event)
|
|||||||
case QEvent::GraphicsSceneHoverMove:
|
case QEvent::GraphicsSceneHoverMove:
|
||||||
// If the tooltip isn't visible, run through showing the tooltip again
|
// If the tooltip isn't visible, run through showing the tooltip again
|
||||||
// so that it only becomes visible after a stationary hover
|
// so that it only becomes visible after a stationary hover
|
||||||
if (Plasma::ToolTipManager::self()->isToolTipVisible(widget)) {
|
if (Plasma::ToolTipManager::self()->isVisible(widget)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,19 +360,19 @@ bool ToolTipManager::eventFilter(QObject *watched, QEvent *event)
|
|||||||
// initialized, in which case view() will return 0.
|
// initialized, in which case view() will return 0.
|
||||||
QGraphicsView *parentView = viewFor(widget);
|
QGraphicsView *parentView = viewFor(widget);
|
||||||
if (parentView) {
|
if (parentView) {
|
||||||
showToolTip(widget);
|
show(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case QEvent::GraphicsSceneHoverLeave:
|
case QEvent::GraphicsSceneHoverLeave:
|
||||||
delayedHideToolTip();
|
delayedHide();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEvent::GraphicsSceneMousePress:
|
case QEvent::GraphicsSceneMousePress:
|
||||||
case QEvent::GraphicsSceneWheel:
|
case QEvent::GraphicsSceneWheel:
|
||||||
hideToolTip(widget);
|
hide(widget);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -46,14 +46,14 @@ class Applet;
|
|||||||
* data.mainText = i18n("My Title");
|
* data.mainText = i18n("My Title");
|
||||||
* data.subText = i18n("This is a little tooltip");
|
* data.subText = i18n("This is a little tooltip");
|
||||||
* data.image = KIcon("some-icon").pixmap(IconSize(KIconLoader::Desktop));
|
* data.image = KIcon("some-icon").pixmap(IconSize(KIconLoader::Desktop));
|
||||||
* Plasma::ToolTipManager::self()->setToolTipContent(widget, data);
|
* Plasma::ToolTipManager::self()->setContent(widget, data);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* Note that, since a Plasma::Applet is a QGraphicsWidget, you can use
|
* Note that, since a Plasma::Applet is a QGraphicsWidget, you can use
|
||||||
* Plasma::ToolTipManager::self()->setToolTipContent(this, data); in the
|
* Plasma::ToolTipManager::self()->setContent(this, data); in the
|
||||||
* applet's init() method to set a tooltip for the whole applet.
|
* applet's init() method to set a tooltip for the whole applet.
|
||||||
*
|
*
|
||||||
* The tooltip will be registered automatically by setToolTipContent(). It will be
|
* The tooltip will be registered automatically by setContent(). It will be
|
||||||
* automatically unregistered when the associated widget is deleted, freeing the
|
* automatically unregistered when the associated widget is deleted, freeing the
|
||||||
* memory used by the tooltip, but you can manually unregister it at any time by
|
* memory used by the tooltip, but you can manually unregister it at any time by
|
||||||
* calling unregisterWidget().
|
* calling unregisterWidget().
|
||||||
@ -103,7 +103,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @param widget the widget for which the tooltip will be displayed
|
* @param widget the widget for which the tooltip will be displayed
|
||||||
*/
|
*/
|
||||||
void showToolTip(QGraphicsWidget *widget);
|
void show(QGraphicsWidget *widget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out whether the tooltip for a given widget is currently being displayed.
|
* Find out whether the tooltip for a given widget is currently being displayed.
|
||||||
@ -112,24 +112,24 @@ public:
|
|||||||
* @return true if the tooltip of the widget is currently displayed,
|
* @return true if the tooltip of the widget is currently displayed,
|
||||||
* false if not
|
* false if not
|
||||||
*/
|
*/
|
||||||
bool isToolTipVisible(QGraphicsWidget *widget) const;
|
bool isVisible(QGraphicsWidget *widget) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hides the currently showing tooltip after a short amount of time.
|
* Hides the currently showing tooltip after a short amount of time.
|
||||||
*/
|
*/
|
||||||
void delayedHideToolTip();
|
void delayedHide();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hides the tooltip for a widget immediately.
|
* Hides the tooltip for a widget immediately.
|
||||||
*
|
*
|
||||||
* @param widget the widget to hide the tooltip for
|
* @param widget the widget to hide the tooltip for
|
||||||
*/
|
*/
|
||||||
void hideToolTip(QGraphicsWidget *widget);
|
void hide(QGraphicsWidget *widget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a widget with the tooltip manager.
|
* Registers a widget with the tooltip manager.
|
||||||
*
|
*
|
||||||
* Note that setToolTipContent() will register the widget if it
|
* Note that setContent() will register the widget if it
|
||||||
* has not already been registered, and so you do not normally
|
* has not already been registered, and so you do not normally
|
||||||
* need to use the method.
|
* need to use the method.
|
||||||
*
|
*
|
||||||
@ -137,7 +137,7 @@ public:
|
|||||||
* register your widget with registerWidget(), then implement
|
* register your widget with registerWidget(), then implement
|
||||||
* a slot named toolTipAboutToShow for the widget. This will be
|
* a slot named toolTipAboutToShow for the widget. This will be
|
||||||
* called before the tooltip is shown, allowing you to set the
|
* called before the tooltip is shown, allowing you to set the
|
||||||
* data with setToolTipContent().
|
* data with setContent().
|
||||||
*
|
*
|
||||||
* If the widget also has a toolTipHidden slot, this will be called
|
* If the widget also has a toolTipHidden slot, this will be called
|
||||||
* after the tooltip is hidden.
|
* after the tooltip is hidden.
|
||||||
@ -165,7 +165,8 @@ public:
|
|||||||
* @param data the content of the tooltip. If an empty ToolTipContent
|
* @param data the content of the tooltip. If an empty ToolTipContent
|
||||||
* is passed in, the tooltip content will be reset.
|
* is passed in, the tooltip content will be reset.
|
||||||
*/
|
*/
|
||||||
void setToolTipContent(QGraphicsWidget *widget, const ToolTipContent &data);
|
void setContent(QGraphicsWidget *widget,
|
||||||
|
const ToolTipContent &data = ToolTipContent());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user