Commit 08df0e47 authored by Eike Ziller's avatar Eike Ziller
Browse files

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: default avatarDaniel Teske <daniel.teske@digia.com>
parent d190e7ca
......@@ -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 &current)
{
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment