From 4d17a2c50a0dc9b4009091d3b887943c9f2f5897 Mon Sep 17 00:00:00 2001 From: Vikas Pachdha Date: Mon, 29 Jun 2020 18:21:34 +0200 Subject: [PATCH] AssetExport: UI improvements Add checkbox to export assets and fix progress bar Task-number: QDS-1560 Change-Id: I8a23f4bc4a2f7ba99fcc4cf235ce94fa69ac151a Reviewed-by: Tim Jenssen --- .../assetexporterplugin/assetexportdialog.cpp | 13 ++++++++- .../assetexporterplugin/assetexportdialog.h | 2 ++ .../assetexporterplugin/assetexportdialog.ui | 28 +++++++++++++++---- .../assetexporterplugin/assetexporter.cpp | 9 ++++-- .../assetexporterplugin/assetexporter.h | 1 + 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.cpp b/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.cpp index 0de2a1b08de..f05ebe87515 100644 --- a/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.cpp +++ b/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.cpp @@ -35,6 +35,7 @@ #include "utils/fileutils.h" #include "utils/outputformatter.h" +#include #include #include #include @@ -86,6 +87,15 @@ AssetExportDialog::AssetExportDialog(const Utils::FilePath &exportPath, Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), m_ui->exportPath->path()); }); + auto optionsWidget = new QWidget; + m_ui->advancedOptions->setSummaryText(tr("Advanced Options")); + m_ui->advancedOptions->setWidget(optionsWidget); + auto optionsLayout = new QHBoxLayout(optionsWidget); + optionsLayout->setMargin(8); + m_exportAssetsCheck = new QCheckBox(tr("Export assets"), this); + m_exportAssetsCheck->setChecked(true); + optionsLayout->addWidget(m_exportAssetsCheck); + m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); m_ui->stackedWidget->addWidget(m_filesView); @@ -138,7 +148,8 @@ void AssetExportDialog::onExport() TaskHub::clearTasks(Constants::TASK_CATEGORY_ASSET_EXPORT); m_exportLogs->clear(); - m_assetExporter.exportQml(m_filePathModel.files(), m_ui->exportPath->fileName()); + m_assetExporter.exportQml(m_filePathModel.files(), m_ui->exportPath->fileName(), + m_exportAssetsCheck->isChecked()); } void AssetExportDialog::onExportStateChanged(AssetExporter::ParsingState newState) diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.h b/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.h index 7bf68b6a748..e452fff6bcb 100644 --- a/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.h +++ b/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.h @@ -34,6 +34,7 @@ QT_BEGIN_NAMESPACE class QPushButton; +class QCheckBox; class QListView; class QPlainTextEdit; QT_END_NAMESPACE @@ -74,6 +75,7 @@ private: FilePathModel &m_filePathModel; std::unique_ptr m_ui; QPushButton *m_exportBtn = nullptr; + QCheckBox *m_exportAssetsCheck = nullptr; QListView *m_filesView = nullptr; QPlainTextEdit *m_exportLogs = nullptr; Utils::OutputFormatter *m_outputFormatter = nullptr; diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.ui b/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.ui index 38c2152098c..a4e7ec91d9c 100644 --- a/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.ui +++ b/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.ui @@ -14,9 +14,6 @@ Export QML - - - @@ -30,10 +27,10 @@ - + - + 1000 @@ -43,13 +40,26 @@ - + + + + + 0 + 8 + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Close + + + @@ -59,6 +69,12 @@
utils/pathchooser.h
1 + + Utils::DetailsWidget + QWidget +
utils/detailswidget.h
+ 1 +
diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp b/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp index bf2b53e4b54..1ea1e09e923 100644 --- a/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp +++ b/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp @@ -116,15 +116,17 @@ void AssetExporter::exportQml(const Utils::FilePaths &qmlFiles, const Utils::Fil ExportNotification::addInfo(tr("Exporting metadata at %1. Export assets: ") .arg(exportPath.toUserOutput()) .arg(exportAssets? tr("Yes") : tr("No"))); - // TODO Asset export notifyProgress(0.0); - Q_UNUSED(exportAssets); m_exportFiles = qmlFiles; + m_totalFileCount = m_exportFiles.count(); m_components = QJsonArray(); m_exportPath = exportPath; m_currentState.change(ParsingState::Parsing); triggerLoadNextFile(); - m_assetDumper = make_unique(); + if (exportAssets) + m_assetDumper = make_unique(); + else + m_assetDumper.reset(); } void AssetExporter::cancel() @@ -159,6 +161,7 @@ void AssetExporter::exportComponent(const ModelNode &rootNode) Component exporter(*this, rootNode); exporter.exportComponent(); m_components.append(exporter.json()); + notifyProgress((m_totalFileCount - m_exportFiles.count()) * 0.8 / m_totalFileCount); } void AssetExporter::notifyLoadError(AssetExporterView::LoadState state) diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexporter.h b/src/plugins/qmldesigner/assetexporterplugin/assetexporter.h index 508147fa068..01b125167be 100644 --- a/src/plugins/qmldesigner/assetexporterplugin/assetexporter.h +++ b/src/plugins/qmldesigner/assetexporterplugin/assetexporter.h @@ -100,6 +100,7 @@ private: ProjectExplorer::Project *m_project = nullptr; AssetExporterView *m_view = nullptr; Utils::FilePaths m_exportFiles; + unsigned int m_totalFileCount = 0; Utils::FilePath m_exportPath; QJsonArray m_components; QSet m_usedHashes;