forked from qt-creator/qt-creator
Hardcode search terms for designer options page
By taking the translated text from designer. This way we don't freeze directly when filtering the options page. We still have to initialize designer (and therefore freeze) the moment that category gets selected though (which can also happen during filtering). Task-number: QTCREATORBUG-9584 Change-Id: I88275db97f87a5da8c565bccc8ae41de3b51a135 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
@@ -91,3 +91,43 @@ QList<Core::IOptionsPage *> SettingsPageProvider::pages() const
|
||||
}
|
||||
return FormEditorW::instance()->optionsPages();
|
||||
}
|
||||
|
||||
bool SettingsPageProvider::matches(const QString &searchKeyWord) const
|
||||
{
|
||||
// to avoid fully initializing designer when typing something in the options' filter edit
|
||||
// we hardcode matching of UI text from the designer pages, which are taken if the designer pages
|
||||
// were not yet loaded
|
||||
// luckily linguist cannot resolve the translated texts, so we do not end up with duplicate
|
||||
// translatable strings for Qt Creator
|
||||
static const struct { const char *context; const char *value; } uitext[] = {
|
||||
{"EmbeddedOptionsPage", "Embedded Design"},
|
||||
{"EmbeddedOptionsPage", "Device Profiles"},
|
||||
{"FormEditorOptionsPage", "Forms"},
|
||||
{"FormEditorOptionsPage", "Preview Zoom"},
|
||||
{"FormEditorOptionsPage", "Default Zoom"},
|
||||
{"FormEditorOptionsPage", "Default Grid"},
|
||||
{"qdesigner_internal::GridPanel", "Visible"},
|
||||
{"qdesigner_internal::GridPanel", "Snap"},
|
||||
{"qdesigner_internal::GridPanel", "Reset"},
|
||||
{"qdesigner_internal::GridPanel", "Grid"},
|
||||
{"qdesigner_internal::GridPanel", "Grid &X"},
|
||||
{"qdesigner_internal::GridPanel", "Grid &Y"},
|
||||
{"PreviewConfigurationWidget", "Print/Preview Configuration"},
|
||||
{"PreviewConfigurationWidget", "Style"},
|
||||
{"PreviewConfigurationWidget", "Style sheet"},
|
||||
{"PreviewConfigurationWidget", "Device skin"},
|
||||
{"TemplateOptionsPage", "Template Paths"},
|
||||
{"qdesigner_internal::TemplateOptionsWidget", "Additional Template Paths"}
|
||||
};
|
||||
static const size_t itemCount = sizeof(uitext)/sizeof(uitext[0]);
|
||||
if (m_keywords.isEmpty()) {
|
||||
m_keywords.reserve(itemCount);
|
||||
for (size_t i = 0; i < itemCount; ++i)
|
||||
m_keywords << QCoreApplication::translate(uitext[i].context, uitext[i].value).remove(QLatin1Char('&'));
|
||||
}
|
||||
foreach (const QString &key, m_keywords) {
|
||||
if (key.contains(searchKeyWord, Qt::CaseInsensitive))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user