forked from qt-creator/qt-creator
QmlDesigner: Add single translation context to DesignerCore
Change-Id: Ibb2947045ed5d54bccad21c4e00ba7a90ec78000 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -171,6 +171,7 @@ extend_qtc_library(QmlDesignerCore
|
||||
abstractview.h
|
||||
bytearraymodifier.h
|
||||
componenttextmodifier.h
|
||||
designercoretr.h
|
||||
forwardview.h
|
||||
itemlibraryentry.h
|
||||
model.h
|
||||
|
@@ -2,6 +2,9 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "invalidargumentexception.h"
|
||||
|
||||
#include <designercoretr.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QCoreApplication>
|
||||
/*!
|
||||
@@ -19,8 +22,7 @@ QString InvalidArgumentException::invalidArgumentDescription(int line,
|
||||
const QByteArray &argument)
|
||||
{
|
||||
if (QString::fromUtf8(function) == QLatin1String("createNode")) {
|
||||
return QCoreApplication::translate("QmlDesigner::InvalidArgumentException",
|
||||
"Failed to create item of type %1").arg(QString::fromUtf8(argument));
|
||||
return DesignerCore::Tr::tr("Failed to create item of type %1.").arg(QString::fromUtf8(argument));
|
||||
}
|
||||
|
||||
return Exception::defaultDescription(line, function, file);
|
||||
|
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "invalididexception.h"
|
||||
|
||||
#include <designercoretr.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -10,17 +12,15 @@ namespace QmlDesigner {
|
||||
static QString descriptionBasedOnReason(InvalidIdException::Reason reason)
|
||||
{
|
||||
if (reason == InvalidIdException::InvalidCharacters)
|
||||
return QCoreApplication::translate("InvalidIdException",
|
||||
"Only alphanumeric characters and underscore allowed.\n"
|
||||
"Ids must begin with a lowercase letter.");
|
||||
return DesignerCore::Tr::tr("Only alphanumeric characters and underscore allowed.\n"
|
||||
"Ids must begin with a lowercase letter.");
|
||||
|
||||
return QCoreApplication::translate("InvalidIdException", "Ids have to be unique.");
|
||||
return DesignerCore::Tr::tr("Ids have to be unique.");
|
||||
}
|
||||
|
||||
static QString decorateDescriptionWithId(const QString &id, const QString &description)
|
||||
{
|
||||
return QCoreApplication::translate("InvalidIdException", "Invalid Id: %1\n%2")
|
||||
.arg(id, description);
|
||||
return DesignerCore::Tr::tr("Invalid Id: %1\n%2").arg(id, description);
|
||||
}
|
||||
|
||||
InvalidIdException::InvalidIdException(int line,
|
||||
|
@@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2024 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 DesignerCore {
|
||||
|
||||
struct Tr
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QtC::DesignerCore)
|
||||
};
|
||||
|
||||
} // namespace DesignerCore
|
@@ -8,6 +8,7 @@
|
||||
#include "metainforeader.h"
|
||||
#include "modelnode.h"
|
||||
|
||||
#include <designercoretr.h>
|
||||
#include <externaldependenciesinterface.h>
|
||||
#include <invalidmetainfoexception.h>
|
||||
|
||||
@@ -114,8 +115,7 @@ void MetaInfoPrivate::parseItemLibraryDescriptions(const ExternalDependenciesInt
|
||||
const QString errorMessage = plugin->metaInfo() + QLatin1Char('\n') + QLatin1Char('\n')
|
||||
+ reader.errors().join(QLatin1Char('\n'));
|
||||
QMessageBox::warning(nullptr,
|
||||
QCoreApplication::translate(
|
||||
"QmlDesigner::Internal::MetaInfoPrivate", "Invalid meta info"),
|
||||
DesignerCore::Tr::tr("Invalid meta info."),
|
||||
errorMessage); // not nice but the code will be removed in the near future
|
||||
#endif
|
||||
}
|
||||
@@ -132,8 +132,7 @@ void MetaInfoPrivate::parseItemLibraryDescriptions(const ExternalDependenciesInt
|
||||
const QString errorMessage = path.toString() + QLatin1Char('\n') + QLatin1Char('\n')
|
||||
+ reader.errors().join(QLatin1Char('\n'));
|
||||
QMessageBox::warning(nullptr,
|
||||
QCoreApplication::translate(
|
||||
"QmlDesigner::Internal::MetaInfoPrivate", "Invalid meta info"),
|
||||
DesignerCore::Tr::tr("Invalid meta info."),
|
||||
errorMessage); // not nice but the code will be removed in the near future
|
||||
#endif
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include "metainforeader.h"
|
||||
#include "metainfo.h"
|
||||
|
||||
#include <designercoretr.h>
|
||||
#include <invalidmetainfoexception.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -81,8 +82,7 @@ void MetaInfoReader::elementStart(const QString &name,
|
||||
case ParsingHints:
|
||||
case Finished:
|
||||
case Undefined: setParserState(Error);
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Illegal state while parsing."),
|
||||
currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Illegal state while parsing."), currentSourceLocation());
|
||||
case Error:
|
||||
default: return;
|
||||
}
|
||||
@@ -102,8 +102,7 @@ void MetaInfoReader::elementEnd()
|
||||
case ParsingDocument:
|
||||
case Finished:
|
||||
case Undefined: setParserState(Error);
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Illegal state while parsing."),
|
||||
currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Illegal state while parsing."), currentSourceLocation());
|
||||
case Error:
|
||||
default: return;
|
||||
}
|
||||
@@ -123,15 +122,13 @@ void MetaInfoReader::propertyDefinition(const QString &name,
|
||||
case ParsingQmlSource: readQmlSourceProperty(name, value); break;
|
||||
case ParsingExtraFile: readExtraFileProperty(name, value); break;
|
||||
case ParsingMetaInfo:
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("No property definition allowed."),
|
||||
currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("No property definition allowed."), currentSourceLocation());
|
||||
break;
|
||||
case ParsingDocument:
|
||||
case ParsingHints: readHint(name, value); break;
|
||||
case Finished:
|
||||
case Undefined: setParserState(Error);
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Illegal state while parsing."),
|
||||
currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Illegal state while parsing."), currentSourceLocation());
|
||||
case Error:
|
||||
default: return;
|
||||
}
|
||||
@@ -194,30 +191,26 @@ MetaInfoReader::ParserSate MetaInfoReader::readItemLibraryEntryElement(const QSt
|
||||
} else if (name == ExtraFileElementName) {
|
||||
return ParsingExtraFile;
|
||||
} else {
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Invalid type %1").arg(name),
|
||||
currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Invalid type %1.").arg(name), currentSourceLocation());
|
||||
return Error;
|
||||
}
|
||||
}
|
||||
|
||||
MetaInfoReader::ParserSate MetaInfoReader::readPropertyElement(const QString &name)
|
||||
{
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Invalid type %1").arg(name),
|
||||
currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Invalid type %1.").arg(name), currentSourceLocation());
|
||||
return Error;
|
||||
}
|
||||
|
||||
MetaInfoReader::ParserSate MetaInfoReader::readQmlSourceElement(const QString &name)
|
||||
{
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Invalid type %1").arg(name),
|
||||
currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Invalid type %1.").arg(name), currentSourceLocation());
|
||||
return Error;
|
||||
}
|
||||
|
||||
MetaInfoReader::ParserSate MetaInfoReader::readExtraFileElement(const QString &name)
|
||||
{
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Invalid type %1").arg(name),
|
||||
currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Invalid type %1.").arg(name), currentSourceLocation());
|
||||
return Error;
|
||||
}
|
||||
|
||||
@@ -230,8 +223,7 @@ void MetaInfoReader::readTypeProperty(const QString &name, const QVariant &value
|
||||
} else if (name == QStringLiteral("icon")) {
|
||||
m_currentIcon = absoluteFilePathForDocument(value.toString());
|
||||
} else {
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Unknown property for Type %1")
|
||||
.arg(name),
|
||||
addError(DesignerCore::Tr::tr("Unknown property for Type %1.").arg(name),
|
||||
currentSourceLocation());
|
||||
setParserState(Error);
|
||||
}
|
||||
@@ -252,9 +244,7 @@ void MetaInfoReader::readItemLibraryEntryProperty(const QString &name, const QVa
|
||||
} else if (name == QStringLiteral("toolTip")) {
|
||||
m_currentEntry.setToolTip(value.toString());
|
||||
} else {
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr(
|
||||
"Unknown property for ItemLibraryEntry %1")
|
||||
.arg(name),
|
||||
addError(DesignerCore::Tr::tr("Unknown property for ItemLibraryEntry %1.").arg(name),
|
||||
currentSourceLocation());
|
||||
setParserState(Error);
|
||||
}
|
||||
@@ -285,8 +275,7 @@ void MetaInfoReader::readPropertyProperty(const QString &name, const QVariant &v
|
||||
} else if (name == QStringLiteral("value")) {
|
||||
m_currentPropertyValue = deEscapeVariant(value);
|
||||
} else {
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Unknown property for Property %1")
|
||||
.arg(name),
|
||||
addError(DesignerCore::Tr::tr("Unknown property for Property %1.").arg(name),
|
||||
currentSourceLocation());
|
||||
setParserState(Error);
|
||||
}
|
||||
@@ -297,8 +286,7 @@ void MetaInfoReader::readQmlSourceProperty(const QString &name, const QVariant &
|
||||
if (name == QLatin1String("source")) {
|
||||
m_currentEntry.setQmlPath(absoluteFilePathForDocument(value.toString()));
|
||||
} else {
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Unknown property for QmlSource %1")
|
||||
.arg(name),
|
||||
addError(DesignerCore::Tr::tr("Unknown property for QmlSource %1.").arg(name),
|
||||
currentSourceLocation());
|
||||
setParserState(Error);
|
||||
}
|
||||
@@ -309,8 +297,7 @@ void MetaInfoReader::readExtraFileProperty(const QString &name, const QVariant &
|
||||
if (name == QLatin1String("source")) {
|
||||
m_currentEntry.addExtraFilePath(absoluteFilePathForDocument(value.toString()));
|
||||
} else {
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Unknown property for ExtraFile %1")
|
||||
.arg(name),
|
||||
addError(DesignerCore::Tr::tr("Unknown property for ExtraFile %1.").arg(name),
|
||||
currentSourceLocation());
|
||||
setParserState(Error);
|
||||
}
|
||||
@@ -358,9 +345,7 @@ void MetaInfoReader::syncItemLibraryEntries()
|
||||
try {
|
||||
m_metaInfo.itemLibraryInfo()->addEntries(m_bufferedEntries, m_overwriteDuplicates);
|
||||
} catch (const InvalidMetaInfoException &) {
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr(
|
||||
"Invalid or duplicate library entry %1")
|
||||
.arg(m_currentEntry.name()),
|
||||
addError(DesignerCore::Tr::tr("Invalid or duplicate library entry %1.").arg(m_currentEntry.name()),
|
||||
currentSourceLocation());
|
||||
}
|
||||
m_bufferedEntries.clear();
|
||||
@@ -378,8 +363,7 @@ void MetaInfoReader::insertProperty()
|
||||
|
||||
void MetaInfoReader::addErrorInvalidType(const QString &typeName)
|
||||
{
|
||||
addError(::QmlDesigner::Internal::MetaInfoReader::tr("Invalid type %1").arg(typeName),
|
||||
currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Invalid type %1.").arg(typeName), currentSourceLocation());
|
||||
}
|
||||
|
||||
QString MetaInfoReader::absoluteFilePathForDocument(const QString &relativeFilePath)
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include "subcomponentmanager.h"
|
||||
#include "metainforeader.h"
|
||||
|
||||
#include <designercoretr.h>
|
||||
#include <externaldependenciesinterface.h>
|
||||
#include <invalidmetainfoexception.h>
|
||||
#include <model.h>
|
||||
@@ -214,11 +215,9 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a
|
||||
} catch (const InvalidMetaInfoException &e) {
|
||||
qWarning() << e.description();
|
||||
const QString errorMessage = metaInfoFile.absoluteFilePath() + QLatin1Char('\n') + QLatin1Char('\n') + reader.errors().join(QLatin1Char('\n'));
|
||||
QMessageBox::warning(
|
||||
m_externalDependencies.mainWindow(),
|
||||
QCoreApplication::translate("SubComponentManager::parseDirectory",
|
||||
"Invalid meta info"),
|
||||
errorMessage);
|
||||
QMessageBox::warning(m_externalDependencies.mainWindow(),
|
||||
DesignerCore::Tr::tr("Invalid meta info."),
|
||||
errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -434,7 +433,7 @@ void SubComponentManager::parseQuick3DAssetsItem(const QString &importUrl, const
|
||||
ItemLibraryEntry itemLibraryEntry;
|
||||
itemLibraryEntry.setType(type.toUtf8(), 1, 0);
|
||||
itemLibraryEntry.setName(name);
|
||||
itemLibraryEntry.setCategory(::QmlDesigner::SubComponentManager::tr("My 3D Components"));
|
||||
itemLibraryEntry.setCategory(DesignerCore::Tr::tr("My 3D Components"));
|
||||
itemLibraryEntry.setCustomComponentSource(qmlIt.fileInfo().absoluteFilePath());
|
||||
itemLibraryEntry.setRequiredImport(importUrl);
|
||||
itemLibraryEntry.setTypeIcon(QIcon(defaultIconPath));
|
||||
|
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <documentmessage.h>
|
||||
|
||||
#include <designercoretr.h>
|
||||
|
||||
#include <qmljs/parser/qmljsengine_p.h>
|
||||
#include <qmljs/parser/qmljsdiagnosticmessage_p.h>
|
||||
|
||||
@@ -48,9 +50,9 @@ QString DocumentMessage::toString() const
|
||||
QString str;
|
||||
|
||||
if (m_type == ParseError)
|
||||
str += ::QmlDesigner::DocumentMessage::tr("Error parsing");
|
||||
str += DesignerCore::Tr::tr("Error parsing");
|
||||
else if (m_type == InternalError)
|
||||
str += ::QmlDesigner::DocumentMessage::tr("Internal error");
|
||||
str += DesignerCore::Tr::tr("Internal error");
|
||||
|
||||
if (url().isValid()) {
|
||||
if (!str.isEmpty())
|
||||
@@ -62,14 +64,16 @@ QString DocumentMessage::toString() const
|
||||
if (line() != -1) {
|
||||
if (!str.isEmpty())
|
||||
str += QLatin1Char(' ');
|
||||
str += ::QmlDesigner::DocumentMessage::tr("line %1\n").arg(line());
|
||||
str += DesignerCore::Tr::tr("line %1").arg(line());
|
||||
str += "\n";
|
||||
}
|
||||
|
||||
if (column() != -1) {
|
||||
if (!str.isEmpty())
|
||||
str += QLatin1Char(' ');
|
||||
|
||||
str += ::QmlDesigner::DocumentMessage::tr("column %1\n").arg(column());
|
||||
str += DesignerCore::Tr::tr("column %1").arg(column());
|
||||
str += "\n";
|
||||
}
|
||||
|
||||
if (!str.isEmpty())
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "annotation.h"
|
||||
#include "bindingproperty.h"
|
||||
#include "designercoretr.h"
|
||||
#include "internalnode_p.h"
|
||||
#include "model_p.h"
|
||||
#include "nodeabstractproperty.h"
|
||||
@@ -105,24 +106,24 @@ QString ModelNode::getIdValidityErrorMessage(const QString &id)
|
||||
return {}; // valid
|
||||
|
||||
if (id.at(0).isUpper())
|
||||
return ::QObject::tr("ID cannot start with an uppercase character (%1).").arg(id);
|
||||
return DesignerCore::Tr::tr("ID cannot start with an uppercase character (%1).").arg(id);
|
||||
|
||||
if (id.at(0).isDigit())
|
||||
return ::QObject::tr("ID cannot start with a number (%1).").arg(id);
|
||||
return DesignerCore::Tr::tr("ID cannot start with a number (%1).").arg(id);
|
||||
|
||||
if (id.contains(' '))
|
||||
return ::QObject::tr("ID cannot include whitespace (%1).").arg(id);
|
||||
return DesignerCore::Tr::tr("ID cannot include whitespace (%1).").arg(id);
|
||||
|
||||
if (ModelUtils::isQmlKeyword(id))
|
||||
return ::QObject::tr("%1 is a reserved QML keyword.").arg(id);
|
||||
return DesignerCore::Tr::tr("%1 is a reserved QML keyword.").arg(id);
|
||||
|
||||
if (ModelUtils::isQmlBuiltinType(id))
|
||||
return ::QObject::tr("%1 is a reserved Qml type.").arg(id);
|
||||
return DesignerCore::Tr::tr("%1 is a reserved Qml type.").arg(id);
|
||||
|
||||
if (ModelUtils::isDiscouragedQmlId(id))
|
||||
return ::QObject::tr("%1 is a reserved property keyword.").arg(id);
|
||||
return DesignerCore::Tr::tr("%1 is a reserved property keyword.").arg(id);
|
||||
|
||||
return ::QObject::tr("ID includes invalid characters (%1).").arg(id);
|
||||
return DesignerCore::Tr::tr("ID includes invalid characters (%1).").arg(id);
|
||||
}
|
||||
|
||||
bool ModelNode::hasId() const
|
||||
|
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "widgetpluginpath.h"
|
||||
#include <designercoretr.h>
|
||||
#include <iwidgetplugin.h>
|
||||
|
||||
#include <utils/filepath.h>
|
||||
@@ -42,18 +43,17 @@ static IWidgetPlugin *instance(WidgetPluginData &p)
|
||||
|
||||
if (!(loader.isLoaded() || loader.load())) {
|
||||
p.failed = true;
|
||||
p.errorMessage = QCoreApplication::translate("WidgetPluginManager",
|
||||
"Failed to create instance of file "
|
||||
"\"%1\": %2").arg(p.path).arg(loader.errorString());
|
||||
p.errorMessage = DesignerCore::Tr::tr("Failed to create instance of file "
|
||||
"\"%1\": %2")
|
||||
.arg(p.path)
|
||||
.arg(loader.errorString());
|
||||
qWarning() << p.errorMessage;
|
||||
return nullptr;
|
||||
}
|
||||
QObject *object = loader.instance();
|
||||
if (!object) {
|
||||
p.failed = true;
|
||||
p.errorMessage = QCoreApplication::translate("WidgetPluginManager",
|
||||
"Failed to create instance of file \"%1\"."
|
||||
).arg(p.path);
|
||||
p.errorMessage = DesignerCore::Tr::tr("Failed to create instance of file \"%1\".").arg(p.path);
|
||||
qWarning() << p.errorMessage;
|
||||
return nullptr;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "projectstorage.h"
|
||||
|
||||
#include <designercoretr.h>
|
||||
#include <invalidmetainfoexception.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -81,7 +82,7 @@ void TypeAnnotationReader::elementStart(const QString &name,
|
||||
case Finished:
|
||||
case Undefined:
|
||||
setParserState(Error);
|
||||
addError(TypeAnnotationReader::tr("Illegal state while parsing."), currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Illegal state while parsing."), currentSourceLocation());
|
||||
[[fallthrough]];
|
||||
case Error:
|
||||
break;
|
||||
@@ -120,7 +121,7 @@ void TypeAnnotationReader::elementEnd()
|
||||
case Finished:
|
||||
case Undefined:
|
||||
setParserState(Error);
|
||||
addError(TypeAnnotationReader::tr("Illegal state while parsing."), currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Illegal state while parsing."), currentSourceLocation());
|
||||
[[fallthrough]];
|
||||
case Error:
|
||||
break;
|
||||
@@ -149,7 +150,7 @@ void TypeAnnotationReader::propertyDefinition(const QString &name,
|
||||
readExtraFileProperty(name, value);
|
||||
break;
|
||||
case ParsingMetaInfo:
|
||||
addError(TypeAnnotationReader::tr("No property definition allowed."), currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("No property definition allowed."), currentSourceLocation());
|
||||
break;
|
||||
case ParsingDocument:
|
||||
case ParsingHints:
|
||||
@@ -158,7 +159,7 @@ void TypeAnnotationReader::propertyDefinition(const QString &name,
|
||||
case Finished:
|
||||
case Undefined:
|
||||
setParserState(Error);
|
||||
addError(TypeAnnotationReader::tr("Illegal state while parsing."), currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Illegal state while parsing."), currentSourceLocation());
|
||||
[[fallthrough]];
|
||||
case Error:
|
||||
break;
|
||||
@@ -218,26 +219,26 @@ TypeAnnotationReader::ParserSate TypeAnnotationReader::readItemLibraryEntryEleme
|
||||
} else if (name == extraFileElementName) {
|
||||
return ParsingExtraFile;
|
||||
} else {
|
||||
addError(TypeAnnotationReader::tr("Invalid type %1").arg(name), currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Invalid type %1.").arg(name), currentSourceLocation());
|
||||
return Error;
|
||||
}
|
||||
}
|
||||
|
||||
TypeAnnotationReader::ParserSate TypeAnnotationReader::readPropertyElement(const QString &name)
|
||||
{
|
||||
addError(TypeAnnotationReader::tr("Invalid type %1").arg(name), currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Invalid type %1.").arg(name), currentSourceLocation());
|
||||
return Error;
|
||||
}
|
||||
|
||||
TypeAnnotationReader::ParserSate TypeAnnotationReader::readQmlSourceElement(const QString &name)
|
||||
{
|
||||
addError(TypeAnnotationReader::tr("Invalid type %1").arg(name), currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Invalid type %1.").arg(name), currentSourceLocation());
|
||||
return Error;
|
||||
}
|
||||
|
||||
TypeAnnotationReader::ParserSate TypeAnnotationReader::readExtraFileElement(const QString &name)
|
||||
{
|
||||
addError(TypeAnnotationReader::tr("Invalid type %1").arg(name), currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Invalid type %1.").arg(name), currentSourceLocation());
|
||||
return Error;
|
||||
}
|
||||
|
||||
@@ -271,7 +272,7 @@ void TypeAnnotationReader::readTypeProperty(QStringView name, const QVariant &va
|
||||
} else if (name == "icon"_L1) {
|
||||
m_typeAnnotations.back().iconPath = absoluteFilePathForDocument(value.toString());
|
||||
} else {
|
||||
addError(TypeAnnotationReader::tr("Unknown property for Type %1").arg(name),
|
||||
addError(DesignerCore::Tr::tr("Unknown property for Type %1.").arg(name),
|
||||
currentSourceLocation());
|
||||
setParserState(Error);
|
||||
}
|
||||
@@ -293,7 +294,7 @@ void TypeAnnotationReader::readItemLibraryEntryProperty(QStringView name, const
|
||||
} else if (name == "toolTip"_L1) {
|
||||
m_itemLibraryEntries.back()["toolTip"] = value;
|
||||
} else {
|
||||
addError(TypeAnnotationReader::tr("Unknown property for ItemLibraryEntry %1").arg(name),
|
||||
addError(DesignerCore::Tr::tr("Unknown property for ItemLibraryEntry %1.").arg(name),
|
||||
currentSourceLocation());
|
||||
setParserState(Error);
|
||||
}
|
||||
@@ -327,7 +328,7 @@ void TypeAnnotationReader::readPropertyProperty(QStringView name, const QVariant
|
||||
} else if (name == "value"_L1) {
|
||||
m_currentProperty.value = deEscapeVariant(value);
|
||||
} else {
|
||||
addError(TypeAnnotationReader::tr("Unknown property for Property %1").arg(name),
|
||||
addError(DesignerCore::Tr::tr("Unknown property for Property %1.").arg(name),
|
||||
currentSourceLocation());
|
||||
setParserState(Error);
|
||||
}
|
||||
@@ -338,7 +339,7 @@ void TypeAnnotationReader::readQmlSourceProperty(QStringView name, const QVarian
|
||||
if (name == "source"_L1) {
|
||||
m_itemLibraryEntries.back()["templatePath"] = absoluteFilePathForDocument(value.toString());
|
||||
} else {
|
||||
addError(TypeAnnotationReader::tr("Unknown property for QmlSource %1").arg(name),
|
||||
addError(DesignerCore::Tr::tr("Unknown property for QmlSource %1.").arg(name),
|
||||
currentSourceLocation());
|
||||
setParserState(Error);
|
||||
}
|
||||
@@ -350,7 +351,7 @@ void TypeAnnotationReader::readExtraFileProperty(QStringView name, const QVarian
|
||||
m_itemLibraryEntries.back()["extraFilePaths"].push_back(
|
||||
absoluteFilePathForDocument(value.toString()));
|
||||
} else {
|
||||
addError(TypeAnnotationReader::tr("Unknown property for ExtraFile %1").arg(name),
|
||||
addError(DesignerCore::Tr::tr("Unknown property for ExtraFile %1.").arg(name),
|
||||
currentSourceLocation());
|
||||
setParserState(Error);
|
||||
}
|
||||
@@ -484,7 +485,7 @@ void TypeAnnotationReader::insertProperty()
|
||||
|
||||
void TypeAnnotationReader::addErrorInvalidType(const QString &typeName)
|
||||
{
|
||||
addError(TypeAnnotationReader::tr("Invalid type %1").arg(typeName), currentSourceLocation());
|
||||
addError(DesignerCore::Tr::tr("Invalid type %1.").arg(typeName), currentSourceLocation());
|
||||
}
|
||||
|
||||
Utils::PathString TypeAnnotationReader::absoluteFilePathForDocument(Utils::PathString relativeFilePath)
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "abstractproperty.h"
|
||||
#include "bindingproperty.h"
|
||||
#include "designercoretr.h"
|
||||
#include "documentmessage.h"
|
||||
#include "filemanager/firstdefinitionfinder.h"
|
||||
#include "filemanager/objectlengthcalculator.h"
|
||||
@@ -938,7 +939,7 @@ Document::MutablePtr TextToModelMerger::createParsedDocument(const QUrl &url, co
|
||||
if (data.isEmpty()) {
|
||||
if (errors) {
|
||||
QmlJS::DiagnosticMessage msg;
|
||||
msg.message = QObject::tr("Empty document");
|
||||
msg.message = DesignerCore::Tr::tr("Empty document.");
|
||||
errors->append(DocumentMessage(msg, url));
|
||||
}
|
||||
return {};
|
||||
@@ -2174,7 +2175,10 @@ void TextToModelMerger::collectLinkErrors(QList<DocumentMessage> *errors, const
|
||||
void TextToModelMerger::collectImportErrors(QList<DocumentMessage> *errors)
|
||||
{
|
||||
if (m_rewriterView->model()->imports().isEmpty()) {
|
||||
const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger", "No import statements found."));
|
||||
const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error,
|
||||
SourceLocation(0, 0, 0, 0),
|
||||
DesignerCore::Tr::tr(
|
||||
"No import statements found."));
|
||||
errors->append(
|
||||
DocumentMessage(diagnosticMessage, QUrl::fromLocalFile(m_document->fileName().path())));
|
||||
}
|
||||
@@ -2192,9 +2196,7 @@ void TextToModelMerger::collectImportErrors(QList<DocumentMessage> *errors)
|
||||
const QmlJS::DiagnosticMessage diagnosticMessage(
|
||||
QmlJS::Severity::Error,
|
||||
SourceLocation(0, 0, 0, 0),
|
||||
QCoreApplication::translate(
|
||||
"QmlDesigner::TextToModelMerger",
|
||||
"Qt Quick 6 is not supported with a Qt 5 kit."));
|
||||
DesignerCore::Tr::tr("Qt Quick 6 is not supported with a Qt 5 kit."));
|
||||
errors->prepend(
|
||||
DocumentMessage(diagnosticMessage,
|
||||
QUrl::fromLocalFile(m_document->fileName().path())));
|
||||
@@ -2203,8 +2205,7 @@ void TextToModelMerger::collectImportErrors(QList<DocumentMessage> *errors)
|
||||
const QmlJS::DiagnosticMessage diagnosticMessage(
|
||||
QmlJS::Severity::Error,
|
||||
SourceLocation(0, 0, 0, 0),
|
||||
QCoreApplication::translate("QmlDesigner::TextToModelMerger",
|
||||
"The Design Mode requires a valid Qt kit."));
|
||||
DesignerCore::Tr::tr("The Design Mode requires a valid Qt kit."));
|
||||
errors->prepend(DocumentMessage(diagnosticMessage,
|
||||
QUrl::fromLocalFile(m_document->fileName().path())));
|
||||
}
|
||||
@@ -2212,7 +2213,7 @@ void TextToModelMerger::collectImportErrors(QList<DocumentMessage> *errors)
|
||||
}
|
||||
|
||||
if (!hasQtQuick)
|
||||
errors->append(DocumentMessage(QCoreApplication::translate("QmlDesigner::TextToModelMerger", "No import for Qt Quick found.")));
|
||||
errors->append(DocumentMessage(DesignerCore::Tr::tr("No import for Qt Quick found.")));
|
||||
}
|
||||
|
||||
void TextToModelMerger::collectSemanticErrorsAndWarnings(
|
||||
|
Reference in New Issue
Block a user