StudioWelcome: Disable welcome page during download

Change-Id: Ic85dfd79e4c43822805ce2a7f392f9b0a5d2a923
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Thomas Hartmann
2022-07-20 19:16:15 +02:00
parent 792c5271e2
commit b899a27c86
3 changed files with 23 additions and 5 deletions

View File

@@ -456,21 +456,28 @@ DataModelDownloader::DataModelDownloader(QObject * /* parent */)
&FileDownloader::progressChanged, &FileDownloader::progressChanged,
this, this,
&DataModelDownloader::progressChanged); &DataModelDownloader::progressChanged);
connect(&m_fileDownloader,
&FileDownloader::downloadFailed,
this,
&DataModelDownloader::downloadFailed);
} }
void DataModelDownloader::start() bool DataModelDownloader::start()
{ {
if (!enableDownload()) { if (!enableDownload()) {
m_available = false; m_available = false;
emit availableChanged(); emit availableChanged();
return; return false;
} }
m_fileDownloader.setUrl(QUrl::fromUserInput( m_fileDownloader.setUrl(QUrl::fromUserInput(
"https://download.qt.io/learning/examples/qtdesignstudio/dataImports.zip")); "https://download.qt.io/learning/examples/qtdesignstudio/dataImports.zip"));
connect(&m_fileDownloader, &FileDownloader::availableChanged, this, [this]() { bool started = false;
connect(&m_fileDownloader, &FileDownloader::availableChanged, this, [this, &started]() {
m_available = m_fileDownloader.available(); m_available = m_fileDownloader.available();
@@ -484,6 +491,8 @@ void DataModelDownloader::start()
if (!m_forceDownload && (m_fileDownloader.lastModified() <= m_birthTime)) if (!m_forceDownload && (m_fileDownloader.lastModified() <= m_birthTime))
return; return;
started = true;
m_fileDownloader.start(); m_fileDownloader.start();
connect(&m_fileDownloader, &FileDownloader::finishedChanged, this, [this]() { connect(&m_fileDownloader, &FileDownloader::finishedChanged, this, [this]() {
if (m_fileDownloader.finished()) { if (m_fileDownloader.finished()) {
@@ -501,6 +510,7 @@ void DataModelDownloader::start()
} }
}); });
}); });
return started;
} }
bool DataModelDownloader::exists() const bool DataModelDownloader::exists() const

View File

@@ -163,7 +163,7 @@ class DataModelDownloader : public QObject
public: public:
explicit DataModelDownloader(QObject *parent = nullptr); explicit DataModelDownloader(QObject *parent = nullptr);
void start(); bool start();
bool exists() const; bool exists() const;
bool available() const; bool available() const;
Utils::FilePath targetFolder() const; Utils::FilePath targetFolder() const;
@@ -174,6 +174,7 @@ signals:
void finished(); void finished();
void availableChanged(); void availableChanged();
void progressChanged(); void progressChanged();
void downloadFailed();
private: private:
FileDownloader m_fileDownloader; FileDownloader m_fileDownloader;

View File

@@ -656,9 +656,16 @@ WelcomeMode::WelcomeMode()
m_modeWidget->engine()->clearComponentCache(); m_modeWidget->engine()->clearComponentCache();
m_modeWidget->setSource(source); m_modeWidget->setSource(source);
m_modeWidget->rootObject()->setProperty("loadingProgress", 100); m_modeWidget->rootObject()->setProperty("loadingProgress", 100);
m_modeWidget->setEnabled(true);
}); });
m_dataModelDownloader->start(); connect(m_dataModelDownloader, &DataModelDownloader::downloadFailed, this, [this]() {
m_modeWidget->setEnabled(true);
});
if (m_dataModelDownloader->start())
m_modeWidget->setEnabled(false);
/* /*
connect(Core::ModeManager::instance(), &Core::ModeManager::currentModeChanged, this, [this](Utils::Id mode){ connect(Core::ModeManager::instance(), &Core::ModeManager::currentModeChanged, this, [this](Utils::Id mode){