StudioWelcomePage: Disable data download by default

QML/Designer/EnableWelcomePageDownload is not set,
no download or probing will start.

Change-Id: Icadd29b2a8c0439ebd8435b987647f5d6f7167a7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2022-05-27 15:22:39 +02:00
parent f6fdcfef53
commit 255f7f836f

View File

@@ -57,6 +57,12 @@
using namespace Utils; using namespace Utils;
static bool enableDownload()
{
const QString lastQDSVersionEntry = "QML/Designer/EnableWelcomePageDownload";
return Core::ICore::settings()->value(lastQDSVersionEntry, false).toBool();
}
void ExampleCheckout::registerTypes() void ExampleCheckout::registerTypes()
{ {
static bool once = []() { static bool once = []() {
@@ -186,6 +192,12 @@ bool FileDownloader::available() const
void FileDownloader::probeUrl() void FileDownloader::probeUrl()
{ {
if (!enableDownload()) {
m_available = false;
emit availableChanged();
return;
}
auto request = QNetworkRequest(m_url); auto request = QNetworkRequest(m_url);
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, request.setAttribute(QNetworkRequest::RedirectPolicyAttribute,
QNetworkRequest::UserVerifiedRedirectPolicy); QNetworkRequest::UserVerifiedRedirectPolicy);
@@ -447,6 +459,13 @@ DataModelDownloader::DataModelDownloader(QObject * /* parent */)
void DataModelDownloader::start() void DataModelDownloader::start()
{ {
if (!enableDownload()) {
m_available = false;
emit availableChanged();
return;
}
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"));