diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index 108c33beb..46fc92195 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -80,13 +80,18 @@ void SettingsDialog::initUi() // TODO: add originally selected page // find next visible page - if (!this->selectedTab_->isVisible()) + if (this->lastSelectedByUser_ && + this->lastSelectedByUser_->isVisible()) + { + this->selectTab(this->lastSelectedByUser_, false); + } + else if (!this->selectedTab_->isVisible()) { for (auto &&tab : this->tabs_) { if (tab->isVisible()) { - this->selectTab(tab); + this->selectTab(tab, false); break; } } @@ -189,7 +194,7 @@ void SettingsDialog::addTab(SettingsPage *page, Qt::Alignment alignment) } } -void SettingsDialog::selectTab(SettingsDialogTab *tab) +void SettingsDialog::selectTab(SettingsDialogTab *tab, bool byUser) { this->ui_.pageStack->setCurrentWidget(tab->getSettingsPage()); @@ -205,6 +210,10 @@ void SettingsDialog::selectTab(SettingsDialogTab *tab) "border-top: 1px solid #444;" "border-bottom: 1px solid #444;"); this->selectedTab_ = tab; + if (byUser) + { + this->lastSelectedByUser_ = tab; + } } void SettingsDialog::selectPage(SettingsPage *page) diff --git a/src/widgets/dialogs/SettingsDialog.hpp b/src/widgets/dialogs/SettingsDialog.hpp index e637fa280..87bdb52af 100644 --- a/src/widgets/dialogs/SettingsDialog.hpp +++ b/src/widgets/dialogs/SettingsDialog.hpp @@ -43,7 +43,7 @@ private: void initUi(); void addTabs(); void addTab(SettingsPage *page, Qt::Alignment alignment = Qt::AlignTop); - void selectTab(SettingsDialogTab *tab); + void selectTab(SettingsDialogTab *tab, bool byUser = true); void selectPage(SettingsPage *page); void onOkClicked(); @@ -61,6 +61,7 @@ private: std::vector tabs_; std::vector pages_; SettingsDialogTab *selectedTab_{}; + SettingsDialogTab *lastSelectedByUser_{}; friend class SettingsDialogTab; };