EffectComposer: Clean up tr()

Use Tr::tr, clean up translatable strings.

Change-Id: Ie88a3407f5127307d06057529cad1b7db004a8f0
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
(cherry picked from commit 256c3b3c99)
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Eike Ziller
2025-02-11 14:19:45 +01:00
parent f596a9f3d6
commit be7b5eb679
11 changed files with 90 additions and 57 deletions

View File

@@ -9,6 +9,7 @@ add_qtc_plugin(EffectComposer
effectcomposereditablenodesmodel.cpp effectcomposereditablenodesmodel.h
effectcodeeditorwidget.cpp effectcodeeditorwidget.h
effectcomposerplugin.cpp
effectcomposertr.h
effectcomposerwidget.cpp effectcomposerwidget.h
effectcomposerview.cpp effectcomposerview.h
effectcomposermodel.cpp effectcomposermodel.h

View File

@@ -3,6 +3,7 @@
#include "effectcodeeditorwidget.h"
#include "effectcomposertr.h"
#include "effectsautocomplete.h"
#include <qmldesigner/textmodifier/indentingtexteditormodifier.h>
@@ -48,14 +49,12 @@ EffectCodeEditorWidget::EffectCodeEditorWidget()
* We have to register our own active auto completion shortcut, because the original shortcut will
* use the cursor position of the original editor in the editor manager.
*/
m_completionAction = new QAction(tr("Trigger Completion"), this);
m_completionAction = new QAction(Tr::tr("Trigger Completion"), this);
Core::Command *command = Core::ActionManager::registerAction(
m_completionAction, TextEditor::Constants::COMPLETE_THIS, context);
command->setDefaultKeySequence(QKeySequence(
Core::useMacShortcuts
? tr("Meta+Space")
: tr("Ctrl+Space")));
command->setDefaultKeySequence(
QKeySequence(Core::useMacShortcuts ? Tr::tr("Meta+Space") : Tr::tr("Ctrl+Space")));
connect(m_completionAction, &QAction::triggered, this, [this] {
invokeAssist(TextEditor::Completion);
@@ -148,7 +147,7 @@ void EffectDocument::triggerPendingUpdates()
EffectCodeEditorFactory::EffectCodeEditorFactory()
{
setId(EFFECTEDITOR_CONTEXT_ID);
setDisplayName(::Core::Tr::tr("Effect Code Editor"));
setDisplayName(Tr::tr("Effect Code Editor"));
addMimeType(EFFECTEDITOR_CONTEXT_ID);
addMimeType(Utils::Constants::QML_MIMETYPE);
addMimeType(Utils::Constants::QMLTYPES_MIMETYPE);

View File

@@ -4,6 +4,7 @@
#include "effectcomposereditablenodesmodel.h"
#include "effectcomposermodel.h"
#include "effectcomposertr.h"
namespace EffectComposer {
@@ -140,7 +141,7 @@ void EffectComposerEditableNodesModel::reload()
const int mainIdx = m_sourceModel->mainCodeEditorIndex();
m_data.append(Item{tr("Main"), mainIdx});
m_data.append(Item{Tr::tr("Main"), mainIdx});
m_sourceToItemMap.insert(mainIdx, 0);
const int sourceSize = m_sourceModel->rowCount();
for (int i = 0; i < sourceSize; ++i) {

View File

@@ -4,6 +4,7 @@
#include "effectcomposermodel.h"
#include "compositionnode.h"
#include "effectcomposertr.h"
#include "effectshaderscodeeditor.h"
#include "effectutils.h"
#include "propertyhandler.h"
@@ -292,9 +293,9 @@ QString EffectComposerModel::getUniqueEffectName() const
QString EffectComposerModel::getUniqueDisplayName(const QStringList reservedNames) const
{
return QmlDesigner::UniqueName::generate(tr("New Property"), [&reservedNames] (const QString &name) {
return reservedNames.contains(name);
});
return QmlDesigner::UniqueName::generate(
Tr::tr("New Property"),
[&reservedNames](const QString &name) { return reservedNames.contains(name); });
}
bool EffectComposerModel::nameExists(const QString &name) const
@@ -315,10 +316,11 @@ void EffectComposerModel::chooseCustomPreviewImage()
QmlDesigner::DesignDocument *document = QmlDesigner::QmlDesignerPlugin::instance()->currentDesignDocument();
const FilePath currentDir = lastDir.isEmpty() ? document->fileName().parentDir()
: lastDir;
const QStringList fileNames = QFileDialog::getOpenFileNames(Core::ICore::dialogParent(),
tr("Select custom effect background image"),
const QStringList fileNames = QFileDialog::getOpenFileNames(
Core::ICore::dialogParent(),
Tr::tr("Select Custom Effect Background Image"),
currentDir.toFSPathString(),
tr("Image Files (%1)").arg(suffixes.join(" ")));
Tr::tr("Image Files (%1)").arg(suffixes.join(" ")));
if (!fileNames.isEmpty()) {
FilePath imageFile = FilePath::fromString(fileNames.first());
@@ -618,22 +620,20 @@ void EffectComposerModel::setEffectError(const QString &errorMessage, int type,
QString EffectComposerModel::effectErrors() const
{
static const QStringList errorTypeStrings {
"Common",
"QML parsing",
"Shader",
"Preprocessor"
};
static const QString messageTemplate = tr("%1 error: %2\n");
QString retval;
static const QStringList errorTypeStrings{
Tr::tr("Common error: %1"),
Tr::tr("QML parsing error: %1"),
Tr::tr("Shader error: %1"),
Tr::tr("Preprocessor error: %1")};
QString retval;
for (const QList<EffectError> &errors : std::as_const(m_effectErrors)) {
for (const EffectError &e : errors) {
if (!e.m_message.isEmpty()) {
int index = e.m_type;
if (index < 0 || index >= errorTypeStrings.size())
index = 0;
retval.append(messageTemplate.arg(errorTypeStrings[index], e.m_message));
retval.append(errorTypeStrings[index].arg(e.m_message) + "\n");
}
}
}
@@ -860,7 +860,10 @@ R"(
ExpandingSpacer {}
}
)";
s += animSec.arg(tr("Animation"), tr("Running"), tr("Set this property to animate the effect."));
s += animSec.arg(
Tr::tr("Animation"),
Tr::tr("Running"),
Tr::tr("Set this property to animate the effect."));
if (m_shaderFeatures.enabled(ShaderFeatures::Time)) {
QString timeProp =
@@ -884,7 +887,10 @@ R"(
ExpandingSpacer {}
}
)";
s += timeProp.arg(tr("Time"), tr("This property allows explicit control of current animation time when Running property is false."));
s += timeProp.arg(
Tr::tr("Time"),
Tr::tr("This property allows explicit control of current animation time when "
"Running property is false."));
}
if (m_shaderFeatures.enabled(ShaderFeatures::Frame)) {
@@ -909,7 +915,10 @@ R"(
ExpandingSpacer {}
}
)";
s += frameProp.arg(tr("Frame"), tr("This property allows explicit control of current animation frame when Running property is false."));
s += frameProp.arg(
Tr::tr("Frame"),
Tr::tr("This property allows explicit control of current animation frame when "
"Running property is false."));
}
s += " }\n";
@@ -945,8 +954,11 @@ R"(
}
}
)";
s += generalSection.arg(tr("General"), tr("Extra Margin"),
tr("This property specifies how much of extra space is reserved for the effect outside the parent geometry."));
s += generalSection.arg(
Tr::tr("General"),
Tr::tr("Extra Margin"),
Tr::tr("This property specifies how much of extra space is reserved for the effect "
"outside the parent geometry."));
}
for (const auto &node : std::as_const(m_nodes)) {

View File

@@ -0,0 +1,15 @@
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <QCoreApplication>
namespace EffectComposer {
struct Tr
{
Q_DECLARE_TR_FUNCTIONS(QtC::EffectComposer)
};
} // namespace EffectComposee

View File

@@ -3,6 +3,7 @@
#include "effectcomposeruniformstablemodel.h"
#include "effectcomposertr.h"
#include "uniform.h"
#include <utils/algorithm.h>
@@ -15,14 +16,6 @@ namespace EffectComposer {
namespace {
struct Tr
{
static inline QString tr(const auto &text)
{
return EffectComposerUniformsTableModel::tr(text);
}
};
struct RoleColMap
{
using UniformRole = EffectComposerUniformsModel::Roles;

View File

@@ -5,6 +5,7 @@
#include "effectcomposermodel.h"
#include "effectcomposernodesmodel.h"
#include "effectcomposertr.h"
#include "effectcomposerwidget.h"
#include "listmodelwidthcalculator.h"
#include "studioquickwidget.h"
@@ -113,10 +114,11 @@ QmlDesigner::WidgetInfo EffectComposerView::widgetInfo()
});
}
return createWidgetInfo(m_widget.data(),
return createWidgetInfo(
m_widget.data(),
"EffectComposer",
QmlDesigner::WidgetInfo::LeftPane,
tr("Effect Composer [beta]"));
Tr::tr("Effect Composer [beta]"));
}
void EffectComposerView::customNotification([[maybe_unused]] const AbstractView *view,

View File

@@ -6,6 +6,7 @@
#include "effectcomposercontextobject.h"
#include "effectcomposermodel.h"
#include "effectcomposernodesmodel.h"
#include "effectcomposertr.h"
#include "effectcomposerview.h"
#include "effectutils.h"
#include "propertyhandler.h"
@@ -76,7 +77,7 @@ EffectComposerWidget::EffectComposerWidget(EffectComposerView *view)
, m_effectComposerView(view)
, m_quickWidget{new StudioQuickWidget(this)}
{
setWindowTitle(tr("Effect Composer", "Title of effect composer widget"));
setWindowTitle(Tr::tr("Effect Composer", "Title of effect composer widget"));
setMinimumWidth(400);
// create the inner widget

View File

@@ -5,6 +5,7 @@
#include "effectcomposereditablenodesmodel.h"
#include "effectcomposermodel.h"
#include "effectcomposertr.h"
#include "effectcomposeruniformsmodel.h"
#include "effectcomposeruniformstablemodel.h"
#include "effectcomposerwidget.h"
@@ -271,7 +272,7 @@ void EffectShadersCodeEditor::insertTextToCursorPosition(const QString &text)
EffectShadersCodeEditor *EffectShadersCodeEditor::instance()
{
static EffectShadersCodeEditor *editorInstance
= new EffectShadersCodeEditor(tr("Shaders Code Editor"), Core::ICore::dialogParent());
= new EffectShadersCodeEditor(Tr::tr("Shaders Code Editor"), Core::ICore::dialogParent());
return editorInstance;
}

View File

@@ -4,6 +4,7 @@
#pragma once
#include "effectcodeeditorwidget.h"
#include "effectcomposertr.h"
#include <texteditor/texteditor.h>
@@ -50,7 +51,8 @@ class EffectShadersCodeEditor : public QWidget
NOTIFY selectedShaderChanged)
public:
EffectShadersCodeEditor(const QString &title = tr("Untitled Editor"), QWidget *parent = nullptr);
EffectShadersCodeEditor(
const QString &title = Tr::tr("Untitled Editor"), QWidget *parent = nullptr);
~EffectShadersCodeEditor() override;
void showWidget();

View File

@@ -2,6 +2,9 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "uniform.h"
#include "effectcomposertr.h"
#include <qmldesignerplugin.h>
#include "propertyhandler.h"
@@ -328,27 +331,27 @@ R"(
case Type::Vec2: {
QVector2D minVal = m_minValue.value<QVector2D>();
QVector2D maxVal = m_maxValue.value<QVector2D>();
appendVectorSpinbox("x", tr("X"), minVal.x(), maxVal.x(), true);
appendVectorSpinbox("y", tr("Y"), minVal.y(), maxVal.y(), false);
appendVectorSpinbox("x", Tr::tr("X"), minVal.x(), maxVal.x(), true);
appendVectorSpinbox("y", Tr::tr("Y"), minVal.y(), maxVal.y(), false);
break;
}
case Type::Vec3: {
QVector3D minVal = m_minValue.value<QVector3D>();
QVector3D maxVal = m_maxValue.value<QVector3D>();
appendVectorSpinbox("x", tr("X"), minVal.x(), maxVal.x(), true);
appendVectorSpinbox("y", tr("Y"), minVal.y(), maxVal.y(), false);
appendVectorSpinbox("x", Tr::tr("X"), minVal.x(), maxVal.x(), true);
appendVectorSpinbox("y", Tr::tr("Y"), minVal.y(), maxVal.y(), false);
appendVectorSeparator();
appendVectorSpinbox("z", tr("Z"), minVal.z(), maxVal.z(), true);
appendVectorSpinbox("z", Tr::tr("Z"), minVal.z(), maxVal.z(), true);
break;
}
case Type::Vec4: {
QVector4D minVal = m_minValue.value<QVector4D>();
QVector4D maxVal = m_maxValue.value<QVector4D>();
appendVectorSpinbox("x", tr("X"), minVal.x(), maxVal.x(), true);
appendVectorSpinbox("y", tr("Y"), minVal.y(), maxVal.y(), false);
appendVectorSpinbox("x", Tr::tr("X"), minVal.x(), maxVal.x(), true);
appendVectorSpinbox("y", Tr::tr("Y"), minVal.y(), maxVal.y(), false);
appendVectorSeparator();
appendVectorSpinbox("z", tr("Z"), minVal.z(), maxVal.z(), true);
appendVectorSpinbox("w", tr("W"), minVal.w(), maxVal.w(), false);
appendVectorSpinbox("z", Tr::tr("Z"), minVal.z(), maxVal.z(), true);
appendVectorSpinbox("w", Tr::tr("W"), minVal.w(), maxVal.w(), false);
break;
}
case Type::Color: {
@@ -383,10 +386,13 @@ R"(
backendValue: backendValues.%2
}
)";
specs += typeSpec.arg(m_name + "Url")
specs
+= typeSpec.arg(m_name + "Url")
.arg(m_name)
.arg(m_displayName + tr(" Item"))
.arg(tr("Set this to use an item in the scene as %1 instead of the above image.")
.arg(Tr::tr("%1 Item").arg(m_displayName))
.arg(
Tr::tr(
"Set this to use an item in the scene as %1 instead of the above image.")
.arg(m_displayName));
break;
}