diff --git a/src/plugins/effectcomposer/CMakeLists.txt b/src/plugins/effectcomposer/CMakeLists.txt index 04c620c4980..9c73910ca39 100644 --- a/src/plugins/effectcomposer/CMakeLists.txt +++ b/src/plugins/effectcomposer/CMakeLists.txt @@ -10,6 +10,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 diff --git a/src/plugins/effectcomposer/effectcodeeditorwidget.cpp b/src/plugins/effectcomposer/effectcodeeditorwidget.cpp index 0cfaf8d3bf1..0f95212a15e 100644 --- a/src/plugins/effectcomposer/effectcodeeditorwidget.cpp +++ b/src/plugins/effectcomposer/effectcodeeditorwidget.cpp @@ -3,6 +3,7 @@ #include "effectcodeeditorwidget.h" +#include "effectcomposertr.h" #include "effectsautocomplete.h" #include "syntaxhighlighter.h" @@ -49,14 +50,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); @@ -149,7 +148,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); diff --git a/src/plugins/effectcomposer/effectcomposereditablenodesmodel.cpp b/src/plugins/effectcomposer/effectcomposereditablenodesmodel.cpp index 6f258d6ac8f..04b7d7a3222 100644 --- a/src/plugins/effectcomposer/effectcomposereditablenodesmodel.cpp +++ b/src/plugins/effectcomposer/effectcomposereditablenodesmodel.cpp @@ -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) { diff --git a/src/plugins/effectcomposer/effectcomposermodel.cpp b/src/plugins/effectcomposer/effectcomposermodel.cpp index b695d0c567e..e2cc3ba13e6 100644 --- a/src/plugins/effectcomposer/effectcomposermodel.cpp +++ b/src/plugins/effectcomposer/effectcomposermodel.cpp @@ -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"), - currentDir.toFSPathString(), - tr("Image Files (%1)").arg(suffixes.join(" "))); + const QStringList fileNames = QFileDialog::getOpenFileNames( + Core::ICore::dialogParent(), + Tr::tr("Select Custom Effect Background Image"), + currentDir.toFSPathString(), + 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 &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)) { diff --git a/src/plugins/effectcomposer/effectcomposertr.h b/src/plugins/effectcomposer/effectcomposertr.h new file mode 100644 index 00000000000..ee0250c20c0 --- /dev/null +++ b/src/plugins/effectcomposer/effectcomposertr.h @@ -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 + +namespace EffectComposer { + +struct Tr +{ + Q_DECLARE_TR_FUNCTIONS(QtC::EffectComposer) +}; + +} // namespace EffectComposee diff --git a/src/plugins/effectcomposer/effectcomposeruniformstablemodel.cpp b/src/plugins/effectcomposer/effectcomposeruniformstablemodel.cpp index f6ac9c7d443..f2bb77e6961 100644 --- a/src/plugins/effectcomposer/effectcomposeruniformstablemodel.cpp +++ b/src/plugins/effectcomposer/effectcomposeruniformstablemodel.cpp @@ -3,6 +3,7 @@ #include "effectcomposeruniformstablemodel.h" +#include "effectcomposertr.h" #include "uniform.h" #include @@ -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; diff --git a/src/plugins/effectcomposer/effectcomposerview.cpp b/src/plugins/effectcomposer/effectcomposerview.cpp index ece8c00fccb..7a228c4e934 100644 --- a/src/plugins/effectcomposer/effectcomposerview.cpp +++ b/src/plugins/effectcomposer/effectcomposerview.cpp @@ -5,6 +5,7 @@ #include "effectcomposermodel.h" #include "effectcomposernodesmodel.h" +#include "effectcomposertr.h" #include "effectcomposerwidget.h" #include "listmodelwidthcalculator.h" #include "studioquickwidget.h" @@ -120,10 +121,11 @@ QmlDesigner::WidgetInfo EffectComposerView::widgetInfo() }); } - return createWidgetInfo(m_widget.data(), - "EffectComposer", - QmlDesigner::WidgetInfo::LeftPane, - tr("Effect Composer [beta]")); + return createWidgetInfo( + m_widget.data(), + "EffectComposer", + QmlDesigner::WidgetInfo::LeftPane, + Tr::tr("Effect Composer [beta]")); } void EffectComposerView::customNotification([[maybe_unused]] const AbstractView *view, diff --git a/src/plugins/effectcomposer/effectcomposerwidget.cpp b/src/plugins/effectcomposer/effectcomposerwidget.cpp index cfbd1252237..427f273961c 100644 --- a/src/plugins/effectcomposer/effectcomposerwidget.cpp +++ b/src/plugins/effectcomposer/effectcomposerwidget.cpp @@ -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" @@ -78,7 +79,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 diff --git a/src/plugins/effectcomposer/effectshaderscodeeditor.cpp b/src/plugins/effectcomposer/effectshaderscodeeditor.cpp index 8eb77c5ae26..2ebd7db8a06 100644 --- a/src/plugins/effectcomposer/effectshaderscodeeditor.cpp +++ b/src/plugins/effectcomposer/effectshaderscodeeditor.cpp @@ -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; } diff --git a/src/plugins/effectcomposer/effectshaderscodeeditor.h b/src/plugins/effectcomposer/effectshaderscodeeditor.h index b6c825ebc04..d520173f712 100644 --- a/src/plugins/effectcomposer/effectshaderscodeeditor.h +++ b/src/plugins/effectcomposer/effectshaderscodeeditor.h @@ -4,6 +4,7 @@ #pragma once #include "effectcodeeditorwidget.h" +#include "effectcomposertr.h" #include @@ -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(); diff --git a/src/plugins/effectcomposer/uniform.cpp b/src/plugins/effectcomposer/uniform.cpp index be25c1c5e47..db7144de49c 100644 --- a/src/plugins/effectcomposer/uniform.cpp +++ b/src/plugins/effectcomposer/uniform.cpp @@ -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 #include "propertyhandler.h" @@ -328,27 +331,27 @@ R"( case Type::Vec2: { QVector2D minVal = m_minValue.value(); QVector2D maxVal = m_maxValue.value(); - 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 maxVal = m_maxValue.value(); - 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 maxVal = m_maxValue.value(); - 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,11 +386,14 @@ R"( backendValue: backendValues.%2 } )"; - 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(m_displayName)); + specs + += typeSpec.arg(m_name + "Url") + .arg(m_name) + .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; } case Type::Define: