From: Shane Synan Date: Wed, 13 Jul 2016 15:27:43 +0000 (-0400) Subject: Auto-resize Settings to fit wide widgets X-Git-Tag: 0.12.5~71 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=b263b745afcc8272a4eeb35e188e73fb45879642 Auto-resize Settings to fit wide widgets Add check for settingsTree width. If it's not at the maximum width, resize the Settings dialog to fit it. Qt should keep the dialog within bounds of the screen, and the user can always resize the dialog if needed. This fixes the Settings dialog squashing the settings tree with the Sonnet spell-checking widget, Ubuntu 16.04 on en_US, and a 1920×1080 screen. (cherry picked from commit 65c463f0154b12bbcd15d3b51ac231dd530fad3a) --- diff --git a/src/qtui/settingsdlg.cpp b/src/qtui/settingsdlg.cpp index 74871c47..9f93937e 100644 --- a/src/qtui/settingsdlg.cpp +++ b/src/qtui/settingsdlg.cpp @@ -45,6 +45,22 @@ SettingsDlg::SettingsDlg(QWidget *parent) connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), SLOT(coreConnectionStateChanged())); setButtonStates(); + + // Some settings panes can take a good bit of space. To avoid squashing the settings tree, try + // to resize the dialog. If needed, it can always be resized by the user to take less space. + // + // Only try to resize if the sizes are valid. This shouldn't happen.. but better to be safe. + // See http://www.qtcentre.org/threads/3427-invalid-sizeHint() + if (ui.settingsTree->sizeHint().isValid() && ui.settingsTree->size().isValid()) { + // Find out how much width would make the settings tree happy + int wantedExtraWidth = ui.settingsTree->sizeHint().width() + - ui.settingsTree->size().width(); + // If more space is needed, try to resize to allow for it. Qt should keep the dialog within + // the bounds of the screen. + if (wantedExtraWidth > 0) { + this->resize(this->width() + wantedExtraWidth, this->height()); + } + } }