forked from qt-creator/qt-creator
AssetExport: UI improvements
Add checkbox to export assets and fix progress bar Task-number: QDS-1560 Change-Id: I8a23f4bc4a2f7ba99fcc4cf235ce94fa69ac151a Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include "utils/fileutils.h"
|
#include "utils/fileutils.h"
|
||||||
#include "utils/outputformatter.h"
|
#include "utils/outputformatter.h"
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
@@ -86,6 +87,15 @@ AssetExportDialog::AssetExportDialog(const Utils::FilePath &exportPath,
|
|||||||
Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), m_ui->exportPath->path());
|
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->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
||||||
|
|
||||||
m_ui->stackedWidget->addWidget(m_filesView);
|
m_ui->stackedWidget->addWidget(m_filesView);
|
||||||
@@ -138,7 +148,8 @@ void AssetExportDialog::onExport()
|
|||||||
TaskHub::clearTasks(Constants::TASK_CATEGORY_ASSET_EXPORT);
|
TaskHub::clearTasks(Constants::TASK_CATEGORY_ASSET_EXPORT);
|
||||||
m_exportLogs->clear();
|
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)
|
void AssetExportDialog::onExportStateChanged(AssetExporter::ParsingState newState)
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QCheckBox;
|
||||||
class QListView;
|
class QListView;
|
||||||
class QPlainTextEdit;
|
class QPlainTextEdit;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@@ -74,6 +75,7 @@ private:
|
|||||||
FilePathModel &m_filePathModel;
|
FilePathModel &m_filePathModel;
|
||||||
std::unique_ptr<Ui::AssetExportDialog> m_ui;
|
std::unique_ptr<Ui::AssetExportDialog> m_ui;
|
||||||
QPushButton *m_exportBtn = nullptr;
|
QPushButton *m_exportBtn = nullptr;
|
||||||
|
QCheckBox *m_exportAssetsCheck = nullptr;
|
||||||
QListView *m_filesView = nullptr;
|
QListView *m_filesView = nullptr;
|
||||||
QPlainTextEdit *m_exportLogs = nullptr;
|
QPlainTextEdit *m_exportLogs = nullptr;
|
||||||
Utils::OutputFormatter *m_outputFormatter = nullptr;
|
Utils::OutputFormatter *m_outputFormatter = nullptr;
|
||||||
|
@@ -14,9 +14,6 @@
|
|||||||
<string>Export QML</string>
|
<string>Export QML</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="Utils::PathChooser" name="exportPath" native="true"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -30,10 +27,10 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="2" column="0" colspan="2">
|
||||||
<widget class="QStackedWidget" name="stackedWidget"/>
|
<widget class="QStackedWidget" name="stackedWidget"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QProgressBar" name="exportProgress">
|
<widget class="QProgressBar" name="exportProgress">
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>1000</number>
|
<number>1000</number>
|
||||||
@@ -43,13 +40,26 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="Utils::DetailsWidget" name="advancedOptions" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>8</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Close</set>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Close</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="Utils::PathChooser" name="exportPath" native="true"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
@@ -59,6 +69,12 @@
|
|||||||
<header location="global">utils/pathchooser.h</header>
|
<header location="global">utils/pathchooser.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>Utils::DetailsWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header location="global">utils/detailswidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@@ -116,15 +116,17 @@ void AssetExporter::exportQml(const Utils::FilePaths &qmlFiles, const Utils::Fil
|
|||||||
ExportNotification::addInfo(tr("Exporting metadata at %1. Export assets: ")
|
ExportNotification::addInfo(tr("Exporting metadata at %1. Export assets: ")
|
||||||
.arg(exportPath.toUserOutput())
|
.arg(exportPath.toUserOutput())
|
||||||
.arg(exportAssets? tr("Yes") : tr("No")));
|
.arg(exportAssets? tr("Yes") : tr("No")));
|
||||||
// TODO Asset export
|
|
||||||
notifyProgress(0.0);
|
notifyProgress(0.0);
|
||||||
Q_UNUSED(exportAssets);
|
|
||||||
m_exportFiles = qmlFiles;
|
m_exportFiles = qmlFiles;
|
||||||
|
m_totalFileCount = m_exportFiles.count();
|
||||||
m_components = QJsonArray();
|
m_components = QJsonArray();
|
||||||
m_exportPath = exportPath;
|
m_exportPath = exportPath;
|
||||||
m_currentState.change(ParsingState::Parsing);
|
m_currentState.change(ParsingState::Parsing);
|
||||||
triggerLoadNextFile();
|
triggerLoadNextFile();
|
||||||
|
if (exportAssets)
|
||||||
m_assetDumper = make_unique<AssetDumper>();
|
m_assetDumper = make_unique<AssetDumper>();
|
||||||
|
else
|
||||||
|
m_assetDumper.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetExporter::cancel()
|
void AssetExporter::cancel()
|
||||||
@@ -159,6 +161,7 @@ void AssetExporter::exportComponent(const ModelNode &rootNode)
|
|||||||
Component exporter(*this, rootNode);
|
Component exporter(*this, rootNode);
|
||||||
exporter.exportComponent();
|
exporter.exportComponent();
|
||||||
m_components.append(exporter.json());
|
m_components.append(exporter.json());
|
||||||
|
notifyProgress((m_totalFileCount - m_exportFiles.count()) * 0.8 / m_totalFileCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetExporter::notifyLoadError(AssetExporterView::LoadState state)
|
void AssetExporter::notifyLoadError(AssetExporterView::LoadState state)
|
||||||
|
@@ -100,6 +100,7 @@ private:
|
|||||||
ProjectExplorer::Project *m_project = nullptr;
|
ProjectExplorer::Project *m_project = nullptr;
|
||||||
AssetExporterView *m_view = nullptr;
|
AssetExporterView *m_view = nullptr;
|
||||||
Utils::FilePaths m_exportFiles;
|
Utils::FilePaths m_exportFiles;
|
||||||
|
unsigned int m_totalFileCount = 0;
|
||||||
Utils::FilePath m_exportPath;
|
Utils::FilePath m_exportPath;
|
||||||
QJsonArray m_components;
|
QJsonArray m_components;
|
||||||
QSet<QByteArray> m_usedHashes;
|
QSet<QByteArray> m_usedHashes;
|
||||||
|
Reference in New Issue
Block a user