aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/assetexporterplugin
diff options
context:
space:
mode:
authorVikas Pachdha <vikas.pachdha@qt.io>2020-06-11 19:56:53 +0200
committerVikas Pachdha <vikas.pachdha@qt.io>2020-06-18 19:20:07 +0000
commit7f1b28626406eb7da39f543181f142a95d9d46c6 (patch)
tree763220ce6db689a7805616e76e4944a734547208 /src/plugins/qmldesigner/assetexporterplugin
parente1e7a1786fdba2dc0aac6cb2d9ad6d3b7688678c (diff)
AssetExporter: Add import notification task
Task-number: QDS-1560 Change-Id: I09c14c22206c299f7a50f1a843c6dc4ebac670e2 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner/assetexporterplugin')
-rw-r--r--src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp16
-rw-r--r--src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.cpp4
-rw-r--r--src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.pri2
-rw-r--r--src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.qbs2
-rw-r--r--src/plugins/qmldesigner/assetexporterplugin/assetexportpluginconstants.h2
-rw-r--r--src/plugins/qmldesigner/assetexporterplugin/exportnotification.cpp58
-rw-r--r--src/plugins/qmldesigner/assetexporterplugin/exportnotification.h33
7 files changed, 113 insertions, 4 deletions
diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp b/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp
index b667584529..812898e378 100644
--- a/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp
+++ b/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp
@@ -24,6 +24,7 @@
****************************************************************************/
#include "assetexporter.h"
#include "componentexporter.h"
+#include "exportnotification.h"
#include "plaintexteditmodifier.h"
#include "rewriterview.h"
@@ -134,6 +135,9 @@ bool AssetExporter::preProcessProject()
void AssetExporter::exportQml(const Utils::FilePaths &qmlFiles, const Utils::FilePath &exportPath,
bool exportAssets)
{
+ ExportNotification::addInfo(tr("Exporting metadata at %1. Export assets: ")
+ .arg(exportPath.toUserOutput())
+ .arg(exportAssets? tr("Yes") : tr("No")));
// TODO Asset export
Q_UNUSED(exportAssets);
m_exportFiles = qmlFiles;
@@ -145,6 +149,7 @@ void AssetExporter::exportQml(const Utils::FilePaths &qmlFiles, const Utils::Fil
void AssetExporter::cancel()
{
+ ExportNotification::addInfo("Cancelling export.");
if (m_preprocessWatcher && !m_preprocessWatcher->isCanceled() &&
!m_preprocessWatcher->isFinished()) {
m_preprocessWatcher->cancel();
@@ -181,8 +186,8 @@ void AssetExporter::notifyLoadError(AssetExporterView::LoadState state)
default:
return;
}
- // TODO. Communicate errors to user
qCDebug(loggerError) << "QML load error:" << errorStr;
+ ExportNotification::addError(tr("Loading QML failed. %1").arg(errorStr));
}
void AssetExporter::onQmlFileLoaded()
@@ -208,24 +213,27 @@ void AssetExporter::loadNextFile()
// Load the next pending file.
const Utils::FilePath file = m_exportFiles.takeFirst();
+ ExportNotification::addInfo(tr("Exporting file %1.").arg(file.toUserOutput()));
qCDebug(loggerInfo) << "Loading next file" << file;
m_view->loadQmlFile(file);
}
void AssetExporter::writeMetadata() const
{
- qCDebug(loggerInfo) << "Writing metadata";
+ ExportNotification::addInfo(tr("Writing metadata to file %1.").
+ arg(m_exportPath.toUserOutput()));
m_currentState.change(ParsingState::WritingJson);
QJsonObject jsonRoot; // TODO: Write plugin info to root
jsonRoot.insert("artboards", m_components);
QJsonDocument doc(jsonRoot);
if (doc.isNull() || doc.isEmpty()) {
- qCDebug(loggerWarn) << "Empty JSON document";
+ ExportNotification::addError(tr("Empty JSON document."));
} else {
Utils::FileSaver saver(m_exportPath.toString(), QIODevice::Text);
saver.write(doc.toJson(QJsonDocument::Indented));
if (!saver.finalize()) {
- qCDebug(loggerError) << "Cannot write Metadata file: " << saver.errorString();
+ ExportNotification::addError(tr("Writing metadata failed. %1").
+ arg(saver.errorString()));
}
}
m_currentState.change(ParsingState::ExportingDone);
diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.cpp b/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.cpp
index e23b516828..6ac8906946 100644
--- a/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.cpp
+++ b/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.cpp
@@ -41,6 +41,7 @@
#include "projectexplorer/session.h"
#include "projectexplorer/project.h"
#include "projectexplorer/session.h"
+#include "projectexplorer/taskhub.h"
#include "extensionsystem/pluginmanager.h"
#include "extensionsystem/pluginspec.h"
@@ -57,6 +58,9 @@ namespace QmlDesigner {
AssetExporterPlugin::AssetExporterPlugin() :
m_view(new AssetExporterView)
{
+ ProjectExplorer::TaskHub::addCategory( Constants::TASK_CATEGORY_ASSET_EXPORT,
+ tr("Asset Export"), false);
+
auto *designerPlugin = QmlDesigner::QmlDesignerPlugin::instance();
auto &viewManager = designerPlugin->viewManager();
viewManager.registerViewTakingOwnership(m_view);
diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.pri b/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.pri
index 17027e9776..8c8c512659 100644
--- a/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.pri
+++ b/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.pri
@@ -13,6 +13,7 @@ HEADERS += \
assetexporterview.h \
assetexportpluginconstants.h \
componentexporter.h \
+ exportnotification.h \
parsers/modelitemnodeparser.h \
parsers/modelnodeparser.h
@@ -22,6 +23,7 @@ SOURCES += \
assetexporterplugin.cpp \
assetexporterview.cpp \
componentexporter.cpp \
+ exportnotification.cpp \
parsers/modelitemnodeparser.cpp \
parsers/modelnodeparser.cpp
diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.qbs b/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.qbs
index b6cd9ddfc3..538d7b1980 100644
--- a/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.qbs
+++ b/src/plugins/qmldesigner/assetexporterplugin/assetexporterplugin.qbs
@@ -43,6 +43,8 @@ QtcProduct {
"assetexportpluginconstants.h",
"componentexporter.cpp",
"componentexporter.h",
+ "exportnotification.cpp",
+ "exportnotification.h",
"parsers/modelitemnodeparser.cpp",
"parsers/modelitemnodeparser.h",
"parsers/modelnodeparser.cpp",
diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexportpluginconstants.h b/src/plugins/qmldesigner/assetexporterplugin/assetexportpluginconstants.h
index 8432e6b840..79145bb145 100644
--- a/src/plugins/qmldesigner/assetexporterplugin/assetexportpluginconstants.h
+++ b/src/plugins/qmldesigner/assetexporterplugin/assetexportpluginconstants.h
@@ -29,5 +29,7 @@ namespace Constants {
const char EXPORT_QML[] = "Designer.ExportPlugin.ExportQml";
+const char TASK_CATEGORY_ASSET_EXPORT[] = "AssetExporter.Export";
+
}
}
diff --git a/src/plugins/qmldesigner/assetexporterplugin/exportnotification.cpp b/src/plugins/qmldesigner/assetexporterplugin/exportnotification.cpp
new file mode 100644
index 0000000000..d4259c3fe2
--- /dev/null
+++ b/src/plugins/qmldesigner/assetexporterplugin/exportnotification.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd
+** All rights reserved.
+** For any questions to The Qt Company, please use contact form at http://www.qt.io/contact-us
+**
+** This file is part of the Qt Asset Importer module.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://www.qt.io/contact-us
+**
+******************************************************************************/
+#include "exportnotification.h"
+#include "assetexportpluginconstants.h"
+
+#include "projectexplorer/taskhub.h"
+
+#include <QLoggingCategory>
+
+namespace {
+Q_LOGGING_CATEGORY(loggerDebug, "qtc.designer.assetExportPlugin.exportNotification", QtDebugMsg)
+}
+
+using namespace ProjectExplorer;
+namespace {
+static void addTask(Task::TaskType type, const QString &desc)
+{
+ qCDebug(loggerDebug) << desc;
+ Task task(type, desc, {}, -1, QmlDesigner::Constants::TASK_CATEGORY_ASSET_EXPORT);
+ TaskHub::addTask(task);
+}
+}
+
+namespace QmlDesigner {
+
+void ExportNotification::addError(const QString &errMsg)
+{
+ addTask(Task::Error, errMsg);
+}
+
+void ExportNotification::addWarning(const QString &warningMsg)
+{
+ addTask(Task::Warning, warningMsg);
+}
+
+void ExportNotification::addInfo(const QString &infoMsg)
+{
+ addTask(Task::Unknown, infoMsg);
+}
+} // QmlDesigner
diff --git a/src/plugins/qmldesigner/assetexporterplugin/exportnotification.h b/src/plugins/qmldesigner/assetexporterplugin/exportnotification.h
new file mode 100644
index 0000000000..23fab1b8fa
--- /dev/null
+++ b/src/plugins/qmldesigner/assetexporterplugin/exportnotification.h
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd
+** All rights reserved.
+** For any questions to The Qt Company, please use contact form at http://www.qt.io/contact-us
+**
+** This file is part of the Qt Asset Importer module.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://www.qt.io/contact-us
+**
+******************************************************************************/
+#pragma once
+
+#include <QString>
+
+namespace QmlDesigner {
+class ExportNotification
+{
+public:
+ static void addError(const QString &errMsg);
+ static void addWarning(const QString &warningMsg);
+ static void addInfo(const QString &infoMsg);
+};
+} // QmlDesigner