X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fsettingsdlg.cpp;h=7d4134678219e3270e7a39d91b499bb9f9b405d8;hb=b8e812857ca64834078e1f620bf98fffa48b7768;hp=b347127ca42cbf3fd488ff84941f02ca8f9a857d;hpb=0a43227b8cd44625f4881cc1545d42c8c8a4876c;p=quassel.git diff --git a/src/qtui/settingsdlg.cpp b/src/qtui/settingsdlg.cpp index b347127c..7d413467 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()); + } + } }