Fix lupdate issues

Some failures to find the right tr() without fully qualifying

Change-Id: I6566786dc93b07dcf01f3bdce83ebd404f4fd6e8
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2023-06-12 10:25:36 +02:00
parent a0969feadf
commit 890debd658
3 changed files with 84 additions and 64 deletions

View File

@@ -42,14 +42,14 @@ ProjectInfo::ConstPtr ProjectInfoGenerator::generate(const QPromise<ProjectInfo:
}); });
}; };
if (m_cToolchainMissing) { if (m_cToolchainMissing) {
showWarning(Tr::tr( showWarning(
"The project contains C source files, but the currently active kit " ::CppEditor::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.")); "has no C compiler. The code model will not be fully functional."));
} }
if (m_cxxToolchainMissing) { if (m_cxxToolchainMissing) {
showWarning(Tr::tr( showWarning(::CppEditor::Tr::tr(
"The project contains C++ source files, but the currently active kit " "The project contains C++ source files, but the currently active kit "
"has no C++ compiler. The code model will not be fully functional.")); "has no C++ compiler. The code model will not be fully functional."));
} }
return projectInfo; return projectInfo;
} }

View File

@@ -62,6 +62,8 @@
using namespace Utils; using namespace Utils;
using namespace Core; using namespace Core;
namespace PE = ProjectExplorer;
namespace ProjectExplorer { namespace ProjectExplorer {
/*! /*!
@@ -207,9 +209,10 @@ Project::Project(const QString &mimeType, const FilePath &fileName)
d->m_document = std::make_unique<ProjectDocument>(mimeType, fileName, this); d->m_document = std::make_unique<ProjectDocument>(mimeType, fileName, this);
DocumentManager::addDocument(d->m_document.get()); DocumentManager::addDocument(d->m_document.get());
d->m_macroExpander.setDisplayName(Tr::tr("Project")); d->m_macroExpander.setDisplayName(::PE::Tr::tr("Project"));
d->m_macroExpander.registerVariable("Project:Name", Tr::tr("Project Name"), d->m_macroExpander.registerVariable("Project:Name", ::PE::Tr::tr("Project Name"), [this] {
[this] { return displayName(); }); return displayName();
});
// Only set up containernode after d is set so that it will find the project directory! // Only set up containernode after d is set so that it will find the project directory!
d->m_containerNode = std::make_unique<ContainerNode>(this); d->m_containerNode = std::make_unique<ContainerNode>(this);
@@ -443,7 +446,7 @@ Tasks Project::projectIssues(const Kit *k) const
{ {
Tasks result; Tasks result;
if (!k->isValid()) if (!k->isValid())
result.append(createProjectTask(Task::TaskType::Error, Tr::tr("Kit is not valid."))); result.append(createProjectTask(Task::TaskType::Error, ::PE::Tr::tr("Kit is not valid.")));
return {}; return {};
} }
@@ -524,8 +527,8 @@ bool Project::copySteps(Target *sourceTarget, Target *newTarget)
if (fatalError) { if (fatalError) {
// That could be a more granular error message // That could be a more granular error message
QMessageBox::critical(ICore::dialogParent(), QMessageBox::critical(ICore::dialogParent(),
Tr::tr("Incompatible Kit"), ::PE::Tr::tr("Incompatible Kit"),
Tr::tr("Kit %1 is incompatible with kit %2.") ::PE::Tr::tr("Kit %1 is incompatible with kit %2.")
.arg(sourceTarget->kit()->displayName()) .arg(sourceTarget->kit()->displayName())
.arg(newTarget->kit()->displayName())); .arg(newTarget->kit()->displayName()));
} else if (!buildconfigurationError.isEmpty() } else if (!buildconfigurationError.isEmpty()
@@ -534,27 +537,27 @@ bool Project::copySteps(Target *sourceTarget, Target *newTarget)
QString error; QString error;
if (!buildconfigurationError.isEmpty()) if (!buildconfigurationError.isEmpty())
error += Tr::tr("Build configurations:") + QLatin1Char('\n') error += ::PE::Tr::tr("Build configurations:") + QLatin1Char('\n')
+ buildconfigurationError.join(QLatin1Char('\n')); + buildconfigurationError.join(QLatin1Char('\n'));
if (!deployconfigurationError.isEmpty()) { if (!deployconfigurationError.isEmpty()) {
if (!error.isEmpty()) if (!error.isEmpty())
error.append(QLatin1Char('\n')); error.append(QLatin1Char('\n'));
error += Tr::tr("Deploy configurations:") + QLatin1Char('\n') error += ::PE::Tr::tr("Deploy configurations:") + QLatin1Char('\n')
+ deployconfigurationError.join(QLatin1Char('\n')); + deployconfigurationError.join(QLatin1Char('\n'));
} }
if (!runconfigurationError.isEmpty()) { if (!runconfigurationError.isEmpty()) {
if (!error.isEmpty()) if (!error.isEmpty())
error.append(QLatin1Char('\n')); error.append(QLatin1Char('\n'));
error += Tr::tr("Run configurations:") + QLatin1Char('\n') error += ::PE::Tr::tr("Run configurations:") + QLatin1Char('\n')
+ runconfigurationError.join(QLatin1Char('\n')); + runconfigurationError.join(QLatin1Char('\n'));
} }
QMessageBox msgBox(ICore::dialogParent()); QMessageBox msgBox(ICore::dialogParent());
msgBox.setIcon(QMessageBox::Warning); msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(Tr::tr("Partially Incompatible Kit")); msgBox.setWindowTitle(::PE::Tr::tr("Partially Incompatible Kit"));
msgBox.setText(Tr::tr("Some configurations could not be copied.")); msgBox.setText(::PE::Tr::tr("Some configurations could not be copied."));
msgBox.setDetailedText(error); msgBox.setDetailedText(error);
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
fatalError = msgBox.exec() != QDialog::Accepted; fatalError = msgBox.exec() != QDialog::Accepted;
@@ -728,11 +731,11 @@ FilePath Project::projectDirectory(const FilePath &top)
void Project::changeRootProjectDirectory() void Project::changeRootProjectDirectory()
{ {
FilePath rootPath = FileUtils::getExistingDirectory( FilePath rootPath = FileUtils::getExistingDirectory(nullptr,
nullptr, ::PE::Tr::tr("Select the Root Directory"),
Tr::tr("Select the Root Directory"), rootProjectDirectory(),
rootProjectDirectory(), QFileDialog::ShowDirsOnly
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); | QFileDialog::DontResolveSymlinks);
if (rootPath != d->m_rootProjectDirectory) { if (rootPath != d->m_rootProjectDirectory) {
d->m_rootProjectDirectory = rootPath; d->m_rootProjectDirectory = rootPath;
setNamedSettings(Constants::PROJECT_ROOT_PATH_KEY, d->m_rootProjectDirectory.toString()); setNamedSettings(Constants::PROJECT_ROOT_PATH_KEY, d->m_rootProjectDirectory.toString());
@@ -817,20 +820,27 @@ void Project::createTargetFromMap(const QVariantMap &map, int index)
if (!deviceTypeId.isValid()) if (!deviceTypeId.isValid())
deviceTypeId = Constants::DESKTOP_DEVICE_TYPE; deviceTypeId = Constants::DESKTOP_DEVICE_TYPE;
const QString formerKitName = targetMap.value(Target::displayNameKey()).toString(); const QString formerKitName = targetMap.value(Target::displayNameKey()).toString();
k = KitManager::registerKit([deviceTypeId, &formerKitName](Kit *kit) { k = KitManager::registerKit(
const QString kitNameSuggestion = formerKitName.contains(Tr::tr("Replacement for")) [deviceTypeId, &formerKitName](Kit *kit) {
? formerKitName : Tr::tr("Replacement for \"%1\"").arg(formerKitName); const QString kitNameSuggestion
= formerKitName.contains(::PE::Tr::tr("Replacement for"))
? formerKitName
: ::PE::Tr::tr("Replacement for \"%1\"").arg(formerKitName);
const QString tempKitName = makeUniquelyNumbered(kitNameSuggestion, const QString tempKitName = makeUniquelyNumbered(kitNameSuggestion,
transform(KitManager::kits(), &Kit::unexpandedDisplayName)); transform(KitManager::kits(), &Kit::unexpandedDisplayName));
kit->setUnexpandedDisplayName(tempKitName); kit->setUnexpandedDisplayName(tempKitName);
DeviceTypeKitAspect::setDeviceTypeId(kit, deviceTypeId); DeviceTypeKitAspect::setDeviceTypeId(kit, deviceTypeId);
kit->makeReplacementKit(); kit->makeReplacementKit();
kit->setup(); kit->setup();
}, id); },
id);
QTC_ASSERT(k, return); QTC_ASSERT(k, return);
TaskHub::addTask(BuildSystemTask(Task::Warning, Tr::tr("Project \"%1\" was configured for " TaskHub::addTask(BuildSystemTask(
"kit \"%2\" with id %3, which does not exist anymore. The new kit \"%4\" was " Task::Warning,
"created in its place, in an attempt not to lose custom project settings.") ::PE::Tr::tr(
"Project \"%1\" was configured for "
"kit \"%2\" with id %3, which does not exist anymore. The new kit \"%4\" was "
"created in its place, in an attempt not to lose custom project settings.")
.arg(displayName(), formerKitName, id.toString(), k->displayName()))); .arg(displayName(), formerKitName, id.toString(), k->displayName())));
} }
@@ -1081,7 +1091,8 @@ QStringList Project::availableQmlPreviewTranslations(QString *errorMessage)
const QDir languageDirectory(projectDirectory + "/i18n"); const QDir languageDirectory(projectDirectory + "/i18n");
const auto qmFiles = languageDirectory.entryList({"qml_*.qm"}); const auto qmFiles = languageDirectory.entryList({"qml_*.qm"});
if (qmFiles.isEmpty() && errorMessage) if (qmFiles.isEmpty() && errorMessage)
errorMessage->append(Tr::tr("Could not find any qml_*.qm file at \"%1\"").arg(languageDirectory.absolutePath())); errorMessage->append(::PE::Tr::tr("Could not find any qml_*.qm file at \"%1\"")
.arg(languageDirectory.absolutePath()));
return transform(qmFiles, [](const QString &qmFile) { return transform(qmFiles, [](const QString &qmFile) {
const int localeStartPosition = qmFile.lastIndexOf("_") + 1; const int localeStartPosition = qmFile.lastIndexOf("_") + 1;
const int localeEndPosition = qmFile.size() - QString(".qm").size(); const int localeEndPosition = qmFile.size() - QString(".qm").size();
@@ -1167,7 +1178,7 @@ void Project::addVariablesToMacroExpander(const QByteArray &prefix,
const QByteArray prefixWithoutColon = fullPrefix.chopped(1); const QByteArray prefixWithoutColon = fullPrefix.chopped(1);
expander->registerVariable(fullPrefix + "Name", expander->registerVariable(fullPrefix + "Name",
//: %1 is something like "Active project" //: %1 is something like "Active project"
Tr::tr("%1: Name.").arg(descriptor), ::PE::Tr::tr("%1: Name.").arg(descriptor),
[projectGetter]() -> QString { [projectGetter]() -> QString {
if (const Project *const project = projectGetter()) if (const Project *const project = projectGetter())
return project->displayName(); return project->displayName();
@@ -1175,7 +1186,7 @@ void Project::addVariablesToMacroExpander(const QByteArray &prefix,
}); });
expander->registerFileVariables(prefixWithoutColon, expander->registerFileVariables(prefixWithoutColon,
//: %1 is something like "Active project" //: %1 is something like "Active project"
Tr::tr("%1: Full path to main file.").arg(descriptor), ::PE::Tr::tr("%1: Full path to main file.").arg(descriptor),
[projectGetter]() -> FilePath { [projectGetter]() -> FilePath {
if (const Project *const project = projectGetter()) if (const Project *const project = projectGetter())
return project->projectFilePath(); return project->projectFilePath();
@@ -1183,7 +1194,7 @@ void Project::addVariablesToMacroExpander(const QByteArray &prefix,
}); });
expander->registerVariable(fullPrefix + "Kit:Name", expander->registerVariable(fullPrefix + "Kit:Name",
//: %1 is something like "Active project" //: %1 is something like "Active project"
Tr::tr("%1: The name of the active kit.").arg(descriptor), ::PE::Tr::tr("%1: The name of the active kit.").arg(descriptor),
[targetGetter]() -> QString { [targetGetter]() -> QString {
if (const Target *const target = targetGetter()) if (const Target *const target = targetGetter())
return target->kit()->displayName(); return target->kit()->displayName();
@@ -1191,7 +1202,8 @@ void Project::addVariablesToMacroExpander(const QByteArray &prefix,
}); });
expander->registerVariable(fullPrefix + "BuildConfig:Name", expander->registerVariable(fullPrefix + "BuildConfig:Name",
//: %1 is something like "Active project" //: %1 is something like "Active project"
Tr::tr("%1: Name of the active build configuration.").arg(descriptor), ::PE::Tr::tr("%1: Name of the active build configuration.")
.arg(descriptor),
[bcGetter]() -> QString { [bcGetter]() -> QString {
if (const BuildConfiguration *const bc = bcGetter()) if (const BuildConfiguration *const bc = bcGetter())
return bc->displayName(); return bc->displayName();
@@ -1199,25 +1211,27 @@ void Project::addVariablesToMacroExpander(const QByteArray &prefix,
}); });
expander->registerVariable(fullPrefix + "BuildConfig:Type", expander->registerVariable(fullPrefix + "BuildConfig:Type",
//: %1 is something like "Active project" //: %1 is something like "Active project"
Tr::tr("%1: Type of the active build configuration.").arg(descriptor), ::PE::Tr::tr("%1: Type of the active build configuration.")
.arg(descriptor),
[bcGetter]() -> QString { [bcGetter]() -> QString {
const BuildConfiguration *const bc = bcGetter(); const BuildConfiguration *const bc = bcGetter();
const BuildConfiguration::BuildType type const BuildConfiguration::BuildType type
= bc ? bc->buildType() : BuildConfiguration::Unknown; = bc ? bc->buildType() : BuildConfiguration::Unknown;
return BuildConfiguration::buildTypeName(type); return BuildConfiguration::buildTypeName(type);
}); });
expander expander->registerVariable(fullPrefix + "BuildConfig:Path",
->registerVariable(fullPrefix + "BuildConfig:Path", //: %1 is something like "Active project"
//: %1 is something like "Active project" ::PE::Tr::tr("%1: Full build path of active build configuration.")
Tr::tr("%1: Full build path of active build configuration.").arg(descriptor), .arg(descriptor),
[bcGetter]() -> QString { [bcGetter]() -> QString {
if (const BuildConfiguration *const bc = bcGetter()) if (const BuildConfiguration *const bc = bcGetter())
return bc->buildDirectory().toUserOutput(); return bc->buildDirectory().toUserOutput();
return {}; return {};
}); });
expander->registerPrefix(fullPrefix + "BuildConfig:Env", expander->registerPrefix(fullPrefix + "BuildConfig:Env",
//: %1 is something like "Active project" //: %1 is something like "Active project"
Tr::tr("%1: Variables in the active build environment.").arg(descriptor), ::PE::Tr::tr("%1: Variables in the active build environment.")
.arg(descriptor),
[bcGetter](const QString &var) { [bcGetter](const QString &var) {
if (BuildConfiguration *const bc = bcGetter()) if (BuildConfiguration *const bc = bcGetter())
return bc->environment().expandedValueForKey(var); return bc->environment().expandedValueForKey(var);
@@ -1226,7 +1240,8 @@ void Project::addVariablesToMacroExpander(const QByteArray &prefix,
expander->registerVariable(fullPrefix + "RunConfig:Name", expander->registerVariable(fullPrefix + "RunConfig:Name",
//: %1 is something like "Active project" //: %1 is something like "Active project"
Tr::tr("%1: Name of the active run configuration.").arg(descriptor), ::PE::Tr::tr("%1: Name of the active run configuration.")
.arg(descriptor),
[rcGetter]() -> QString { [rcGetter]() -> QString {
if (const RunConfiguration *const rc = rcGetter()) if (const RunConfiguration *const rc = rcGetter())
return rc->displayName(); return rc->displayName();
@@ -1234,27 +1249,30 @@ void Project::addVariablesToMacroExpander(const QByteArray &prefix,
}); });
expander->registerFileVariables(fullPrefix + "RunConfig:Executable", expander->registerFileVariables(fullPrefix + "RunConfig:Executable",
//: %1 is something like "Active project" //: %1 is something like "Active project"
Tr::tr("%1: Executable of the active run configuration.") ::PE::Tr::tr("%1: Executable of the active run configuration.")
.arg(descriptor), .arg(descriptor),
[rcGetter]() -> FilePath { [rcGetter]() -> FilePath {
if (const RunConfiguration *const rc = rcGetter()) if (const RunConfiguration *const rc = rcGetter())
return rc->commandLine().executable(); return rc->commandLine().executable();
return {}; return {};
}); });
expander->registerPrefix(fullPrefix + "RunConfig:Env", expander
//: %1 is something like "Active project" ->registerPrefix(fullPrefix + "RunConfig:Env",
Tr::tr("%1: Variables in the environment of the active run configuration.") //: %1 is something like "Active project"
.arg(descriptor), ::PE::Tr::tr(
[rcGetter](const QString &var) { "%1: Variables in the environment of the active run configuration.")
if (const RunConfiguration *const rc = rcGetter()) { .arg(descriptor),
if (const auto envAspect = rc->aspect<EnvironmentAspect>()) [rcGetter](const QString &var) {
return envAspect->environment().expandedValueForKey(var); if (const RunConfiguration *const rc = rcGetter()) {
} if (const auto envAspect = rc->aspect<EnvironmentAspect>())
return QString(); return envAspect->environment().expandedValueForKey(var);
}); }
return QString();
});
expander->registerVariable(fullPrefix + "RunConfig:WorkingDir", expander->registerVariable(fullPrefix + "RunConfig:WorkingDir",
//: %1 is something like "Active project" //: %1 is something like "Active project"
Tr::tr("%1: Working directory of the active run configuration.") ::PE::Tr::tr(
"%1: Working directory of the active run configuration.")
.arg(descriptor), .arg(descriptor),
[rcGetter] { [rcGetter] {
if (const RunConfiguration *const rc = rcGetter()) { if (const RunConfiguration *const rc = rcGetter()) {

View File

@@ -3,6 +3,8 @@
#include "bakelightsconnectionmanager.h" #include "bakelightsconnectionmanager.h"
#include "qmldesignertr.h"
#include <puppettocreatorcommand.h> #include <puppettocreatorcommand.h>
namespace QmlDesigner { namespace QmlDesigner {
@@ -34,10 +36,10 @@ void BakeLightsConnectionManager::dispatchCommand(const QVariant &command,
m_progressCallback(cmd.data().toString()); m_progressCallback(cmd.data().toString());
break; break;
case PuppetToCreatorCommand::BakeLightsAborted: case PuppetToCreatorCommand::BakeLightsAborted:
m_finishedCallback(tr("Baking aborted: %1").arg(cmd.data().toString())); m_finishedCallback(Tr::tr("Baking aborted: %1").arg(cmd.data().toString()));
break; break;
case PuppetToCreatorCommand::BakeLightsFinished: case PuppetToCreatorCommand::BakeLightsFinished:
m_finishedCallback(tr("Baking finished!")); m_finishedCallback(Tr::tr("Baking finished!"));
break; break;
default: default:
break; break;