From dd61482046dffc6cd765068865245f27db2eaf0e Mon Sep 17 00:00:00 2001 From: nerix Date: Sat, 24 Feb 2024 12:52:16 +0100 Subject: [PATCH] fix: tooltips showing out-of-bounds after loading images (#5186) --- CHANGELOG.md | 1 + src/widgets/BaseWindow.cpp | 15 +++++++++++++++ src/widgets/BaseWindow.hpp | 14 ++++++++++++++ src/widgets/TooltipWidget.cpp | 1 + src/widgets/helper/ChannelView.cpp | 1 + 5 files changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fa10e00e..930d43624 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,7 @@ - Bugfix: Reply contexts now use the color of the replied-to message. (#5145) - Bugfix: Fixed top-level window getting stuck after opening settings. (#5161, #5166) - Bugfix: Fixed link info not updating without moving the cursor. (#5178) +- Bugfix: Fixed tooltips getting out of bounds when loading images. (#5186) - Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978) - Dev: Change clang-format from v14 to v16. (#4929) - Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791) diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index ca7d02d44..c34edf96f 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -531,14 +531,29 @@ void BaseWindow::leaveEvent(QEvent *) void BaseWindow::moveTo(QPoint point, widgets::BoundsChecking mode) { + this->lastBoundsCheckPosition_ = point; + this->lastBoundsCheckMode_ = mode; widgets::moveWindowTo(this, point, mode); } void BaseWindow::showAndMoveTo(QPoint point, widgets::BoundsChecking mode) { + this->lastBoundsCheckPosition_ = point; + this->lastBoundsCheckMode_ = mode; widgets::showAndMoveWindowTo(this, point, mode); } +bool BaseWindow::applyLastBoundsCheck() +{ + if (this->lastBoundsCheckMode_ == widgets::BoundsChecking::Off) + { + return false; + } + + this->moveTo(this->lastBoundsCheckPosition_, this->lastBoundsCheckMode_); + return true; +} + void BaseWindow::resizeEvent(QResizeEvent *) { // Queue up save because: Window resized diff --git a/src/widgets/BaseWindow.hpp b/src/widgets/BaseWindow.hpp index fa7526b49..e59c8ae81 100644 --- a/src/widgets/BaseWindow.hpp +++ b/src/widgets/BaseWindow.hpp @@ -65,6 +65,15 @@ public: **/ void showAndMoveTo(QPoint point, widgets::BoundsChecking mode); + /// @brief Applies the last moveTo operation if that one was bounds-checked + /// + /// If there was a previous moveTo or showAndMoveTo operation with a mode + /// other than `Off`, a moveTo is repeated with the last supplied @a point + /// and @a mode. Note that in the case of showAndMoveTo, moveTo is run. + /// + /// @returns true if there was a previous bounds-checked moveTo operation + bool applyLastBoundsCheck(); + float scale() const override; float qtFontScale() const; @@ -152,6 +161,11 @@ private: std::vector