Update containsMouse even if tooltips are disabled globally.

ToolTipAreas are often the critical path for mouse handling, since
hover events are not filterable from below in the item hierarchy.
When disabling tooltips also stops updating containsMouse code has
no way to adapt, since there's no API to read the pref from within
QML. This changes the implementation of the pref to only prevent
tooltips from being shown, but still continue to handle hover events.
This commit is contained in:
Eike Hein 2014-05-19 10:25:25 +02:00
parent 14ab84f5cc
commit cfda5c4d70
2 changed files with 11 additions and 5 deletions

View File

@ -35,12 +35,16 @@ int ToolTip::s_dialogUsers = 0;
ToolTip::ToolTip(QQuickItem *parent) ToolTip::ToolTip(QQuickItem *parent)
: QQuickItem(parent), : QQuickItem(parent),
m_tooltipsEnabledGlobally(false),
m_containsMouse(false), m_containsMouse(false),
m_location(Plasma::Types::Floating), m_location(Plasma::Types::Floating),
m_active(true), m_active(true),
m_interactive(false), m_interactive(false),
m_usingDialog(false) m_usingDialog(false)
{ {
setAcceptHoverEvents(true);
setFiltersChildMouseEvents(true);
m_showTimer = new QTimer(this); m_showTimer = new QTimer(this);
m_showTimer->setSingleShot(true); m_showTimer->setSingleShot(true);
connect(m_showTimer, &QTimer::timeout, this, &ToolTip::showToolTip); connect(m_showTimer, &QTimer::timeout, this, &ToolTip::showToolTip);
@ -71,10 +75,7 @@ void ToolTip::settingsChanged()
KConfigGroup cg(&config, "PlasmaToolTips"); KConfigGroup cg(&config, "PlasmaToolTips");
m_interval = cg.readEntry("Delay", 700); m_interval = cg.readEntry("Delay", 700);
bool enabled = m_interval > 0; m_tooltipsEnabledGlobally = (m_interval > 0);
setAcceptHoverEvents(enabled);
setFiltersChildMouseEvents(enabled);
} }
QQuickItem *ToolTip::mainItem() const QQuickItem *ToolTip::mainItem() const
@ -306,7 +307,11 @@ void ToolTip::setContainsMouse(bool contains)
void ToolTip::hoverEnterEvent(QHoverEvent *event) void ToolTip::hoverEnterEvent(QHoverEvent *event)
{ {
setContainsMouse(true); setContainsMouse(true);
//m_showTimer->stop();
if (!m_tooltipsEnabledGlobally) {
return;
}
if (tooltipDialogInstance()->isVisible()) { if (tooltipDialogInstance()->isVisible()) {
// We signal the tooltipmanager that we're "potentially interested, // We signal the tooltipmanager that we're "potentially interested,
// and ask to keep it open for a bit, so other items get the chance // and ask to keep it open for a bit, so other items get the chance

View File

@ -174,6 +174,7 @@ private Q_SLOTS:
void settingsChanged(); void settingsChanged();
private: private:
bool m_tooltipsEnabledGlobally;
bool m_containsMouse; bool m_containsMouse;
Plasma::Types::Location m_location; Plasma::Types::Location m_location;
QWeakPointer<QQuickItem> m_mainItem; QWeakPointer<QQuickItem> m_mainItem;