From 61d5bbbdadc54d2ad02d4a98f04285d6ffc0f282 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Fri, 18 Feb 2022 10:11:01 +0100 Subject: [PATCH] QmlDesigner: Fix example download missing setting When starting with a clean config the location for download/extraction of an example is empty. The first call to the settings needed a default location. Change-Id: I2d63f805dc46c564f13346648f3e3bf29a0970d8 Reviewed-by: Qt CI Bot Reviewed-by: Thomas Hartmann --- src/plugins/studiowelcome/examplecheckout.cpp | 4 +-- .../studiowelcome/studiowelcomeplugin.cpp | 33 +++++++++++-------- .../studiowelcome/studiowelcomeplugin.h | 5 +-- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/plugins/studiowelcome/examplecheckout.cpp b/src/plugins/studiowelcome/examplecheckout.cpp index a3c7d70e710..9cbc57cd827 100644 --- a/src/plugins/studiowelcome/examplecheckout.cpp +++ b/src/plugins/studiowelcome/examplecheckout.cpp @@ -239,9 +239,7 @@ FileExtractor::FileExtractor(QObject *parent) : QObject(parent) { m_targetPath = Utils::FilePath::fromString( - Core::ICore::settings() - ->value(StudioWelcome::Internal::EXAMPLES_DOWNLOAD_PATH) - .toString()); + StudioWelcome::Internal::StudioWelcomePlugin::examplesPathSetting()); m_timer.setInterval(100); m_timer.setSingleShot(false); diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.cpp b/src/plugins/studiowelcome/studiowelcomeplugin.cpp index e89bc5fa1d1..dfb554c2974 100644 --- a/src/plugins/studiowelcome/studiowelcomeplugin.cpp +++ b/src/plugins/studiowelcome/studiowelcomeplugin.cpp @@ -98,6 +98,8 @@ const char STATISTICS_COLLECTION_MODE[] = "StatisticsCollectionMode"; const char NO_TELEMETRY[] = "NoTelemetry"; const char CRASH_REPORTER_SETTING[] = "CrashReportingEnabled"; +const char EXAMPLES_DOWNLOAD_PATH[] = "StudioWelcome/ExamplesDownloadPath"; + QPointer s_view = nullptr; static StudioWelcomePlugin *s_pluginInstance = nullptr; @@ -676,6 +678,20 @@ void StudioWelcomePlugin::resumeRemoveSplashTimer() m_removeSplashTimer.start(m_removeSplashRemainingTime); } +Utils::FilePath StudioWelcomePlugin::defaultExamplesPath() +{ + return Utils::FilePath::fromString( + QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)) + .pathAppended("QtDesignStudio"); +} + +QString StudioWelcomePlugin::examplesPathSetting() +{ + return Core::ICore::settings() + ->value(EXAMPLES_DOWNLOAD_PATH, defaultExamplesPath().toString()) + .toString(); +} + WelcomeMode::WelcomeMode() { setDisplayName(tr("Studio")); @@ -778,18 +794,6 @@ void setSettingIfDifferent(const QString &key, bool value, bool &dirty) } } -const Utils::FilePath defaultExamplesPath = Utils::FilePath::fromString( - QStandardPaths::writableLocation( - QStandardPaths::DocumentsLocation)) - .pathAppended("QtDesignStudio"); - -static QString examplesPathSetting() -{ - return Core::ICore::settings() - ->value(EXAMPLES_DOWNLOAD_PATH, defaultExamplesPath.toString()) - .toString(); -} - WelcomeMode::~WelcomeMode() { delete m_modeWidget; @@ -836,11 +840,12 @@ StudioSettingsPage::StudioSettingsPage() examplesGroupBox->setLayout(horizontalLayout); auto label = new QLabel(tr("Examples path:")); - m_pathChooser->setFilePath(Utils::FilePath::fromString(examplesPathSetting())); + m_pathChooser->setFilePath( + Utils::FilePath::fromString(StudioWelcomePlugin::examplesPathSetting())); auto resetButton = new QPushButton(tr("Reset Path")); connect(resetButton, &QPushButton::clicked, this, [this]() { - m_pathChooser->setFilePath(defaultExamplesPath); + m_pathChooser->setFilePath(StudioWelcomePlugin::defaultExamplesPath()); }); horizontalLayout->addWidget(label); diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.h b/src/plugins/studiowelcome/studiowelcomeplugin.h index 11274b68a6b..cd6b8ea87f2 100644 --- a/src/plugins/studiowelcome/studiowelcomeplugin.h +++ b/src/plugins/studiowelcome/studiowelcomeplugin.h @@ -36,8 +36,6 @@ QT_FORWARD_DECLARE_CLASS(QCheckBox) namespace StudioWelcome { namespace Internal { -const char EXAMPLES_DOWNLOAD_PATH[] = "StudioWelcome/ExamplesDownloadPath"; - class StudioSettingsPage : public Core::IOptionsPageWidget { public: @@ -80,6 +78,9 @@ public: void pauseRemoveSplashTimer(); void resumeRemoveSplashTimer(); + static Utils::FilePath defaultExamplesPath(); + static QString examplesPathSetting(); + signals: void examplesDownloadPathChanged(const QString &path);