From d88e788f7fba600e3504939e26845e08838410fb Mon Sep 17 00:00:00 2001 From: tytan652 Date: Sat, 3 Sep 2022 11:54:25 +0200 Subject: [PATCH] UI: Reduce settings dialog height if greater than the desktop Co-authored-by: Warchamp7 Co-authored-by: derrod Co-authored-by: Ryan Foster --- UI/window-basic-settings.cpp | 14 ++++++++++++++ UI/window-basic-settings.hpp | 1 + 2 files changed, 15 insertions(+) diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 4a8e42fe3..d94ff32fc 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -4279,6 +4279,20 @@ void OBSBasicSettings::closeEvent(QCloseEvent *event) event->ignore(); } +void OBSBasicSettings::showEvent(QShowEvent *event) +{ + QDialog::showEvent(event); + + /* Reduce the height of the widget area if too tall compared to the screen + * size (e.g., 720p) with potential window decoration (e.g., titlebar). */ + const int titleBarHeight = + QApplication::style()->pixelMetric(QStyle::PM_TitleBarHeight); + const int maxHeight = + round(screen()->availableGeometry().height() - titleBarHeight); + if (size().height() >= maxHeight) + resize(size().width(), maxHeight); +} + void OBSBasicSettings::reject() { if (AskIfCanCloseSettings()) diff --git a/UI/window-basic-settings.hpp b/UI/window-basic-settings.hpp index 01bffeb49..7f0db483d 100644 --- a/UI/window-basic-settings.hpp +++ b/UI/window-basic-settings.hpp @@ -480,6 +480,7 @@ private slots: protected: virtual void closeEvent(QCloseEvent *event) override; + virtual void showEvent(QShowEvent *event) override; void reject() override; public: