diff --git a/src/Gui/DlgPreferences.ui b/src/Gui/DlgPreferences.ui index 092907905d..844f91547f 100644 --- a/src/Gui/DlgPreferences.ui +++ b/src/Gui/DlgPreferences.ui @@ -6,10 +6,16 @@ 0 0 - 800 - 600 + 1000 + 900 + + + 1000 + 600 + + Preferences @@ -209,13 +215,65 @@ QFrame::item { padding: 6px 8px }; - + - - 1 - 1 + + 0 + 0 + + QFrame::NoFrame + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustIgnored + + + true + + + + + 0 + 0 + 726 + 669 + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 1 + 1 + + + + + + diff --git a/src/Gui/DlgPreferencesImp.cpp b/src/Gui/DlgPreferencesImp.cpp index baa741cbb2..28fcbf1e97 100644 --- a/src/Gui/DlgPreferencesImp.cpp +++ b/src/Gui/DlgPreferencesImp.cpp @@ -114,6 +114,10 @@ DlgPreferencesImp::DlgPreferencesImp(QWidget* parent, Qt::WindowFlags fl) &QPushButton::clicked, this, &DlgPreferencesImp::showResetOptions); + connect(ui->groupWidgetStack, + &QStackedWidget::currentChanged, + this, + &DlgPreferencesImp::onStackWidgetChange); ui->groupsTreeView->setModel(&_model); @@ -193,6 +197,15 @@ PreferencesPageItem* DlgPreferencesImp::createGroup(const std::string &groupName auto groupPages = new QStackedWidget; groupPages->setProperty(GroupNameProperty, QVariant(groupNameQString)); + connect(groupPages, + &QStackedWidget::currentChanged, + this, + &DlgPreferencesImp::onStackWidgetChange); + + + if (ui->groupWidgetStack->count() > 0) { + groupPages->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + } ui->groupWidgetStack->addWidget(groupPages); auto item = new PreferencesPageItem; @@ -255,6 +268,11 @@ void DlgPreferencesImp::createPageInGroup(PreferencesPageItem *groupItem, const page->loadSettings(); auto pages = qobject_cast(groupItem->getWidget()); + + if (pages->count() > 0) { + page->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + } + pages->addWidget(page); } catch (const Base::Exception& e) { @@ -637,7 +655,6 @@ void DlgPreferencesImp::restartIfRequired() void DlgPreferencesImp::showEvent(QShowEvent* ev) { - this->adjustSize(); QDialog::showEvent(ev); } @@ -668,6 +685,20 @@ void DlgPreferencesImp::onPageSelected(const QModelIndex& index) updatePageDependentLabels(); } +void DlgPreferencesImp::onStackWidgetChange(int index) +{ + auto stack = qobject_cast(sender()); + + for (int i = 0; i < stack->count(); i++) { + auto current = stack->widget(i); + current->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + } + + if (auto selected = stack->widget(index)) { + selected->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + } +} + void DlgPreferencesImp::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { diff --git a/src/Gui/DlgPreferencesImp.h b/src/Gui/DlgPreferencesImp.h index 013aa1ced7..d683c5e900 100644 --- a/src/Gui/DlgPreferencesImp.h +++ b/src/Gui/DlgPreferencesImp.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -150,6 +151,7 @@ protected: protected Q_SLOTS: void onButtonBoxClicked(QAbstractButton*); void onPageSelected(const QModelIndex &index); + void onStackWidgetChange(int index); private: /** @name for internal use only */