From cfda5c4d7046a69606f56c49533fbf2e38d7a319 Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Mon, 19 May 2014 10:25:25 +0200 Subject: [PATCH] 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. --- src/declarativeimports/core/tooltip.cpp | 15 ++++++++++----- src/declarativeimports/core/tooltip.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/declarativeimports/core/tooltip.cpp b/src/declarativeimports/core/tooltip.cpp index 2bd0482fc..11aaaff73 100644 --- a/src/declarativeimports/core/tooltip.cpp +++ b/src/declarativeimports/core/tooltip.cpp @@ -35,12 +35,16 @@ int ToolTip::s_dialogUsers = 0; ToolTip::ToolTip(QQuickItem *parent) : QQuickItem(parent), + m_tooltipsEnabledGlobally(false), m_containsMouse(false), m_location(Plasma::Types::Floating), m_active(true), m_interactive(false), m_usingDialog(false) { + setAcceptHoverEvents(true); + setFiltersChildMouseEvents(true); + m_showTimer = new QTimer(this); m_showTimer->setSingleShot(true); connect(m_showTimer, &QTimer::timeout, this, &ToolTip::showToolTip); @@ -71,10 +75,7 @@ void ToolTip::settingsChanged() KConfigGroup cg(&config, "PlasmaToolTips"); m_interval = cg.readEntry("Delay", 700); - bool enabled = m_interval > 0; - - setAcceptHoverEvents(enabled); - setFiltersChildMouseEvents(enabled); + m_tooltipsEnabledGlobally = (m_interval > 0); } QQuickItem *ToolTip::mainItem() const @@ -306,7 +307,11 @@ void ToolTip::setContainsMouse(bool contains) void ToolTip::hoverEnterEvent(QHoverEvent *event) { setContainsMouse(true); - //m_showTimer->stop(); + + if (!m_tooltipsEnabledGlobally) { + return; + } + if (tooltipDialogInstance()->isVisible()) { // We signal the tooltipmanager that we're "potentially interested, // and ask to keep it open for a bit, so other items get the chance diff --git a/src/declarativeimports/core/tooltip.h b/src/declarativeimports/core/tooltip.h index c8ad88663..e0451663a 100644 --- a/src/declarativeimports/core/tooltip.h +++ b/src/declarativeimports/core/tooltip.h @@ -174,6 +174,7 @@ private Q_SLOTS: void settingsChanged(); private: + bool m_tooltipsEnabledGlobally; bool m_containsMouse; Plasma::Types::Location m_location; QWeakPointer m_mainItem;