prefere user selected tab in settings search

This commit is contained in:
fourtf 2019-09-02 17:22:14 +02:00
parent a6fd6300c9
commit 661a36c2e4
2 changed files with 14 additions and 4 deletions

View file

@ -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)

View file

@ -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<SettingsDialogTab *> tabs_;
std::vector<SettingsPage *> pages_;
SettingsDialogTab *selectedTab_{};
SettingsDialogTab *lastSelectedByUser_{};
friend class SettingsDialogTab;
};