add basic hiding of SettingsTabs

This commit is contained in:
fourtf
2019-09-02 16:39:21 +02:00
parent 54c26d2228
commit b0459ba646
5 changed files with 51 additions and 21 deletions
+25 -7
View File
@@ -67,13 +67,31 @@ void SettingsDialog::initUi()
auto edit = title.emplace<QLineEdit>().assign(&this->ui_.search);
QTimer::singleShot(100, edit.getElement(),
[edit = edit.getElement()]() { edit->setFocus(); });
QObject::connect(edit.getElement(), &QLineEdit::textChanged, this,
[this](const QString &text) {
for (auto &&page : this->pages_)
{
page->filterElements(text);
}
});
QObject::connect(
edit.getElement(), &QLineEdit::textChanged, this,
[this](const QString &text) {
// filter elements and hide pages
for (auto &&page : this->pages_)
{
// filterElements returns true if anything on the page matches the search query
page->tab()->setVisible(page->filterElements(text));
}
// TODO: add originally selected page
// find next visible page
if (!this->selectedTab_->isVisible())
{
for (auto &&tab : this->tabs_)
{
if (tab->isVisible())
{
this->selectTab(tab);
break;
}
}
}
});
right.emplace<QStackedLayout>()
.assign(&this->ui_.pageStack)