CMake: Move to Tr::tr

Change-Id: I169da93b5184351cb915d4c198fd33318fcfe06f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2022-09-29 15:26:31 +02:00
parent 9f25c2dedf
commit ab4c9b9679
65 changed files with 509 additions and 2228 deletions

View File

@@ -10,6 +10,7 @@
#include "cmakekitinformation.h"
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include "cmakeprojectmanagertr.h"
#include "cmakeprojectplugin.h"
#include "cmakespecificsettings.h"
#include "configmodel.h"
@@ -75,8 +76,8 @@
using namespace ProjectExplorer;
using namespace Utils;
using namespace CMakeProjectManager::Internal;
using namespace CMakeProjectManager::Internal;
namespace CMakeProjectManager {
static Q_LOGGING_CATEGORY(cmakeBuildConfigurationLog, "qtc.cmake.bc", QtWarningMsg);
@@ -96,8 +97,6 @@ namespace Internal {
class CMakeBuildSettingsWidget : public NamedWidget
{
Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::CMakeBuildSettingsWidget)
public:
CMakeBuildSettingsWidget(CMakeBuildSystem *bc);
@@ -165,7 +164,7 @@ static QModelIndex mapToSource(const QAbstractItemView *view, const QModelIndex
}
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
NamedWidget(tr("CMake")),
NamedWidget(Tr::tr("CMake")),
m_buildSystem(bs),
m_configModel(new ConfigModel(this)),
m_configFilterModel(new CategorySortFilterModel(this)),
@@ -211,19 +210,19 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
m_warningMessageLabel->setVisible(false);
m_configurationStates = new QTabBar(this);
m_configurationStates->addTab(tr("Initial Configuration"));
m_configurationStates->addTab(tr("Current Configuration"));
m_configurationStates->addTab(Tr::tr("Initial Configuration"));
m_configurationStates->addTab(Tr::tr("Current Configuration"));
connect(m_configurationStates, &QTabBar::currentChanged, this, [this](int index) {
updateConfigurationStateIndex(index);
});
m_kitConfiguration = new QPushButton(tr("Kit Configuration"));
m_kitConfiguration->setToolTip(tr("Edit the current kit's CMake configuration."));
m_kitConfiguration = new QPushButton(Tr::tr("Kit Configuration"));
m_kitConfiguration->setToolTip(Tr::tr("Edit the current kit's CMake configuration."));
m_kitConfiguration->setFixedWidth(m_kitConfiguration->sizeHint().width());
connect(m_kitConfiguration, &QPushButton::clicked, this, [this]() { kitCMakeConfiguration(); });
m_filterEdit = new FancyLineEdit;
m_filterEdit->setPlaceholderText(tr("Filter"));
m_filterEdit->setPlaceholderText(Tr::tr("Filter"));
m_filterEdit->setFiltering(true);
auto tree = new TreeView;
connect(tree, &TreeView::activated,
@@ -271,46 +270,46 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks
connect(&m_showProgressTimer, &QTimer::timeout, [this]() { m_progressIndicator->show(); });
m_addButton = new QPushButton(tr("&Add"));
m_addButton->setToolTip(tr("Add a new configuration value."));
m_addButton = new QPushButton(Tr::tr("&Add"));
m_addButton->setToolTip(Tr::tr("Add a new configuration value."));
auto addButtonMenu = new QMenu(this);
addButtonMenu->addAction(tr("&Boolean"))->setData(
addButtonMenu->addAction(Tr::tr("&Boolean"))->setData(
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::BOOLEAN)));
addButtonMenu->addAction(tr("&String"))->setData(
addButtonMenu->addAction(Tr::tr("&String"))->setData(
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::STRING)));
addButtonMenu->addAction(tr("&Directory"))->setData(
addButtonMenu->addAction(Tr::tr("&Directory"))->setData(
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::DIRECTORY)));
addButtonMenu->addAction(tr("&File"))->setData(
addButtonMenu->addAction(Tr::tr("&File"))->setData(
QVariant::fromValue(static_cast<int>(ConfigModel::DataItem::FILE)));
m_addButton->setMenu(addButtonMenu);
m_editButton = new QPushButton(tr("&Edit"));
m_editButton->setToolTip(tr("Edit the current CMake configuration value."));
m_editButton = new QPushButton(Tr::tr("&Edit"));
m_editButton->setToolTip(Tr::tr("Edit the current CMake configuration value."));
m_setButton = new QPushButton(tr("&Set"));
m_setButton->setToolTip(tr("Set a value in the CMake configuration."));
m_setButton = new QPushButton(Tr::tr("&Set"));
m_setButton->setToolTip(Tr::tr("Set a value in the CMake configuration."));
m_unsetButton = new QPushButton(tr("&Unset"));
m_unsetButton->setToolTip(tr("Unset a value in the CMake configuration."));
m_unsetButton = new QPushButton(Tr::tr("&Unset"));
m_unsetButton->setToolTip(Tr::tr("Unset a value in the CMake configuration."));
m_resetButton = new QPushButton(tr("&Reset"));
m_resetButton->setToolTip(tr("Reset all unapplied changes."));
m_resetButton = new QPushButton(Tr::tr("&Reset"));
m_resetButton->setToolTip(Tr::tr("Reset all unapplied changes."));
m_resetButton->setEnabled(false);
m_batchEditButton = new QPushButton(tr("Batch Edit..."));
m_batchEditButton->setToolTip(tr("Set or reset multiple values in the CMake configuration."));
m_batchEditButton = new QPushButton(Tr::tr("Batch Edit..."));
m_batchEditButton->setToolTip(Tr::tr("Set or reset multiple values in the CMake configuration."));
m_showAdvancedCheckBox = new QCheckBox(tr("Advanced"));
m_showAdvancedCheckBox = new QCheckBox(Tr::tr("Advanced"));
connect(m_configView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, [this](const QItemSelection &, const QItemSelection &) {
updateSelection();
});
m_reconfigureButton = new QPushButton(tr("Run CMake"));
m_reconfigureButton = new QPushButton(Tr::tr("Run CMake"));
m_reconfigureButton->setEnabled(false);
auto clearBox = new QCheckBox(tr("Clear system environment"), this);
auto clearBox = new QCheckBox(Tr::tr("Clear system environment"), this);
clearBox->setChecked(cbc->useClearConfigureEnvironment());
auto envWidget = new EnvironmentWidget(this, EnvironmentWidget::TypeLocal, clearBox);
@@ -479,14 +478,14 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
connect(addButtonMenu, &QMenu::triggered, this, [this](QAction *action) {
ConfigModel::DataItem::Type type =
static_cast<ConfigModel::DataItem::Type>(action->data().value<int>());
QString value = tr("<UNSET>");
QString value = Tr::tr("<UNSET>");
if (type == ConfigModel::DataItem::BOOLEAN)
value = QString::fromLatin1("OFF");
m_configModel->appendConfiguration(tr("<UNSET>"), value, type, isInitialConfiguration());
m_configModel->appendConfiguration(Tr::tr("<UNSET>"), value, type, isInitialConfiguration());
const TreeItem *item = m_configModel->findNonRootItem([&value, type](TreeItem *item) {
ConfigModel::DataItem dataItem = ConfigModel::dataItemFromIndex(item->index());
return dataItem.key == tr("<UNSET>") && dataItem.type == type && dataItem.value == value;
return dataItem.key == Tr::tr("<UNSET>") && dataItem.type == type && dataItem.value == value;
});
QModelIndex idx = m_configModel->indexForItem(item);
idx = m_configTextFilterModel->mapFromSource(m_configFilterModel->mapFromSource(idx));
@@ -537,14 +536,14 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
void CMakeBuildSettingsWidget::batchEditConfiguration()
{
auto dialog = new QDialog(this);
dialog->setWindowTitle(tr("Edit CMake Configuration"));
dialog->setWindowTitle(Tr::tr("Edit CMake Configuration"));
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setModal(true);
auto layout = new QVBoxLayout(dialog);
auto editor = new QPlainTextEdit(dialog);
auto label = new QLabel(dialog);
label->setText(tr("Enter one CMake <a href=\"variable\">variable</a> per line.<br/>"
label->setText(Tr::tr("Enter one CMake <a href=\"variable\">variable</a> per line.<br/>"
"To set or change a variable, use -D&lt;variable&gt;:&lt;type&gt;=&lt;value&gt;.<br/>"
"&lt;type&gt; can have one of the following values: FILEPATH, PATH, BOOL, INTERNAL, or STRING.<br/>"
"To unset a variable, use -U&lt;variable&gt;.<br/>"));
@@ -598,9 +597,9 @@ void CMakeBuildSettingsWidget::reconfigureWithInitialParameters()
if (!doNotAsk) {
QDialogButtonBox::StandardButton reply = Utils::CheckableMessageBox::question(
Core::ICore::dialogParent(),
tr("Re-configure with Initial Parameters"),
tr("Clear CMake configuration and configure with initial parameters?"),
tr("Do not ask again"),
Tr::tr("Re-configure with Initial Parameters"),
Tr::tr("Clear CMake configuration and configure with initial parameters?"),
Tr::tr("Do not ask again"),
&doNotAsk,
QDialogButtonBox::Yes | QDialogButtonBox::No,
QDialogButtonBox::Yes);
@@ -657,7 +656,7 @@ void CMakeBuildSettingsWidget::kitCMakeConfiguration()
m_buildSystem->kit()->blockNotification();
auto dialog = new QDialog(this);
dialog->setWindowTitle(tr("Kit CMake Configuration"));
dialog->setWindowTitle(Tr::tr("Kit CMake Configuration"));
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setModal(true);
dialog->setSizeGripEnabled(true);
@@ -708,7 +707,7 @@ void CMakeBuildSettingsWidget::updateConfigureDetailsWidgetsSummary(
cmd.addArgs(configurationArguments);
params.setCommandLine(cmd);
m_configureDetailsWidget->setSummaryText(params.summary(tr("Configure")));
m_configureDetailsWidget->setSummaryText(params.summary(Tr::tr("Configure")));
m_configureDetailsWidget->setState(DetailsWidget::Expanded);
}
@@ -777,14 +776,14 @@ void CMakeBuildSettingsWidget::updateButtonState()
// Update label and text boldness of the reconfigure button
QFont reconfigureButtonFont = m_reconfigureButton->font();
if (isParsing) {
m_reconfigureButton->setText(tr("Stop CMake"));
m_reconfigureButton->setText(Tr::tr("Stop CMake"));
reconfigureButtonFont.setBold(false);
} else {
m_reconfigureButton->setEnabled(true);
if (isInitial) {
m_reconfigureButton->setText(tr("Re-configure with Initial Parameters"));
m_reconfigureButton->setText(Tr::tr("Re-configure with Initial Parameters"));
} else {
m_reconfigureButton->setText(tr("Run CMake"));
m_reconfigureButton->setText(Tr::tr("Run CMake"));
}
reconfigureButtonFont.setBold(isInitial ? m_configModel->hasChanges(isInitial)
: !configChanges.isEmpty());
@@ -998,21 +997,21 @@ QAction *CMakeBuildSettingsWidget::createForceAction(int type, const QModelIndex
QString typeString;
switch (type) {
case ConfigModel::DataItem::BOOLEAN:
typeString = tr("bool", "display string for cmake type BOOLEAN");
typeString = Tr::tr("bool", "display string for cmake type BOOLEAN");
break;
case ConfigModel::DataItem::FILE:
typeString = tr("file", "display string for cmake type FILE");
typeString = Tr::tr("file", "display string for cmake type FILE");
break;
case ConfigModel::DataItem::DIRECTORY:
typeString = tr("directory", "display string for cmake type DIRECTORY");
typeString = Tr::tr("directory", "display string for cmake type DIRECTORY");
break;
case ConfigModel::DataItem::STRING:
typeString = tr("string", "display string for cmake type STRING");
typeString = Tr::tr("string", "display string for cmake type STRING");
break;
case ConfigModel::DataItem::UNKNOWN:
return nullptr;
}
QAction *forceAction = new QAction(tr("Force to %1").arg(typeString), nullptr);
QAction *forceAction = new QAction(Tr::tr("Force to %1").arg(typeString), nullptr);
forceAction->setEnabled(m_configModel->canForceTo(idx, t));
connect(forceAction, &QAction::triggered,
this, [this, idx, t]() { m_configModel->forceTo(idx, t); });
@@ -1033,7 +1032,7 @@ bool CMakeBuildSettingsWidget::eventFilter(QObject *target, QEvent *event)
auto menu = new QMenu(this);
connect(menu, &QMenu::triggered, menu, &QMenu::deleteLater);
auto help = new QAction(tr("Help"), this);
auto help = new QAction(Tr::tr("Help"), this);
menu->addAction(help);
connect(help, &QAction::triggered, this, [=] {
const CMakeConfigItem item = ConfigModel::dataItemFromIndex(idx).toCMakeConfigItem();
@@ -1058,8 +1057,8 @@ bool CMakeBuildSettingsWidget::eventFilter(QObject *target, QEvent *event)
menu->addSeparator();
auto applyKitOrInitialValue = new QAction(isInitialConfiguration()
? tr("Apply Kit Value")
: tr("Apply Initial Configuration Value"),
? Tr::tr("Apply Kit Value")
: Tr::tr("Apply Initial Configuration Value"),
this);
menu->addAction(applyKitOrInitialValue);
connect(applyKitOrInitialValue, &QAction::triggered, this, [this] {
@@ -1079,7 +1078,7 @@ bool CMakeBuildSettingsWidget::eventFilter(QObject *target, QEvent *event)
menu->addSeparator();
auto copy = new QAction(tr("Copy"), this);
auto copy = new QAction(Tr::tr("Copy"), this);
menu->addAction(copy);
connect(copy, &QAction::triggered, this, [this] {
const QModelIndexList selectedIndexes = m_configView->selectionModel()->selectedIndexes();
@@ -1377,8 +1376,8 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
if (QDir(oldDir).exists("CMakeCache.txt") && !QDir(newDir).exists("CMakeCache.txt")) {
if (QMessageBox::information(
Core::ICore::dialogParent(),
tr("Changing Build Directory"),
tr("Change the build directory to \"%1\" and start with a "
Tr::tr("Changing Build Directory"),
Tr::tr("Change the build directory to \"%1\" and start with a "
"basic CMake configuration?")
.arg(newDir),
QMessageBox::Ok,
@@ -1398,7 +1397,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
additionalCMakeArgumentsAspect->setMacroExpanderProvider([this] { return macroExpander(); });
macroExpander()->registerVariable(DEVELOPMENT_TEAM_FLAG,
tr("The CMake flag for the development team"),
Tr::tr("The CMake flag for the development team"),
[this] {
const CMakeConfig flags = signingFlags();
if (!flags.isEmpty())
@@ -1406,7 +1405,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
return QString();
});
macroExpander()->registerVariable(PROVISIONING_PROFILE_FLAG,
tr("The CMake flag for the provisioning profile"),
Tr::tr("The CMake flag for the provisioning profile"),
[this] {
const CMakeConfig flags = signingFlags();
if (flags.size() > 1 && !flags.at(1).isUnset) {
@@ -1416,7 +1415,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
});
macroExpander()->registerVariable(CMAKE_OSX_ARCHITECTURES_FLAG,
tr("The CMake flag for the architecture on macOS"),
Tr::tr("The CMake flag for the architecture on macOS"),
[target] {
if (HostOsInfo::isRunningUnderRosetta()) {
if (auto *qt = QtSupport::QtKitAspect::qtVersion(target->kit())) {
@@ -1430,7 +1429,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
return QLatin1String();
});
macroExpander()->registerVariable(QT_QML_DEBUG_FLAG,
tr("The CMake flag for QML debugging, if enabled"),
Tr::tr("The CMake flag for QML debugging, if enabled"),
[this] {
if (aspect<QtSupport::QmlDebuggingAspect>()->value()
== TriState::Enabled) {
@@ -1997,17 +1996,17 @@ BuildInfo CMakeBuildConfigurationFactory::createBuildInfo(BuildType buildType)
break;
case BuildTypeMinSizeRel:
info.typeName = "MinSizeRel";
info.displayName = CMakeBuildConfiguration::tr("Minimum Size Release");
info.displayName = Tr::tr("Minimum Size Release");
info.buildType = BuildConfiguration::Release;
break;
case BuildTypeRelWithDebInfo:
info.typeName = "RelWithDebInfo";
info.displayName = CMakeBuildConfiguration::tr("Release with Debug Information");
info.displayName = Tr::tr("Release with Debug Information");
info.buildType = BuildConfiguration::Profile;
break;
case BuildTypeProfile: {
info.typeName = "Profile";
info.displayName = CMakeBuildConfiguration::tr("Profile");
info.displayName = Tr::tr("Profile");
info.buildType = BuildConfiguration::Profile;
QVariantMap extraInfo;
// override CMake build type, which defaults to info.typeName
@@ -2125,9 +2124,9 @@ Environment CMakeBuildConfiguration::baseConfigureEnvironment() const
QString CMakeBuildConfiguration::baseConfigureEnvironmentText() const
{
if (useClearConfigureEnvironment())
return tr("Clean Environment");
return Tr::tr("Clean Environment");
else
return tr("System Environment");
return Tr::tr("System Environment");
}
QString CMakeBuildSystem::cmakeBuildType() const
@@ -2262,7 +2261,7 @@ void InitialCMakeArgumentsAspect::toMap(QVariantMap &map) const
InitialCMakeArgumentsAspect::InitialCMakeArgumentsAspect()
{
setSettingsKey("CMake.Initial.Parameters");
setLabelText(tr("Additional CMake <a href=\"options\">options</a>:"));
setLabelText(Tr::tr("Additional CMake <a href=\"options\">options</a>:"));
setDisplayStyle(LineEditDisplay);
}
@@ -2273,7 +2272,7 @@ InitialCMakeArgumentsAspect::InitialCMakeArgumentsAspect()
AdditionalCMakeOptionsAspect::AdditionalCMakeOptionsAspect()
{
setSettingsKey("CMake.Additional.Options");
setLabelText(tr("Additional CMake <a href=\"options\">options</a>:"));
setLabelText(Tr::tr("Additional CMake <a href=\"options\">options</a>:"));
setDisplayStyle(LineEditDisplay);
}
@@ -2292,7 +2291,7 @@ SourceDirectoryAspect::SourceDirectoryAspect()
BuildTypeAspect::BuildTypeAspect()
{
setSettingsKey(CMAKE_BUILD_TYPE);
setLabelText(tr("Build type:"));
setLabelText(Tr::tr("Build type:"));
setDisplayStyle(LineEditDisplay);
setDefaultValue("Unknown");
}