X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingsdlg.cpp;h=748c1ffa134f7b379a3542352f6bfce8e2548e4d;hp=74871c4748f733269d30ce91dd7e1b2c65f29abc;hb=68878dc8366f2f4a0afe132847aad9a51a80cdbf;hpb=695758015a80eb8c158a9ac4c0f1c0b547e70df3 diff --git a/src/qtui/settingsdlg.cpp b/src/qtui/settingsdlg.cpp index 74871c47..748c1ffa 100644 --- a/src/qtui/settingsdlg.cpp +++ b/src/qtui/settingsdlg.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -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()); + } + } } @@ -65,7 +81,9 @@ void SettingsDlg::setItemState(QTreeWidgetItem *item) { SettingsPage *sp = qobject_cast(item->data(0, SettingsPageRole).value()); Q_ASSERT(sp); - item->setDisabled(!Client::isConnected() && sp->needsCoreConnection()); + bool disabledDueToConnection = !Client::isConnected() && sp->needsCoreConnection(); + bool disabledDueToOwnChoice = !sp->isSelectable(); + item->setDisabled(disabledDueToConnection || disabledDueToOwnChoice); }