forked from qt-creator/qt-creator
Core: Also strip accelerators from custom option page keywords
This way the custom keywords can use the same translated strings with the actual use of the thing in the gui. Change-Id: I56c7b25b594a0b92980516806ab7d999d7de7937 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/aspects.h>
|
#include <utils/aspects.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -100,23 +101,20 @@ void IOptionsPage::setWidgetCreator(const WidgetCreator &widgetCreator)
|
|||||||
|
|
||||||
QStringList IOptionsPage::keywords() const
|
QStringList IOptionsPage::keywords() const
|
||||||
{
|
{
|
||||||
if (!m_keywordsInitialized) {
|
|
||||||
auto that = const_cast<IOptionsPage *>(this);
|
auto that = const_cast<IOptionsPage *>(this);
|
||||||
QWidget *widget = that->widget();
|
QWidget *widget = that->widget();
|
||||||
if (!widget)
|
if (!widget)
|
||||||
return {};
|
return {};
|
||||||
// find common subwidgets
|
// find common subwidgets
|
||||||
for (const QLabel *label : widget->findChildren<QLabel *>())
|
for (const QLabel *label : widget->findChildren<QLabel *>())
|
||||||
m_keywords << Utils::stripAccelerator(label->text());
|
m_keywords << label->text();
|
||||||
for (const QCheckBox *checkbox : widget->findChildren<QCheckBox *>())
|
for (const QCheckBox *checkbox : widget->findChildren<QCheckBox *>())
|
||||||
m_keywords << Utils::stripAccelerator(checkbox->text());
|
m_keywords << checkbox->text();
|
||||||
for (const QPushButton *pushButton : widget->findChildren<QPushButton *>())
|
for (const QPushButton *pushButton : widget->findChildren<QPushButton *>())
|
||||||
m_keywords << Utils::stripAccelerator(pushButton->text());
|
m_keywords << pushButton->text();
|
||||||
for (const QGroupBox *groupBox : widget->findChildren<QGroupBox *>())
|
for (const QGroupBox *groupBox : widget->findChildren<QGroupBox *>())
|
||||||
m_keywords << Utils::stripAccelerator(groupBox->title());
|
m_keywords << groupBox->title();
|
||||||
|
|
||||||
m_keywordsInitialized = true;
|
|
||||||
}
|
|
||||||
return m_keywords;
|
return m_keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +271,12 @@ const QList<IOptionsPage *> IOptionsPage::allOptionsPages()
|
|||||||
*/
|
*/
|
||||||
bool IOptionsPage::matches(const QRegularExpression ®exp) const
|
bool IOptionsPage::matches(const QRegularExpression ®exp) const
|
||||||
{
|
{
|
||||||
for (const QString &keyword : keywords())
|
if (!m_keywordsInitialized) {
|
||||||
|
m_keywords = Utils::transform(keywords(), Utils::stripAccelerator);
|
||||||
|
m_keywordsInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const QString &keyword : m_keywords)
|
||||||
if (keyword.contains(regexp))
|
if (keyword.contains(regexp))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -63,10 +63,11 @@ public:
|
|||||||
virtual void apply();
|
virtual void apply();
|
||||||
virtual void finish();
|
virtual void finish();
|
||||||
|
|
||||||
virtual QStringList keywords() const;
|
|
||||||
virtual bool matches(const QRegularExpression ®exp) const;
|
virtual bool matches(const QRegularExpression ®exp) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual QStringList keywords() const;
|
||||||
|
|
||||||
void setId(Utils::Id id) { m_id = id; }
|
void setId(Utils::Id id) { m_id = id; }
|
||||||
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
||||||
void setCategory(Utils::Id category) { m_category = category; }
|
void setCategory(Utils::Id category) { m_category = category; }
|
||||||
|
|||||||
Reference in New Issue
Block a user