StudioWelcome: Enable integrating download progress

Change-Id: Iad18c1a0bc49f87a98dcdff46542cf4c373de875
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Thomas Hartmann
2022-01-14 17:47:39 +01:00
parent 4c21852ec6
commit dab8caf6d9
4 changed files with 24 additions and 7 deletions

View File

@@ -45,7 +45,7 @@ using namespace Utils;
ExampleCheckout::ExampleCheckout(QObject *) {}
void ExampleCheckout::checkoutExample(const QUrl &url)
void ExampleCheckout::registerTypes()
{
FileDownloader::registerQmlType();
static bool once = []() {
@@ -55,6 +55,11 @@ void ExampleCheckout::checkoutExample(const QUrl &url)
}();
QTC_ASSERT(once, ;);
}
void ExampleCheckout::checkoutExample(const QUrl &url, const QString &tempFile, const QString &completeBaseFileName)
{
registerTypes();
m_dialog.reset(new QDialog(Core::ICore::dialogParent()));
m_dialog->setModal(true);
@@ -80,6 +85,8 @@ void ExampleCheckout::checkoutExample(const QUrl &url)
QTC_ASSERT(rootObject, qWarning() << "QML error"; return );
rootObject->setProperty("url", url);
rootObject->setProperty("tempFile", tempFile);
rootObject->setProperty("completeBaseName", completeBaseFileName);
m_dialog->show();
@@ -260,6 +267,7 @@ void FileExtractor::setSourceFile(QString &sourceFilePath)
void FileExtractor::setArchiveName(QString &filePath)
{
m_archiveName = filePath;
emit targetFolderExistsChanged();
}
const QString FileExtractor::detailedText()

View File

@@ -43,18 +43,21 @@ class ExampleCheckout : public QObject
public:
explicit ExampleCheckout(QObject *parent = nullptr);
Q_INVOKABLE void checkoutExample(const QUrl &url);
Q_INVOKABLE void checkoutExample(const QUrl &url, const QString &tempFile, const QString &completeBaseFileName);
QString extractionFolder() const;
~ExampleCheckout();
static void registerTypes();
public slots:
void handleCancel();
void handleAccepted();
signals:
void finishedSucessfully();
void progressChanged(int);
private:
std::unique_ptr<QDialog> m_dialog;

View File

@@ -45,15 +45,18 @@ Rectangle {
signal canceled
signal accepted
property string tempFile
property string completeBaseName
StackLayout {
id: stackLayout
anchors.fill: parent
currentIndex: 0
currentIndex: root.tempFile.length === 0 ? 0 : 1
FileExtractor {
id: fileExtractor
sourceFile: downloader.tempFile
archiveName: downloader.completeBaseName
archiveName: root.completeBaseName.length === 0 ? downloader.completeBaseName : root.completeBaseName
sourceFile: root.tempFile.length === 0 ? downloader.tempFile : root.tempFile
}
FileDownloader {

View File

@@ -231,11 +231,13 @@ public:
Q_INVOKABLE void openExample(const QString &example,
const QString &formFile,
const QString &url,
const QString &explicitQmlproject)
const QString &explicitQmlproject,
const QString &tempFile,
const QString &completeBaseName)
{
if (!url.isEmpty()) {
ExampleCheckout *checkout = new ExampleCheckout;
checkout->checkoutExample(QUrl::fromUserInput(url));
checkout->checkoutExample(QUrl::fromUserInput(url), tempFile, completeBaseName);
connect(checkout,
&ExampleCheckout::finishedSucessfully,
this,
@@ -631,6 +633,7 @@ WelcomeMode::WelcomeMode()
setContext(Core::Context(Core::Constants::C_WELCOME_MODE));
QFontDatabase::addApplicationFont(":/studiofonts/TitilliumWeb-Regular.ttf");
ExampleCheckout::registerTypes();
m_modeWidget = new QQuickWidget;
m_modeWidget->setMinimumSize(1024, 768);