QML: Use new message manager API

That is more evocative. Also avoid some instances of popping up the
general messages pane, which should preferably only happen on direct
user interaction.

Task-number: QTCREATORBUG-24430
Change-Id: I69bb49f84c1486fd32b2a048ca4d76dceb6a0b2b
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Eike Ziller
2020-12-17 10:30:03 +01:00
parent c2911ab7f1
commit 37a0ef29c0
4 changed files with 36 additions and 27 deletions

View File

@@ -89,9 +89,10 @@ void GenerateResource::generateMenuEntry()
if (resourceFileName.isEmpty()) if (resourceFileName.isEmpty())
return; return;
Core::MessageManager::write(QCoreApplication::translate("QmlDesigner::GenerateResource", Core::MessageManager::writeSilently(
"Generate a resource file out of project %1 to %2").arg( QCoreApplication::translate("QmlDesigner::GenerateResource",
currentProject->displayName(), QDir::toNativeSeparators(resourceFileName))); "Generate a resource file out of project %1 to %2")
.arg(currentProject->displayName(), QDir::toNativeSeparators(resourceFileName)));
QTemporaryFile temp(projectPath + "/XXXXXXX.create.resource.qrc"); QTemporaryFile temp(projectPath + "/XXXXXXX.create.resource.qrc");
if (!temp.open()) if (!temp.open())
@@ -111,34 +112,41 @@ void GenerateResource::generateMenuEntry()
for (const auto &arguments : {arguments1, arguments2}) { for (const auto &arguments : {arguments1, arguments2}) {
rccProcess.start(rccBinary.toString(), arguments); rccProcess.start(rccBinary.toString(), arguments);
if (!rccProcess.waitForStarted()) { if (!rccProcess.waitForStarted()) {
Core::MessageManager::write(QCoreApplication::translate("QmlDesigner::GenerateResource", Core::MessageManager::writeDisrupting(
"Unable to generate resource file: %1").arg(resourceFileName)); QCoreApplication::translate("QmlDesigner::GenerateResource",
"Unable to generate resource file: %1")
.arg(resourceFileName));
return; return;
} }
QByteArray stdOut; QByteArray stdOut;
QByteArray stdErr; QByteArray stdErr;
if (!Utils::SynchronousProcess::readDataFromProcess(rccProcess, 30, &stdOut, &stdErr, true)) { if (!Utils::SynchronousProcess::readDataFromProcess(rccProcess, 30, &stdOut, &stdErr, true)) {
Utils::SynchronousProcess::stopProcess(rccProcess); Utils::SynchronousProcess::stopProcess(rccProcess);
Core::MessageManager::write(QCoreApplication::translate("QmlDesigner::GenerateResource", Core::MessageManager::writeDisrupting(
"A timeout occurred running \"%1\"").arg(rccBinary.toString() + arguments.join(" "))); QCoreApplication::translate("QmlDesigner::GenerateResource",
"A timeout occurred running \"%1\"")
.arg(rccBinary.toString() + arguments.join(" ")));
return ; return ;
} }
if (!stdOut.trimmed().isEmpty()) { if (!stdOut.trimmed().isEmpty()) {
Core::MessageManager::write(QString::fromLocal8Bit(stdOut)); Core::MessageManager::writeFlashing(QString::fromLocal8Bit(stdOut));
} }
if (!stdErr.trimmed().isEmpty()) if (!stdErr.trimmed().isEmpty())
Core::MessageManager::write(QString::fromLocal8Bit(stdErr)); Core::MessageManager::writeFlashing(QString::fromLocal8Bit(stdErr));
if (rccProcess.exitStatus() != QProcess::NormalExit) { if (rccProcess.exitStatus() != QProcess::NormalExit) {
Core::MessageManager::write(QCoreApplication::translate("QmlDesigner::GenerateResource", Core::MessageManager::writeDisrupting(
"\"%1\" crashed.").arg(rccBinary.toString() + arguments.join(" "))); QCoreApplication::translate("QmlDesigner::GenerateResource", "\"%1\" crashed.")
.arg(rccBinary.toString() + arguments.join(" ")));
return; return;
} }
if (rccProcess.exitCode() != 0) { if (rccProcess.exitCode() != 0) {
Core::MessageManager::write(QCoreApplication::translate("QmlDesigner::GenerateResource", Core::MessageManager::writeDisrupting(
"\"%1\" failed (exit code %2).").arg(rccBinary.toString() + QCoreApplication::translate("QmlDesigner::GenerateResource",
" " + arguments.join(" ")).arg(rccProcess.exitCode())); "\"%1\" failed (exit code %2).")
.arg(rccBinary.toString() + " " + arguments.join(" "))
.arg(rccProcess.exitCode()));
return; return;
} }

View File

@@ -196,11 +196,13 @@ void QmlPreviewConnectionManager::createPreviewClient()
m_qmlPreviewClient->announceError(path); m_qmlPreviewClient->announceError(path);
}); });
connect(m_qmlPreviewClient.data(), &QmlPreviewClient::errorReported, connect(m_qmlPreviewClient.data(),
this, [](const QString &error) { &QmlPreviewClient::errorReported,
Core::MessageManager::write("Error loading QML Live Preview:"); this,
Core::MessageManager::write(error); [](const QString &error) {
}); Core::MessageManager::writeDisrupting("Error loading QML Live Preview:");
Core::MessageManager::writeSilently(error);
});
connect(m_qmlPreviewClient.data(), &QmlPreviewClient::fpsReported, connect(m_qmlPreviewClient.data(), &QmlPreviewClient::fpsReported,
this, [this](const QmlPreviewClient::FpsInfo &frames) { this, [this](const QmlPreviewClient::FpsInfo &frames) {

View File

@@ -119,7 +119,7 @@ static bool defaultFileClassifier(const QString &filename)
static void defaultFpsHandler(quint16 frames[8]) static void defaultFpsHandler(quint16 frames[8])
{ {
Core::MessageManager::write(QString::fromLatin1("QML preview: %1 fps").arg(frames[0])); Core::MessageManager::writeSilently(QString::fromLatin1("QML preview: %1 fps").arg(frames[0]));
} }
class QmlPreviewPluginPrivate : public QObject class QmlPreviewPluginPrivate : public QObject

View File

@@ -146,10 +146,9 @@ void QmlBuildSystem::parseProject(RefreshOptions options)
this, &QmlBuildSystem::refreshFiles); this, &QmlBuildSystem::refreshFiles);
} else { } else {
MessageManager::write(tr("Error while loading project file %1.") MessageManager::writeFlashing(tr("Error while loading project file %1.")
.arg(projectFilePath().toUserOutput()), .arg(projectFilePath().toUserOutput()));
MessageManager::NoModeSwitch); MessageManager::writeSilently(errorMessage);
MessageManager::write(errorMessage);
} }
} }
if (m_projectItem) { if (m_projectItem) {
@@ -167,9 +166,9 @@ void QmlBuildSystem::parseProject(RefreshOptions options)
Utils::FileReader reader; Utils::FileReader reader;
QString errorMessage; QString errorMessage;
if (!reader.fetch(mainFilePath, &errorMessage)) { if (!reader.fetch(mainFilePath, &errorMessage)) {
MessageManager::write(tr("Warning while loading project file %1.") MessageManager::writeFlashing(tr("Warning while loading project file %1.")
.arg(projectFilePath().toUserOutput())); .arg(projectFilePath().toUserOutput()));
MessageManager::write(errorMessage); MessageManager::writeSilently(errorMessage);
} }
} }
} }