diff options
author | Eike Ziller <eike.ziller@qt.io> | 2022-05-23 12:26:27 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2022-05-23 12:26:27 +0200 |
commit | f14b1a484ac2f47b4296c1bf2b2c11267baafe9a (patch) | |
tree | 4ecd8a66c8712c0df4bab04ec5a42a8db666b9ca /src/plugins/studiowelcome | |
parent | 21d0175dabff43eaf35658f1153187553019444f (diff) | |
parent | 2e8bfee96667402c355e09be9b8785874393da11 (diff) | |
download | qt-creator-f14b1a484ac2f47b4296c1bf2b2c11267baafe9a.tar.gz |
Merge remote-tracking branch 'origin/7.0'
Change-Id: I7037b2b400617b0be0e1a010dd293e4f96d77328
Diffstat (limited to 'src/plugins/studiowelcome')
-rw-r--r-- | src/plugins/studiowelcome/examplecheckout.cpp | 14 | ||||
-rw-r--r-- | src/plugins/studiowelcome/examplecheckout.h | 2 | ||||
-rw-r--r-- | src/plugins/studiowelcome/studiowelcomeplugin.cpp | 43 |
3 files changed, 44 insertions, 15 deletions
diff --git a/src/plugins/studiowelcome/examplecheckout.cpp b/src/plugins/studiowelcome/examplecheckout.cpp index 46678a21dd..b69c66db62 100644 --- a/src/plugins/studiowelcome/examplecheckout.cpp +++ b/src/plugins/studiowelcome/examplecheckout.cpp @@ -437,8 +437,13 @@ static Utils::FilePath tempFilePath() DataModelDownloader::DataModelDownloader(QObject * /* parent */) { auto fileInfo = targetFolder().toFileInfo(); - m_birthTime = fileInfo.birthTime(); + m_birthTime = fileInfo.lastModified(); m_exists = fileInfo.exists(); + + connect(&m_fileDownloader, + &FileDownloader::progressChanged, + this, + &DataModelDownloader::progressChanged); } void DataModelDownloader::start() @@ -457,7 +462,7 @@ void DataModelDownloader::start() return; } - if (!m_forceDownload && m_fileDownloader.lastModified() < m_birthTime) + if (!m_forceDownload && (m_fileDownloader.lastModified() <= m_birthTime)) return; m_fileDownloader.start(); @@ -498,3 +503,8 @@ void DataModelDownloader::setForceDownload(bool b) { m_forceDownload = b; } + +int DataModelDownloader::progress() const +{ + return m_fileDownloader.progress(); +} diff --git a/src/plugins/studiowelcome/examplecheckout.h b/src/plugins/studiowelcome/examplecheckout.h index a6c0df3ace..fae0fea336 100644 --- a/src/plugins/studiowelcome/examplecheckout.h +++ b/src/plugins/studiowelcome/examplecheckout.h @@ -168,10 +168,12 @@ public: bool available() const; Utils::FilePath targetFolder() const; void setForceDownload(bool b); + int progress() const; signals: void finished(); void availableChanged(); + void progressChanged(); private: FileDownloader m_fileDownloader; diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.cpp b/src/plugins/studiowelcome/studiowelcomeplugin.cpp index 67ef39249f..635cf52795 100644 --- a/src/plugins/studiowelcome/studiowelcomeplugin.cpp +++ b/src/plugins/studiowelcome/studiowelcomeplugin.cpp @@ -213,12 +213,16 @@ public: Q_INVOKABLE void createProject() { - ProjectExplorer::ProjectExplorerPlugin::openNewProjectDialog(); + QTimer::singleShot(0, []() { + ProjectExplorer::ProjectExplorerPlugin::openNewProjectDialog(); + }); } Q_INVOKABLE void openProject() { - ProjectExplorer::ProjectExplorerPlugin::openOpenProjectDialog(); + QTimer::singleShot(0, []() { + ProjectExplorer::ProjectExplorerPlugin::openOpenProjectDialog(); + }); } Q_INVOKABLE void openProjectAt(int row) @@ -493,6 +497,12 @@ bool StudioWelcomePlugin::initialize(const QStringList &arguments, QString *erro return true; } +static bool forceDownLoad() +{ + const QString lastQDSVersionEntry = "QML/Designer/ForceWelcomePageDownload"; + return Core::ICore::settings()->value(lastQDSVersionEntry, false).toBool(); +} + static bool showSplashScreen() { const QString lastQDSVersionEntry = "QML/Designer/lastQDSVersion"; @@ -606,19 +616,10 @@ WelcomeMode::WelcomeMode() m_dataModelDownloader->targetFolder()); m_dataModelDownloader->setForceDownload(true); } - Utils::FilePath readme = Utils::FilePath::fromUserInput(welcomePagePath - + "/dataImports/readme.txt"); + Utils::FilePath readme = Utils::FilePath::fromUserInput(m_dataModelDownloader->targetFolder().toString() + + "/readme.txt"); - if (!readme.exists()) // Only downloads contain the readme - m_dataModelDownloader->setForceDownload(true); - m_dataModelDownloader->start(); - - connect(m_dataModelDownloader, &DataModelDownloader::finished, this, [this](){ - auto source = m_modeWidget->source(); - m_modeWidget->engine()->clearComponentCache(); - m_modeWidget->setSource(source); - }); const Utils::Icon FLAT({{":/studiowelcome/images/mode_welcome_mask.png", Utils::Theme::IconsBaseColor}}); const Utils::Icon FLAT_ACTIVE({{":/studiowelcome/images/mode_welcome_mask.png", @@ -643,6 +644,22 @@ WelcomeMode::WelcomeMode() m_modeWidget->engine()->setOutputWarningsToStandardError(false); + if (forceDownLoad() || !readme.exists()) // Only downloads contain the readme + m_dataModelDownloader->setForceDownload(true); + + connect(m_dataModelDownloader, &DataModelDownloader::progressChanged, this, [this](){ + m_modeWidget->rootObject()->setProperty("loadingProgress", m_dataModelDownloader->progress()); + }); + + connect(m_dataModelDownloader, &DataModelDownloader::finished, this, [this](){ + auto source = m_modeWidget->source(); + m_modeWidget->engine()->clearComponentCache(); + m_modeWidget->setSource(source); + m_modeWidget->rootObject()->setProperty("loadingProgress", 100); + }); + + m_dataModelDownloader->start(); + connect(Core::ModeManager::instance(), &Core::ModeManager::currentModeChanged, this, [this](Utils::Id mode){ bool active = (mode == Core::Constants::MODE_WELCOME); m_modeWidget->rootObject()->setProperty("active", active); |