fix: tooltips showing out-of-bounds after loading images (#5186)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<Button *> buttons;
|
||||
} ui_;
|
||||
|
||||
/// The last @a pos from moveTo and showAndMoveTo
|
||||
QPoint lastBoundsCheckPosition_;
|
||||
/// The last @a mode from moveTo and showAndMoveTo
|
||||
widgets::BoundsChecking lastBoundsCheckMode_ = widgets::BoundsChecking::Off;
|
||||
|
||||
#ifdef USEWINSDK
|
||||
/// @brief Returns the HWND of this window if it has one
|
||||
///
|
||||
|
||||
@@ -90,6 +90,7 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||
if (needSizeAdjustment)
|
||||
{
|
||||
this->adjustSize();
|
||||
this->applyLastBoundsCheck();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3121,6 +3121,7 @@ void ChannelView::pendingLinkInfoStateChanged()
|
||||
return;
|
||||
}
|
||||
this->setLinkInfoTooltip(this->pendingLinkInfo_.data());
|
||||
this->tooltipWidget_->applyLastBoundsCheck();
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user