diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2024-03-07 12:30:25 +0200 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2024-03-14 13:22:43 +0200 |
commit | a4e0908df2f908f2da1401a8f11e838d124f1291 (patch) | |
tree | 6e0efc138b243b206b0fd244bf34dd28f375893a /src/sdk/settingsdialog.cpp | |
parent | ce47a87dcfaaf59da8f6a927468b00dcb43d1ae4 (diff) |
Disable 'clear cache' button until new cache settings are applied
Check the cache validity and use it as the initial state for the button.
After clearing the cache, regardless of success, the cache will become
invalid so the button should stay disabled until new settings are
applied and the cache is reinitialized.
Also disable the button in case the selected cache path does not match
the one currently applied in the settings.
Task-number: QTIFW-3252
Change-Id: I1b403fbc8a6680dfd5222296479ab0821cdb4a37
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/sdk/settingsdialog.cpp')
-rw-r--r-- | src/sdk/settingsdialog.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/sdk/settingsdialog.cpp b/src/sdk/settingsdialog.cpp index acd364b2f..0a16377b3 100644 --- a/src/sdk/settingsdialog.cpp +++ b/src/sdk/settingsdialog.cpp @@ -242,8 +242,19 @@ SettingsDialog::SettingsDialog(PackageManagerCore *core, QWidget *parent) connect(m_ui->m_clearPushButton, &QAbstractButton::clicked, this, &SettingsDialog::clearLocalCacheClicked); - connect(m_ui->m_clearPushButton, &QAbstractButton::clicked, - this, [&] { m_cacheCleared = true; }); + connect(m_ui->m_clearPushButton, &QAbstractButton::clicked, this, [&] { + // Disable the button as the new settings will only take effect after + // closing the dialog. + m_ui->m_clearPushButton->setEnabled(false); + m_cacheCleared = true; + }); + connect(m_ui->m_cachePathLineEdit, &QLineEdit::textChanged, this, [&] { + if (!m_cacheCleared) { + // Disable the button if the path is modified between applying settings + m_ui->m_clearPushButton->setEnabled( + settings.localCachePath() == m_ui->m_cachePathLineEdit->text()); + } + }); useTmpRepositoriesOnly(settings.hasReplacementRepos()); m_ui->m_useTmpRepositories->setChecked(settings.hasReplacementRepos()); @@ -256,8 +267,9 @@ SettingsDialog::SettingsDialog(PackageManagerCore *core, QWidget *parent) m_ui->m_repositories->setVisible(settings.repositorySettingsPageVisible()); } - m_ui->m_cachePathLineEdit->setText(settings.localCachePath()); - showClearCacheProgress(false); + m_ui->m_cachePathLineEdit->setText(settings.localCachePath()); + m_ui->m_clearPushButton->setEnabled(m_core->isValidCache()); + showClearCacheProgress(false); } void SettingsDialog::showClearCacheProgress(bool show) |