Skip to content

Commit

Permalink
UI: Reduce settings dialog height if greater than the desktop
Browse files Browse the repository at this point in the history
Co-authored-by: Warchamp7 <warchamp2003@hotmail.com>
Co-authored-by: derrod <dennis@obsproject.com>
Co-authored-by: Ryan Foster <ryan@obsproject.com>
  • Loading branch information
4 people committed Apr 15, 2024
1 parent dcd1bd9 commit d88e788
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions UI/window-basic-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions UI/window-basic-settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ private slots:

protected:
virtual void closeEvent(QCloseEvent *event) override;
virtual void showEvent(QShowEvent *event) override;
void reject() override;

public:
Expand Down

0 comments on commit d88e788

Please sign in to comment.