From cd8bb1d92303b47cf23c2a2c0f3b6624dade6001 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 5 Jun 2023 18:54:37 +0200 Subject: [PATCH] ExampleCheckout: Replace the usage of Archive with Unarchiver Change-Id: I76550b618bcc631fc9575343eb4b8552cb21a018 Reviewed-by: Reviewed-by: Qt CI Bot Reviewed-by: hjk --- src/plugins/studiowelcome/examplecheckout.cpp | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/plugins/studiowelcome/examplecheckout.cpp b/src/plugins/studiowelcome/examplecheckout.cpp index b919bf29394..c22156a91c7 100644 --- a/src/plugins/studiowelcome/examplecheckout.cpp +++ b/src/plugins/studiowelcome/examplecheckout.cpp @@ -66,11 +66,11 @@ QString DataModelDownloader::targetPath() const return QmlDesigner::Paths::examplesPathSetting(); } -static Utils::FilePath tempFilePath() +static FilePath tempFilePath() { QStandardPaths::StandardLocation location = QStandardPaths::CacheLocation; - return Utils::FilePath::fromString(QStandardPaths::writableLocation(location)) + return FilePath::fromString(QStandardPaths::writableLocation(location)) .pathAppended("QtDesignStudio"); } @@ -118,17 +118,18 @@ DataModelDownloader::DataModelDownloader(QObject * /* parent */) m_started = false; if (m_fileDownloader.finished()) { - const Utils::FilePath archiveFile = Utils::FilePath::fromString( - m_fileDownloader.outputFile()); - QTC_ASSERT(Utils::Archive::supportsFile(archiveFile), return ); - auto archive = new Utils::Archive(archiveFile, tempFilePath()); - QTC_ASSERT(archive->isValid(), delete archive; return ); - QObject::connect(archive, &Utils::Archive::finished, this, [this, archive](bool ret) { - QTC_CHECK(ret); - archive->deleteLater(); + const FilePath archiveFile = FilePath::fromString(m_fileDownloader.outputFile()); + const auto sourceAndCommand = Unarchiver::sourceAndCommand(archiveFile); + QTC_ASSERT(sourceAndCommand, return); + auto unarchiver = new Unarchiver; + unarchiver->setSourceAndCommand(*sourceAndCommand); + unarchiver->setDestDir(tempFilePath()); + QObject::connect(unarchiver, &Unarchiver::done, this, [this, unarchiver](bool success) { + QTC_CHECK(success); + unarchiver->deleteLater(); emit finished(); }); - archive->unarchive(); + unarchiver->start(); } }); } @@ -180,9 +181,9 @@ bool DataModelDownloader::available() const return m_available; } -Utils::FilePath DataModelDownloader::targetFolder() const +FilePath DataModelDownloader::targetFolder() const { - return Utils::FilePath::fromUserInput(tempFilePath().toString() + "/" + "dataImports"); + return FilePath::fromUserInput(tempFilePath().toString() + "/" + "dataImports"); } void DataModelDownloader::setForceDownload(bool b)