From 08df0e4798aaed17622ebaba9b1ab4e76ad68237 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 18 Nov 2013 16:09:47 +0100 Subject: [PATCH] Preferences: Fix shown widget when filtering * choose an enabled tab if current tab gets disabled (for some reason that is not automatically done by QTabWidget * don't show any widget if the filter string is not matched by anything Task-number: QTCREATORBUG-8318 Change-Id: I0066c2b3aeb9cc0cdacaa0a88f9adbc70c20cfa7 Reviewed-by: Daniel Teske --- src/plugins/coreplugin/dialogs/settingsdialog.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp index 4593488c1b5..42fde01cea9 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -382,6 +382,7 @@ void SettingsDialog::createGui() headerHLayout->addWidget(m_headerLabel); m_stackedLayout->setMargin(0); + m_stackedLayout->addWidget(new QWidget); // no category selected, for example when filtering QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Apply | @@ -467,6 +468,7 @@ void SettingsDialog::disconnectTabWidgets() void SettingsDialog::updateEnabledTabs(Category *category, const QString &searchText) { + int firstEnabledTab = -1; for (int i = 0; i < category->pages.size(); ++i) { const IOptionsPage *page = category->pages.at(i); const bool enabled = searchText.isEmpty() @@ -474,13 +476,24 @@ void SettingsDialog::updateEnabledTabs(Category *category, const QString &search || page->displayName().contains(searchText, Qt::CaseInsensitive) || page->matches(searchText); category->tabWidget->setTabEnabled(i, enabled); + if (enabled && firstEnabledTab < 0) + firstEnabledTab = i; + } + if (!category->tabWidget->isTabEnabled(category->tabWidget->currentIndex()) + && firstEnabledTab != -1) { + // QTabWidget is dumb, so this can happen + category->tabWidget->setCurrentIndex(firstEnabledTab); } } void SettingsDialog::currentChanged(const QModelIndex ¤t) { - if (current.isValid()) + if (current.isValid()) { showCategory(m_proxyModel->mapToSource(current).row()); + } else { + m_stackedLayout->setCurrentIndex(0); + m_headerLabel->setText(QString()); + } } void SettingsDialog::currentTabChanged(int index)