Do bounds-checking on more windows (#4797)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2023-12-02 12:56:03 +01:00
committed by GitHub
parent e327ed4166
commit c4c94473ae
17 changed files with 120 additions and 38 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ void initUpdateButton(Button &button,
globalPoint.setX(0);
}
dialog->move(globalPoint);
dialog->moveTo(globalPoint, widgets::BoundsChecking::DesiredPosition);
dialog->show();
dialog->raise();
+13
View File
@@ -79,4 +79,17 @@ void moveWindowTo(QWidget *window, QPoint position, BoundsChecking mode)
}
}
void showAndMoveWindowTo(QWidget *window, QPoint position, BoundsChecking mode)
{
#ifdef Q_OS_WINDOWS
window->show();
moveWindowTo(window, position, mode);
#else
moveWindowTo(window, position, mode);
window->show();
#endif
}
} // namespace chatterino::widgets
+10
View File
@@ -26,4 +26,14 @@ enum class BoundsChecking {
void moveWindowTo(QWidget *window, QPoint position,
BoundsChecking mode = BoundsChecking::DesiredPosition);
/// Moves the `window` to the (global) `position`
/// while doing bounds-checking according to `mode` to ensure the window stays on one screen.
/// Will also call show on the `window`, order is dependant on platform.
///
/// @param window The window to move.
/// @param position The global position to move the window to.
/// @param mode The desired bounds checking.
void showAndMoveWindowTo(QWidget *window, QPoint position,
BoundsChecking mode = BoundsChecking::DesiredPosition);
} // namespace chatterino::widgets