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);