From dd62707d535cd556f89ee3080ac234cf2ba5c426 Mon Sep 17 00:00:00 2001 From: nerix Date: Tue, 9 Apr 2024 14:25:08 +0200 Subject: [PATCH] fix: hide tooltip on window leave event (#5309) --- CHANGELOG.md | 2 ++ src/widgets/BaseWindow.cpp | 1 + src/widgets/BaseWindow.hpp | 1 + src/widgets/splits/SplitHeader.cpp | 14 ++++++++++++++ 4 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9ca57c90..10c71cf5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unversioned +- Bugfix: Fixed split tooltip getting stuck in some cases. (#5309) + ## 2.5.0-beta.1 - Major: Twitch follower emotes can now be correctly tabbed in other channels when you are subscribed to the channel the emote is from. (#4922) diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index c819c8f4a..a61322fce 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -527,6 +527,7 @@ void BaseWindow::changeEvent(QEvent *) void BaseWindow::leaveEvent(QEvent *) { + this->leaving.invoke(); } void BaseWindow::moveTo(QPoint point, widgets::BoundsChecking mode) diff --git a/src/widgets/BaseWindow.hpp b/src/widgets/BaseWindow.hpp index e59c8ae81..b9f21b08d 100644 --- a/src/widgets/BaseWindow.hpp +++ b/src/widgets/BaseWindow.hpp @@ -85,6 +85,7 @@ public: void setTopMost(bool topMost); pajlada::Signals::NoArgSignal closing; + pajlada::Signals::NoArgSignal leaving; static bool supportsCustomWindowFrame(); diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index b8b811ca4..ed4a59b18 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -257,6 +257,20 @@ SplitHeader::SplitHeader(Split *split) getSettings()->headerStreamTitle.connect(_, this->managedConnections_); getSettings()->headerGame.connect(_, this->managedConnections_); getSettings()->headerUptime.connect(_, this->managedConnections_); + + auto *window = dynamic_cast(this->window()); + if (window) + { + // Hack: In some cases Qt doesn't send the leaveEvent the "actual" last mouse receiver. + // This can happen when quickly moving the mouse out of the window and right clicking. + // To prevent the tooltip from getting stuck, we use the window's leaveEvent. + this->managedConnections_.managedConnect(window->leaving, [this] { + if (this->tooltipWidget_->isVisible()) + { + this->tooltipWidget_->hide(); + } + }); + } } void SplitHeader::initializeLayout()