CppEditor: Convert to Tr::tr

Change-Id: Ic4025e06e17c45eb6dc2162fb7f21f5b8aebe84d
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Alessandro Portale
2023-01-11 20:43:10 +01:00
committed by hjk
parent 85d067af91
commit f7bcd4f574
57 changed files with 664 additions and 1677 deletions

View File

@@ -4,6 +4,7 @@
#include "abstracteditorsupport.h"
#include "cppeditorplugin.h"
#include "cppeditortr.h"
#include "cppfilesettingspage.h"
#include "cppmodelmanager.h"
@@ -42,9 +43,9 @@ QString AbstractEditorSupport::licenseTemplate(const FilePath &filePath, const Q
{
const QString license = Internal::CppFileSettings::licenseTemplate();
Utils::MacroExpander expander;
expander.registerVariable("Cpp:License:FileName", tr("The file name."),
expander.registerVariable("Cpp:License:FileName", Tr::tr("The file name."),
[filePath] { return filePath.fileName(); });
expander.registerVariable("Cpp:License:ClassName", tr("The class name."),
expander.registerVariable("Cpp:License:ClassName", Tr::tr("The class name."),
[className] { return className; });
return Utils::TemplateEngine::processText(&expander, license, nullptr);

View File

@@ -28,7 +28,8 @@ namespace TextEditor { class TextDocument; }
namespace CppEditor {
// For clang code model only, move?
struct CPPEDITOR_EXPORT ToolTipInfo {
struct CPPEDITOR_EXPORT ToolTipInfo
{
QString text;
QString briefComment;

View File

@@ -5,6 +5,7 @@
#include "clangdiagnosticconfigswidget.h"
#include "cppcodemodelsettings.h"
#include "cppeditortr.h"
#include "cpptoolsreuse.h"
#include <coreplugin/icore.h>
@@ -55,7 +56,7 @@ ClangDiagnosticConfigs ClangDiagnosticConfigsSelectionWidget::customConfigs() co
QString ClangDiagnosticConfigsSelectionWidget::label() const
{
return tr("Diagnostic configuration:");
return Tr::tr("Diagnostic configuration:");
}
void ClangDiagnosticConfigsSelectionWidget::setUpUi(bool withLabel)
@@ -80,7 +81,7 @@ void ClangDiagnosticConfigsSelectionWidget::onButtonClicked()
widget->layout()->setContentsMargins(0, 0, 0, 0);
QDialog dialog;
dialog.setWindowTitle(ClangDiagnosticConfigsWidget::tr("Diagnostic Configurations"));
dialog.setWindowTitle(Tr::tr("Diagnostic Configurations"));
dialog.setLayout(new QVBoxLayout);
dialog.layout()->addWidget(widget);
auto *buttonsBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);

View File

@@ -4,6 +4,7 @@
#include "clangdiagnosticconfigswidget.h"
#include "clangdiagnosticconfigsmodel.h"
#include "cppeditortr.h"
#include "wrappablelineedit.h"
#include <utils/environment.h>
@@ -65,13 +66,11 @@ public:
class ConfigsModel : public TreeModel<TreeItem, GroupNode, ConfigNode>
{
Q_OBJECT
public:
ConfigsModel(const ClangDiagnosticConfigs &configs)
{
m_builtinRoot = new GroupNode(tr("Built-in"));
m_customRoot = new GroupNode(tr("Custom"));
m_builtinRoot = new GroupNode(Tr::tr("Built-in"));
m_customRoot = new GroupNode(Tr::tr("Custom"));
rootItem()->appendChild(m_builtinRoot);
rootItem()->appendChild(m_customRoot);
@@ -118,17 +117,15 @@ private:
class ClangBaseChecksWidget : public QWidget
{
Q_DECLARE_TR_FUNCTIONS(CppEditor::ClangBaseChecks)
public:
ClangBaseChecksWidget()
{
auto label = new QLabel(tr("For appropriate options, consult the GCC or Clang manual "
"pages or the <a href=\"https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html\">"
"GCC online documentation</a>."));
auto label = new QLabel(Tr::tr("For appropriate options, consult the GCC or Clang manual "
"pages or the %1 GCC online documentation</a>.")
.arg("<a href=\"https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html\">"));
label->setOpenExternalLinks(true);
useFlagsFromBuildSystemCheckBox = new QCheckBox(tr("Use diagnostic flags from build system"));
useFlagsFromBuildSystemCheckBox = new QCheckBox(Tr::tr("Use diagnostic flags from build system"));
diagnosticOptionsTextEdit = new WrappableLineEdit;
@@ -151,9 +148,9 @@ ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(const ClangDiagnostic
: QWidget(parent)
, m_configsModel(new ConfigsModel(configs))
{
auto copyButton = new QPushButton(tr("Copy..."));
m_renameButton = new QPushButton(tr("Rename..."));
m_removeButton = new QPushButton(tr("Remove"));
auto copyButton = new QPushButton(Tr::tr("Copy..."));
m_renameButton = new QPushButton(Tr::tr("Rename..."));
m_removeButton = new QPushButton(Tr::tr("Remove"));
m_infoLabel = new InfoLabel;
@@ -169,7 +166,7 @@ ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(const ClangDiagnostic
m_clangBaseChecks = new ClangBaseChecksWidget;
m_tabWidget = new QTabWidget;
m_tabWidget->addTab(m_clangBaseChecks, tr("Clang Warnings"));
m_tabWidget->addTab(m_clangBaseChecks, Tr::tr("Clang Warnings"));
using namespace Layouting;
@@ -206,10 +203,10 @@ void ClangDiagnosticConfigsWidget::onCopyButtonClicked()
const ClangDiagnosticConfig &config = currentConfig();
bool dialogAccepted = false;
const QString newName = QInputDialog::getText(this,
tr("Copy Diagnostic Configuration"),
tr("Diagnostic configuration name:"),
Tr::tr("Copy Diagnostic Configuration"),
Tr::tr("Diagnostic configuration name:"),
QLineEdit::Normal,
tr("%1 (Copy)").arg(config.displayName()),
Tr::tr("%1 (Copy)").arg(config.displayName()),
&dialogAccepted);
if (dialogAccepted) {
const ClangDiagnosticConfig customConfig
@@ -229,8 +226,8 @@ void ClangDiagnosticConfigsWidget::onRenameButtonClicked()
bool dialogAccepted = false;
const QString newName = QInputDialog::getText(this,
tr("Rename Diagnostic Configuration"),
tr("New name:"),
Tr::tr("Rename Diagnostic Configuration"),
Tr::tr("New name:"),
QLineEdit::Normal,
config.displayName(),
&dialogAccepted);
@@ -280,7 +277,7 @@ static QString validateDiagnosticOptions(const QStringList &options)
for (const QString &option : options) {
if (!isValidOption(option))
return ClangDiagnosticConfigsWidget::tr("Option \"%1\" is invalid.").arg(option);
return Tr::tr("Option \"%1\" is invalid.").arg(option);
}
return QString();
@@ -343,7 +340,7 @@ void ClangDiagnosticConfigsWidget::sync()
if (config.isReadOnly()) {
m_infoLabel->setType(InfoLabel::Information);
m_infoLabel->setText(tr("Copy this configuration to customize it."));
m_infoLabel->setText(Tr::tr("Copy this configuration to customize it."));
m_infoLabel->setFilled(false);
}
@@ -369,11 +366,11 @@ void ClangDiagnosticConfigsWidget::updateValidityWidgets(const QString &errorMes
{
if (errorMessage.isEmpty()) {
m_infoLabel->setType(InfoLabel::Information);
m_infoLabel->setText(tr("Configuration passes sanity checks."));
m_infoLabel->setText(Tr::tr("Configuration passes sanity checks."));
m_infoLabel->setFilled(false);
} else {
m_infoLabel->setType(InfoLabel::Error);
m_infoLabel->setText(tr("%1").arg(errorMessage));
m_infoLabel->setText(Tr::tr("%1").arg(errorMessage));
m_infoLabel->setFilled(true);
}
}
@@ -411,6 +408,4 @@ QTabWidget *ClangDiagnosticConfigsWidget::tabWidget() const
return m_tabWidget;
}
} // CppEditor namespace
#include "clangdiagnosticconfigswidget.moc"
} // CppEditor

View File

@@ -5,10 +5,11 @@
#include "cpplocalsymbols.h"
#include "cppeditortr.h"
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <QCoreApplication>
#include <QDebug>
// This is for experimeting highlighting ctors/dtors as functions (instead of types).
@@ -503,11 +504,9 @@ bool CheckSymbols::visit(SimpleDeclarationAST *ast)
// Add a diagnostic message if non-virtual function has override/final marker
if ((_usages.back().kind != SemanticHighlighter::VirtualFunctionDeclarationUse)) {
if (funTy->isOverride())
warning(declrIdNameAST, QCoreApplication::translate(
"CPlusplus::CheckSymbols", "Only virtual functions can be marked 'override'"));
warning(declrIdNameAST, Tr::tr("Only virtual functions can be marked 'override'"));
else if (funTy->isFinal())
warning(declrIdNameAST, QCoreApplication::translate(
"CPlusPlus::CheckSymbols", "Only virtual functions can be marked 'final'"));
warning(declrIdNameAST, Tr::tr("Only virtual functions can be marked 'final'"));
}
}
}
@@ -776,8 +775,7 @@ void CheckSymbols::checkNamespace(NameAST *name)
const unsigned length = tokenAt(name->lastToken() - 1).utf16charsEnd()
- tokenAt(name->firstToken()).utf16charsBegin();
warning(line, column, QCoreApplication::translate("CPlusPlus::CheckSymbols",
"Expected a namespace-name"), length);
warning(line, column, Tr::tr( "Expected a namespace-name"), length);
}
bool CheckSymbols::hasVirtualDestructor(Class *klass) const
@@ -1398,9 +1396,9 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
// Add a diagnostic message if argument count does not match
if (matchType == Match_TooFewArgs)
warning(line, column, QCoreApplication::translate("CplusPlus::CheckSymbols", "Too few arguments"), length);
warning(line, column, Tr::tr("Too few arguments"), length);
else if (matchType == Match_TooManyArgs)
warning(line, column, QCoreApplication::translate("CPlusPlus::CheckSymbols", "Too many arguments"), length);
warning(line, column, Tr::tr("Too many arguments"), length);
const Result use(line, column, length, kind);
addUse(use);

View File

@@ -5,8 +5,9 @@
#include "baseeditordocumentprocessor.h"
#include "cppcodemodelinspectordumper.h"
#include "cppeditorwidget.h"
#include "cppeditordocument.h"
#include "cppeditorwidget.h"
#include "cppeditortr.h"
#include "cppmodelmanager.h"
#include "cpptoolsreuse.h"
#include "cppworkingcopy.h"
@@ -1433,7 +1434,7 @@ CppCodeModelInspectorDialog::CppCodeModelInspectorDialog(QWidget *parent)
Row {
m_partGeneralView,
Column {
tr("Compiler Flags"),
Tr::tr("Compiler Flags"),
m_partGeneralCompilerFlagsEdit,
},
}

View File

@@ -5,6 +5,7 @@
#include "clangdiagnosticconfigsmodel.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cpptoolsreuse.h"
#include <coreplugin/icore.h>
@@ -218,10 +219,10 @@ QString ClangdSettings::priorityToString(const IndexingPriority &priority)
QString ClangdSettings::priorityToDisplayString(const IndexingPriority &priority)
{
switch (priority) {
case IndexingPriority::Background: return tr("Background Priority");
case IndexingPriority::Normal: return tr("Normal Priority");
case IndexingPriority::Low: return tr("Low Priority");
case IndexingPriority::Off: return tr("Off");
case IndexingPriority::Background: return Tr::tr("Background Priority");
case IndexingPriority::Normal: return Tr::tr("Normal Priority");
case IndexingPriority::Low: return Tr::tr("Low Priority");
case IndexingPriority::Off: return Tr::tr("Off");
}
return {};
}

View File

@@ -6,6 +6,7 @@
#include "clangdiagnosticconfigsselectionwidget.h"
#include "clangdiagnosticconfigswidget.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cpptoolsreuse.h"
#include <coreplugin/icore.h>
@@ -39,8 +40,6 @@ namespace CppEditor::Internal {
class CppCodeModelSettingsWidget final : public Core::IOptionsPageWidget
{
Q_DECLARE_TR_FUNCTIONS(CppEditor::Internal::CppCodeModelSettingsWidget)
public:
CppCodeModelSettingsWidget(CppCodeModelSettings *s);
@@ -63,18 +62,18 @@ CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(CppCodeModelSettings *s)
: m_settings(s)
{
m_interpretAmbiguousHeadersAsCHeaders
= new QCheckBox(tr("Interpret ambiguous headers as C headers"));
= new QCheckBox(Tr::tr("Interpret ambiguous headers as C headers"));
m_skipIndexingBigFilesCheckBox = new QCheckBox(tr("Do not index files greater than"));
m_skipIndexingBigFilesCheckBox = new QCheckBox(Tr::tr("Do not index files greater than"));
m_skipIndexingBigFilesCheckBox->setChecked(m_settings->skipIndexingBigFiles());
m_bigFilesLimitSpinBox = new QSpinBox;
m_bigFilesLimitSpinBox->setSuffix(tr("MB"));
m_bigFilesLimitSpinBox->setSuffix(Tr::tr("MB"));
m_bigFilesLimitSpinBox->setRange(1, 500);
m_bigFilesLimitSpinBox->setValue(m_settings->indexerFileSizeLimitInMb());
m_ignoreFilesCheckBox = new QCheckBox(tr("Ignore files"));
m_ignoreFilesCheckBox->setToolTip(tr(
m_ignoreFilesCheckBox = new QCheckBox(Tr::tr("Ignore files"));
m_ignoreFilesCheckBox->setToolTip(Tr::tr(
"<html><head/><body><p>Ignore files that match these wildcard patterns, one wildcard per line.</p></body></html>"));
m_ignoreFilesCheckBox->setChecked(m_settings->ignoreFiles());
@@ -86,17 +85,17 @@ CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(CppCodeModelSettings *s)
m_ignorePatternTextEdit->setEnabled(m_ignoreFilesCheckBox->isChecked());
});
m_ignorePchCheckBox = new QCheckBox(tr("Ignore precompiled headers"));
m_ignorePchCheckBox->setToolTip(tr(
m_ignorePchCheckBox = new QCheckBox(Tr::tr("Ignore precompiled headers"));
m_ignorePchCheckBox->setToolTip(Tr::tr(
"<html><head/><body><p>When precompiled headers are not ignored, the parsing for code "
"completion and semantic highlighting will process the precompiled header before "
"processing any file.</p></body></html>"));
m_useBuiltinPreprocessorCheckBox = new QCheckBox(tr("Use built-in preprocessor to show "
"pre-processed files"));
m_useBuiltinPreprocessorCheckBox = new QCheckBox(Tr::tr("Use built-in preprocessor to show "
"pre-processed files"));
m_useBuiltinPreprocessorCheckBox->setToolTip
(tr("Uncheck this to invoke the actual compiler "
"to show a pre-processed source file in the editor."));
(Tr::tr("Uncheck this to invoke the actual compiler "
"to show a pre-processed source file in the editor."));
m_interpretAmbiguousHeadersAsCHeaders->setChecked(
m_settings->interpretAmbigiousHeadersAsCHeaders());
@@ -108,7 +107,7 @@ CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(CppCodeModelSettings *s)
Column {
Group {
title(tr("General")),
title(Tr::tr("General")),
Column {
m_interpretAmbiguousHeadersAsCHeaders,
m_ignorePchCheckBox,
@@ -181,9 +180,9 @@ bool CppCodeModelSettingsWidget::applyGeneralWidgetsToSettings() const
CppCodeModelSettingsPage::CppCodeModelSettingsPage(CppCodeModelSettings *settings)
{
setId(Constants::CPP_CODE_MODEL_SETTINGS_ID);
setDisplayName(CppCodeModelSettingsWidget::tr("Code Model"));
setDisplayName(Tr::tr("Code Model"));
setCategory(Constants::CPP_SETTINGS_CATEGORY);
setDisplayCategory(QCoreApplication::translate("CppEditor", "C++"));
setDisplayCategory(Tr::tr("C++"));
setCategoryIconPath(":/projectexplorer/images/settingscategory_cpp.png");
setWidgetCreator([settings] { return new CppCodeModelSettingsWidget(settings); });
}
@@ -211,7 +210,7 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
: d(new Private)
{
const ClangdSettings settings(settingsData);
const QString indexingToolTip = tr(
const QString indexingToolTip = Tr::tr(
"If background indexing is enabled, global symbol searches will yield\n"
"more accurate results, at the cost of additional CPU load when\n"
"the project is first opened.\n"
@@ -225,22 +224,22 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
"unused.\n"
"Normal Priority: Reduced priority compared to interactive work.\n"
"Low Priority: Same priority as other clangd work.");
const QString workerThreadsToolTip = tr(
const QString workerThreadsToolTip = Tr::tr(
"Number of worker threads used by clangd. Background indexing also uses this many "
"worker threads.");
const QString autoIncludeToolTip = tr(
const QString autoIncludeToolTip = Tr::tr(
"Controls whether clangd may insert header files as part of symbol completion.");
const QString documentUpdateToolTip = tr(
const QString documentUpdateToolTip = Tr::tr(
"Defines the amount of time Qt Creator waits before sending document changes to the "
"server.\n"
"If the document changes again while waiting, this timeout resets.");
const QString sizeThresholdToolTip = tr(
const QString sizeThresholdToolTip = Tr::tr(
"Files greater than this will not be opened as documents in clangd.\n"
"The built-in code model will handle highlighting, completion and so on.");
const QString completionResultToolTip = tr(
const QString completionResultToolTip = Tr::tr(
"The maximum number of completion results returned by clangd.");
d->useClangdCheckBox.setText(tr("Use clangd"));
d->useClangdCheckBox.setText(Tr::tr("Use clangd"));
d->useClangdCheckBox.setChecked(settings.useClangd());
d->clangdChooser.setExpectedKind(Utils::PathChooser::ExistingCommand);
d->clangdChooser.setFilePath(settings.clangdFilePath());
@@ -253,7 +252,7 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
d->indexingComboBox.setCurrentIndex(d->indexingComboBox.count() - 1);
}
d->indexingComboBox.setToolTip(indexingToolTip);
d->autoIncludeHeadersCheckBox.setText(tr("Insert header files on completion"));
d->autoIncludeHeadersCheckBox.setText(Tr::tr("Insert header files on completion"));
d->autoIncludeHeadersCheckBox.setChecked(settings.autoIncludeHeaders());
d->autoIncludeHeadersCheckBox.setToolTip(autoIncludeToolTip);
d->threadLimitSpinBox.setValue(settings.workerThreadLimit());
@@ -265,7 +264,7 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
d->documentUpdateThreshold.setSingleStep(100);
d->documentUpdateThreshold.setSuffix(" ms");
d->documentUpdateThreshold.setToolTip(documentUpdateToolTip);
d->sizeThresholdCheckBox.setText(tr("Ignore files greater than"));
d->sizeThresholdCheckBox.setText(Tr::tr("Ignore files greater than"));
d->sizeThresholdCheckBox.setChecked(settings.sizeThresholdEnabled());
d->sizeThresholdCheckBox.setToolTip(sizeThresholdToolTip);
d->sizeThresholdSpinBox.setMinimum(1);
@@ -274,34 +273,34 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
d->sizeThresholdSpinBox.setValue(settings.sizeThresholdInKb());
d->sizeThresholdSpinBox.setToolTip(sizeThresholdToolTip);
const auto completionResultsLabel = new QLabel(tr("Completion results:"));
const auto completionResultsLabel = new QLabel(Tr::tr("Completion results:"));
completionResultsLabel->setToolTip(completionResultToolTip);
d->completionResults.setMinimum(0);
d->completionResults.setMaximum(std::numeric_limits<int>::max());
d->completionResults.setValue(settings.completionResults());
d->completionResults.setToolTip(completionResultToolTip);
d->completionResults.setSpecialValueText(tr("No limit"));
d->completionResults.setSpecialValueText(Tr::tr("No limit"));
const auto layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(&d->useClangdCheckBox);
const auto formLayout = new QFormLayout;
const auto chooserLabel = new QLabel(tr("Path to executable:"));
const auto chooserLabel = new QLabel(Tr::tr("Path to executable:"));
formLayout->addRow(chooserLabel, &d->clangdChooser);
formLayout->addRow(QString(), &d->versionWarningLabel);
const auto indexingPriorityLayout = new QHBoxLayout;
indexingPriorityLayout->addWidget(&d->indexingComboBox);
indexingPriorityLayout->addStretch(1);
const auto indexingPriorityLabel = new QLabel(tr("Background indexing:"));
const auto indexingPriorityLabel = new QLabel(Tr::tr("Background indexing:"));
indexingPriorityLabel->setToolTip(indexingToolTip);
formLayout->addRow(indexingPriorityLabel, indexingPriorityLayout);
const auto threadLimitLayout = new QHBoxLayout;
threadLimitLayout->addWidget(&d->threadLimitSpinBox);
threadLimitLayout->addStretch(1);
const auto threadLimitLabel = new QLabel(tr("Worker thread count:"));
const auto threadLimitLabel = new QLabel(Tr::tr("Worker thread count:"));
threadLimitLabel->setToolTip(workerThreadsToolTip);
formLayout->addRow(threadLimitLabel, threadLimitLayout);
@@ -314,7 +313,7 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
const auto documentUpdateThresholdLayout = new QHBoxLayout;
documentUpdateThresholdLayout->addWidget(&d->documentUpdateThreshold);
documentUpdateThresholdLayout->addStretch(1);
const auto documentUpdateThresholdLabel = new QLabel(tr("Document update threshold:"));
const auto documentUpdateThresholdLabel = new QLabel(Tr::tr("Document update threshold:"));
documentUpdateThresholdLabel->setToolTip(documentUpdateToolTip);
formLayout->addRow(documentUpdateThresholdLabel, documentUpdateThresholdLayout);
const auto sizeThresholdLayout = new QHBoxLayout;
@@ -334,18 +333,18 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
if (!isForProject) {
d->sessionsModel.setStringList(settingsData.sessionsWithOneClangd);
d->sessionsModel.sort(0);
d->sessionsGroupBox = new QGroupBox(tr("Sessions with a single clangd instance"));
d->sessionsGroupBox = new QGroupBox(Tr::tr("Sessions with a single clangd instance"));
const auto sessionsView = new Utils::ListView;
sessionsView->setModel(&d->sessionsModel);
sessionsView->setToolTip(
tr("By default, Qt Creator runs one clangd process per project.\n"
Tr::tr("By default, Qt Creator runs one clangd process per project.\n"
"If you have sessions with tightly coupled projects that should be\n"
"managed by the same clangd process, add them here."));
const auto outerSessionsLayout = new QHBoxLayout;
const auto innerSessionsLayout = new QHBoxLayout(d->sessionsGroupBox);
const auto buttonsLayout = new QVBoxLayout;
const auto addButton = new QPushButton(tr("Add ..."));
const auto removeButton = new QPushButton(tr("Remove"));
const auto addButton = new QPushButton(Tr::tr("Add ..."));
const auto removeButton = new QPushButton(Tr::tr("Remove"));
buttonsLayout->addWidget(addButton);
buttonsLayout->addWidget(removeButton);
buttonsLayout->addStretch(1);
@@ -380,7 +379,7 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
if (sessions.isEmpty())
return;
sessions.sort();
dlg.setLabelText(tr("Choose a session:"));
dlg.setLabelText(Tr::tr("Choose a session:"));
dlg.setComboBoxItems(sessions);
if (dlg.exec() == QDialog::Accepted) {
currentSessions << dlg.textValue();
@@ -391,7 +390,7 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
}
const auto configFilesHelpLabel = new QLabel;
configFilesHelpLabel->setText(tr("Additional settings are available via "
configFilesHelpLabel->setText(Tr::tr("Additional settings are available via "
"<a href=\"https://clangd.llvm.org/config\"> clangd configuration files</a>.<br>"
"User-specific settings go <a href=\"%1\">here</a>, "
"project-specific settings can be configured by putting a .clangd file into "
@@ -444,12 +443,12 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
const Utils::FilePath clangdPath = d->clangdChooser.filePath();
const QVersionNumber clangdVersion = ClangdSettings::clangdVersion(clangdPath);
if (clangdVersion.isNull()) {
labelSetter.setWarning(tr("Failed to retrieve clangd version: "
"Unexpected clangd output."));
labelSetter.setWarning(Tr::tr("Failed to retrieve clangd version: "
"Unexpected clangd output."));
return;
}
if (clangdVersion < QVersionNumber(14)) {
labelSetter.setWarning(tr("The clangd version is %1, but %2 or greater is required.")
labelSetter.setWarning(Tr::tr("The clangd version is %1, but %2 or greater is required.")
.arg(clangdVersion.toString()).arg(14));
return;
}
@@ -505,8 +504,6 @@ ClangdSettings::Data ClangdSettingsWidget::settingsData() const
class ClangdSettingsPageWidget final : public Core::IOptionsPageWidget
{
Q_DECLARE_TR_FUNCTIONS(CppEditor::Internal::ClangdSettingsWidget)
public:
ClangdSettingsPageWidget() : m_widget(ClangdSettings::instance().data(), false)
{
@@ -523,7 +520,7 @@ private:
ClangdSettingsPage::ClangdSettingsPage()
{
setId(Constants::CPP_CLANGD_SETTINGS_ID);
setDisplayName(ClangdSettingsWidget::tr("Clangd"));
setDisplayName(Tr::tr("Clangd"));
setCategory(Constants::CPP_SETTINGS_CATEGORY);
setWidgetCreator([] { return new ClangdSettingsPageWidget; });
}

View File

@@ -7,6 +7,7 @@
#include "cppcodestylepreferences.h"
#include "cppcodestylesnippets.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cpppointerdeclarationformatter.h"
#include "cpptoolssettings.h"
@@ -82,78 +83,84 @@ static void applyRefactorings(QTextDocument *textDocument, TextEditorWidget *edi
class CppCodeStylePreferencesWidgetPrivate
{
Q_DECLARE_TR_FUNCTIONS(CppEditor::Internal::CppCodeStyleSettingsPage)
public:
CppCodeStylePreferencesWidgetPrivate(CppCodeStylePreferencesWidget *widget)
: q(widget)
, m_indentAccessSpecifiers(createCheckBox(tr("\"public\", \"protected\" and\n"
"\"private\" within class body")))
, m_indentAccessSpecifiers(createCheckBox(Tr::tr("\"public\", \"protected\" and\n"
"\"private\" within class body")))
, m_indentDeclarationsRelativeToAccessSpecifiers(
createCheckBox(tr("Declarations relative to \"public\",\n"
createCheckBox(Tr::tr("Declarations relative to \"public\",\n"
"\"protected\" and \"private\"")))
, m_indentFunctionBody(createCheckBox(tr("Statements within function body")))
, m_indentBlockBody(createCheckBox(tr("Statements within blocks")))
, m_indentNamespaceBody(createCheckBox(tr("Declarations within\n"
, m_indentFunctionBody(createCheckBox(Tr::tr("Statements within function body")))
, m_indentBlockBody(createCheckBox(Tr::tr("Statements within blocks")))
, m_indentNamespaceBody(createCheckBox(Tr::tr("Declarations within\n"
"\"namespace\" definition")))
, m_indentClassBraces(createCheckBox(tr("Class declarations")))
, m_indentNamespaceBraces(createCheckBox(tr("Namespace declarations")))
, m_indentEnumBraces(createCheckBox(tr("Enum declarations")))
, m_indentFunctionBraces(createCheckBox(tr("Function declarations")))
, m_indentBlockBraces(createCheckBox(tr("Blocks")))
, m_indentSwitchLabels(createCheckBox(tr("\"case\" or \"default\"")))
, m_indentCaseStatements(createCheckBox(tr("Statements relative to\n"
, m_indentClassBraces(createCheckBox(Tr::tr("Class declarations")))
, m_indentNamespaceBraces(createCheckBox(Tr::tr("Namespace declarations")))
, m_indentEnumBraces(createCheckBox(Tr::tr("Enum declarations")))
, m_indentFunctionBraces(createCheckBox(Tr::tr("Function declarations")))
, m_indentBlockBraces(createCheckBox(Tr::tr("Blocks")))
, m_indentSwitchLabels(createCheckBox(Tr::tr("\"case\" or \"default\"")))
, m_indentCaseStatements(createCheckBox(Tr::tr("Statements relative to\n"
"\"case\" or \"default\"")))
, m_indentCaseBlocks(createCheckBox(tr("Blocks relative to\n"
, m_indentCaseBlocks(createCheckBox(Tr::tr("Blocks relative to\n"
"\"case\" or \"default\"")))
, m_indentCaseBreak(createCheckBox(tr("\"break\" statement relative to\n"
, m_indentCaseBreak(createCheckBox(Tr::tr("\"break\" statement relative to\n"
"\"case\" or \"default\"")))
, m_alignAssignments(createCheckBox(tr("Align after assignments"),
tr("<html><head/><body>\n"
"Enables alignment to tokens after =, += etc. When the option is disabled, regular continuation line indentation will be used.<br>\n"
"<br>\n"
"With alignment:\n"
"<pre>\n"
"a = a +\n"
" b\n"
"</pre>\n"
"Without alignment:\n"
"<pre>\n"
"a = a +\n"
" b\n"
"</pre>\n"
"</body></html>")))
, m_extraPaddingConditions(createCheckBox(tr("Add extra padding to conditions\n"
"if they would align to the next line"),
tr("<html><head/><body>\n"
"Adds an extra level of indentation to multiline conditions in the switch, if, while and foreach statements if they would otherwise have the same or less indentation than a nested statement.\n"
"\n"
"For four-spaces indentation only if statement conditions are affected. Without extra padding:\n"
"<pre>\n"
"if (a &&\n"
" b)\n"
" c;\n"
"</pre>\n"
"With extra padding:\n"
"<pre>\n"
"if (a &&\n"
" b)\n"
" c;\n"
"</pre>\n"
"</body></html>")))
, m_bindStarToIdentifier(createCheckBox(tr("Identifier"),
tr("<html><head/><body>This does not apply to the star and reference symbol in pointer/reference to functions and arrays, e.g.:\n"
"<pre> int (&rf)() = ...;\n"
" int (*pf)() = ...;\n"
"\n"
" int (&ra)[2] = ...;\n"
" int (*pa)[2] = ...;\n"
"\n"
"</pre></body></html>")))
, m_bindStarToTypeName(createCheckBox(tr("Type name")))
, m_bindStarToLeftSpecifier(createCheckBox(tr("Left const/volatile")))
, m_bindStarToRightSpecifier(createCheckBox(tr("Right const/volatile"),
tr("This does not apply to references.")))
, m_alignAssignments(createCheckBox(
Tr::tr("Align after assignments"),
Tr::tr("<html><head/><body>\n"
"Enables alignment to tokens after =, += etc. When the option is disabled, "
"regular continuation line indentation will be used.<br>\n"
"<br>\n"
"With alignment:\n"
"<pre>\n"
"a = a +\n"
" b\n"
"</pre>\n"
"Without alignment:\n"
"<pre>\n"
"a = a +\n"
" b\n"
"</pre>\n"
"</body></html>")))
, m_extraPaddingConditions(createCheckBox(
Tr::tr("Add extra padding to conditions\n"
"if they would align to the next line"),
Tr::tr("<html><head/><body>\n"
"Adds an extra level of indentation to multiline conditions in the switch, "
"if, while and foreach statements if they would otherwise have the same or "
"less indentation than a nested statement.\n"
"\n"
"For four-spaces indentation only if statement conditions are affected. "
"Without extra padding:\n"
"<pre>\n"
"if (a &&\n"
" b)\n"
" c;\n"
"</pre>\n"
"With extra padding:\n"
"<pre>\n"
"if (a &&\n"
" b)\n"
" c;\n"
"</pre>\n"
"</body></html>")))
, m_bindStarToIdentifier(createCheckBox(
Tr::tr("Identifier"),
Tr::tr("<html><head/><body>This does not apply to the star and reference symbol "
"in pointer/reference to functions and arrays, e.g.:\n"
"<pre> int (&rf)() = ...;\n"
" int (*pf)() = ...;\n"
"\n"
" int (&ra)[2] = ...;\n"
" int (*pa)[2] = ...;\n"
"\n"
"</pre></body></html>")))
, m_bindStarToTypeName(createCheckBox(Tr::tr("Type name")))
, m_bindStarToLeftSpecifier(createCheckBox(Tr::tr("Left const/volatile")))
, m_bindStarToRightSpecifier(createCheckBox(Tr::tr("Right const/volatile"),
Tr::tr("This does not apply to references.")))
, m_categoryTab(new QTabWidget)
, m_tabSettingsWidget(new TabSettingsWidget)
{
@@ -178,12 +185,12 @@ public:
},
createPreview(0)
}.attachTo(generalTab);
m_categoryTab->addTab(generalTab, tr("General"));
m_categoryTab->addTab(generalTab, Tr::tr("General"));
m_controllers.append(m_tabSettingsWidget);
QWidget *contentTab = new QWidget;
Group contentGroup {
title(tr("Indent")),
title(Tr::tr("Indent")),
Column {
m_indentAccessSpecifiers,
m_indentDeclarationsRelativeToAccessSpecifiers,
@@ -197,12 +204,12 @@ public:
contentGroup,
createPreview(1)
}.attachTo(contentTab);
m_categoryTab->addTab(contentTab, tr("Content"));
m_categoryTab->addTab(contentTab, Tr::tr("Content"));
m_controllers.append(contentGroup.widget);
QWidget *bracesTab = new QWidget;
Group bracesGroup {
title(tr("Indent Braces")),
title(Tr::tr("Indent Braces")),
Column {
m_indentClassBraces,
m_indentNamespaceBraces,
@@ -216,12 +223,12 @@ public:
bracesGroup,
createPreview(2)
}.attachTo(bracesTab);
m_categoryTab->addTab(bracesTab, tr("Braces"));
m_categoryTab->addTab(bracesTab, Tr::tr("Braces"));
m_controllers.append(bracesGroup.widget);
QWidget *switchTab = new QWidget;
Group switchGroup {
title(tr("Indent within \"switch\"")),
title(Tr::tr("Indent within \"switch\"")),
Column {
m_indentSwitchLabels,
m_indentCaseStatements,
@@ -234,12 +241,12 @@ public:
switchGroup,
createPreview(3)
}.attachTo(switchTab);
m_categoryTab->addTab(switchTab, tr("\"switch\""));
m_categoryTab->addTab(switchTab, Tr::tr("\"switch\""));
m_controllers.append(switchGroup.widget);
QWidget *alignmentTab = new QWidget;
Group alignmentGroup {
title(tr("Align")),
title(Tr::tr("Align")),
Column {
m_alignAssignments,
m_extraPaddingConditions,
@@ -250,12 +257,12 @@ public:
alignmentGroup,
createPreview(4)
}.attachTo(alignmentTab);
m_categoryTab->addTab(alignmentTab, tr("Alignment"));
m_categoryTab->addTab(alignmentTab, Tr::tr("Alignment"));
m_controllers.append(alignmentGroup.widget);
QWidget *typesTab = new QWidget;
Group typesGroup {
title(tr("Bind '*' and '&&' in types/declarations to")),
title(Tr::tr("Bind '*' and '&&' in types/declarations to")),
Column {
m_bindStarToIdentifier,
m_bindStarToTypeName,
@@ -268,7 +275,7 @@ public:
typesGroup,
createPreview(5)
}.attachTo(typesTab);
m_categoryTab->addTab(typesTab, tr("Pointers and References"));
m_categoryTab->addTab(typesTab, Tr::tr("Pointers and References"));
m_controllers.append(typesGroup.widget);
Row { m_categoryTab }.attachTo(q);
@@ -574,7 +581,7 @@ void CppCodeStylePreferencesWidget::finish()
CppCodeStyleSettingsPage::CppCodeStyleSettingsPage()
{
setId(Constants::CPP_CODE_STYLE_SETTINGS_ID);
setDisplayName(QCoreApplication::translate("CppEditor", Constants::CPP_CODE_STYLE_SETTINGS_NAME));
setDisplayName(Tr::tr("Code Style"));
setCategory(Constants::CPP_SETTINGS_CATEGORY);
}

View File

@@ -11,7 +11,6 @@ namespace Constants {
const char M_CONTEXT[] = "CppEditor.ContextMenu";
const char G_CONTEXT_FIRST[] = "CppEditor.GFirst";
const char CPPEDITOR_ID[] = "CppEditor.C++Editor";
const char CPPEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "C++ Editor");
const char SWITCH_DECLARATION_DEFINITION[] = "CppEditor.SwitchDeclarationDefinition";
const char OPEN_DECLARATION_DEFINITION_IN_NEXT_SPLIT[] = "CppEditor.OpenDeclarationDefinitionInNextSplit";
const char FOLLOW_SYMBOL_TO_TYPE[] = "TextEditor.FollowSymbolToType";
@@ -96,12 +95,9 @@ const char CPP_CLANG_DIAG_CONFIG_QUESTIONABLE[] = "Builtin.Questionable";
const char CPP_CLANG_DIAG_CONFIG_BUILDSYSTEM[] = "Builtin.BuildSystem";
const char CPP_CODE_STYLE_SETTINGS_ID[] = "A.Cpp.Code Style";
const char CPP_CODE_STYLE_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppEditor", "Code Style");
const char CPP_FILE_SETTINGS_ID[] = "B.Cpp.File Naming";
const char CPP_FILE_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppEditor", "File Naming");
const char CPP_CODE_MODEL_SETTINGS_ID[] = "C.Cpp.Code Model";
const char CPP_DIAGNOSTIC_CONFIG_SETTINGS_ID[] = "C.Cpp.Diagnostic Config";
const char CPP_DIAGNOSTIC_CONFIG_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppEditor", "Diagnostic Configurations");
const char CPP_CLANGD_SETTINGS_ID[] = "K.Cpp.Clangd";
const char CPP_SETTINGS_CATEGORY[] = "I.C++";

View File

@@ -7,6 +7,7 @@
#include "cppcodeformatter.h"
#include "cppeditorconstants.h"
#include "cppeditorplugin.h"
#include "cppeditortr.h"
#include "cppmodelmanager.h"
#include "cppeditorconstants.h"
#include "cppeditorplugin.h"
@@ -110,8 +111,8 @@ CppEditorDocument::CppEditorDocument()
minimizableInfoBars()->setSettingsGroup(Constants::CPPEDITOR_SETTINGSGROUP);
minimizableInfoBars()->setPossibleInfoBarEntries(
{{NO_PROJECT_CONFIGURATION,
tr("<b>Warning</b>: This file is not part of any project. "
"The code model might have issues parsing this file properly.")}});
Tr::tr("<b>Warning</b>: This file is not part of any project. "
"The code model might have issues parsing this file properly.")}});
// See also onFilePathChanged() for more initialization
}
@@ -343,8 +344,8 @@ void CppEditorDocument::showHideInfoBarAboutMultipleParseContexts(bool show)
if (show) {
InfoBarEntry info(id,
tr("Note: Multiple parse contexts are available for this file. "
"Choose the preferred one from the editor toolbar."),
Tr::tr("Note: Multiple parse contexts are available for this file. "
"Choose the preferred one from the editor toolbar."),
InfoBarEntry::GlobalSuppression::Enabled);
info.removeCancelButton();
if (infoBar()->canInfoBeAdded(id))

View File

@@ -4,6 +4,7 @@
#include "cppeditoroutline.h"
#include "cppeditordocument.h"
#include "cppeditortr.h"
#include "cppeditorwidget.h"
#include "cppmodelmanager.h"
#include "cppoutlinemodel.h"
@@ -95,7 +96,7 @@ CppEditorOutline::CppEditorOutline(CppEditorWidget *editorWidget)
m_combo->setMaxVisibleItems(40);
m_combo->setContextMenuPolicy(Qt::ActionsContextMenu);
m_sortAction = new QAction(tr("Sort Alphabetically"), m_combo);
m_sortAction = new QAction(Tr::tr("Sort Alphabetically"), m_combo);
m_sortAction->setCheckable(true);
m_sortAction->setChecked(isSorted());
connect(m_sortAction, &QAction::toggled,

View File

@@ -10,6 +10,7 @@
#include "cppcodestylesettingspage.h"
#include "cppeditorconstants.h"
#include "cppeditordocument.h"
#include "cppeditortr.h"
#include "cppeditorwidget.h"
#include "cppfilesettingspage.h"
#include "cppincludehierarchy.h"
@@ -124,7 +125,7 @@ public:
CppEditorFactory()
{
setId(Constants::CPPEDITOR_ID);
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::CPPEDITOR_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("OpenWith::Editors","C++ Editor"));
addMimeType(Constants::C_SOURCE_MIMETYPE);
addMimeType(Constants::C_HEADER_MIMETYPE);
addMimeType(Constants::CPP_SOURCE_MIMETYPE);
@@ -237,53 +238,53 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *mcpptools = ActionManager::createMenu(Constants::M_TOOLS_CPP);
QMenu *menu = mcpptools->menu();
menu->setTitle(tr("&C++"));
menu->setTitle(Tr::tr("&C++"));
menu->setEnabled(true);
mtools->addMenu(mcpptools);
// Actions
Context context(Constants::CPPEDITOR_ID);
QAction *switchAction = new QAction(tr("Switch Header/Source"), this);
QAction *switchAction = new QAction(Tr::tr("Switch Header/Source"), this);
Command *command = ActionManager::registerAction(switchAction, Constants::SWITCH_HEADER_SOURCE, context, true);
command->setDefaultKeySequence(QKeySequence(Qt::Key_F4));
mcpptools->addAction(command);
connect(switchAction, &QAction::triggered,
this, [] { CppModelManager::switchHeaderSource(false); });
QAction *openInNextSplitAction = new QAction(tr("Open Corresponding Header/Source in Next Split"), this);
QAction *openInNextSplitAction = new QAction(Tr::tr("Open Corresponding Header/Source in Next Split"), this);
command = ActionManager::registerAction(openInNextSplitAction, Constants::OPEN_HEADER_SOURCE_IN_NEXT_SPLIT, context, true);
command->setDefaultKeySequence(QKeySequence(HostOsInfo::isMacHost()
? tr("Meta+E, F4")
: tr("Ctrl+E, F4")));
? Tr::tr("Meta+E, F4")
: Tr::tr("Ctrl+E, F4")));
mcpptools->addAction(command);
connect(openInNextSplitAction, &QAction::triggered,
this, [] { CppModelManager::switchHeaderSource(true); });
MacroExpander *expander = globalMacroExpander();
expander->registerVariable("Cpp:LicenseTemplate",
tr("The license template."),
Tr::tr("The license template."),
[]() { return CppEditorPlugin::licenseTemplate(); });
expander->registerFileVariables("Cpp:LicenseTemplatePath",
tr("The configured path to the license template"),
Tr::tr("The configured path to the license template"),
[]() { return CppEditorPlugin::licenseTemplatePath(); });
expander->registerVariable(
"Cpp:PragmaOnce",
tr("Insert \"#pragma once\" instead of \"#ifndef\" include guards into header file"),
Tr::tr("Insert \"#pragma once\" instead of \"#ifndef\" include guards into header file"),
[] { return usePragmaOnce() ? QString("true") : QString(); });
const auto quickFixSettingsPanelFactory = new ProjectPanelFactory;
quickFixSettingsPanelFactory->setPriority(100);
quickFixSettingsPanelFactory->setId(Constants::QUICK_FIX_PROJECT_PANEL_ID);
quickFixSettingsPanelFactory->setDisplayName(
QCoreApplication::translate("CppEditor", Constants::QUICK_FIX_SETTINGS_DISPLAY_NAME));
Tr::tr("CppEditor", Constants::QUICK_FIX_SETTINGS_DISPLAY_NAME));
quickFixSettingsPanelFactory->setCreateWidgetFunction([](Project *project) {
return new CppQuickFixProjectSettingsWidget(project);
});
ProjectPanelFactory::registerFactory(quickFixSettingsPanelFactory);
SnippetProvider::registerGroup(Constants::CPP_SNIPPETS_GROUP_ID, tr("C++", "SnippetProvider"),
SnippetProvider::registerGroup(Constants::CPP_SNIPPETS_GROUP_ID, Tr::tr("C++", "SnippetProvider"),
&decorateCppEditor);
createCppQuickFixes();
@@ -296,28 +297,28 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
ActionContainer *touchBar = ActionManager::actionContainer(Core::Constants::TOUCH_BAR);
cmd = ActionManager::command(Constants::SWITCH_HEADER_SOURCE);
cmd->setTouchBarText(tr("Header/Source", "text on macOS touch bar"));
cmd->setTouchBarText(Tr::tr("Header/Source", "text on macOS touch bar"));
contextMenu->addAction(cmd, Constants::G_CONTEXT_FIRST);
touchBar->addAction(cmd, Core::Constants::G_TOUCHBAR_NAVIGATION);
cmd = ActionManager::command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR);
cmd->setTouchBarText(tr("Follow", "text on macOS touch bar"));
cmd->setTouchBarText(Tr::tr("Follow", "text on macOS touch bar"));
contextMenu->addAction(cmd, Constants::G_CONTEXT_FIRST);
cppToolsMenu->addAction(cmd);
touchBar->addAction(cmd, Core::Constants::G_TOUCHBAR_NAVIGATION);
QAction *openPreprocessorDialog = new QAction(tr("Additional Preprocessor Directives..."), this);
QAction *openPreprocessorDialog = new QAction(Tr::tr("Additional Preprocessor Directives..."), this);
cmd = ActionManager::registerAction(openPreprocessorDialog,
Constants::OPEN_PREPROCESSOR_DIALOG, context);
cmd->setDefaultKeySequence(QKeySequence());
connect(openPreprocessorDialog, &QAction::triggered, this, &CppEditorPlugin::showPreProcessorDialog);
cppToolsMenu->addAction(cmd);
QAction *switchDeclarationDefinition = new QAction(tr("Switch Between Function Declaration/Definition"), this);
QAction *switchDeclarationDefinition = new QAction(Tr::tr("Switch Between Function Declaration/Definition"), this);
cmd = ActionManager::registerAction(switchDeclarationDefinition,
Constants::SWITCH_DECLARATION_DEFINITION, context, true);
cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F2")));
cmd->setTouchBarText(tr("Decl/Def", "text on macOS touch bar"));
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Shift+F2")));
cmd->setTouchBarText(Tr::tr("Decl/Def", "text on macOS touch bar"));
connect(switchDeclarationDefinition, &QAction::triggered,
this, &CppEditorPlugin::switchDeclarationDefinition);
contextMenu->addAction(cmd, Constants::G_CONTEXT_FIRST);
@@ -328,21 +329,21 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
cppToolsMenu->addAction(cmd);
QAction *openDeclarationDefinitionInNextSplit =
new QAction(tr("Open Function Declaration/Definition in Next Split"), this);
new QAction(Tr::tr("Open Function Declaration/Definition in Next Split"), this);
cmd = ActionManager::registerAction(openDeclarationDefinitionInNextSplit,
Constants::OPEN_DECLARATION_DEFINITION_IN_NEXT_SPLIT, context, true);
cmd->setDefaultKeySequence(QKeySequence(HostOsInfo::isMacHost()
? tr("Meta+E, Shift+F2")
: tr("Ctrl+E, Shift+F2")));
? Tr::tr("Meta+E, Shift+F2")
: Tr::tr("Ctrl+E, Shift+F2")));
connect(openDeclarationDefinitionInNextSplit, &QAction::triggered,
this, &CppEditorPlugin::openDeclarationDefinitionInNextSplit);
cppToolsMenu->addAction(cmd);
QAction * const followSymbolToType = new QAction(tr("Follow Symbol Under Cursor to Type"),
QAction * const followSymbolToType = new QAction(Tr::tr("Follow Symbol Under Cursor to Type"),
this);
cmd = ActionManager::registerAction(followSymbolToType, Constants::FOLLOW_SYMBOL_TO_TYPE,
context, true);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F2")));
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Shift+F2")));
connect(followSymbolToType, &QAction::triggered, this, []{
if (CppEditorWidget *editorWidget = currentCppEditorWidget())
editorWidget->followSymbolToType(false);
@@ -350,12 +351,12 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
contextMenu->addAction(cmd, Constants::G_CONTEXT_FIRST);
cppToolsMenu->addAction(cmd);
QAction * const followSymbolToTypeInNextSplit =
new QAction(tr("Follow Symbol to Type in Next Split"), this);
new QAction(Tr::tr("Follow Symbol to Type in Next Split"), this);
cmd = ActionManager::registerAction(followSymbolToTypeInNextSplit,
Constants::FOLLOW_SYMBOL_TO_TYPE_IN_NEXT_SPLIT, context, true);
cmd->setDefaultKeySequence(QKeySequence(HostOsInfo::isMacHost()
? tr("Meta+E, Ctrl+Shift+F2")
: tr("Ctrl+E, Ctrl+Shift+F2")));
? Tr::tr("Meta+E, Ctrl+Shift+F2")
: Tr::tr("Ctrl+E, Ctrl+Shift+F2")));
connect(followSymbolToTypeInNextSplit, &QAction::triggered, this, []{
if (CppEditorWidget *editorWidget = currentCppEditorWidget())
editorWidget->followSymbolToType(true);
@@ -366,7 +367,7 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
contextMenu->addAction(cmd, Constants::G_CONTEXT_FIRST);
cppToolsMenu->addAction(cmd);
d->m_findRefsCategorizedAction = new QAction(tr("Find References With Access Type"), this);
d->m_findRefsCategorizedAction = new QAction(Tr::tr("Find References With Access Type"), this);
cmd = ActionManager::registerAction(d->m_findRefsCategorizedAction,
"CppEditor.FindRefsCategorized", context);
connect(d->m_findRefsCategorizedAction, &QAction::triggered, this, [this] {
@@ -379,7 +380,7 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
contextMenu->addAction(cmd, Constants::G_CONTEXT_FIRST);
cppToolsMenu->addAction(cmd);
QAction * const showPreprocessedAction = new QAction(tr("Show Preprocessed Source"), this);
QAction * const showPreprocessedAction = new QAction(Tr::tr("Show Preprocessed Source"), this);
command = ActionManager::registerAction(showPreprocessedAction,
Constants::SHOW_PREPROCESSED_FILE, context);
mcpptools->addAction(command);
@@ -388,14 +389,14 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
this, [] { CppModelManager::showPreprocessedFile(false); });
QAction * const showPreprocessedInSplitAction = new QAction
(tr("Show Preprocessed Source in Next Split"), this);
(Tr::tr("Show Preprocessed Source in Next Split"), this);
command = ActionManager::registerAction(showPreprocessedInSplitAction,
Constants::SHOW_PREPROCESSED_FILE_SPLIT, context);
mcpptools->addAction(command);
connect(showPreprocessedInSplitAction, &QAction::triggered,
this, [] { CppModelManager::showPreprocessedFile(true); });
QAction *const findUnusedFunctionsAction = new QAction(tr("Find Unused Functions"), this);
QAction *const findUnusedFunctionsAction = new QAction(Tr::tr("Find Unused Functions"), this);
command = ActionManager::registerAction(findUnusedFunctionsAction,
"CppTools.FindUnusedFunctions");
mcpptools->addAction(command);
@@ -403,7 +404,7 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
CppModelManager::findUnusedFunctions({});
});
QAction *const findUnusedFunctionsInSubProjectAction
= new QAction(tr("Find Unused C/C++ Functions"), this);
= new QAction(Tr::tr("Find Unused C/C++ Functions"), this);
command = ActionManager::registerAction(findUnusedFunctionsInSubProjectAction,
"CppTools.FindUnusedFunctionsInSubProject");
for (ActionContainer *const projectContextMenu :
@@ -417,16 +418,16 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
CppModelManager::findUnusedFunctions(node->directory());
});
d->m_openTypeHierarchyAction = new QAction(tr("Open Type Hierarchy"), this);
d->m_openTypeHierarchyAction = new QAction(Tr::tr("Open Type Hierarchy"), this);
cmd = ActionManager::registerAction(d->m_openTypeHierarchyAction, Constants::OPEN_TYPE_HIERARCHY, context);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Shift+T") : tr("Ctrl+Shift+T")));
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+Shift+T") : Tr::tr("Ctrl+Shift+T")));
connect(d->m_openTypeHierarchyAction, &QAction::triggered, this, &CppEditorPlugin::openTypeHierarchy);
contextMenu->addAction(cmd, Constants::G_CONTEXT_FIRST);
cppToolsMenu->addAction(cmd);
d->m_openIncludeHierarchyAction = new QAction(tr("Open Include Hierarchy"), this);
d->m_openIncludeHierarchyAction = new QAction(Tr::tr("Open Include Hierarchy"), this);
cmd = ActionManager::registerAction(d->m_openIncludeHierarchyAction, Constants::OPEN_INCLUDE_HIERARCHY, context);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Shift+I") : tr("Ctrl+Shift+I")));
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+Shift+I") : Tr::tr("Ctrl+Shift+I")));
connect(d->m_openIncludeHierarchyAction, &QAction::triggered, this, &CppEditorPlugin::openIncludeHierarchy);
contextMenu->addAction(cmd, Constants::G_CONTEXT_FIRST);
cppToolsMenu->addAction(cmd);
@@ -439,7 +440,7 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
// Update context in global context
cppToolsMenu->addSeparator(Core::Constants::G_DEFAULT_THREE);
d->m_reparseExternallyChangedFiles = new QAction(tr("Reparse Externally Changed Files"), this);
d->m_reparseExternallyChangedFiles = new QAction(Tr::tr("Reparse Externally Changed Files"), this);
cmd = ActionManager::registerAction(d->m_reparseExternallyChangedFiles, Constants::UPDATE_CODEMODEL);
CppModelManager *cppModelManager = CppModelManager::instance();
connect(d->m_reparseExternallyChangedFiles, &QAction::triggered,
@@ -447,9 +448,9 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
cppToolsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE);
ActionContainer *toolsDebug = ActionManager::actionContainer(Core::Constants::M_TOOLS_DEBUG);
QAction *inspectCppCodeModel = new QAction(tr("Inspect C++ Code Model..."), this);
QAction *inspectCppCodeModel = new QAction(Tr::tr("Inspect C++ Code Model..."), this);
cmd = ActionManager::registerAction(inspectCppCodeModel, Constants::INSPECT_CPP_CODEMODEL);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Shift+F12") : tr("Ctrl+Shift+F12")));
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+Shift+F12") : Tr::tr("Ctrl+Shift+F12")));
connect(inspectCppCodeModel, &QAction::triggered, d, &CppEditorPluginPrivate::inspectCppCodeModel);
toolsDebug->addAction(cmd);
@@ -479,7 +480,7 @@ void CppEditorPlugin::extensionsInitialized()
d->m_clangdSettingsPage = new ClangdSettingsPage;
const auto clangdPanelFactory = new ProjectPanelFactory;
clangdPanelFactory->setPriority(100);
clangdPanelFactory->setDisplayName(tr("Clangd"));
clangdPanelFactory->setDisplayName(Tr::tr("Clangd"));
clangdPanelFactory->setCreateWidgetFunction([](Project *project) {
return new ClangdProjectSettingsWidget(project);
});

View File

@@ -5,20 +5,21 @@
#include "cppcodeformatter.h"
#include "cppcompletionassistprovider.h"
#include "doxygengenerator.h"
#include "cppeditorconstants.h"
#include "cppeditordocument.h"
#include "cppeditoroutline.h"
#include "cppeditorplugin.h"
#include "cppeditortr.h"
#include "cppfunctiondecldeflink.h"
#include "cpplocalrenaming.h"
#include "cppmodelmanager.h"
#include "cpppreprocessordialog.h"
#include "cppsemanticinfo.h"
#include "cppselectionchanger.h"
#include "cppquickfixassistant.h"
#include "cppselectionchanger.h"
#include "cppsemanticinfo.h"
#include "cpptoolssettings.h"
#include "cppuseselectionsupdater.h"
#include "doxygengenerator.h"
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
@@ -47,6 +48,7 @@
#include <cplusplus/ASTPath.h>
#include <cplusplus/FastPreprocessor.h>
#include <cplusplus/MatchingText.h>
#include <utils/infobar.h>
#include <utils/progressindicator.h>
#include <utils/qtcassert.h>
@@ -1017,8 +1019,6 @@ static void addRefactoringActions(QMenu *menu, std::unique_ptr<AssistInterface>
class ProgressIndicatorMenuItem : public QWidgetAction
{
Q_OBJECT
public:
ProgressIndicatorMenuItem(QObject *parent) : QWidgetAction(parent) {}
@@ -1031,7 +1031,7 @@ protected:
QMenu *CppEditorWidget::createRefactorMenu(QWidget *parent) const
{
auto *menu = new QMenu(tr("&Refactor"), parent);
auto *menu = new QMenu(Tr::tr("&Refactor"), parent);
menu->addAction(ActionManager::command(TextEditor::Constants::RENAME_SYMBOL)->action());
// ### enable
@@ -1411,5 +1411,3 @@ void CppEditorWidget::enableTestMode() { d->inTestMode = true; }
#endif
} // namespace CppEditor
#include "cppeditorwidget.moc"

View File

@@ -4,6 +4,7 @@
#include "cppfilesettingspage.h"
#include "cppeditorplugin.h"
#include "cppeditortr.h"
#include <app/app_version.h>
@@ -38,7 +39,7 @@ const char sourceSearchPathsKeyC[] = "SourceSearchPaths";
const char headerPragmaOnceC[] = "HeaderPragmaOnce";
const char licenseTemplatePathKeyC[] = "LicenseTemplate";
const char *licenseTemplateTemplate = QT_TRANSLATE_NOOP("CppEditor::Internal::CppFileSettingsWidget",
const char *licenseTemplateTemplate = QT_TRANSLATE_NOOP("CppEditor",
"/**************************************************************************\n"
"** %1 license header template\n"
"** Special keywords: %USER% %DATE% %YEAR%\n"
@@ -234,8 +235,6 @@ QString CppFileSettings::licenseTemplate()
class CppFileSettingsWidget final : public Core::IOptionsPageWidget
{
Q_DECLARE_TR_FUNCTIONS(CppEditor::Internal::CppFileSettingsPage)
public:
explicit CppFileSettingsWidget(CppFileSettings *settings);
@@ -265,29 +264,29 @@ CppFileSettingsWidget::CppFileSettingsWidget(CppFileSettings *settings)
, m_headerSuffixComboBox(new QComboBox)
, m_headerSearchPathsEdit(new QLineEdit)
, m_headerPrefixesEdit(new QLineEdit)
, m_headerPragmaOnceCheckBox(new QCheckBox(tr("Use \"#pragma once\" instead of \"#ifndef\" guards")))
, m_headerPragmaOnceCheckBox(new QCheckBox(Tr::tr("Use \"#pragma once\" instead of \"#ifndef\" guards")))
, m_sourceSuffixComboBox(new QComboBox)
, m_sourceSearchPathsEdit(new QLineEdit)
, m_sourcePrefixesEdit(new QLineEdit)
, m_lowerCaseFileNamesCheckBox(new QCheckBox(tr("&Lower case file names")))
, m_lowerCaseFileNamesCheckBox(new QCheckBox(Tr::tr("&Lower case file names")))
, m_licenseTemplatePathChooser(new PathChooser)
{
m_headerSearchPathsEdit->setToolTip(tr("Comma-separated list of header paths.\n"
m_headerSearchPathsEdit->setToolTip(Tr::tr("Comma-separated list of header paths.\n"
"\n"
"Paths can be absolute or relative to the directory of the current open document.\n"
"\n"
"These paths are used in addition to current directory on Switch Header/Source."));
m_headerPrefixesEdit->setToolTip(tr("Comma-separated list of header prefixes.\n"
m_headerPrefixesEdit->setToolTip(Tr::tr("Comma-separated list of header prefixes.\n"
"\n"
"These prefixes are used in addition to current file name on Switch Header/Source."));
m_headerPragmaOnceCheckBox->setToolTip(
tr("Uses \"#pragma once\" instead of \"#ifndef\" include guards."));
m_sourceSearchPathsEdit->setToolTip(tr("Comma-separated list of source paths.\n"
Tr::tr("Uses \"#pragma once\" instead of \"#ifndef\" include guards."));
m_sourceSearchPathsEdit->setToolTip(Tr::tr("Comma-separated list of source paths.\n"
"\n"
"Paths can be absolute or relative to the directory of the current open document.\n"
"\n"
"These paths are used in addition to current directory on Switch Header/Source."));
m_sourcePrefixesEdit->setToolTip(tr("Comma-separated list of source prefixes.\n"
m_sourcePrefixesEdit->setToolTip(Tr::tr("Comma-separated list of source prefixes.\n"
"\n"
"These prefixes are used in addition to current file name on Switch Header/Source."));
@@ -297,23 +296,23 @@ CppFileSettingsWidget::CppFileSettingsWidget(CppFileSettings *settings)
Group {
title("Headers"),
Form {
tr("&Suffix:"), m_headerSuffixComboBox, st, br,
tr("S&earch paths:"), m_headerSearchPathsEdit, br,
tr("&Prefixes:"), m_headerPrefixesEdit, br,
tr("Include guards"), m_headerPragmaOnceCheckBox
Tr::tr("&Suffix:"), m_headerSuffixComboBox, st, br,
Tr::tr("S&earch paths:"), m_headerSearchPathsEdit, br,
Tr::tr("&Prefixes:"), m_headerPrefixesEdit, br,
Tr::tr("Include guards"), m_headerPragmaOnceCheckBox
}
},
Group {
title("Sources"),
Form {
tr("S&uffix:"), m_sourceSuffixComboBox, st, br,
tr("Se&arch paths:"), m_sourceSearchPathsEdit, br,
tr("P&refixes:"), m_sourcePrefixesEdit
Tr::tr("S&uffix:"), m_sourceSuffixComboBox, st, br,
Tr::tr("Se&arch paths:"), m_sourceSearchPathsEdit, br,
Tr::tr("P&refixes:"), m_sourcePrefixesEdit
}
},
m_lowerCaseFileNamesCheckBox,
Form {
tr("License &template:"), m_licenseTemplatePathChooser
Tr::tr("License &template:"), m_licenseTemplatePathChooser
},
st
}.attachTo(this);
@@ -334,7 +333,7 @@ CppFileSettingsWidget::CppFileSettingsWidget(CppFileSettings *settings)
}
m_licenseTemplatePathChooser->setExpectedKind(PathChooser::File);
m_licenseTemplatePathChooser->setHistoryCompleter(QLatin1String("Cpp.LicenseTemplate.History"));
m_licenseTemplatePathChooser->addButton(tr("Edit..."), this, [this] { slotEdit(); });
m_licenseTemplatePathChooser->addButton(Tr::tr("Edit..."), this, [this] { slotEdit(); });
setSettings(*m_settings);
}
@@ -404,11 +403,11 @@ void CppFileSettingsWidget::slotEdit()
FilePath path = licenseTemplatePath();
if (path.isEmpty()) {
// Pick a file name and write new template, edit with C++
path = FileUtils::getSaveFilePath(this, tr("Choose Location for New License Template File"));
path = FileUtils::getSaveFilePath(this, Tr::tr("Choose Location for New License Template File"));
if (path.isEmpty())
return;
FileSaver saver(path, QIODevice::Text);
saver.write(tr(licenseTemplateTemplate).arg(Core::Constants::IDE_DISPLAY_NAME).toUtf8());
saver.write(Tr::tr(licenseTemplateTemplate).arg(Core::Constants::IDE_DISPLAY_NAME).toUtf8());
if (!saver.finalize(this))
return;
setLicenseTemplatePath(path);
@@ -422,7 +421,7 @@ void CppFileSettingsWidget::slotEdit()
CppFileSettingsPage::CppFileSettingsPage(CppFileSettings *settings)
{
setId(Constants::CPP_FILE_SETTINGS_ID);
setDisplayName(QCoreApplication::translate("CppEditor", Constants::CPP_FILE_SETTINGS_NAME));
setDisplayName(Tr::tr("File Naming"));
setCategory(Constants::CPP_SETTINGS_CATEGORY);
setWidgetCreator([settings] { return new CppFileSettingsWidget(settings); });
}

View File

@@ -5,6 +5,7 @@
#include "cppcodemodelsettings.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cppmodelmanager.h"
#include "cpptoolsreuse.h"
#include "cppworkingcopy.h"
@@ -55,13 +56,13 @@ QWidget *CppSearchResultFilter::createWidget()
const auto widget = new QWidget;
const auto layout = new QVBoxLayout(widget);
layout->setContentsMargins(0, 0, 0, 0);
const auto readsCheckBox = new QCheckBox(Internal::CppFindReferences::tr("Reads"));
const auto readsCheckBox = new QCheckBox(Tr::tr("Reads"));
readsCheckBox->setChecked(m_showReads);
const auto writesCheckBox = new QCheckBox(Internal::CppFindReferences::tr("Writes"));
const auto writesCheckBox = new QCheckBox(Tr::tr("Writes"));
writesCheckBox->setChecked(m_showWrites);
const auto declsCheckBox = new QCheckBox(Internal::CppFindReferences::tr("Declarations"));
const auto declsCheckBox = new QCheckBox(Tr::tr("Declarations"));
declsCheckBox->setChecked(m_showDecls);
const auto otherCheckBox = new QCheckBox(Internal::CppFindReferences::tr("Other"));
const auto otherCheckBox = new QCheckBox(Tr::tr("Other"));
otherCheckBox->setChecked(m_showOther);
layout->addWidget(readsCheckBox);
layout->addWidget(writesCheckBox);
@@ -376,7 +377,7 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
bool replace)
{
CPlusPlus::Overview overview;
SearchResult *search = SearchResultWindow::instance()->startNewSearch(tr("C++ Usages:"),
SearchResult *search = SearchResultWindow::instance()->startNewSearch(Tr::tr("C++ Usages:"),
QString(),
overview.prettyName(CPlusPlus::LookupContext::fullyQualifiedName(symbol)),
replace ? SearchResultWindow::SearchAndReplace
@@ -435,8 +436,8 @@ void CppFindReferences::findAll_helper(SearchResult *search, CPlusPlus::Symbol *
workingCopy, context, symbol, categorize);
createWatcher(result, search);
FutureProgress *progress = ProgressManager::addTask(result, tr("Searching for Usages"),
CppEditor::Constants::TASK_SEARCH);
FutureProgress *progress = ProgressManager::addTask(result, Tr::tr("Searching for Usages"),
CppEditor::Constants::TASK_SEARCH);
connect(progress, &FutureProgress::clicked, search, &SearchResult::popup);
}
@@ -601,8 +602,8 @@ static void searchFinished(SearchResult *search, QFutureWatcher<CPlusPlus::Usage
auto renameCheckBox = qobject_cast<QCheckBox *>(search->additionalReplaceWidget());
if (renameCheckBox) {
renameCheckBox->setText(CppFindReferences::tr("Re&name %n files", nullptr, filesToRename.size()));
renameCheckBox->setToolTip(CppFindReferences::tr("Files:\n%1").arg(filesToRename.join('\n')));
renameCheckBox->setText(Tr::tr("Re&name %n files", nullptr, filesToRename.size()));
renameCheckBox->setToolTip(Tr::tr("Files:\n%1").arg(filesToRename.join('\n')));
renameCheckBox->setVisible(true);
}
}
@@ -727,7 +728,7 @@ void CppFindReferences::findMacroUses(const CPlusPlus::Macro &macro, const QStri
bool replace)
{
SearchResult *search = SearchResultWindow::instance()->startNewSearch(
tr("C++ Macro Usages:"),
Tr::tr("C++ Macro Usages:"),
QString(),
macro.nameToQString(),
replace ? SearchResultWindow::SearchAndReplace
@@ -769,8 +770,8 @@ void CppFindReferences::findMacroUses(const CPlusPlus::Macro &macro, const QStri
workingCopy, snapshot, macro);
createWatcher(result, search);
FutureProgress *progress = ProgressManager::addTask(result, tr("Searching for Usages"),
CppEditor::Constants::TASK_SEARCH);
FutureProgress *progress = ProgressManager::addTask(result, Tr::tr("Searching for Usages"),
CppEditor::Constants::TASK_SEARCH);
connect(progress, &FutureProgress::clicked, search, &SearchResult::popup);
}

View File

@@ -5,6 +5,7 @@
#include "cppcodestylesettings.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cppeditorwidget.h"
#include "cpplocalsymbols.h"
#include "cppquickfixassistant.h"
@@ -270,7 +271,7 @@ void FunctionDeclDefLink::apply(CppEditorWidget *editor, bool jumpToMatch)
newTargetFile->apply();
} else {
ToolTip::show(editor->toolTipPosition(linkSelection),
tr("Target file was changed, could not apply changes"));
Tr::tr("Target file was changed, could not apply changes"));
}
}
@@ -305,9 +306,9 @@ void FunctionDeclDefLink::showMarker(CppEditorWidget *editor)
QString message;
if (targetDeclaration->asFunctionDefinition())
message = tr("Apply changes to definition");
message = Tr::tr("Apply changes to definition");
else
message = tr("Apply changes to declaration");
message = Tr::tr("Apply changes to declaration");
Core::Command *quickfixCommand = Core::ActionManager::command(TextEditor::Constants::QUICKFIX_THIS);
if (quickfixCommand)

View File

@@ -43,7 +43,6 @@ private:
class FunctionDeclDefLink
{
Q_DECLARE_TR_FUNCTIONS(CppEditor::Internal::FunctionDeclDefLink)
Q_DISABLE_COPY(FunctionDeclDefLink)
FunctionDeclDefLink() = default;
public:

View File

@@ -4,13 +4,14 @@
#include "cppincludehierarchy.h"
#include "baseeditordocumentprocessor.h"
#include "editordocumenthandle.h"
#include "cppeditorwidget.h"
#include "cppeditorconstants.h"
#include "cppeditordocument.h"
#include "cppeditorplugin.h"
#include "cppeditortr.h"
#include "cppeditorwidget.h"
#include "cppelementevaluator.h"
#include "cppmodelmanager.h"
#include "editordocumenthandle.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/find/itemviewfind.h>
@@ -160,9 +161,9 @@ QVariant CppIncludeHierarchyItem::data(int column, int role) const
Q_UNUSED(column)
if (role == Qt::DisplayRole) {
if (isPhony() && childCount() == 0)
return QString(m_fileName + ' ' + CppIncludeHierarchyModel::tr("(none)"));
return QString(m_fileName + ' ' + Tr::tr("(none)"));
if (m_isCyclic)
return QString(m_fileName + ' ' + CppIncludeHierarchyModel::tr("(cyclic)"));
return QString(m_fileName + ' ' + Tr::tr("(cyclic)"));
return m_fileName;
}
@@ -224,9 +225,9 @@ void CppIncludeHierarchyModel::buildHierarchy(const FilePath &document)
{
m_editorFilePath = document;
rootItem()->removeChildren();
rootItem()->createChild(FilePath::fromPathPart(tr("Includes")),
rootItem()->createChild(FilePath::fromPathPart(Tr::tr("Includes")),
CppIncludeHierarchyItem::InIncludes);
rootItem()->createChild(FilePath::fromPathPart(tr("Included by")),
rootItem()->createChild(FilePath::fromPathPart(Tr::tr("Included by")),
CppIncludeHierarchyItem::InIncludedBy);
}
@@ -368,7 +369,7 @@ CppIncludeHierarchyWidget::CppIncludeHierarchyWidget()
m_treeView->setItemDelegate(&m_delegate);
connect(m_treeView, &QAbstractItemView::activated, this, &CppIncludeHierarchyWidget::onItemActivated);
m_includeHierarchyInfoLabel = new QLabel(tr("No include hierarchy available"), this);
m_includeHierarchyInfoLabel = new QLabel(Tr::tr("No include hierarchy available"), this);
m_includeHierarchyInfoLabel->setAlignment(Qt::AlignCenter);
m_includeHierarchyInfoLabel->setAutoFillBackground(true);
m_includeHierarchyInfoLabel->setBackgroundRole(QPalette::Base);
@@ -383,7 +384,7 @@ CppIncludeHierarchyWidget::CppIncludeHierarchyWidget()
m_toggleSync = new QToolButton(this);
m_toggleSync->setIcon(Utils::Icons::LINK_TOOLBAR.icon());
m_toggleSync->setCheckable(true);
m_toggleSync->setToolTip(tr("Synchronize with Editor"));
m_toggleSync->setToolTip(Tr::tr("Synchronize with Editor"));
connect(m_toggleSync, &QToolButton::clicked,
this, &CppIncludeHierarchyWidget::syncFromEditorManager);
@@ -496,7 +497,7 @@ void CppIncludeHierarchyWidget::syncFromEditorManager()
CppIncludeHierarchyFactory::CppIncludeHierarchyFactory()
{
setDisplayName(tr("Include Hierarchy"));
setDisplayName(Tr::tr("Include Hierarchy"));
setPriority(800);
setId(Constants::INCLUDE_HIERARCHY_ID);
}

View File

@@ -4,6 +4,7 @@
#include "cppincludesfilter.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cppmodelmanager.h"
#include <cplusplus/CppDocument.h>
@@ -98,9 +99,9 @@ CppIncludesFilter::CppIncludesFilter()
setId(Constants::INCLUDES_FILTER_ID);
setDisplayName(Constants::INCLUDES_FILTER_DISPLAY_NAME);
setDescription(
tr("Matches all files that are included by all C++ files in all projects. Append "
"\"+<number>\" or \":<number>\" to jump to the given line number. Append another "
"\"+<number>\" or \":<number>\" to jump to the column number as well."));
Tr::tr("Matches all files that are included by all C++ files in all projects. Append "
"\"+<number>\" or \":<number>\" to jump to the given line number. Append another "
"\"+<number>\" or \":<number>\" to jump to the column number as well."));
setDefaultShortcutString("ai");
setDefaultIncludedByDefault(true);
setPriority(ILocatorFilter::Low);

View File

@@ -9,8 +9,6 @@ namespace CppEditor::Internal {
class CppIncludesFilter : public Core::BaseFileFilter
{
Q_OBJECT
public:
CppIncludesFilter();

View File

@@ -6,6 +6,7 @@
#include "builtineditordocumentparser.h"
#include "cppchecksymbols.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cppsourceprocessor.h"
#include "searchsymbols.h"
@@ -328,7 +329,7 @@ QFuture<void> CppIndexingSupport::refreshSourceFiles(const QSet<QString> &source
m_synchronizer.addFuture(result);
if (mode == CppModelManager::ForcedProgressNotification || sourceFiles.count() > 1) {
Core::ProgressManager::addTask(result, QCoreApplication::translate("CppEditor::Internal::BuiltinIndexingSupport", "Parsing C/C++ Files"),
Core::ProgressManager::addTask(result, Tr::tr("Parsing C/C++ Files"),
CppEditor::Constants::TASK_INDEX);
}

View File

@@ -4,6 +4,7 @@
#include "cppinsertvirtualmethods.h"
#include "cppcodestylesettings.h"
#include "cppeditortr.h"
#include "cppquickfixassistant.h"
#include "cpptoolsreuse.h"
#include "functionutils.h"
@@ -509,8 +510,7 @@ public:
: CppQuickFixOperation(interface, 0)
, m_factory(factory)
{
setDescription(QCoreApplication::translate(
"CppEditor::QuickFix", "Insert Virtual Functions of Base Classes"));
setDescription(Tr::tr("Insert Virtual Functions of Base Classes"));
const QList<AST *> &path = interface.path();
const int pathSize = path.size();
@@ -1008,35 +1008,35 @@ void InsertVirtualMethodsDialog::initGui()
if (m_view)
return;
setWindowTitle(tr("Insert Virtual Functions"));
setWindowTitle(Tr::tr("Insert Virtual Functions"));
auto globalVerticalLayout = new QVBoxLayout;
// View
QGroupBox *groupBoxView = new QGroupBox(tr("&Functions to insert:"), this);
QGroupBox *groupBoxView = new QGroupBox(Tr::tr("&Functions to insert:"), this);
auto groupBoxViewLayout = new QVBoxLayout(groupBoxView);
m_filter = new QLineEdit(this);
m_filter->setClearButtonEnabled(true);
m_filter->setPlaceholderText(tr("Filter"));
m_filter->setPlaceholderText(Tr::tr("Filter"));
groupBoxViewLayout->addWidget(m_filter);
m_view = new QTreeView(this);
m_view->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_view->setHeaderHidden(true);
groupBoxViewLayout->addWidget(m_view);
m_hideReimplementedFunctions =
new QCheckBox(tr("&Hide reimplemented functions"), this);
new QCheckBox(Tr::tr("&Hide reimplemented functions"), this);
groupBoxViewLayout->addWidget(m_hideReimplementedFunctions);
// Insertion options
QGroupBox *groupBoxImplementation = new QGroupBox(tr("&Insertion options:"), this);
QGroupBox *groupBoxImplementation = new QGroupBox(Tr::tr("&Insertion options:"), this);
auto groupBoxImplementationLayout = new QVBoxLayout(groupBoxImplementation);
m_insertMode = new QComboBox(this);
m_insertMode->addItem(tr("Insert only declarations"), ModeOnlyDeclarations);
m_insertMode->addItem(tr("Insert definitions inside class"), ModeInsideClass);
m_insertMode->addItem(tr("Insert definitions outside class"), ModeOutsideClass);
m_insertMode->addItem(tr("Insert definitions in implementation file"), ModeImplementationFile);
m_virtualKeyword = new QCheckBox(tr("Add \"&virtual\" to function declaration"), this);
m_insertMode->addItem(Tr::tr("Insert only declarations"), ModeOnlyDeclarations);
m_insertMode->addItem(Tr::tr("Insert definitions inside class"), ModeInsideClass);
m_insertMode->addItem(Tr::tr("Insert definitions outside class"), ModeOutsideClass);
m_insertMode->addItem(Tr::tr("Insert definitions in implementation file"), ModeImplementationFile);
m_virtualKeyword = new QCheckBox(Tr::tr("Add \"&virtual\" to function declaration"), this);
m_overrideReplacementCheckBox = new QCheckBox(
tr("Add \"override\" equivalent to function declaration:"), this);
Tr::tr("Add \"override\" equivalent to function declaration:"), this);
m_overrideReplacementComboBox = new QComboBox(this);
QSizePolicy sizePolicy = m_overrideReplacementComboBox->sizePolicy();
sizePolicy.setHorizontalPolicy(QSizePolicy::Expanding);
@@ -1047,7 +1047,7 @@ void InsertVirtualMethodsDialog::initGui()
auto clearUserAddedReplacements = new QAction(this);
clearUserAddedReplacements->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon());
clearUserAddedReplacements->setText(tr("Clear Added \"override\" Equivalents"));
clearUserAddedReplacements->setText(Tr::tr("Clear Added \"override\" Equivalents"));
connect(clearUserAddedReplacements, &QAction::triggered, [this] {
m_availableOverrideReplacements = defaultOverrideReplacements();
updateOverrideReplacementsComboBox();
@@ -1116,7 +1116,7 @@ void InsertVirtualMethodsDialog::initData()
if (m_hasImplementationFile) {
if (m_insertMode->count() == 3) {
m_insertMode->addItem(tr("Insert definitions in implementation file"),
m_insertMode->addItem(Tr::tr("Insert definitions in implementation file"),
ModeImplementationFile);
}
} else {

View File

@@ -537,7 +537,7 @@ void CppModelManager::findUnusedFunctions(const FilePath &folder)
QTC_ASSERT(functionsFilter, return);
const QPointer<Core::SearchResult> search
= Core::SearchResultWindow::instance()
->startNewSearch(tr("Find Unused Functions"),
->startNewSearch(Tr::tr("Find Unused Functions"),
{},
{},
Core::SearchResultWindow::SearchOnly,
@@ -1253,9 +1253,8 @@ static QSet<QString> filteredFilesRemoved(const QSet<QString> &files, int fileSi
for (const QRegularExpression &rx: std::as_const(regexes)) {
QRegularExpressionMatch match = rx.match(filePath.absoluteFilePath().path());
if (match.hasMatch()) {
const QString msg = QCoreApplication::translate(
"CppIndexer",
"C++ Indexer: Skipping file \"%1\" because its path matches the ignore pattern.")
const QString msg = Tr::tr("C++ Indexer: Skipping file \"%1\" "
"because its path matches the ignore pattern.")
.arg(filePath.displayName());
QMetaObject::invokeMethod(Core::MessageManager::instance(),
[msg]() { Core::MessageManager::writeSilently(msg); });

View File

@@ -3,8 +3,9 @@
#include "cppoutline.h"
#include "cppeditoroutline.h"
#include "cppeditordocument.h"
#include "cppeditoroutline.h"
#include "cppeditortr.h"
#include "cppmodelmanager.h"
#include "cppoutlinemodel.h"
@@ -37,9 +38,9 @@ void CppOutlineTreeView::contextMenuEvent(QContextMenuEvent *event)
QMenu contextMenu;
QAction *action = contextMenu.addAction(tr("Expand All"));
QAction *action = contextMenu.addAction(Tr::tr("Expand All"));
connect(action, &QAction::triggered, this, &QTreeView::expandAll);
action = contextMenu.addAction(tr("Collapse All"));
action = contextMenu.addAction(Tr::tr("Collapse All"));
connect(action, &QAction::triggered, this, &QTreeView::collapseAll);
contextMenu.exec(event->globalPos());

View File

@@ -31,8 +31,8 @@ public:
switch (role) {
case Qt::DisplayRole:
if (parent()->childCount() > 1)
return QString(QT_TRANSLATE_NOOP("CppEditor::OverviewModel", "<Select Symbol>"));
return QString(QT_TRANSLATE_NOOP("CppEditor::OverviewModel", "<No Symbols>"));
return QString(QT_TRANSLATE_NOOP("CppEditor", "<Select Symbol>"));
return QString(QT_TRANSLATE_NOOP("CppEditor", "<No Symbols>"));
default:
return QVariant();
}

View File

@@ -3,6 +3,7 @@
#include "cppparsecontext.h"
#include "cppeditortr.h"
#include "cppeditorwidget.h"
#include <QAction>
@@ -30,12 +31,12 @@ QString ParseContextModel::currentToolTip() const
if (!index.isValid())
return QString();
return tr("<p><b>Active Parse Context</b>:<br/>%1</p>"
"<p>Multiple parse contexts (set of defines, include paths, and so on) "
"are available for this file.</p>"
"<p>Choose a parse context to set it as the preferred one. "
"Clear the preference from the context menu.</p>")
.arg(data(index, Qt::ToolTipRole).toString());
return Tr::tr("<p><b>Active Parse Context</b>:<br/>%1</p>"
"<p>Multiple parse contexts (set of defines, include paths, and so on) "
"are available for this file.</p>"
"<p>Choose a parse context to set it as the preferred one. "
"Clear the preference from the context menu.</p>")
.arg(data(index, Qt::ToolTipRole).toString());
}
void ParseContextModel::setPreferred(int index)
@@ -120,7 +121,7 @@ ParseContextWidget::ParseContextWidget(ParseContextModel &parseContextModel, QWi
setSizePolicy(policy);
// Set up context menu with a clear action
setContextMenuPolicy(Qt::ActionsContextMenu);
m_clearPreferredAction = new QAction(tr("Clear Preferred Parse Context"), this);
m_clearPreferredAction = new QAction(Tr::tr("Clear Preferred Parse Context"), this);
connect(m_clearPreferredAction, &QAction::triggered, this, [this] {
m_parseContextModel.clearPreferred();
});

View File

@@ -4,6 +4,7 @@
#include "cpppreprocessordialog.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cpptoolsreuse.h"
#include <projectexplorer/session.h>
@@ -23,7 +24,7 @@ CppPreProcessorDialog::CppPreProcessorDialog(const FilePath &filePath, QWidget *
, m_filePath(filePath)
{
resize(400, 300);
setWindowTitle(tr("Additional C++ Preprocessor Directives"));
setWindowTitle(Tr::tr("Additional C++ Preprocessor Directives"));
const QString key = Constants::EXTRA_PREPROCESSOR_DIRECTIVES + m_filePath.toString();
const QString directives = ProjectExplorer::SessionManager::value(key).toString();
@@ -38,7 +39,7 @@ CppPreProcessorDialog::CppPreProcessorDialog(const FilePath &filePath, QWidget *
using namespace Layouting;
Column {
tr("Additional C++ Preprocessor Directives for %1:").arg(m_filePath.fileName()),
Tr::tr("Additional C++ Preprocessor Directives for %1:").arg(m_filePath.fileName()),
m_editWidget,
buttonBox,
}.attachTo(this);

View File

@@ -3,6 +3,7 @@
#include "cppprojectinfogenerator.h"
#include "cppeditortr.h"
#include "cppprojectfilecategorizer.h"
#include <projectexplorer/headerpath.h>
@@ -47,12 +48,12 @@ ProjectInfo::ConstPtr ProjectInfoGenerator::generate()
});
};
if (m_cToolchainMissing) {
showWarning(QCoreApplication::translate("CppEditor",
showWarning(Tr::tr(
"The project contains C source files, but the currently active kit "
"has no C compiler. The code model will not be fully functional."));
}
if (m_cxxToolchainMissing) {
showWarning(QCoreApplication::translate("CppEditor",
showWarning(Tr::tr(
"The project contains C++ source files, but the currently active kit "
"has no C++ compiler. The code model will not be fully functional."));
}

View File

@@ -3,6 +3,7 @@
#include "cppprojectupdater.h"
#include "cppeditortr.h"
#include "cppmodelmanager.h"
#include "cppprojectinfogenerator.h"
#include "generatedcodemodelsupport.h"
@@ -102,7 +103,7 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo,
};
m_taskTree.reset(new TaskTree(root));
auto progress = new Core::TaskProgress(m_taskTree.get());
progress->setDisplayName(tr("Preparing C++ Code Model"));
progress->setDisplayName(Tr::tr("Preparing C++ Code Model"));
m_taskTree->start();
}

View File

@@ -6,6 +6,7 @@
#include "baseeditordocumentprocessor.h"
#include "cppcodestylesettings.h"
#include "cppeditordocument.h"
#include "cppeditortr.h"
#include "cppeditorwidget.h"
#include "cppfunctiondecldeflink.h"
#include "cppinsertvirtualmethods.h"
@@ -332,7 +333,7 @@ public:
QString description() const override
{
return QApplication::translate("CppEditor::QuickFix", "Rewrite Using %1").arg(replacement);
return Tr::tr("Rewrite Using %1").arg(replacement);
}
void perform() override
@@ -424,9 +425,9 @@ public:
QString description() const override
{
if (replacement.isEmpty())
return QApplication::translate("CppEditor::QuickFix", "Swap Operands");
return Tr::tr("Swap Operands");
else
return QApplication::translate("CppEditor::QuickFix", "Rewrite Using %1").arg(replacement);
return Tr::tr("Rewrite Using %1").arg(replacement);
}
void perform() override
@@ -567,8 +568,7 @@ void RewriteLogicalAnd::match(const CppQuickFixInterface &interface, QuickFixOpe
file->tokenAt(op->pattern->binary_op_token).is(T_AMPER_AMPER) &&
file->tokenAt(op->left->unary_op_token).is(T_EXCLAIM) &&
file->tokenAt(op->right->unary_op_token).is(T_EXCLAIM)) {
op->setDescription(QApplication::translate("CppEditor::QuickFix",
"Rewrite Condition Using ||"));
op->setDescription(Tr::tr("Rewrite Condition Using ||"));
op->setPriority(index);
result.append(op);
}
@@ -601,8 +601,7 @@ public:
: CppQuickFixOperation(interface, priority)
, declaration(decl)
{
setDescription(QApplication::translate("CppEditor::QuickFix",
"Split Declaration"));
setDescription(Tr::tr("Split Declaration"));
}
void perform() override
@@ -693,7 +692,7 @@ public:
: CppQuickFixOperation(interface, priority)
, _statement(statement)
{
setDescription(QApplication::translate("CppEditor::QuickFix", "Add Curly Braces"));
setDescription(Tr::tr("Add Curly Braces"));
}
void perform() override
@@ -759,8 +758,7 @@ public:
MoveDeclarationOutOfIfOp(const CppQuickFixInterface &interface)
: CppQuickFixOperation(interface)
{
setDescription(QApplication::translate("CppEditor::QuickFix",
"Move Declaration out of Condition"));
setDescription(Tr::tr("Move Declaration out of Condition"));
reset();
}
@@ -834,8 +832,7 @@ public:
MoveDeclarationOutOfWhileOp(const CppQuickFixInterface &interface)
: CppQuickFixOperation(interface)
{
setDescription(QApplication::translate("CppEditor::QuickFix",
"Move Declaration out of Condition"));
setDescription(Tr::tr("Move Declaration out of Condition"));
reset();
}
@@ -920,8 +917,7 @@ public:
, pattern(pattern)
, condition(condition)
{
setDescription(QApplication::translate("CppEditor::QuickFix",
"Split if Statement"));
setDescription(Tr::tr("Split if Statement"));
}
void perform() override
@@ -1085,7 +1081,7 @@ static QByteArray charToStringEscapeSequences(const QByteArray &content)
static QString msgQtStringLiteralDescription(const QString &replacement)
{
return QApplication::translate("CppEditor::QuickFix", "Enclose in %1(...)").arg(replacement);
return Tr::tr("Enclose in %1(...)").arg(replacement);
}
static QString stringLiteralReplacement(unsigned actions)
@@ -1256,8 +1252,7 @@ void WrapStringLiteral::match(const CppQuickFixInterface &interface, QuickFixOpe
const QByteArray contents(file->tokenAt(charLiteral->literal_token).identifier->chars());
if (!charToStringEscapeSequences(contents).isEmpty()) {
actions = DoubleQuoteAction | ConvertEscapeSequencesToStringAction;
description = QApplication::translate("CppEditor::QuickFix",
"Convert to String Literal");
description = Tr::tr("Convert to String Literal");
result << new WrapStringLiteralOp(interface, priority, actions,
description, literal);
}
@@ -1271,13 +1266,12 @@ void WrapStringLiteral::match(const CppQuickFixInterface &interface, QuickFixOpe
if (!stringToCharEscapeSequences(contents).isEmpty()) {
actions = EncloseInQLatin1CharAction | SingleQuoteAction
| ConvertEscapeSequencesToCharAction | objectiveCActions;
QString description = QApplication::translate("CppEditor::QuickFix",
"Convert to Character Literal and Enclose in QLatin1Char(...)");
QString description =
Tr::tr("Convert to Character Literal and Enclose in QLatin1Char(...)");
result << new WrapStringLiteralOp(interface, priority, actions,
description, literal);
actions &= ~EncloseInQLatin1CharAction;
description = QApplication::translate("CppEditor::QuickFix",
"Convert to Character Literal");
description = Tr::tr("Convert to Character Literal");
result << new WrapStringLiteralOp(interface, priority, actions,
description, literal);
}
@@ -1310,7 +1304,7 @@ void TranslateStringLiteral::match(const CppQuickFixInterface &interface,
const Name *trName = control->identifier("tr");
// Check whether we are in a function:
const QString description = QApplication::translate("CppEditor::QuickFix", "Mark as Translatable");
const QString description = Tr::tr("Mark as Translatable");
for (int i = path.size() - 1; i >= 0; --i) {
if (FunctionDefinitionAST *definition = path.at(i)->asFunctionDefinition()) {
Function *function = definition->symbol;
@@ -1365,8 +1359,7 @@ public:
, stringLiteral(stringLiteral)
, qlatin1Call(qlatin1Call)
{
setDescription(QApplication::translate("CppEditor::QuickFix",
"Convert to Objective-C String Literal"));
setDescription(Tr::tr("Convert to Objective-C String Literal"));
}
void perform() override
@@ -1510,7 +1503,7 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi
*/
const QString replacement = QString::asprintf("0x%lX", value);
auto op = new ConvertNumericLiteralOp(interface, start, start + numberLength, replacement);
op->setDescription(QApplication::translate("CppEditor::QuickFix", "Convert to Hexadecimal"));
op->setDescription(Tr::tr("Convert to Hexadecimal"));
op->setPriority(priority);
result << op;
}
@@ -1527,7 +1520,7 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi
*/
const QString replacement = QString::asprintf("0%lo", value);
auto op = new ConvertNumericLiteralOp(interface, start, start + numberLength, replacement);
op->setDescription(QApplication::translate("CppEditor::QuickFix", "Convert to Octal"));
op->setDescription(Tr::tr("Convert to Octal"));
op->setPriority(priority);
result << op;
}
@@ -1544,7 +1537,7 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi
*/
const QString replacement = QString::asprintf("%lu", value);
auto op = new ConvertNumericLiteralOp(interface, start, start + numberLength, replacement);
op->setDescription(QApplication::translate("CppEditor::QuickFix", "Convert to Decimal"));
op->setDescription(Tr::tr("Convert to Decimal"));
op->setPriority(priority);
result << op;
}
@@ -1568,7 +1561,7 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi
replacement.append(QString::fromStdString(b.to_string()).remove(re));
}
auto op = new ConvertNumericLiteralOp(interface, start, start + numberLength, replacement);
op->setDescription(QApplication::translate("CppEditor::QuickFix", "Convert to Binary"));
op->setDescription(Tr::tr("Convert to Binary"));
op->setPriority(priority);
result << op;
}
@@ -1587,7 +1580,7 @@ public:
, binaryAST(binaryAST)
, simpleNameAST(simpleNameAST)
{
setDescription(QApplication::translate("CppEditor::QuickFix", "Add Local Declaration"));
setDescription(Tr::tr("Add Local Declaration"));
}
void perform() override
@@ -1701,7 +1694,7 @@ public:
, m_isAllUpper(name.isUpper())
, m_test(test)
{
setDescription(QApplication::translate("CppEditor::QuickFix", "Convert to Camel Case"));
setDescription(Tr::tr("Convert to Camel Case"));
}
void perform() override
@@ -1783,7 +1776,7 @@ AddIncludeForUndefinedIdentifierOp::AddIncludeForUndefinedIdentifierOp(
: CppQuickFixOperation(interface, priority)
, m_include(include)
{
setDescription(QApplication::translate("CppEditor::QuickFix", "Add #include %1").arg(m_include));
setDescription(Tr::tr("Add #include %1").arg(m_include));
}
void AddIncludeForUndefinedIdentifierOp::perform()
@@ -1801,8 +1794,7 @@ AddForwardDeclForUndefinedIdentifierOp::AddForwardDeclForUndefinedIdentifierOp(
int symbolPos)
: CppQuickFixOperation(interface, priority), m_className(fqClassName), m_symbolPos(symbolPos)
{
setDescription(QApplication::translate("CppEditor::QuickFix",
"Add forward declaration for %1").arg(m_className));
setDescription(Tr::tr("Add forward declaration for %1").arg(m_className));
}
void AddForwardDeclForUndefinedIdentifierOp::perform()
@@ -2056,7 +2048,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
QList<Core::LocatorFilterEntry> matches;
const QString currentDocumentFilePath = interface.semanticInfo().doc->filePath().toString();
const ProjectExplorer::HeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath);
QList<Utils::FilePath> headers;
FilePaths headers;
// Find an include file through the locator
if (matchName(nameAst->name, &matches, &className)) {
@@ -2149,11 +2141,9 @@ public:
{
QString targetString;
if (target == TargetPrevious)
targetString = QApplication::translate("CppEditor::QuickFix",
"Switch with Previous Parameter");
targetString = Tr::tr("Switch with Previous Parameter");
else
targetString = QApplication::translate("CppEditor::QuickFix",
"Switch with Next Parameter");
targetString = Tr::tr("Switch with Next Parameter");
setDescription(targetString);
}
@@ -2228,11 +2218,10 @@ public:
{
QString description;
if (m_change.operationList().size() == 1) {
description = QApplication::translate("CppEditor::QuickFix",
description = Tr::tr(
"Reformat to \"%1\"").arg(m_change.operationList().constFirst().text);
} else { // > 1
description = QApplication::translate("CppEditor::QuickFix",
"Reformat Pointers or References");
description = Tr::tr("Reformat Pointers or References");
}
setDescription(description);
}
@@ -2395,8 +2384,7 @@ public:
, compoundStatement(compoundStatement)
, values(values)
{
setDescription(QApplication::translate("CppEditor::QuickFix",
"Complete Switch Statement"));
setDescription(Tr::tr("Complete Switch Statement"));
}
void perform() override
@@ -2533,8 +2521,7 @@ public:
, m_xsSpec(xsSpec)
, m_decl(decl)
{
setDescription(QCoreApplication::translate("CppEditor::InsertDeclOperation",
"Add %1 Declaration")
setDescription(Tr::tr("Add %1 Declaration")
.arg(InsertionPointLocator::accessSpecToString(xsSpec)));
}
@@ -2696,19 +2683,14 @@ public:
const FilePath targetFile = m_loc.isValid() ? m_loc.filePath() : m_targetFilePath;
const FilePath resolved = targetFile.relativePathFrom(declFile.parentDir());
setPriority(2);
setDescription(QCoreApplication::translate("CppEditor::InsertDefOperation",
"Add Definition in %1")
.arg(resolved.displayName()));
setDescription(Tr::tr("Add Definition in %1").arg(resolved.displayName()));
} else if (freeFunction) {
setDescription(QCoreApplication::translate("CppEditor::InsertDefOperation",
"Add Definition Here"));
setDescription(Tr::tr("Add Definition Here"));
} else if (m_defpos == DefPosInsideClass) {
setDescription(QCoreApplication::translate("CppEditor::InsertDefOperation",
"Add Definition Inside Class"));
setDescription(Tr::tr("Add Definition Inside Class"));
} else if (m_defpos == DefPosOutsideClass) {
setPriority(1);
setDescription(QCoreApplication::translate("CppEditor::InsertDefOperation",
"Add Definition Outside Class"));
setDescription(Tr::tr("Add Definition Outside Class"));
}
}
@@ -2959,8 +2941,7 @@ public:
const QString &type)
: CppQuickFixOperation(interface), m_class(theClass), m_member(member), m_type(type)
{
setDescription(QCoreApplication::translate("CppEditor::Quickfix",
"Add Class Member \"%1\"").arg(m_member));
setDescription(Tr::tr("Add Class Member \"%1\"").arg(m_member));
}
private:
@@ -2970,8 +2951,8 @@ private:
if (type.isEmpty()) {
type = QInputDialog::getText(
Core::ICore::dialogParent(),
QCoreApplication::translate("CppEditor::Quickfix","Provide the type"),
QCoreApplication::translate("CppEditor::Quickfix","Data type:"),
Tr::tr("Provide the type"),
Tr::tr("Data type:"),
QLineEdit::Normal);
}
if (type.isEmpty())
@@ -3101,15 +3082,14 @@ using MemberFunctionImplSettings = QList<MemberFunctionImplSetting>;
class AddImplementationsDialog : public QDialog
{
Q_DECLARE_TR_FUNCTIONS(AddImplementationsDialog)
public:
AddImplementationsDialog(const QList<Symbol *> &candidates, const Utils::FilePath &implFile)
AddImplementationsDialog(const QList<Symbol *> &candidates, const FilePath &implFile)
: QDialog(Core::ICore::dialogParent()), m_candidates(candidates)
{
setWindowTitle(tr("Member Function Implementations"));
setWindowTitle(Tr::tr("Member Function Implementations"));
const auto defaultImplTargetComboBox = new QComboBox;
QStringList implTargetStrings{tr("None"), tr("Inline"), tr("Outside Class")};
QStringList implTargetStrings{Tr::tr("None"), Tr::tr("Inline"), Tr::tr("Outside Class")};
if (!implFile.isEmpty())
implTargetStrings.append(implFile.fileName());
defaultImplTargetComboBox->insertItems(0, implTargetStrings);
@@ -3121,7 +3101,7 @@ public:
}
});
const auto defaultImplTargetLayout = new QHBoxLayout;
defaultImplTargetLayout->addWidget(new QLabel(tr("Default implementation location:")));
defaultImplTargetLayout->addWidget(new QLabel(Tr::tr("Default implementation location:")));
defaultImplTargetLayout->addWidget(defaultImplTargetComboBox);
const auto candidatesLayout = new QGridLayout;
@@ -3149,7 +3129,7 @@ public:
defaultImplTargetComboBox->setCurrentIndex(implTargetStrings.size() - 1);
const auto mainLayout = new QVBoxLayout(this);
mainLayout->addLayout(defaultImplTargetLayout);
mainLayout->addWidget(Utils::Layouting::createHr(this));
mainLayout->addWidget(Layouting::createHr(this));
mainLayout->addLayout(candidatesLayout);
mainLayout->addWidget(buttonBox);
}
@@ -3182,7 +3162,7 @@ public:
InsertDefsOperation(const CppQuickFixInterface &interface)
: CppQuickFixOperation(interface)
{
setDescription(CppQuickFixFactory::tr("Create Implementations for Member Functions"));
setDescription(Tr::tr("Create Implementations for Member Functions"));
m_classAST = astForClassOperations(interface);
if (!m_classAST)
@@ -3742,38 +3722,37 @@ public:
// of the enum 'GenerateFlag'
int p = 0;
if (possibleFlags & HaveExistingQProperty) {
const auto desc = CppQuickFixFactory::tr("Generate Missing Q_PROPERTY Members");
const QString desc = Tr::tr("Generate Missing Q_PROPERTY Members");
results << new GenerateGetterSetterOp(interface, data, possibleFlags, ++p, desc);
} else {
if (possibleFlags & GenerateSetter) {
const auto desc = CppQuickFixFactory::tr("Generate Setter");
const QString desc = Tr::tr("Generate Setter");
results << new GenerateGetterSetterOp(interface, data, GenerateSetter, ++p, desc);
}
if (possibleFlags & GenerateGetter) {
const auto desc = CppQuickFixFactory::tr("Generate Getter");
const QString desc = Tr::tr("Generate Getter");
results << new GenerateGetterSetterOp(interface, data, GenerateGetter, ++p, desc);
}
if (possibleFlags & GenerateGetter && possibleFlags & GenerateSetter) {
const auto desc = CppQuickFixFactory::tr("Generate Getter and Setter");
const auto flags = GenerateGetter | GenerateSetter;
const QString desc = Tr::tr("Generate Getter and Setter");
const int flags = GenerateGetter | GenerateSetter;
results << new GenerateGetterSetterOp(interface, data, flags, ++p, desc);
}
if (possibleFlags & GenerateConstantProperty) {
const auto desc = CppQuickFixFactory::tr(
"Generate Constant Q_PROPERTY and Missing Members");
const auto flags = possibleFlags & ~(GenerateSetter | GenerateSignal | GenerateReset);
const QString desc = Tr::tr("Generate Constant Q_PROPERTY and Missing Members");
const int flags = possibleFlags & ~(GenerateSetter | GenerateSignal | GenerateReset);
results << new GenerateGetterSetterOp(interface, data, flags, ++p, desc);
}
if (possibleFlags & GenerateProperty) {
if (possibleFlags & GenerateReset) {
const auto desc = CppQuickFixFactory::tr(
const QString desc = Tr::tr(
"Generate Q_PROPERTY and Missing Members with Reset Function");
const auto flags = possibleFlags & ~GenerateConstantProperty;
const int flags = possibleFlags & ~GenerateConstantProperty;
results << new GenerateGetterSetterOp(interface, data, flags, ++p, desc);
}
const auto desc = CppQuickFixFactory::tr("Generate Q_PROPERTY and Missing Members");
const auto flags = possibleFlags & ~GenerateConstantProperty & ~GenerateReset;
const QString desc = Tr::tr("Generate Q_PROPERTY and Missing Members");
const int flags = possibleFlags & ~GenerateConstantProperty & ~GenerateReset;
results << new GenerateGetterSetterOp(interface, data, flags, ++p, desc);
}
}
@@ -4402,7 +4381,7 @@ public:
};
using GetterSetterCandidates = std::vector<MemberInfo>;
class CandidateTreeItem : public Utils::TreeItem
class CandidateTreeItem : public TreeItem
{
public:
enum Column {
@@ -4499,8 +4478,6 @@ private:
class GenerateGettersSettersDialog : public QDialog
{
Q_DECLARE_TR_FUNCTIONS(GenerateGettersSettersDialog)
static constexpr CandidateTreeItem::Column CheckBoxColumn[4]
= {CandidateTreeItem::Column::GetterColumn,
CandidateTreeItem::Column::SetterColumn,
@@ -4513,20 +4490,20 @@ public:
, m_candidates(candidates)
{
using Flags = GenerateGetterSetterOp::GenerateFlag;
setWindowTitle(tr("Getters and Setters"));
const auto model = new Utils::TreeModel<Utils::TreeItem, CandidateTreeItem>(this);
setWindowTitle(Tr::tr("Getters and Setters"));
const auto model = new TreeModel<TreeItem, CandidateTreeItem>(this);
model->setHeader(QStringList({
tr("Member"),
tr("Getter"),
tr("Setter"),
tr("Signal"),
tr("Reset"),
tr("QProperty"),
tr("Constant QProperty"),
Tr::tr("Member"),
Tr::tr("Getter"),
Tr::tr("Setter"),
Tr::tr("Signal"),
Tr::tr("Reset"),
Tr::tr("QProperty"),
Tr::tr("Constant QProperty"),
}));
for (MemberInfo &candidate : m_candidates)
model->rootItem()->appendChild(new CandidateTreeItem(&candidate));
const auto view = new Utils::BaseTreeView(this);
const auto view = new BaseTreeView(this);
view->setModel(model);
int optimalWidth = 0;
for (int i = 0; i < model->columnCount(QModelIndex{}); ++i) {
@@ -4566,13 +4543,13 @@ public:
})) {
const Column column = CheckBoxColumn[i];
if (column == Column::GetterColumn)
checkBoxes[i] = new QCheckBox(tr("Create getters for all members"));
checkBoxes[i] = new QCheckBox(Tr::tr("Create getters for all members"));
else if (column == Column::SetterColumn)
checkBoxes[i] = new QCheckBox(tr("Create setters for all members"));
checkBoxes[i] = new QCheckBox(Tr::tr("Create setters for all members"));
else if (column == Column::SignalColumn)
checkBoxes[i] = new QCheckBox(tr("Create signals for all members"));
checkBoxes[i] = new QCheckBox(Tr::tr("Create signals for all members"));
else if (column == Column::QPropertyColumn)
checkBoxes[i] = new QCheckBox(tr("Create Q_PROPERTY for all members"));
checkBoxes[i] = new QCheckBox(Tr::tr("Create Q_PROPERTY for all members"));
createConnections(checkBoxes[i], column);
}
@@ -4605,8 +4582,8 @@ public:
});
const auto mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(new QLabel(tr("Select the getters and setters "
"to be created.")));
mainLayout->addWidget(new QLabel(Tr::tr("Select the getters and setters "
"to be created.")));
for (auto checkBox : checkBoxes) {
if (checkBox)
mainLayout->addWidget(checkBox);
@@ -4631,7 +4608,7 @@ public:
GenerateGettersSettersOperation(const CppQuickFixInterface &interface)
: CppQuickFixOperation(interface)
{
setDescription(CppQuickFixFactory::tr("Create Getter and Setter Member Functions"));
setDescription(Tr::tr("Create Getter and Setter Member Functions"));
m_classAST = astForClassOperations(interface);
if (!m_classAST)
@@ -4786,7 +4763,7 @@ public:
, m_relevantDecls(relevantDecls)
, m_functionNameGetter(functionNameGetter)
{
setDescription(QCoreApplication::translate("QuickFix::ExtractFunction", "Extract Function"));
setDescription(Tr::tr("Extract Function"));
}
void perform() override
@@ -4952,16 +4929,14 @@ public:
ExtractFunctionOptions getOptions() const
{
QDialog dlg(Core::ICore::dialogParent());
dlg.setWindowTitle(QCoreApplication::translate("QuickFix::ExtractFunction",
"Extract Function Refactoring"));
dlg.setWindowTitle(Tr::tr("Extract Function Refactoring"));
auto layout = new QFormLayout(&dlg);
auto funcNameEdit = new Utils::FancyLineEdit;
funcNameEdit->setValidationFunction([](Utils::FancyLineEdit *edit, QString *) {
auto funcNameEdit = new FancyLineEdit;
funcNameEdit->setValidationFunction([](FancyLineEdit *edit, QString *) {
return ExtractFunctionOptions::isValidFunctionName(edit->text());
});
layout->addRow(QCoreApplication::translate("QuickFix::ExtractFunction",
"Function name"), funcNameEdit);
layout->addRow(Tr::tr("Function name"), funcNameEdit);
auto accessCombo = new QComboBox;
accessCombo->addItem(
@@ -4982,8 +4957,7 @@ public:
accessCombo->addItem(
InsertionPointLocator::accessSpecToString(InsertionPointLocator::PrivateSlot),
InsertionPointLocator::PrivateSlot);
layout->addRow(QCoreApplication::translate("QuickFix::ExtractFunction",
"Access"), accessCombo);
layout->addRow(Tr::tr("Access"), accessCombo);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QObject::connect(buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept);
@@ -5424,8 +5398,7 @@ public:
m_literal(literal),
m_functionDefinition(function)
{
setDescription(QApplication::translate("CppEditor::QuickFix",
"Extract Constant as Function Parameter"));
setDescription(Tr::tr("Extract Constant as Function Parameter"));
}
struct FoundDeclaration
@@ -5691,8 +5664,8 @@ public:
{
setDescription(
mode == FromPointer
? CppQuickFixFactory::tr("Convert to Stack Variable")
: CppQuickFixFactory::tr("Convert to Pointer"));
? Tr::tr("Convert to Stack Variable")
: Tr::tr("Convert to Pointer"));
}
void perform() override
@@ -6220,7 +6193,7 @@ void ApplyDeclDefLinkChanges::match(const CppQuickFixInterface &interface,
return;
auto op = new ApplyDeclDefLinkOperation(interface, link);
op->setDescription(FunctionDeclDefLink::tr("Apply Function Signature Changes"));
op->setDescription(Tr::tr("Apply Function Signature Changes"));
result << op;
}
@@ -6367,13 +6340,10 @@ public:
, m_headerFilePath(funcDef->symbol->filePath())
{
if (m_type == MoveFuncDefRefactoringHelper::MoveOutside) {
setDescription(QCoreApplication::translate("CppEditor::QuickFix",
"Move Definition Outside Class"));
setDescription(Tr::tr("Move Definition Outside Class"));
} else {
const FilePath resolved = m_cppFilePath.relativePathFrom(m_headerFilePath.parentDir());
setDescription(QCoreApplication::translate("CppEditor::QuickFix",
"Move Definition to %1")
.arg(resolved.displayName()));
setDescription(Tr::tr("Move Definition to %1").arg(resolved.displayName()));
}
}
@@ -6463,12 +6433,10 @@ public:
, m_headerFilePath(classDef->symbol->filePath())
{
if (m_type == MoveFuncDefRefactoringHelper::MoveOutside) {
setDescription(QCoreApplication::translate("CppEditor::QuickFix", "Move All Function "
"Definitions Outside Class"));
setDescription(Tr::tr("Definitions Outside Class"));
} else {
const FilePath resolved = m_cppFilePath.relativePathFrom(m_headerFilePath.parentDir());
setDescription(QCoreApplication::translate("CppEditor::QuickFix",
"Move All Function Definitions to %1")
setDescription(Tr::tr("Move All Function Definitions to %1")
.arg(resolved.displayName()));
}
}
@@ -6543,13 +6511,10 @@ public:
, m_toRange(toRange)
{
if (m_toFilePath == m_fromFilePath) {
setDescription(QCoreApplication::translate("CppEditor::QuickFix",
"Move Definition to Class"));
setDescription(Tr::tr("Move Definition to Class"));
} else {
const FilePath resolved = m_toFilePath.relativePathFrom(m_fromFilePath.parentDir());
setDescription(QCoreApplication::translate("CppEditor::QuickFix",
"Move Definition to %1")
.arg(resolved.displayName()));
setDescription(Tr::tr("Move Definition to %1").arg(resolved.displayName()));
}
}
@@ -6725,7 +6690,7 @@ public:
, m_originalName(m_oo.prettyName(m_name))
, m_file(CppRefactoringChanges(snapshot()).file(filePath()))
{
setDescription(QApplication::translate("CppEditor::QuickFix", "Assign to Local Variable"));
setDescription(Tr::tr("Assign to Local Variable"));
}
private:
@@ -6944,7 +6909,7 @@ public:
, m_expression(expression)
, m_type(type)
{
setDescription(QApplication::translate("CppEditor::QuickFix", "Optimize for-Loop"));
setDescription(Tr::tr("Optimize for-Loop"));
}
void perform() override
@@ -7123,11 +7088,9 @@ public:
, m_escape(escape)
{
if (m_escape) {
setDescription(QApplication::translate("CppEditor::QuickFix",
"Escape String Literal as UTF-8"));
setDescription(Tr::tr("Escape String Literal as UTF-8"));
} else {
setDescription(QApplication::translate("CppEditor::QuickFix",
"Unescape String Literal as UTF-8"));
setDescription(Tr::tr("Unescape String Literal as UTF-8"));
}
}
@@ -7306,8 +7269,7 @@ public:
ConvertQt4ConnectOperation(const CppQuickFixInterface &interface, const ChangeSet &changes)
: CppQuickFixOperation(interface, 1), m_changes(changes)
{
setDescription(QApplication::translate("CppEditor::QuickFix",
"Convert connect() to Qt 5 Style"));
setDescription(Tr::tr("Convert connect() to Qt 5 Style"));
}
private:
@@ -7992,15 +7954,13 @@ public:
{
const QString name = Overview{}.prettyName(usingDirective->name->name);
if (m_removeAllAtGlobalScope) {
setDescription(QApplication::translate(
"CppEditor::QuickFix",
setDescription(Tr::tr(
"Remove All Occurrences of \"using namespace %1\" in Global Scope "
"and Adjust Type Names Accordingly")
.arg(name));
} else {
setDescription(QApplication::translate("CppEditor::QuickFix",
"Remove \"using namespace %1\" and "
"Adjust Type Names Accordingly")
setDescription(Tr::tr("Remove \"using namespace %1\" and "
"Adjust Type Names Accordingly")
.arg(name));
}
}
@@ -8354,13 +8314,13 @@ public:
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) {
case ShouldInitColumn:
return tr("Initialize in Constructor");
return Tr::tr("Initialize in Constructor");
case MemberNameColumn:
return tr("Member Name");
return Tr::tr("Member Name");
case ParameterNameColumn:
return tr("Parameter Name");
return Tr::tr("Parameter Name");
case DefaultValueColumn:
return tr("Default Value");
return Tr::tr("Default Value");
}
}
return {};
@@ -8628,7 +8588,7 @@ public:
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) {
case 0:
return CppQuickFixFactory::tr("Base Class Constructors");
return Tr::tr("Base Class Constructors");
}
}
return {};
@@ -8651,12 +8611,11 @@ public:
class GenerateConstructorDialog : public QDialog
{
Q_DECLARE_TR_FUNCTIONS(GenerateConstructorDialog)
public:
GenerateConstructorDialog(ConstructorParams *constructorParamsModel,
ParentClassConstructors &constructors)
{
setWindowTitle(tr("Constructor"));
setWindowTitle(Tr::tr("Constructor"));
const auto treeModel = new ParentClassesModel(this, constructors);
const auto treeView = new QTreeView(this);
@@ -8688,7 +8647,7 @@ public:
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
const auto errorLabel = new QLabel(
tr("Parameters without default value must come before parameters with default value."));
Tr::tr("Parameters without default value must come before parameters with default value."));
errorLabel->setStyleSheet("color: #ff0000");
errorLabel->setVisible(false);
QSizePolicy labelSizePolicy = errorLabel->sizePolicy();
@@ -8702,7 +8661,7 @@ public:
});
// setup select all/none checkbox
QCheckBox *const checkBox = new QCheckBox(tr("Initialize all members"));
QCheckBox *const checkBox = new QCheckBox(Tr::tr("Initialize all members"));
checkBox->setChecked(true);
connect(checkBox, &QCheckBox::stateChanged, [model = constructorParamsModel](int state) {
if (state != Qt::PartiallyChecked) {
@@ -8739,14 +8698,14 @@ public:
for (auto a : {A::Public, A::Protected, A::Private})
accessCombo->addItem(InsertionPointLocator::accessSpecToString(a), a);
const auto row = new QHBoxLayout();
row->addWidget(new QLabel(tr("Access") + ":"));
row->addWidget(new QLabel(Tr::tr("Access") + ":"));
row->addWidget(accessCombo);
row->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
const auto mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(
new QLabel(tr("Select the members to be initialized in the constructor.\n"
"Use drag and drop to change the order of the parameters.")));
new QLabel(Tr::tr("Select the members to be initialized in the constructor.\n"
"Use drag and drop to change the order of the parameters.")));
mainLayout->addLayout(row);
mainLayout->addWidget(checkBox);
mainLayout->addWidget(view);
@@ -8771,7 +8730,7 @@ public:
GenerateConstructorOperation(const CppQuickFixInterface &interface)
: CppQuickFixOperation(interface)
{
setDescription(CppQuickFixFactory::tr("Generate Constructor"));
setDescription(Tr::tr("Generate Constructor"));
m_classAST = astForClassOperations(interface);
if (!m_classAST)

View File

@@ -2,8 +2,12 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppquickfixprojectsettings.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include <coreplugin/icore.h>
#include <QMessageBox>
#include <QPushButton>
#include <QSettings>
@@ -11,10 +15,11 @@
namespace CppEditor {
namespace Internal {
using namespace Constants;
static const char SETTINGS_FILE_NAME[] = ".cppQuickFix";
static const char USE_GLOBAL_SETTINGS[] = "UseGlobalSettings";
const char SETTINGS_FILE_NAME[] = ".cppQuickFix";
const char USE_GLOBAL_SETTINGS[] = "UseGlobalSettings";
CppQuickFixProjectsSettings::CppQuickFixProjectsSettings(ProjectExplorer::Project *project)
{
@@ -103,15 +108,15 @@ bool CppQuickFixProjectsSettings::useCustomSettings()
m_settingsFile = defaultLocation;
} else if (m_settingsFile != defaultLocation) {
QMessageBox msgBox(Core::ICore::dialogParent());
msgBox.setText(tr("Quick Fix settings are saved in a file. Existing settings file "
"\"%1\" found. Should this file be used or a "
"new one be created?")
msgBox.setText(Tr::tr("Quick Fix settings are saved in a file. Existing settings file "
"\"%1\" found. Should this file be used or a "
"new one be created?")
.arg(m_settingsFile.toString()));
QPushButton *cancel = msgBox.addButton(QMessageBox::Cancel);
cancel->setToolTip(tr("Switch Back to Global Settings"));
QPushButton *useExisting = msgBox.addButton(tr("Use Existing"), QMessageBox::AcceptRole);
cancel->setToolTip(Tr::tr("Switch Back to Global Settings"));
QPushButton *useExisting = msgBox.addButton(Tr::tr("Use Existing"), QMessageBox::AcceptRole);
useExisting->setToolTip(m_settingsFile.toString());
QPushButton *createNew = msgBox.addButton(tr("Create New"), QMessageBox::ActionRole);
QPushButton *createNew = msgBox.addButton(Tr::tr("Create New"), QMessageBox::ActionRole);
createNew->setToolTip(defaultLocation.toString());
msgBox.exec();
if (msgBox.clickedButton() == createNew) {

View File

@@ -4,6 +4,7 @@
#include "cppquickfixprojectsettingswidget.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cppquickfixsettingswidget.h"
#include <QFile>
@@ -55,9 +56,9 @@ void CppQuickFixProjectSettingsWidget::currentItemChanged(bool useGlobalSettings
{
if (useGlobalSettings) {
const auto &path = m_projectSettings->filePathOfSettingsFile();
m_pushButton->setToolTip(tr("Custom settings are saved in a file. If you use the "
"global settings, you can delete that file."));
m_pushButton->setText(tr("Delete Custom Settings File"));
m_pushButton->setToolTip(Tr::tr("Custom settings are saved in a file. If you use the "
"global settings, you can delete that file."));
m_pushButton->setText(Tr::tr("Delete Custom Settings File"));
m_pushButton->setVisible(!path.isEmpty() && path.exists());
m_projectSettings->useGlobalSettings();
} else /*Custom*/ {
@@ -65,8 +66,8 @@ void CppQuickFixProjectSettingsWidget::currentItemChanged(bool useGlobalSettings
setUseGlobalSettings(!m_projectSettings->useCustomSettings());
return;
}
m_pushButton->setToolTip(tr("Resets all settings to the global settings."));
m_pushButton->setText(tr("Reset to Global"));
m_pushButton->setToolTip(Tr::tr("Resets all settings to the global settings."));
m_pushButton->setText(Tr::tr("Reset to Global"));
m_pushButton->setVisible(true);
// otherwise you change the comboBox and exit and have no custom settings:
m_projectSettings->saveOwnSettings();

View File

@@ -12,6 +12,7 @@
#include <QRegularExpression>
namespace CppEditor {
CppQuickFixSettings::CppQuickFixSettings(bool loadGlobalSettings)
{
setDefaultSettings();

View File

@@ -4,18 +4,19 @@
#include "cppquickfixsettingspage.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cppquickfixsettings.h"
#include "cppquickfixsettingswidget.h"
#include <QCoreApplication>
#include <QtDebug>
using namespace CppEditor::Internal;
namespace CppEditor::Internal {
CppQuickFixSettingsPage::CppQuickFixSettingsPage()
{
setId(Constants::QUICK_FIX_SETTINGS_ID);
setDisplayName(QCoreApplication::translate("CppEditor", Constants::QUICK_FIX_SETTINGS_DISPLAY_NAME));
setDisplayName(Tr::tr("CppEditor", Constants::QUICK_FIX_SETTINGS_DISPLAY_NAME));
setCategory(Constants::CPP_SETTINGS_CATEGORY);
}
@@ -35,7 +36,9 @@ void CppQuickFixSettingsPage::apply()
s->saveAsGlobalSettings();
}
void CppEditor::Internal::CppQuickFixSettingsPage::finish()
void CppQuickFixSettingsPage::finish()
{
delete m_widget;
}
} // CppEditor::Internal

View File

@@ -2,6 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppquickfixsettingswidget.h"
#include "cppeditortr.h"
#include "cppquickfixsettings.h"
#include <utils/layoutbuilder.h>
@@ -48,10 +50,10 @@ LineCountSpinBox::LineCountSpinBox(QWidget *parent)
: QWidget(parent)
{
m_checkBox = new QCheckBox;
m_opLabel = new QLabel(QCoreApplication::translate("CppEditor::Internal::CppQuickFixSettingsWidget", "\342\211\245"));
m_opLabel = new QLabel(Tr::tr("\342\211\245"));
m_spinBox = new QSpinBox;
m_spinBox->setMinimum(1);
m_unitLabel = new QLabel(QCoreApplication::translate("CppEditor::Internal::CppQuickFixSettingsWidget", "lines"));
m_unitLabel = new QLabel(Tr::tr("lines"));
using namespace Layouting;
Row { m_checkBox, m_opLabel, m_spinBox, m_unitLabel, }.attachTo(this, WithoutMargins);
@@ -103,8 +105,8 @@ CppQuickFixSettingsWidget::CppQuickFixSettingsWidget(QWidget *parent)
return label;
};
const QString placeHolderTect = tr("See tool tip for more information");
const QString toolTip = tr(
const QString placeHolderTect = Tr::tr("See tool tip for more information");
const QString toolTip = Tr::tr(
R"==(Use <name> for the variable
Use <camel> for camel case
Use <snake> for snake case
@@ -115,7 +117,7 @@ e.g. name = "m_test_foo_":
"set<Camel> => "setTestFoo")==");
m_lineEdit_getterAttribute = new QLineEdit;
m_lineEdit_getterAttribute->setPlaceholderText(tr("For example, [[nodiscard]]"));
m_lineEdit_getterAttribute->setPlaceholderText(Tr::tr("For example, [[nodiscard]]"));
m_lineEdit_getterName = new QLineEdit;
m_lineEdit_getterName->setPlaceholderText(placeHolderTect);
m_lineEdit_getterName->setToolTip(toolTip);
@@ -123,34 +125,34 @@ e.g. name = "m_test_foo_":
m_lineEdit_setterName->setPlaceholderText(placeHolderTect);
m_lineEdit_setterName->setToolTip(toolTip);
m_lineEdit_setterParameter = new QLineEdit;
m_lineEdit_setterParameter->setPlaceholderText(tr("For example, new<Name>"));
m_lineEdit_setterParameter->setPlaceholderText(Tr::tr("For example, new<Name>"));
m_lineEdit_setterParameter->setToolTip(toolTip);
m_checkBox_setterSlots = new QCheckBox(tr("Setters should be slots"));
m_checkBox_setterSlots = new QCheckBox(Tr::tr("Setters should be slots"));
m_lineEdit_resetName = new QLineEdit;
m_lineEdit_resetName->setPlaceholderText(tr("Normally reset<Name>"));
m_lineEdit_resetName->setPlaceholderText(Tr::tr("Normally reset<Name>"));
m_lineEdit_resetName->setToolTip(toolTip);
m_lineEdit_signalName = new QLineEdit;
m_lineEdit_signalName->setPlaceholderText(tr("Normally <name>Changed"));
m_lineEdit_signalName->setPlaceholderText(Tr::tr("Normally <name>Changed"));
m_lineEdit_signalName->setToolTip(toolTip);
m_checkBox_signalWithNewValue = new QCheckBox(
tr("Generate signals with the new value as parameter"));
Tr::tr("Generate signals with the new value as parameter"));
m_lineEdit_memberVariableName = new QLineEdit;
m_lineEdit_memberVariableName->setPlaceholderText(tr("For example, m_<name>"));
m_lineEdit_memberVariableName->setPlaceholderText(Tr::tr("For example, m_<name>"));
m_lineEdit_memberVariableName->setToolTip(toolTip);
m_radioButton_generateMissingNamespace = new QRadioButton(tr("Generate missing namespaces"));
m_radioButton_addUsingnamespace = new QRadioButton(tr("Add \"using namespace ...\""));
m_radioButton_generateMissingNamespace = new QRadioButton(Tr::tr("Generate missing namespaces"));
m_radioButton_addUsingnamespace = new QRadioButton(Tr::tr("Add \"using namespace ...\""));
m_radioButton_rewriteTypes = new QRadioButton(
tr("Rewrite types to match the existing namespaces"));
Tr::tr("Rewrite types to match the existing namespaces"));
m_useAutoCheckBox = new QCheckBox(this);
m_useAutoCheckBox->setToolTip(tr("<html><head/><body><p>Uncheck this to make Qt Creator try to "
"derive the type of expression in the &quot;Assign to Local "
"Variable&quot; quickfix.</p><p>Note that this might fail for "
"more complex types.</p></body></html>"));
m_useAutoCheckBox->setText(tr("Use type \"auto\" when creating new variables"));
m_useAutoCheckBox->setToolTip(Tr::tr("<html><head/><body><p>Uncheck this to make Qt Creator try to "
"derive the type of expression in the &quot;Assign to Local "
"Variable&quot; quickfix.</p><p>Note that this might fail for "
"more complex types.</p></body></html>"));
m_useAutoCheckBox->setText(Tr::tr("Use type \"auto\" when creating new variables"));
m_groupBox_customTemplate = new QGroupBox(tr("Template"));
m_groupBox_customTemplate = new QGroupBox(Tr::tr("Template"));
m_groupBox_customTemplate->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
m_groupBox_customTemplate->setEnabled(false);
m_listWidget_customTemplates = new QListWidget;
@@ -158,34 +160,34 @@ e.g. name = "m_test_foo_":
m_listWidget_customTemplates->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
m_lineEdit_customTemplateTypes = new QLineEdit;
m_lineEdit_customTemplateTypes->setToolTip(tr("Separate the types by comma."));
m_lineEdit_customTemplateTypes->setToolTip(Tr::tr("Separate the types by comma."));
m_lineEdit_customTemplateComparison = new QLineEdit;
m_lineEdit_customTemplateAssignment = new QLineEdit;
m_lineEdit_customTemplateReturnExpression = new QLineEdit;
m_lineEdit_customTemplateReturnType = new QLineEdit;
auto customTemplateLabel = new QLabel(tr("Use <new> and <cur> to access the parameter and "
"current value. Use <type> to access the type and <T> "
"for the template parameter."));
auto customTemplateLabel = new QLabel(Tr::tr("Use <new> and <cur> to access the parameter and "
"current value. Use <type> to access the type and <T> "
"for the template parameter."));
customTemplateLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
customTemplateLabel->setWordWrap(true);
auto pushButton_addCustomTemplate = new QPushButton;
pushButton_addCustomTemplate->setText(tr("Add"));
m_pushButton_removeCustomTemplate = new QPushButton(tr("Remove"));
pushButton_addCustomTemplate->setText(Tr::tr("Add"));
m_pushButton_removeCustomTemplate = new QPushButton(Tr::tr("Remove"));
m_pushButton_removeCustomTemplate->setEnabled(false);
m_valueTypes = new QListWidget(this);
m_valueTypes->setToolTip(tr("Normally arguments get passed by const reference. If the Type is "
"one of the following ones, the argument gets passed by value. "
"Namespaces and template arguments are removed. The real Type must "
"contain the given Type. For example, \"int\" matches \"int32_t\" "
"but not \"vector<int>\". \"vector\" matches "
"\"std::pmr::vector<int>\" but not "
"\"std::optional<vector<int>>\""));
auto pushButton_addValueType = new QPushButton(tr("Add"));
auto pushButton_removeValueType = new QPushButton(tr("Remove"));
m_valueTypes->setToolTip(Tr::tr("Normally arguments get passed by const reference. If the Type is "
"one of the following ones, the argument gets passed by value. "
"Namespaces and template arguments are removed. The real Type must "
"contain the given Type. For example, \"int\" matches \"int32_t\" "
"but not \"vector<int>\". \"vector\" matches "
"\"std::pmr::vector<int>\" but not "
"\"std::optional<vector<int>>\""));
auto pushButton_addValueType = new QPushButton(Tr::tr("Add"));
auto pushButton_removeValueType = new QPushButton(Tr::tr("Remove"));
m_returnByConstRefCheckBox = new QCheckBox(tr("Return non-value types by const reference"));
m_returnByConstRefCheckBox = new QCheckBox(Tr::tr("Return non-value types by const reference"));
m_returnByConstRefCheckBox->setChecked(false);
connect(m_listWidget_customTemplates, &QListWidget::currentItemChanged,
@@ -217,45 +219,45 @@ e.g. name = "m_test_foo_":
using namespace Layouting;
Grid {
empty, ulLabel(tr("Generate Setters")), ulLabel(tr("Generate Getters")), br,
tr("Inside class:"), tr("Default"), tr("Default"), br,
tr("Outside class:"), m_lines_setterOutsideClass, m_lines_getterOutsideClass, br,
tr("In .cpp file:"), m_lines_setterInCppFile, m_lines_getterInCppFile, br,
empty, ulLabel(Tr::tr("Generate Setters")), ulLabel(Tr::tr("Generate Getters")), br,
Tr::tr("Inside class:"), Tr::tr("Default"), Tr::tr("Default"), br,
Tr::tr("Outside class:"), m_lines_setterOutsideClass, m_lines_getterOutsideClass, br,
Tr::tr("In .cpp file:"), m_lines_setterInCppFile, m_lines_getterInCppFile, br,
}.attachTo(functionLocationsGrid, WithoutMargins);
if (QGridLayout *gl = qobject_cast<QGridLayout*>(functionLocationsGrid->layout()))
gl->setHorizontalSpacing(48);
Form {
tr("Types:"), m_lineEdit_customTemplateTypes, br,
tr("Comparison:"), m_lineEdit_customTemplateComparison, br,
tr("Assignment:"), m_lineEdit_customTemplateAssignment, br,
tr("Return expression:"), m_lineEdit_customTemplateReturnExpression, br,
tr("Return type:"), m_lineEdit_customTemplateReturnType, br,
Tr::tr("Types:"), m_lineEdit_customTemplateTypes, br,
Tr::tr("Comparison:"), m_lineEdit_customTemplateComparison, br,
Tr::tr("Assignment:"), m_lineEdit_customTemplateAssignment, br,
Tr::tr("Return expression:"), m_lineEdit_customTemplateReturnExpression, br,
Tr::tr("Return type:"), m_lineEdit_customTemplateReturnType, br,
customTemplateLabel, br,
}.attachTo(m_groupBox_customTemplate);
Column {
Group {
title(tr("Generated Function Locations")),
title(Tr::tr("Generated Function Locations")),
Row { functionLocationsGrid, st, },
},
Group {
title(tr("Getter Setter Generation Properties")),
title(Tr::tr("Getter Setter Generation Properties")),
Form {
tr("Getter attributes:"), m_lineEdit_getterAttribute, br,
tr("Getter name:"), m_lineEdit_getterName, br,
tr("Setter name:"), m_lineEdit_setterName, br,
tr("Setter parameter name:"), m_lineEdit_setterParameter, br,
Tr::tr("Getter attributes:"), m_lineEdit_getterAttribute, br,
Tr::tr("Getter name:"), m_lineEdit_getterName, br,
Tr::tr("Setter name:"), m_lineEdit_setterName, br,
Tr::tr("Setter parameter name:"), m_lineEdit_setterParameter, br,
m_checkBox_setterSlots, br,
tr("Reset name:"), m_lineEdit_resetName, br,
tr("Signal name:"), m_lineEdit_signalName, br,
Tr::tr("Reset name:"), m_lineEdit_resetName, br,
Tr::tr("Signal name:"), m_lineEdit_signalName, br,
m_checkBox_signalWithNewValue, br,
tr("Member variable name:"), m_lineEdit_memberVariableName, br,
Tr::tr("Member variable name:"), m_lineEdit_memberVariableName, br,
},
},
Group {
title(tr("Missing Namespace Handling")),
title(Tr::tr("Missing Namespace Handling")),
Form {
m_radioButton_generateMissingNamespace, br,
m_radioButton_addUsingnamespace, br,
@@ -264,7 +266,7 @@ e.g. name = "m_test_foo_":
},
m_useAutoCheckBox,
Group {
title(tr("Custom Getter Setter Templates")),
title(Tr::tr("Custom Getter Setter Templates")),
Row {
Column {
m_listWidget_customTemplates,
@@ -274,7 +276,7 @@ e.g. name = "m_test_foo_":
},
},
Group {
title(tr("Value types:")),
title(Tr::tr("Value types:")),
Row {
m_valueTypes,
Column { pushButton_addValueType, pushButton_removeValueType, st, },

View File

@@ -3,12 +3,13 @@
#include "cppsourceprocessor.h"
#include "cppeditortr.h"
#include "cppmodelmanager.h"
#include "cpptoolsreuse.h"
#include <coreplugin/editormanager/editormanager.h>
#include <utils/fileutils.h>
#include <utils/filepath.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/textfileformat.h>
@@ -65,16 +66,14 @@ inline QByteArray generateFingerPrint(const QList<CPlusPlus::Macro> &definedMacr
inline Message messageNoSuchFile(Document::Ptr &document, const FilePath &filePath, unsigned line)
{
const QString text = QCoreApplication::translate(
"CppSourceProcessor", "%1: No such file or directory").arg(filePath.displayName());
const QString text = Tr::tr("%1: No such file or directory").arg(filePath.displayName());
return Message(Message::Warning, document->filePath(), line, /*column =*/ 0, text);
}
inline Message messageNoFileContents(Document::Ptr &document, const FilePath &filePath,
unsigned line)
{
const QString text = QCoreApplication::translate(
"CppSourceProcessor", "%1: Could not get file contents").arg(filePath.displayName());
const QString text = Tr::tr("%1: Could not get file contents").arg(filePath.displayName());
return Message(Message::Warning, document->filePath(), line, /*column =*/ 0, text);
}

View File

@@ -9,6 +9,7 @@
#include "cppcompletionassist.h"
#include "cppeditorconstants.h"
#include "cppeditorplugin.h"
#include "cppeditortr.h"
#include "cppfilesettingspage.h"
#include "cpphighlighter.h"
#include "cppqtstyleindenter.h"
@@ -344,9 +345,7 @@ bool fileSizeExceedsLimit(const FilePath &filePath, int sizeLimitInMb)
const qint64 fileSizeInMB = filePath.fileSize() / (1000 * 1000);
if (fileSizeInMB > sizeLimitInMb) {
const QString msg = QCoreApplication::translate(
"CppIndexer",
"C++ Indexer: Skipping file \"%1\" because it is too big.")
const QString msg = Tr::tr("C++ Indexer: Skipping file \"%1\" because it is too big.")
.arg(filePath.displayName());
QMetaObject::invokeMethod(Core::MessageManager::instance(),
@@ -373,9 +372,7 @@ static void addBuiltinConfigs(ClangDiagnosticConfigsModel &model)
// Questionable constructs
config = ClangDiagnosticConfig();
config.setId(Constants::CPP_CLANG_DIAG_CONFIG_QUESTIONABLE);
config.setDisplayName(QCoreApplication::translate(
"ClangDiagnosticConfigsModel",
"Checks for questionable constructs"));
config.setDisplayName(Tr::tr("Checks for questionable constructs"));
config.setIsReadOnly(true);
config.setClangOptions({
"-Wall",
@@ -388,8 +385,7 @@ static void addBuiltinConfigs(ClangDiagnosticConfigsModel &model)
// Warning flags from build system
config = ClangDiagnosticConfig();
config.setId(Constants::CPP_CLANG_DIAG_CONFIG_BUILDSYSTEM);
config.setDisplayName(QCoreApplication::translate("ClangDiagnosticConfigsModel",
"Build-system warnings"));
config.setDisplayName(Tr::tr("Build-system warnings"));
config.setIsReadOnly(true);
config.setClazyMode(ClangDiagnosticConfig::ClazyMode::UseCustomChecks);
config.setClangTidyMode(ClangDiagnosticConfig::TidyMode::UseCustomChecks);

View File

@@ -4,6 +4,7 @@
#include "cpptoolssettings.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cppcodestylepreferences.h"
#include "cppcodestylepreferencesfactory.h"
@@ -61,7 +62,7 @@ CppToolsSettings::CppToolsSettings()
// global code style settings
d->m_globalCodeStyle = new CppCodeStylePreferences(this);
d->m_globalCodeStyle->setDelegatingPool(pool);
d->m_globalCodeStyle->setDisplayName(tr("Global", "Settings"));
d->m_globalCodeStyle->setDisplayName(Tr::tr("Global", "Settings"));
d->m_globalCodeStyle->setId(idKey);
pool->addCodeStyle(d->m_globalCodeStyle);
TextEditorSettings::registerCodeStyle(Constants::CPP_SETTINGS_ID, d->m_globalCodeStyle);
@@ -95,7 +96,7 @@ CppToolsSettings::CppToolsSettings()
// Qt style
auto qtCodeStyle = new CppCodeStylePreferences;
qtCodeStyle->setId("qt");
qtCodeStyle->setDisplayName(tr("Qt"));
qtCodeStyle->setDisplayName(Tr::tr("Qt"));
qtCodeStyle->setReadOnly(true);
TabSettings qtTabSettings;
qtTabSettings.m_tabPolicy = TabSettings::SpacesOnlyTabPolicy;
@@ -108,7 +109,7 @@ CppToolsSettings::CppToolsSettings()
// GNU style
auto gnuCodeStyle = new CppCodeStylePreferences;
gnuCodeStyle->setId("gnu");
gnuCodeStyle->setDisplayName(tr("GNU"));
gnuCodeStyle->setDisplayName(Tr::tr("GNU"));
gnuCodeStyle->setReadOnly(true);
TabSettings gnuTabSettings;
gnuTabSettings.m_tabPolicy = TabSettings::MixedTabPolicy;
@@ -169,7 +170,7 @@ CppToolsSettings::CppToolsSettings()
QVariant v;
v.setValue(legacyCodeStyleSettings);
ICodeStylePreferences *oldCreator = pool->createCodeStyle(
"legacy", legacyTabSettings, v, tr("Old Creator"));
"legacy", legacyTabSettings, v, Tr::tr("Old Creator"));
// change the current delegate and save
d->m_globalCodeStyle->setCurrentDelegate(oldCreator);

View File

@@ -4,6 +4,7 @@
#include "cpptypehierarchy.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cppeditorwidget.h"
#include "cppeditorplugin.h"
#include "cppelementevaluator.h"
@@ -84,20 +85,20 @@ void CppTypeHierarchyTreeView::contextMenuEvent(QContextMenuEvent *event)
QMenu contextMenu;
QAction *action = contextMenu.addAction(tr("Open in Editor"));
QAction *action = contextMenu.addAction(Tr::tr("Open in Editor"));
connect(action, &QAction::triggered, this, [this] () {
emit activated(currentIndex());
});
action = contextMenu.addAction(tr("Open Type Hierarchy"));
action = contextMenu.addAction(Tr::tr("Open Type Hierarchy"));
connect(action, &QAction::triggered, this, [this] () {
emit doubleClicked(currentIndex());
});
contextMenu.addSeparator();
action = contextMenu.addAction(tr("Expand All"));
action = contextMenu.addAction(Tr::tr("Expand All"));
connect(action, &QAction::triggered, this, &QTreeView::expandAll);
action = contextMenu.addAction(tr("Collapse All"));
action = contextMenu.addAction(Tr::tr("Collapse All"));
connect(action, &QAction::triggered, this, &QTreeView::collapseAll);
contextMenu.exec(event->globalPos());
@@ -182,7 +183,7 @@ void CppTypeHierarchyWidget::perform()
m_futureWatcher.setFuture(QFuture<void>(m_future));
m_synchronizer.addFuture(m_future);
Core::ProgressManager::addTask(m_future, tr("Evaluating Type Hierarchy"), "TypeHierarchy");
Core::ProgressManager::addTask(m_future, Tr::tr("Evaluating Type Hierarchy"), "TypeHierarchy");
}
void CppTypeHierarchyWidget::performFromExpression(const QString &expression, const FilePath &filePath)
@@ -198,7 +199,7 @@ void CppTypeHierarchyWidget::performFromExpression(const QString &expression, co
m_futureWatcher.setFuture(QFuture<void>(m_future));
m_synchronizer.addFuture(m_future);
Core::ProgressManager::addTask(m_future, tr("Evaluating Type Hierarchy"), "TypeHierarchy");
Core::ProgressManager::addTask(m_future, Tr::tr("Evaluating Type Hierarchy"), "TypeHierarchy");
}
void CppTypeHierarchyWidget::displayHierarchy()
@@ -224,10 +225,10 @@ void CppTypeHierarchyWidget::displayHierarchy()
m_inspectedClass->setText(cppClass->name);
m_inspectedClass->setLink(cppClass->link);
QStandardItem *bases = new QStandardItem(tr("Bases"));
QStandardItem *bases = new QStandardItem(Tr::tr("Bases"));
m_model->invisibleRootItem()->appendRow(bases);
QStandardItem *selectedItem1 = buildHierarchy(*cppClass, bases, true, &CppClass::bases);
QStandardItem *derived = new QStandardItem(tr("Derived"));
QStandardItem *derived = new QStandardItem(Tr::tr("Derived"));
m_model->invisibleRootItem()->appendRow(derived);
QStandardItem *selectedItem2 = buildHierarchy(*cppClass, derived, true, &CppClass::derived);
m_treeView->expandAll();
@@ -263,7 +264,7 @@ QStandardItem *CppTypeHierarchyWidget::buildHierarchy(const CppClass &cppClass,
void CppTypeHierarchyWidget::showNoTypeHierarchyLabel()
{
m_infoLabel->setText(tr("No type hierarchy available"));
m_infoLabel->setText(Tr::tr("No type hierarchy available"));
m_stackLayout->setCurrentWidget(m_infoLabel);
}
@@ -274,7 +275,7 @@ void CppTypeHierarchyWidget::showTypeHierarchy()
void CppTypeHierarchyWidget::showProgress()
{
m_infoLabel->setText(tr("Evaluating type hierarchy..."));
m_infoLabel->setText(Tr::tr("Evaluating type hierarchy..."));
if (!m_progressIndicator) {
m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Large);
m_progressIndicator->attachToWidget(this);
@@ -326,7 +327,7 @@ void CppTypeHierarchyWidget::onItemDoubleClicked(const QModelIndex &index)
// CppTypeHierarchyFactory
CppTypeHierarchyFactory::CppTypeHierarchyFactory()
{
setDisplayName(tr("Type Hierarchy"));
setDisplayName(Tr::tr("Type Hierarchy"));
setPriority(700);
setId(Constants::TYPE_HIERARCHY_ID);
}

View File

@@ -5,6 +5,7 @@
#include "cppvirtualfunctionproposalitem.h"
#include "cppeditortr.h"
#include "cpptoolsreuse.h"
#include "functionutils.h"
#include "symbolfinder.h"
@@ -93,8 +94,7 @@ public:
QTC_ASSERT(m_params.function, return nullptr);
auto *hintItem = new VirtualFunctionProposalItem(Utils::Link());
hintItem->setText(QCoreApplication::translate("VirtualFunctionsAssistProcessor",
"collecting overrides ..."));
hintItem->setText(Tr::tr("collecting overrides ..."));
hintItem->setOrder(-1000);
QList<AssistProposalItemInterface *> items;

View File

@@ -4,6 +4,7 @@
#include "symbolsfindfilter.h"
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include "cppmodelmanager.h"
#include <coreplugin/icore.h>
@@ -121,7 +122,7 @@ void SymbolsFindFilter::startSearch(SearchResult *search)
symbolSearcher, &QObject::deleteLater);
watcher->setFuture(Utils::runAsync(m_manager->sharedThreadPool(),
&SymbolSearcher::runSearch, symbolSearcher));
FutureProgress *progress = ProgressManager::addTask(watcher->future(), tr("Searching for Symbol"),
FutureProgress *progress = ProgressManager::addTask(watcher->future(), Tr::tr("Searching for Symbol"),
Core::Constants::TASK_SEARCH);
connect(progress, &FutureProgress::clicked, search, &SearchResult::popup);
}
@@ -203,22 +204,22 @@ void SymbolsFindFilter::onAllTasksFinished(Id type)
QString SymbolsFindFilter::label() const
{
return tr("C++ Symbols:");
return Tr::tr("C++ Symbols:");
}
QString SymbolsFindFilter::toolTip(FindFlags findFlags) const
{
QStringList types;
if (m_symbolsToSearch & SymbolSearcher::Classes)
types.append(tr("Classes"));
types.append(Tr::tr("Classes"));
if (m_symbolsToSearch & SymbolSearcher::Functions)
types.append(tr("Functions"));
types.append(Tr::tr("Functions"));
if (m_symbolsToSearch & SymbolSearcher::Enums)
types.append(tr("Enums"));
types.append(Tr::tr("Enums"));
if (m_symbolsToSearch & SymbolSearcher::Declarations)
types.append(tr("Declarations"));
return tr("Scope: %1\nTypes: %2\nFlags: %3")
.arg(searchScope() == SymbolSearcher::SearchGlobal ? tr("All") : tr("Projects"),
types.append(Tr::tr("Declarations"));
return Tr::tr("Scope: %1\nTypes: %2\nFlags: %3")
.arg(searchScope() == SymbolSearcher::SearchGlobal ? Tr::tr("All") : Tr::tr("Projects"),
types.join(", "),
IFindFilter::descriptionForFindFlags(findFlags));
}
@@ -235,19 +236,19 @@ SymbolsFindFilterConfigWidget::SymbolsFindFilterConfigWidget(SymbolsFindFilter *
setLayout(layout);
layout->setContentsMargins(0, 0, 0, 0);
auto typeLabel = new QLabel(tr("Types:"));
auto typeLabel = new QLabel(Tr::tr("Types:"));
layout->addWidget(typeLabel, 0, 0);
m_typeClasses = new QCheckBox(tr("Classes"));
m_typeClasses = new QCheckBox(Tr::tr("Classes"));
layout->addWidget(m_typeClasses, 0, 1);
m_typeMethods = new QCheckBox(tr("Functions"));
m_typeMethods = new QCheckBox(Tr::tr("Functions"));
layout->addWidget(m_typeMethods, 0, 2);
m_typeEnums = new QCheckBox(tr("Enums"));
m_typeEnums = new QCheckBox(Tr::tr("Enums"));
layout->addWidget(m_typeEnums, 1, 1);
m_typeDeclarations = new QCheckBox(tr("Declarations"));
m_typeDeclarations = new QCheckBox(Tr::tr("Declarations"));
layout->addWidget(m_typeDeclarations, 1, 2);
// hacks to fix layouting:
@@ -265,10 +266,10 @@ SymbolsFindFilterConfigWidget::SymbolsFindFilterConfigWidget(SymbolsFindFilter *
connect(m_typeDeclarations, &QAbstractButton::clicked,
this, &SymbolsFindFilterConfigWidget::setState);
m_searchProjectsOnly = new QRadioButton(tr("Projects only"));
m_searchProjectsOnly = new QRadioButton(Tr::tr("Projects only"));
layout->addWidget(m_searchProjectsOnly, 2, 1);
m_searchGlobal = new QRadioButton(tr("All files"));
m_searchGlobal = new QRadioButton(Tr::tr("All files"));
layout->addWidget(m_searchGlobal, 2, 2);
m_searchGroup = new QButtonGroup(this);