From 094cd30650c2ad6728fc0c9edd2b6cd5acc279e4 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 15 Sep 2022 15:21:14 +1000 Subject: [PATCH] Move plugins "automatically check for updates" settings key to a new key This change moves the old "app/plugin_installer/checkOnStart" setting key to a new "plugins/automatically-check-for-updates" key, and switches the default value to enable automatic checks This is designed to switch all existing QGIS users to the new default behavior of checking for plugin updates at startup (at a maximum of once every 3 days). It is intended to offer a better QGIS experience to our users, by proactively informing all users when plugins should be updated, ensuring that ALL users are more likely to upgrade plugins and get the bug fixes for plugins promptly. Enterprise users who have customised this setting in their deployments will need to adapt their scripts for the new setting key. --- python/pyplugin_installer/installer_data.py | 7 +++---- src/app/pluginmanager/qgspluginmanager.cpp | 7 ++++--- src/gui/settings/qgssettingsregistrygui.cpp | 1 + src/gui/settings/qgssettingsregistrygui.h | 4 ++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/python/pyplugin_installer/installer_data.py b/python/pyplugin_installer/installer_data.py index 9aa4632a071..1ca11b4b70c 100644 --- a/python/pyplugin_installer/installer_data.py +++ b/python/pyplugin_installer/installer_data.py @@ -41,6 +41,7 @@ import re import configparser import qgis.utils from qgis.core import QgsNetworkAccessManager, QgsApplication +from qgis.gui import QgsGui from qgis.utils import iface, plugin_paths from .version_compare import pyQgisVersion, compareVersions, normalizeVersion, isCompatible @@ -229,13 +230,11 @@ class Repositories(QObject): def checkingOnStart(self) -> bool: """ return true if checking for news and updates is enabled """ - settings = QgsSettings() - return settings.value(settingsGroup + "/checkOnStart", True, type=bool) + return QgsGui.settingsRegistryGui().settingsEntry('plugins/automatically-check-for-updates').value() def setCheckingOnStart(self, state: bool): """ set state of checking for news and updates """ - settings = QgsSettings() - settings.setValue(settingsGroup + "/checkOnStart", state) + QgsGui.settingsRegistryGui().settingsEntry('plugins/automatically-check-for-updates').setValue(state) def saveCheckingOnStartLastDate(self): """ set today's date as the day of last checking """ diff --git a/src/app/pluginmanager/qgspluginmanager.cpp b/src/app/pluginmanager/qgspluginmanager.cpp index 9838c681fb7..beccce40418 100644 --- a/src/app/pluginmanager/qgspluginmanager.cpp +++ b/src/app/pluginmanager/qgspluginmanager.cpp @@ -48,6 +48,8 @@ #include "qgslogger.h" #include "qgspluginitemdelegate.h" #include "qgssettings.h" +#include "qgsgui.h" +#include "qgssettingsregistrygui.h" #ifdef WITH_BINDINGS #include "qgspythonutils.h" #endif @@ -239,7 +241,7 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils *pythonUtils ) connect( buttonInstallFromZip, &QPushButton::clicked, this, &QgsPluginManager::buttonInstallFromZip_clicked ); // Initialize the "Settings" tab widgets - if ( settings.value( settingsGroup + "/checkOnStart", true ).toBool() ) + if ( QgsSettingsRegistryGui::settingsAutomaticallyCheckForPluginUpdates.value() ) { ckbCheckUpdates->setChecked( true ); } @@ -1286,8 +1288,7 @@ void QgsPluginManager::reject() // get the QgsSettings group from the installer QString settingsGroup; QgsPythonRunner::eval( QStringLiteral( "pyplugin_installer.instance().exportSettingsGroup()" ), settingsGroup ); - QgsSettings settings; - settings.setValue( settingsGroup + "/checkOnStart", QVariant( ckbCheckUpdates->isChecked() ) ); + QgsSettingsRegistryGui::settingsAutomaticallyCheckForPluginUpdates.setValue( ckbCheckUpdates->isChecked() ); QgsPythonRunner::run( QStringLiteral( "pyplugin_installer.instance().onManagerClose()" ) ); } #endif diff --git a/src/gui/settings/qgssettingsregistrygui.cpp b/src/gui/settings/qgssettingsregistrygui.cpp index 66891910e10..d84b55a6c01 100644 --- a/src/gui/settings/qgssettingsregistrygui.cpp +++ b/src/gui/settings/qgssettingsregistrygui.cpp @@ -23,6 +23,7 @@ QgsSettingsRegistryGui::QgsSettingsRegistryGui() : QgsSettingsRegistry() { addSettingsEntry( &settingsRespectScreenDPI ); + addSettingsEntry( &settingsAutomaticallyCheckForPluginUpdates ); addSettingsEntry( &QgsStyleManagerDialog::settingLastStyleDatabaseFolder ); QgsApplication::settingsRegistryCore()->addSubRegistry( this ); diff --git a/src/gui/settings/qgssettingsregistrygui.h b/src/gui/settings/qgssettingsregistrygui.h index 5dc9389a75f..fd57de2737f 100644 --- a/src/gui/settings/qgssettingsregistrygui.h +++ b/src/gui/settings/qgssettingsregistrygui.h @@ -47,6 +47,10 @@ class GUI_EXPORT QgsSettingsRegistryGui : public QgsSettingsRegistry #ifndef SIP_RUN //! Settings entry respect screen dpi static const inline QgsSettingsEntryBool settingsRespectScreenDPI = QgsSettingsEntryBool( QStringLiteral( "respect_screen_dpi" ), QgsSettings::Prefix::GUI_QGIS, false ); + + //! Check for plugin updates automatically on startup + static const inline QgsSettingsEntryBool settingsAutomaticallyCheckForPluginUpdates = QgsSettingsEntryBool( QStringLiteral( "automatically-check-for-updates" ), QgsSettings::Prefix::PLUGINS, true, QStringLiteral( "Automatically check for plugin updates on startup" ) ); + #endif };