forked from qt-creator/qt-creator
Core: make options page keywords accessible
Can be used to search for specific settings. Change-Id: I82579837d0595d01be04c3c7f3515854e6fabb87 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -91,6 +91,34 @@ void IOptionsPage::setWidgetCreator(const WidgetCreator &widgetCreator)
|
|||||||
m_widgetCreator = widgetCreator;
|
m_widgetCreator = widgetCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QStringList Core::IOptionsPage::keywords() const
|
||||||
|
|
||||||
|
Returns a list of ui strings that are used inside the widget.
|
||||||
|
*/
|
||||||
|
|
||||||
|
QStringList IOptionsPage::keywords() const
|
||||||
|
{
|
||||||
|
if (!m_keywordsInitialized) {
|
||||||
|
auto that = const_cast<IOptionsPage *>(this);
|
||||||
|
QWidget *widget = that->widget();
|
||||||
|
if (!widget)
|
||||||
|
return {};
|
||||||
|
// find common subwidgets
|
||||||
|
for (const QLabel *label : widget->findChildren<QLabel *>())
|
||||||
|
m_keywords << Utils::stripAccelerator(label->text());
|
||||||
|
for (const QCheckBox *checkbox : widget->findChildren<QCheckBox *>())
|
||||||
|
m_keywords << Utils::stripAccelerator(checkbox->text());
|
||||||
|
for (const QPushButton *pushButton : widget->findChildren<QPushButton *>())
|
||||||
|
m_keywords << Utils::stripAccelerator(pushButton->text());
|
||||||
|
for (const QGroupBox *groupBox : widget->findChildren<QGroupBox *>())
|
||||||
|
m_keywords << Utils::stripAccelerator(groupBox->title());
|
||||||
|
|
||||||
|
m_keywordsInitialized = true;
|
||||||
|
}
|
||||||
|
return m_keywords;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the widget to show in the \uicontrol Options dialog. You should create a widget lazily here,
|
Returns the widget to show in the \uicontrol Options dialog. You should create a widget lazily here,
|
||||||
and delete it again in the finish() method. This method can be called multiple times, so you
|
and delete it again in the finish() method. This method can be called multiple times, so you
|
||||||
@@ -242,24 +270,7 @@ const QList<IOptionsPage *> IOptionsPage::allOptionsPages()
|
|||||||
*/
|
*/
|
||||||
bool IOptionsPage::matches(const QRegularExpression ®exp) const
|
bool IOptionsPage::matches(const QRegularExpression ®exp) const
|
||||||
{
|
{
|
||||||
if (!m_keywordsInitialized) {
|
for (const QString &keyword : keywords())
|
||||||
auto that = const_cast<IOptionsPage *>(this);
|
|
||||||
QWidget *widget = that->widget();
|
|
||||||
if (!widget)
|
|
||||||
return false;
|
|
||||||
// find common subwidgets
|
|
||||||
for (const QLabel *label : widget->findChildren<QLabel *>())
|
|
||||||
m_keywords << Utils::stripAccelerator(label->text());
|
|
||||||
for (const QCheckBox *checkbox : widget->findChildren<QCheckBox *>())
|
|
||||||
m_keywords << Utils::stripAccelerator(checkbox->text());
|
|
||||||
for (const QPushButton *pushButton : widget->findChildren<QPushButton *>())
|
|
||||||
m_keywords << Utils::stripAccelerator(pushButton->text());
|
|
||||||
for (const QGroupBox *groupBox : widget->findChildren<QGroupBox *>())
|
|
||||||
m_keywords << Utils::stripAccelerator(groupBox->title());
|
|
||||||
|
|
||||||
m_keywordsInitialized = true;
|
|
||||||
}
|
|
||||||
for (const QString &keyword : qAsConst(m_keywords))
|
|
||||||
if (keyword.contains(regexp))
|
if (keyword.contains(regexp))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ public:
|
|||||||
using WidgetCreator = std::function<IOptionsPageWidget *()>;
|
using WidgetCreator = std::function<IOptionsPageWidget *()>;
|
||||||
void setWidgetCreator(const WidgetCreator &widgetCreator);
|
void setWidgetCreator(const WidgetCreator &widgetCreator);
|
||||||
|
|
||||||
|
QStringList keywords() const;
|
||||||
|
|
||||||
virtual bool matches(const QRegularExpression ®exp) const;
|
virtual bool matches(const QRegularExpression ®exp) const;
|
||||||
virtual QWidget *widget();
|
virtual QWidget *widget();
|
||||||
virtual void apply();
|
virtual void apply();
|
||||||
|
|||||||
Reference in New Issue
Block a user