forked from qt-creator/qt-creator
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 <daniel.teske@digia.com>
This commit is contained in:
@@ -382,6 +382,7 @@ void SettingsDialog::createGui()
|
|||||||
headerHLayout->addWidget(m_headerLabel);
|
headerHLayout->addWidget(m_headerLabel);
|
||||||
|
|
||||||
m_stackedLayout->setMargin(0);
|
m_stackedLayout->setMargin(0);
|
||||||
|
m_stackedLayout->addWidget(new QWidget); // no category selected, for example when filtering
|
||||||
|
|
||||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok |
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok |
|
||||||
QDialogButtonBox::Apply |
|
QDialogButtonBox::Apply |
|
||||||
@@ -467,6 +468,7 @@ void SettingsDialog::disconnectTabWidgets()
|
|||||||
|
|
||||||
void SettingsDialog::updateEnabledTabs(Category *category, const QString &searchText)
|
void SettingsDialog::updateEnabledTabs(Category *category, const QString &searchText)
|
||||||
{
|
{
|
||||||
|
int firstEnabledTab = -1;
|
||||||
for (int i = 0; i < category->pages.size(); ++i) {
|
for (int i = 0; i < category->pages.size(); ++i) {
|
||||||
const IOptionsPage *page = category->pages.at(i);
|
const IOptionsPage *page = category->pages.at(i);
|
||||||
const bool enabled = searchText.isEmpty()
|
const bool enabled = searchText.isEmpty()
|
||||||
@@ -474,13 +476,24 @@ void SettingsDialog::updateEnabledTabs(Category *category, const QString &search
|
|||||||
|| page->displayName().contains(searchText, Qt::CaseInsensitive)
|
|| page->displayName().contains(searchText, Qt::CaseInsensitive)
|
||||||
|| page->matches(searchText);
|
|| page->matches(searchText);
|
||||||
category->tabWidget->setTabEnabled(i, enabled);
|
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)
|
void SettingsDialog::currentChanged(const QModelIndex ¤t)
|
||||||
{
|
{
|
||||||
if (current.isValid())
|
if (current.isValid()) {
|
||||||
showCategory(m_proxyModel->mapToSource(current).row());
|
showCategory(m_proxyModel->mapToSource(current).row());
|
||||||
|
} else {
|
||||||
|
m_stackedLayout->setCurrentIndex(0);
|
||||||
|
m_headerLabel->setText(QString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::currentTabChanged(int index)
|
void SettingsDialog::currentTabChanged(int index)
|
||||||
|
|||||||
Reference in New Issue
Block a user