diff --git a/python/core/auto_generated/network/qgsnetworkaccessmanager.sip.in b/python/core/auto_generated/network/qgsnetworkaccessmanager.sip.in index 654750605e5f..207d2594e174 100644 --- a/python/core/auto_generated/network/qgsnetworkaccessmanager.sip.in +++ b/python/core/auto_generated/network/qgsnetworkaccessmanager.sip.in @@ -321,8 +321,6 @@ The contents of the reply will be returned after the request is completed or an .. versionadded:: 3.6 %End - const QgsSettingsEntryInteger settingsNetworkTimeout; - signals: void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * ) /Deprecated/; diff --git a/python/core/auto_generated/network/qgsnewsfeedparser.sip.in b/python/core/auto_generated/network/qgsnewsfeedparser.sip.in index b6643c4629da..f3169fa7c025 100644 --- a/python/core/auto_generated/network/qgsnewsfeedparser.sip.in +++ b/python/core/auto_generated/network/qgsnewsfeedparser.sip.in @@ -93,11 +93,6 @@ Returns the authentication configuration for the parser. Returns the settings key used for a feed with the given ``baseUrl``. %End - const QgsSettingsEntryInteger settingsFeedLastFetchTime; - const QgsSettingsEntryString settingsFeedLanguage; - const QgsSettingsEntryDouble settingsFeedLatitude; - const QgsSettingsEntryDouble settingsFeedLongitude; - public slots: void fetch(); diff --git a/python/core/auto_generated/processing/qgsprocessing.sip.in b/python/core/auto_generated/processing/qgsprocessing.sip.in index c14aec992082..de33821c12eb 100644 --- a/python/core/auto_generated/processing/qgsprocessing.sip.in +++ b/python/core/auto_generated/processing/qgsprocessing.sip.in @@ -52,11 +52,6 @@ Converts a source ``type`` to a string representation. %End static const QString TEMPORARY_OUTPUT; - - const QgsSettingsEntryBool settingsPreferFilenameAsLayerName; - const QgsSettingsEntryString settingsTempPath; - const QgsSettingsEntryInteger settingsDefaultOutputVectorLayerExt; - const QgsSettingsEntryInteger settingsDefaultOutputRasterLayerExt; }; /************************************************************************ diff --git a/python/core/auto_generated/qgsapplication.sip.in b/python/core/auto_generated/qgsapplication.sip.in index 79411a972da2..830ac64ea32b 100644 --- a/python/core/auto_generated/qgsapplication.sip.in +++ b/python/core/auto_generated/qgsapplication.sip.in @@ -1004,12 +1004,6 @@ Emits the signal to collect all the strings of .qgs to be included in ts file .. versionadded:: 3.4 %End - const QgsSettingsEntryString settingsLocaleUserLocale; - const QgsSettingsEntryBool settingsLocaleOverrideFlag; - const QgsSettingsEntryString settingsLocaleGlobalLocale; - const QgsSettingsEntryBool settingsLocaleShowGroupSeparator; - const QgsSettingsEntryStringList settingsSearchPathsForSVG; - %If (ANDROID) //dummy method to workaround sip generation issue bool x11EventFilter( XEvent *event ); diff --git a/python/core/auto_generated/qgsgeometryoptions.sip.in b/python/core/auto_generated/qgsgeometryoptions.sip.in index 28da763994c7..6639f8e6d3e5 100644 --- a/python/core/auto_generated/qgsgeometryoptions.sip.in +++ b/python/core/auto_generated/qgsgeometryoptions.sip.in @@ -118,8 +118,6 @@ Read the geometry options from ``node``. .. versionadded:: 3.4 %End - const QgsSettingsEntryString settingsGeometryValidationDefaultChecks; - signals: void checkConfigurationChanged(); diff --git a/python/core/auto_generated/qgslocalizeddatapathregistry.sip.in b/python/core/auto_generated/qgslocalizeddatapathregistry.sip.in index 92873da33fe9..8d0a62681a73 100644 --- a/python/core/auto_generated/qgslocalizeddatapathregistry.sip.in +++ b/python/core/auto_generated/qgslocalizeddatapathregistry.sip.in @@ -60,8 +60,6 @@ Since the paths are stored by order of preference, lower positions in the list t Unregisters a localized path %End - const QgsSettingsEntryStringList settingsLocalizedDataPaths; - private: QgsLocalizedDataPathRegistry( const QgsLocalizedDataPathRegistry &other ); }; diff --git a/python/core/auto_generated/qgsmaprendererjob.sip.in b/python/core/auto_generated/qgsmaprendererjob.sip.in index 9fc86cd56436..49e841509a1d 100644 --- a/python/core/auto_generated/qgsmaprendererjob.sip.in +++ b/python/core/auto_generated/qgsmaprendererjob.sip.in @@ -157,8 +157,6 @@ Returns map settings with which this job was started. - const QgsSettingsEntryBool settingsLogCanvasRefreshEvent; - signals: void renderingLayersFinished(); diff --git a/python/core/auto_generated/settings/qgssettingsregistrycore.sip.in b/python/core/auto_generated/settings/qgssettingsregistrycore.sip.in index 5517cc40cb71..570a37f175d1 100644 --- a/python/core/auto_generated/settings/qgssettingsregistrycore.sip.in +++ b/python/core/auto_generated/settings/qgssettingsregistrycore.sip.in @@ -9,7 +9,6 @@ - class QgsSettingsRegistryCore : QgsSettingsRegistry { %Docstring(signature="appended") diff --git a/src/app/main.cpp b/src/app/main.cpp index 85ae09e399fe..7883dba272d0 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -966,18 +966,20 @@ int main( int argc, char *argv[] ) delete profile; { + QgsSettings settings; + /* Translation file for QGIS. */ - QString myUserTranslation = QgsApplication::settingsLocaleUserLocale.value(); - QString myGlobalLocale = QgsApplication::settingsLocaleGlobalLocale.value(); + QString myUserTranslation = settings.value( QStringLiteral( "locale/userLocale" ), "" ).toString(); + QString myGlobalLocale = settings.value( QStringLiteral( "locale/globalLocale" ), "" ).toString(); bool myShowGroupSeparatorFlag = false; // Default to false - bool myLocaleOverrideFlag = QgsApplication::settingsLocaleOverrideFlag.value(); + bool myLocaleOverrideFlag = settings.value( QStringLiteral( "locale/overrideFlag" ), false ).toBool(); // Override Show Group Separator if the global override flag is set if ( myLocaleOverrideFlag ) { // Default to false again - myShowGroupSeparatorFlag = QgsApplication::settingsLocaleShowGroupSeparator.value(); + myShowGroupSeparatorFlag = settings.value( QStringLiteral( "locale/showGroupSeparator" ), false ).toBool(); } // @@ -991,7 +993,7 @@ int main( int argc, char *argv[] ) // if ( !translationCode.isNull() && !translationCode.isEmpty() ) { - QgsApplication::settingsLocaleUserLocale.setValue( translationCode ); + settings.setValue( QStringLiteral( "locale/userLocale" ), translationCode ); } else { @@ -1000,7 +1002,7 @@ int main( int argc, char *argv[] ) translationCode = QLocale().name(); //setting the locale/userLocale when the --lang= option is not set will allow third party //plugins to always use the same locale as the QGIS, otherwise they can be out of sync - QgsApplication::settingsLocaleUserLocale.setValue( translationCode ); + settings.setValue( QStringLiteral( "locale/userLocale" ), translationCode ); } else { diff --git a/src/app/options/qgsoptions.cpp b/src/app/options/qgsoptions.cpp index cf88ec414238..7c5894328731 100644 --- a/src/app/options/qgsoptions.cpp +++ b/src/app/options/qgsoptions.cpp @@ -24,7 +24,6 @@ #include "qgsgdalutils.h" #include "qgshighlight.h" #include "qgsmapcanvas.h" -#include "qgsmaprendererjob.h" #include "qgsprojectionselectiondialog.h" #include "qgscoordinatereferencesystem.h" #include "qgstolerance.h" @@ -475,7 +474,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetCurrentIndex( index ); // log rendering events, for userspace debugging - mLogCanvasRefreshChkBx->setChecked( QgsMapRendererJob::settingsLogCanvasRefreshEvent.value() ); + mLogCanvasRefreshChkBx->setChecked( mSettings->value( QStringLiteral( "/Map/logCanvasRefreshEvent" ), false ).toBool() ); //set the default projection behavior radio buttons const QgsOptions::UnknownLayerCrsBehavior mode = QgsSettings().enumValue( QStringLiteral( "/projections/unknownCrsBehavior" ), QgsOptions::UnknownLayerCrsBehavior::NoAction, QgsSettings::App ); @@ -1015,9 +1014,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetText( tr( "Detected active locale on your system: %1" ).arg( currentLocale ) ); - QString userLocale = QgsApplication::settingsLocaleUserLocale.value(); - bool showGroupSeparator = QgsApplication::settingsLocaleShowGroupSeparator.value(); - QString globalLocale = QgsApplication::settingsLocaleGlobalLocale.value(); + QString userLocale = mSettings->value( QStringLiteral( "locale/userLocale" ), QString( ) ).toString(); + bool showGroupSeparator = mSettings->value( QStringLiteral( "locale/showGroupSeparator" ), false ).toBool(); + QString globalLocale = mSettings->value( QStringLiteral( "locale/globalLocale" ), currentLocale ).toString(); const QStringList language18nList( i18nList() ); for ( const auto &l : language18nList ) { @@ -1044,7 +1043,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetCurrentIndex( cboTranslation->findData( userLocale ) ); cboGlobalLocale->setCurrentIndex( cboGlobalLocale->findData( globalLocale ) ); - grpLocale->setChecked( QgsApplication::settingsLocaleOverrideFlag.value() ); + bool localeOverrideFlag = mSettings->value( QStringLiteral( "locale/overrideFlag" ), false ).toBool(); + grpLocale->setChecked( localeOverrideFlag ); cbShowGroupSeparator->setChecked( showGroupSeparator ); @@ -1673,7 +1673,7 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "/Raster/cumulativeCutUpper" ), mRasterCumulativeCutUpperDoubleSpinBox->value() / 100.0 ); // log rendering events, for userspace debugging - QgsMapRendererJob::settingsLogCanvasRefreshEvent.setValue( mLogCanvasRefreshChkBx->isChecked() ); + mSettings->setValue( QStringLiteral( "/Map/logCanvasRefreshEvent" ), mLogCanvasRefreshChkBx->isChecked() ); //check behavior so default projection when new layer is added with no //projection defined... @@ -1856,12 +1856,12 @@ void QgsOptions::saveOptions() // // Locale settings // - QgsApplication::settingsLocaleUserLocale.setValue( cboTranslation->currentData().toString() ); - QgsApplication::settingsLocaleOverrideFlag.setValue( grpLocale->isChecked() ); - QgsApplication::settingsLocaleGlobalLocale.setValue( cboGlobalLocale->currentData( ).toString() ); + mSettings->setValue( QStringLiteral( "locale/userLocale" ), cboTranslation->currentData().toString() ); + mSettings->setValue( QStringLiteral( "locale/overrideFlag" ), grpLocale->isChecked() ); + mSettings->setValue( QStringLiteral( "locale/globalLocale" ), cboGlobalLocale->currentData( ).toString() ); // Number settings - QgsApplication::settingsLocaleShowGroupSeparator.setValue( cbShowGroupSeparator->isChecked( ) ); + mSettings->setValue( QStringLiteral( "locale/showGroupSeparator" ), cbShowGroupSeparator->isChecked( ) ); QgsLocalDefaultSettings::setBearingFormat( mBearingFormat.get() ); diff --git a/src/app/qgsprojectproperties.cpp b/src/app/qgsprojectproperties.cpp index f729cd48bbae..ec04358ad434 100644 --- a/src/app/qgsprojectproperties.cpp +++ b/src/app/qgsprojectproperties.cpp @@ -983,7 +983,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa } cbtsLocale->addItem( QIcon( QStringLiteral( ":/images/flags/%1.svg" ).arg( QLatin1String( "en_US" ) ) ), QLocale( QStringLiteral( "en_US" ) ).nativeLanguageName(), QStringLiteral( "en_US" ) ); - cbtsLocale->setCurrentIndex( cbtsLocale->findData( QgsApplication::settingsLocaleUserLocale.value() ) ); + cbtsLocale->setCurrentIndex( cbtsLocale->findData( settings.value( QStringLiteral( "locale/userLocale" ), QString() ).toString() ) ); connect( generateTsFileButton, &QPushButton::clicked, this, &QgsProjectProperties::onGenerateTsFileButton ); diff --git a/src/core/network/qgsnetworkaccessmanager.cpp b/src/core/network/qgsnetworkaccessmanager.cpp index 75c9b0b27aaf..3c4bc09ca978 100644 --- a/src/core/network/qgsnetworkaccessmanager.cpp +++ b/src/core/network/qgsnetworkaccessmanager.cpp @@ -654,12 +654,12 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache( Qt::ConnectionType conn int QgsNetworkAccessManager::timeout() { - return settingsNetworkTimeout.value(); + return QgsSettings().value( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), 60000 ).toInt(); } void QgsNetworkAccessManager::setTimeout( const int time ) { - settingsNetworkTimeout.setValue( time ); + QgsSettings().setValue( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), time ); } QgsNetworkReplyContent QgsNetworkAccessManager::blockingGet( QNetworkRequest &request, const QString &authCfg, bool forceRefresh, QgsFeedback *feedback ) diff --git a/src/core/network/qgsnetworkaccessmanager.h b/src/core/network/qgsnetworkaccessmanager.h index b6b643e1d384..b14800f9e8b6 100644 --- a/src/core/network/qgsnetworkaccessmanager.h +++ b/src/core/network/qgsnetworkaccessmanager.h @@ -31,7 +31,6 @@ #include "qgis_core.h" #include "qgis_sip.h" -#include "qgssettingsentry.h" class QgsFeedback; @@ -500,9 +499,6 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager */ static QgsNetworkReplyContent blockingPost( QNetworkRequest &request, const QByteArray &data, const QString &authCfg = QString(), bool forceRefresh = false, QgsFeedback *feedback = nullptr ); - //! Settings entry network timeout - static const inline QgsSettingsEntryInteger settingsNetworkTimeout = QgsSettingsEntryInteger( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), QgsSettings::NoSection, 60000, QObject::tr( "Network timeout" ) ); - signals: /** diff --git a/src/core/network/qgsnewsfeedparser.cpp b/src/core/network/qgsnewsfeedparser.cpp index 183c0bc91aa7..0489ddfc810f 100644 --- a/src/core/network/qgsnewsfeedparser.cpp +++ b/src/core/network/qgsnewsfeedparser.cpp @@ -40,23 +40,24 @@ QgsNewsFeedParser::QgsNewsFeedParser( const QUrl &feedUrl, const QString &authcf QUrlQuery query( feedUrl ); - const qint64 after = settingsFeedLastFetchTime.value( mSettingsKey ); + const qint64 after = QgsSettings().value( QStringLiteral( "%1/lastFetchTime" ).arg( mSettingsKey ), 0, QgsSettings::Core ).toUInt(); if ( after > 0 ) query.addQueryItem( QStringLiteral( "after" ), qgsDoubleToString( after, 0 ) ); - QString feedLanguage = settingsFeedLanguage.value( mSettingsKey ); + QString feedLanguage = QgsSettings().value( QStringLiteral( "%1/lang" ).arg( mSettingsKey ), QString(), QgsSettings::Core ).toString(); if ( feedLanguage.isEmpty() ) { - feedLanguage = QgsSettings().value( QgsApplication::settingsLocaleUserLocale.key(), QStringLiteral( "en_US" ) ).toString().left( 2 ); + feedLanguage = QgsSettings().value( QStringLiteral( "locale/userLocale" ), QStringLiteral( "en_US" ) ).toString().left( 2 ); } if ( !feedLanguage.isEmpty() && feedLanguage != QLatin1String( "C" ) ) query.addQueryItem( QStringLiteral( "lang" ), feedLanguage ); - if ( settingsFeedLatitude.exists( mSettingsKey ) && settingsFeedLongitude.exists( mSettingsKey ) ) + bool latOk = false; + bool longOk = false; + const double feedLat = QgsSettings().value( QStringLiteral( "%1/latitude" ).arg( mSettingsKey ), QString(), QgsSettings::Core ).toDouble( &latOk ); + const double feedLong = QgsSettings().value( QStringLiteral( "%1/longitude" ).arg( mSettingsKey ), QString(), QgsSettings::Core ).toDouble( &longOk ); + if ( latOk && longOk ) { - const double feedLat = settingsFeedLatitude.value( mSettingsKey ); - const double feedLong = settingsFeedLongitude.value( mSettingsKey ); - // hack to allow testing using local files if ( feedUrl.isLocalFile() ) { @@ -169,7 +170,7 @@ void QgsNewsFeedParser::fetch() void QgsNewsFeedParser::onFetch( const QString &content ) { - settingsFeedLastFetchTime.setValue( mFetchStartTime, mSettingsKey ); + QgsSettings().setValue( mSettingsKey + "/lastFetchTime", mFetchStartTime, QgsSettings::Core ); const QVariant json = QgsJsonUtils::parseJson( content ); diff --git a/src/core/network/qgsnewsfeedparser.h b/src/core/network/qgsnewsfeedparser.h index a1d44444626e..9f6f3268722a 100644 --- a/src/core/network/qgsnewsfeedparser.h +++ b/src/core/network/qgsnewsfeedparser.h @@ -17,7 +17,6 @@ #include "qgis_core.h" #include "qgis_sip.h" -#include "qgssettingsentry.h" #include #include #include @@ -111,15 +110,6 @@ class CORE_EXPORT QgsNewsFeedParser : public QObject */ static QString keyForFeed( const QString &baseUrl ); - //! Settings entry last fetch time - static const inline QgsSettingsEntryInteger settingsFeedLastFetchTime = QgsSettingsEntryInteger( QStringLiteral( "%1/lastFetchTime" ), QgsSettings::Core, 0, QObject::tr( "Feed last fetch time" ), 0 ); - //! Settings entry feed language - static const inline QgsSettingsEntryString settingsFeedLanguage = QgsSettingsEntryString( QStringLiteral( "%1/lang" ), QgsSettings::Core, QString(), QObject::tr( "Feed language" ) ); - //! Settings entry feed latitude - static const inline QgsSettingsEntryDouble settingsFeedLatitude = QgsSettingsEntryDouble( QStringLiteral( "%1/latitude" ), QgsSettings::Core, 0.0, QObject::tr( "Feed latitude" ) ); - //! Settings entry feed longitude - static const inline QgsSettingsEntryDouble settingsFeedLongitude = QgsSettingsEntryDouble( QStringLiteral( "%1/longitude" ), QgsSettings::Core, 0.0, QObject::tr( "Feed longitude" ) ); - public slots: /** diff --git a/src/core/processing/qgsprocessing.h b/src/core/processing/qgsprocessing.h index 53eee28fdcf5..d8424016ff7f 100644 --- a/src/core/processing/qgsprocessing.h +++ b/src/core/processing/qgsprocessing.h @@ -19,7 +19,6 @@ #define QGSPROCESSING_H #include "qgis_core.h" -#include "qgssettingsentry.h" #include // @@ -98,15 +97,6 @@ class CORE_EXPORT QgsProcessing * \since QGIS 3.6 */ static const QString TEMPORARY_OUTPUT; - - //! Settings entry prefer filename as layer name - static const inline QgsSettingsEntryBool settingsPreferFilenameAsLayerName = QgsSettingsEntryBool( QStringLiteral( "Processing/Configuration/PREFER_FILENAME_AS_LAYER_NAME" ), QgsSettings::NoSection, true, QObject::tr( "Prefer filename as layer name" ) ); - //! Settings entry temp path - static const inline QgsSettingsEntryString settingsTempPath = QgsSettingsEntryString( QStringLiteral( "Processing/Configuration/TEMP_PATH2" ), QgsSettings::NoSection, QString() ); - //! Settings entry default output vector layer ext - static const inline QgsSettingsEntryInteger settingsDefaultOutputVectorLayerExt = QgsSettingsEntryInteger( QStringLiteral( "Processing/Configuration/DefaultOutputVectorLayerExt" ), QgsSettings::NoSection, -1 ); - //! Settings entry default output raster layer ext - static const inline QgsSettingsEntryInteger settingsDefaultOutputRasterLayerExt = QgsSettingsEntryInteger( QStringLiteral( "Processing/Configuration/DefaultOutputRasterLayerExt" ), QgsSettings::NoSection, -1 ); }; #endif // QGSPROCESSING_H diff --git a/src/core/processing/qgsprocessingcontext.cpp b/src/core/processing/qgsprocessingcontext.cpp index 4c52a4c46a06..cc07c52d46bc 100644 --- a/src/core/processing/qgsprocessingcontext.cpp +++ b/src/core/processing/qgsprocessingcontext.cpp @@ -197,7 +197,7 @@ void QgsProcessingContext::LayerDetails::setOutputLayerName( QgsMapLayer *layer if ( !layer ) return; - const bool preferFilenameAsLayerName = QgsProcessing::settingsPreferFilenameAsLayerName.value(); + const bool preferFilenameAsLayerName = QgsSettings().value( QStringLiteral( "Processing/Configuration/PREFER_FILENAME_AS_LAYER_NAME" ), true ).toBool(); // note - for temporary layers, we don't use the filename, regardless of user setting (it will be meaningless!) if ( ( !forceName && preferFilenameAsLayerName && !layer->isTemporary() ) || name.isEmpty() ) diff --git a/src/core/processing/qgsprocessingutils.cpp b/src/core/processing/qgsprocessingutils.cpp index fc19b2094dc1..ac72c22fdf2f 100644 --- a/src/core/processing/qgsprocessingutils.cpp +++ b/src/core/processing/qgsprocessingutils.cpp @@ -954,7 +954,7 @@ QString QgsProcessingUtils::tempFolder() static QString sFolder; static QMutex sMutex; QMutexLocker locker( &sMutex ); - const QString basePath = QgsProcessing::settingsTempPath.value(); + const QString basePath = QgsSettings().value( QStringLiteral( "Processing/Configuration/TEMP_PATH2" ) ).toString(); if ( basePath.isEmpty() ) { // default setting -- automatically create a temp folder @@ -1211,7 +1211,8 @@ QgsFields QgsProcessingUtils::indicesToFields( const QList &indices, const QString QgsProcessingUtils::defaultVectorExtension() { - const int setting = QgsProcessing::settingsDefaultOutputVectorLayerExt.value(); + QgsSettings settings; + const int setting = settings.value( QStringLiteral( "Processing/Configuration/DefaultOutputVectorLayerExt" ), -1 ).toInt(); if ( setting == -1 ) return QStringLiteral( "gpkg" ); return QgsVectorFileWriter::supportedFormatExtensions().value( setting, QStringLiteral( "gpkg" ) ); @@ -1219,7 +1220,8 @@ QString QgsProcessingUtils::defaultVectorExtension() QString QgsProcessingUtils::defaultRasterExtension() { - const int setting = QgsProcessing::settingsDefaultOutputRasterLayerExt.value(); + QgsSettings settings; + const int setting = settings.value( QStringLiteral( "Processing/Configuration/DefaultOutputRasterLayerExt" ), -1 ).toInt(); if ( setting == -1 ) return QStringLiteral( "tif" ); return QgsRasterFileWriter::supportedFormatExtensions().value( setting, QStringLiteral( "tif" ) ); diff --git a/src/core/project/qgsproject.cpp b/src/core/project/qgsproject.cpp index 60ac90cbf8e7..181929095f94 100644 --- a/src/core/project/qgsproject.cpp +++ b/src/core/project/qgsproject.cpp @@ -1356,7 +1356,7 @@ bool QgsProject::readProjectFile( const QString &filename, QgsProject::ReadFlags QgsApplication::profiler()->clear( QStringLiteral( "projectload" ) ); QgsScopedRuntimeProfile profile( tr( "Setting up translations" ), QStringLiteral( "projectload" ) ); - QString localeFileName = QStringLiteral( "%1_%2" ).arg( QFileInfo( projectFile.fileName() ).baseName(), QgsApplication::settingsLocaleUserLocale.value() ); + QString localeFileName = QStringLiteral( "%1_%2" ).arg( QFileInfo( projectFile.fileName() ).baseName(), mSettings.value( QStringLiteral( "locale/userLocale" ), QString() ).toString() ); if ( QFile( QStringLiteral( "%1/%2.qm" ).arg( QFileInfo( projectFile.fileName() ).absolutePath(), localeFileName ) ).exists() ) { diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp index f5ceba1b250c..b095dc69dc09 100644 --- a/src/core/qgsapplication.cpp +++ b/src/core/qgsapplication.cpp @@ -1063,7 +1063,7 @@ QString QgsApplication::srsDatabaseFilePath() void QgsApplication::setSvgPaths( const QStringList &svgPaths ) { - settingsSearchPathsForSVG.setValue( svgPaths ); + QgsSettings().setValue( QStringLiteral( "svg/searchPathsForSVG" ), svgPaths ); members()->mSvgPathCacheValid = false; } @@ -1082,7 +1082,8 @@ QStringList QgsApplication::svgPaths() locker.changeMode( QgsReadWriteLocker::Write ); //local directories to search when looking for an SVG with a given basename //defined by user in options dialog - const QStringList pathList = settingsSearchPathsForSVG.value(); + QgsSettings settings; + const QStringList pathList = settings.value( QStringLiteral( "svg/searchPathsForSVG" ) ).toStringList(); // maintain user set order while stripping duplicates QStringList paths; @@ -1224,9 +1225,11 @@ QString QgsApplication::platform() QString QgsApplication::locale() { - if ( settingsLocaleOverrideFlag.value() ) + QgsSettings settings; + bool overrideLocale = settings.value( QStringLiteral( "locale/overrideFlag" ), false ).toBool(); + if ( overrideLocale ) { - QString locale = settingsLocaleUserLocale.value(); + QString locale = settings.value( QStringLiteral( "locale/userLocale" ), QString() ).toString(); // don't differentiate en_US and en_GB if ( locale.startsWith( QLatin1String( "en" ), Qt::CaseInsensitive ) ) { diff --git a/src/core/qgsapplication.h b/src/core/qgsapplication.h index 937e4175f225..2ea07b19e720 100644 --- a/src/core/qgsapplication.h +++ b/src/core/qgsapplication.h @@ -23,7 +23,6 @@ #include "qgis_sip.h" #include "qgsconfig.h" -#include "qgssettingsentry.h" #include "qgstranslationcontext.h" class QgsSettingsRegistryCore; @@ -945,17 +944,6 @@ class CORE_EXPORT QgsApplication : public QApplication */ void collectTranslatableObjects( QgsTranslationContext *translationContext ); - //! Settings entry locale user locale - static const inline QgsSettingsEntryString settingsLocaleUserLocale = QgsSettingsEntryString( QStringLiteral( "locale/userLocale" ), QgsSettings::NoSection, QString() ); - //! Settings entry locale override flag - static const inline QgsSettingsEntryBool settingsLocaleOverrideFlag = QgsSettingsEntryBool( QStringLiteral( "locale/overrideFlag" ), QgsSettings::NoSection, false ); - //! Settings entry locale global locale - static const inline QgsSettingsEntryString settingsLocaleGlobalLocale = QgsSettingsEntryString( QStringLiteral( "locale/globalLocale" ), QgsSettings::NoSection, QString() ); - //! Settings entry locale show group separator - static const inline QgsSettingsEntryBool settingsLocaleShowGroupSeparator = QgsSettingsEntryBool( QStringLiteral( "locale/showGroupSeparator" ), QgsSettings::NoSection, false ); - //! Settings entry search path for SVG - static const inline QgsSettingsEntryStringList settingsSearchPathsForSVG = QgsSettingsEntryStringList( QStringLiteral( "svg/searchPathsForSVG" ), QgsSettings::NoSection, QStringList() ); - #ifdef SIP_RUN SIP_IF_FEATURE( ANDROID ) //dummy method to workaround sip generation issue diff --git a/src/core/qgsgeometryoptions.cpp b/src/core/qgsgeometryoptions.cpp index 750ce7744845..643ee606f1bc 100644 --- a/src/core/qgsgeometryoptions.cpp +++ b/src/core/qgsgeometryoptions.cpp @@ -23,7 +23,7 @@ QgsGeometryOptions::QgsGeometryOptions() { - mGeometryChecks = settingsGeometryValidationDefaultChecks.value().split( ',' ) ; + mGeometryChecks = QgsSettings().value( QStringLiteral( "geometry_validation/default_checks" ) ).toString().split( ',' ) ; } bool QgsGeometryOptions::removeDuplicateNodes() const diff --git a/src/core/qgsgeometryoptions.h b/src/core/qgsgeometryoptions.h index 8fae89986ef4..bceabf4b9348 100644 --- a/src/core/qgsgeometryoptions.h +++ b/src/core/qgsgeometryoptions.h @@ -21,7 +21,6 @@ #include "qgis_core.h" #include "qgis_sip.h" #include "qgsgeometry.h" -#include "qgssettingsentry.h" #include @@ -132,9 +131,6 @@ class CORE_EXPORT QgsGeometryOptions : public QObject */ void readXml( const QDomNode &node ); - //! Settings entry search path for templates - static const inline QgsSettingsEntryString settingsGeometryValidationDefaultChecks = QgsSettingsEntryString( QStringLiteral( "geometry_validation/default_checks" ), QgsSettings::NoSection, QString() ); - signals: /** diff --git a/src/core/qgslocalizeddatapathregistry.cpp b/src/core/qgslocalizeddatapathregistry.cpp index 7c148b05d576..e2749881f5ed 100644 --- a/src/core/qgslocalizeddatapathregistry.cpp +++ b/src/core/qgslocalizeddatapathregistry.cpp @@ -105,10 +105,10 @@ void QgsLocalizedDataPathRegistry::unregisterPath( const QString &path ) void QgsLocalizedDataPathRegistry::readFromSettings() { - setPaths( settingsLocalizedDataPaths.value() ); + setPaths( QgsSettings().value( QStringLiteral( "/qgis/localized_data_paths" ) ).toStringList() ); } void QgsLocalizedDataPathRegistry::writeToSettings() { - settingsLocalizedDataPaths.setValue( paths() ); + QgsSettings().setValue( QStringLiteral( "/qgis/localized_data_paths" ), paths() ); } diff --git a/src/core/qgslocalizeddatapathregistry.h b/src/core/qgslocalizeddatapathregistry.h index b1e222c5efee..fc150d8b10da 100644 --- a/src/core/qgslocalizeddatapathregistry.h +++ b/src/core/qgslocalizeddatapathregistry.h @@ -24,7 +24,6 @@ #include "qgis_core.h" #include "qgis_sip.h" -#include "qgssettingsentry.h" /** * \ingroup core @@ -66,9 +65,6 @@ class CORE_EXPORT QgsLocalizedDataPathRegistry //! Unregisters a localized path void unregisterPath( const QString &path ); - //! Settings entry localized data paths - static const inline QgsSettingsEntryStringList settingsLocalizedDataPaths = QgsSettingsEntryStringList( QStringLiteral( "/qgis/localized_data_paths" ), QgsSettings::NoSection, QStringList() ); - private: #ifdef SIP_RUN QgsLocalizedDataPathRegistry( const QgsLocalizedDataPathRegistry &other ) diff --git a/src/core/qgsmaprendererjob.cpp b/src/core/qgsmaprendererjob.cpp index 2128ac38d2ca..b1f8ac90dd6a 100644 --- a/src/core/qgsmaprendererjob.cpp +++ b/src/core/qgsmaprendererjob.cpp @@ -977,7 +977,8 @@ void QgsMapRendererJob::composeSecondPass( LayerRenderJobs &secondPassJobs, Labe void QgsMapRendererJob::logRenderingTime( const LayerRenderJobs &jobs, const LayerRenderJobs &secondPassJobs, const LabelRenderJob &labelJob ) { - if ( !settingsLogCanvasRefreshEvent.value() ) + QgsSettings settings; + if ( !settings.value( QStringLiteral( "Map/logCanvasRefreshEvent" ), false ).toBool() ) return; QMultiMap elapsed; diff --git a/src/core/qgsmaprendererjob.h b/src/core/qgsmaprendererjob.h index cc382738a866..4534a4020059 100644 --- a/src/core/qgsmaprendererjob.h +++ b/src/core/qgsmaprendererjob.h @@ -29,7 +29,6 @@ #include "qgsmapsettings.h" #include "qgsmaskidprovider.h" -#include "qgssettingsentry.h" class QgsLabelingEngine; @@ -344,9 +343,6 @@ class CORE_EXPORT QgsMapRendererJob : public QObject */ static const QString LABEL_PREVIEW_CACHE_ID SIP_SKIP; - //! Settings entry log canvas refresh event - static const inline QgsSettingsEntryBool settingsLogCanvasRefreshEvent = QgsSettingsEntryBool( QStringLiteral( "Map/logCanvasRefreshEvent" ), QgsSettings::NoSection, false ); - signals: /** diff --git a/src/core/settings/qgssettingsregistrycore.cpp b/src/core/settings/qgssettingsregistrycore.cpp index 2e94674c5fbd..1f5a58f3fb76 100644 --- a/src/core/settings/qgssettingsregistrycore.cpp +++ b/src/core/settings/qgssettingsregistrycore.cpp @@ -17,13 +17,6 @@ #include "qgslayout.h" #include "qgslocator.h" -#include "qgsnetworkaccessmanager.h" -#include "qgsnewsfeedparser.h" -#include "qgsprocessing.h" -#include "qgsapplication.h" -#include "qgsgeometryoptions.h" -#include "qgslocalizeddatapathregistry.h" -#include "qgsmaprendererjob.h" QgsSettingsRegistryCore::QgsSettingsRegistryCore() : QgsSettingsRegistry() @@ -33,32 +26,9 @@ QgsSettingsRegistryCore::QgsSettingsRegistryCore() addSettingsEntry( &QgsLocator::settingsLocatorFilterEnabled ); addSettingsEntry( &QgsLocator::settingsLocatorFilterDefault ); addSettingsEntry( &QgsLocator::settingsLocatorFilterPrefix ); - - addSettingsEntry( &QgsNetworkAccessManager::settingsNetworkTimeout ); - - addSettingsEntry( &QgsNewsFeedParser::settingsFeedLastFetchTime ); - addSettingsEntry( &QgsNewsFeedParser::settingsFeedLanguage ); - addSettingsEntry( &QgsNewsFeedParser::settingsFeedLatitude ); - addSettingsEntry( &QgsNewsFeedParser::settingsFeedLongitude ); - - addSettingsEntry( &QgsProcessing::settingsPreferFilenameAsLayerName ); - addSettingsEntry( &QgsProcessing::settingsTempPath ); - addSettingsEntry( &QgsProcessing::settingsDefaultOutputVectorLayerExt ); - addSettingsEntry( &QgsProcessing::settingsDefaultOutputRasterLayerExt ); - - addSettingsEntry( &QgsApplication::settingsLocaleUserLocale ); - addSettingsEntry( &QgsApplication::settingsLocaleOverrideFlag ); - addSettingsEntry( &QgsApplication::settingsLocaleGlobalLocale ); - addSettingsEntry( &QgsApplication::settingsLocaleShowGroupSeparator ); - addSettingsEntry( &QgsApplication::settingsSearchPathsForSVG ); - - addSettingsEntry( &QgsGeometryOptions::settingsGeometryValidationDefaultChecks ); - - addSettingsEntry( &QgsLocalizedDataPathRegistry::settingsLocalizedDataPaths ); - - addSettingsEntry( &QgsMapRendererJob::settingsLogCanvasRefreshEvent ); } QgsSettingsRegistryCore::~QgsSettingsRegistryCore() { } + diff --git a/src/core/settings/qgssettingsregistrycore.h b/src/core/settings/qgssettingsregistrycore.h index 0f435cc5c257..b85dfe80ee02 100644 --- a/src/core/settings/qgssettingsregistrycore.h +++ b/src/core/settings/qgssettingsregistrycore.h @@ -21,8 +21,6 @@ #include "qgis_sip.h" #include "qgssettingsregistry.h" -#include - /** * \ingroup core * \class QgsSettingsRegistryCore diff --git a/src/gui/qgsconfigureshortcutsdialog.cpp b/src/gui/qgsconfigureshortcutsdialog.cpp index e5dd2a4c0d47..fc514c19e436 100644 --- a/src/gui/qgsconfigureshortcutsdialog.cpp +++ b/src/gui/qgsconfigureshortcutsdialog.cpp @@ -16,7 +16,6 @@ #include "qgsconfigureshortcutsdialog.h" #include "qgsshortcutsmanager.h" -#include "qgsapplication.h" #include "qgslogger.h" #include "qgssettings.h" #include "qgsgui.h" @@ -136,7 +135,7 @@ void QgsConfigureShortcutsDialog::saveShortcuts() QDomDocument doc( QStringLiteral( "shortcuts" ) ); QDomElement root = doc.createElement( QStringLiteral( "qgsshortcuts" ) ); root.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) ); - root.setAttribute( QStringLiteral( "locale" ), settings.value( QgsApplication::settingsLocaleUserLocale.key(), "en_US" ).toString() ); + root.setAttribute( QStringLiteral( "locale" ), settings.value( QStringLiteral( "locale/userLocale" ), "en_US" ).toString() ); doc.appendChild( root ); settings.beginGroup( mManager->settingsPath() ); @@ -203,12 +202,13 @@ void QgsConfigureShortcutsDialog::loadShortcuts() return; } + QgsSettings settings; QString currentLocale; - bool localeOverrideFlag = QgsApplication::settingsLocaleOverrideFlag.value(); + bool localeOverrideFlag = settings.value( QStringLiteral( "locale/overrideFlag" ), false ).toBool(); if ( localeOverrideFlag ) { - currentLocale = QgsApplication::settingsLocaleUserLocale.value( QString(), true, "en_US" ); + currentLocale = settings.value( QStringLiteral( "locale/userLocale" ), "en_US" ).toString(); } else // use QGIS locale { diff --git a/src/gui/qgsgui.cpp b/src/gui/qgsgui.cpp index 4fcf9bdc7004..5db19edc2fad 100644 --- a/src/gui/qgsgui.cpp +++ b/src/gui/qgsgui.cpp @@ -174,7 +174,8 @@ void QgsGui::setWindowManager( QgsWindowManagerInterface *manager ) QgsGui::HigFlags QgsGui::higFlags() { - if ( QgsApplication::settingsLocaleUserLocale.value().startsWith( QLatin1String( "en" ) ) ) + QgsSettings settings; + if ( settings.value( QStringLiteral( "locale/userLocale" ), QString() ).toString().startsWith( QLatin1String( "en" ) ) ) { return HigMenuTextIsTitleCase | HigDialogTitleIsTitleCase; } diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index 0b9e56a6e44e..0740cfb86e5e 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -61,7 +61,6 @@ email : sherman at mrcc.com #include "qgsmapoverviewcanvas.h" #include "qgsmaprenderercache.h" #include "qgsmaprenderercustompainterjob.h" -#include "qgsmaprendererjob.h" #include "qgsmaprendererparalleljob.h" #include "qgsmaprenderersequentialjob.h" #include "qgsmapsettingsutils.h" @@ -706,7 +705,8 @@ void QgsMapCanvas::rendererJobFinished() QPainter p( &img ); emit renderComplete( &p ); - if ( QgsMapRendererJob::settingsLogCanvasRefreshEvent.value() ) + QgsSettings settings; + if ( settings.value( QStringLiteral( "Map/logCanvasRefreshEvent" ), false ).toBool() ) { QString logMsg = tr( "Canvas refresh: %1 ms" ).arg( mJob->renderingTime() ); QgsMessageLog::logMessage( logMsg, tr( "Rendering" ) ); diff --git a/tests/src/analysis/testqgsprocessing.cpp b/tests/src/analysis/testqgsprocessing.cpp index 0f688306fa65..f47a4f061fc1 100644 --- a/tests/src/analysis/testqgsprocessing.cpp +++ b/tests/src/analysis/testqgsprocessing.cpp @@ -2303,11 +2303,11 @@ void TestQgsProcessing::parameters() context2.layersToLoadOnCompletion().values().at( 0 ).setOutputLayerName( rl.get() ); QCOMPARE( rl->name(), QStringLiteral( "landsat" ) ); // unless setting prohibits it... - QgsProcessing::settingsPreferFilenameAsLayerName.setValue( false ); + QgsSettings().setValue( QStringLiteral( "Processing/Configuration/PREFER_FILENAME_AS_LAYER_NAME" ), false ); context2.layersToLoadOnCompletion().values().at( 0 ).setOutputLayerName( rl.get() ); QCOMPARE( rl->name(), QStringLiteral( "my_dest" ) ); // if layer has a layername, we should use that instead of the base file name... - QgsProcessing::settingsPreferFilenameAsLayerName.setValue( true ); + QgsSettings().setValue( QStringLiteral( "Processing/Configuration/PREFER_FILENAME_AS_LAYER_NAME" ), true ); vl = std::make_unique< QgsVectorLayer >( QStringLiteral( TEST_DATA_DIR ) + "/points_gpkg.gpkg|layername=points_small", QString() ); context2.layersToLoadOnCompletion().values().at( 0 ).setOutputLayerName( vl.get() ); QCOMPARE( vl->name(), QStringLiteral( "points_small" ) ); @@ -11042,7 +11042,7 @@ void TestQgsProcessing::tempUtils() QgsSettings settings; QString alternative_tempFolder1 = tempDirPath + QStringLiteral( "/alternative_temp_test_one" ); - QgsProcessing::settingsTempPath.setValue( alternative_tempFolder1 ); + settings.setValue( QStringLiteral( "Processing/Configuration/TEMP_PATH2" ), alternative_tempFolder1 ); // check folder and if it's constant with alternative temp folder 1 tempFolder = QgsProcessingUtils::tempFolder(); QCOMPARE( tempFolder.left( alternative_tempFolder1.length() ), alternative_tempFolder1 ); @@ -11054,7 +11054,7 @@ void TestQgsProcessing::tempUtils() QVERIFY( alternativeTempFile1.startsWith( alternative_tempFolder1 ) ); // change temp folder in the settings again QString alternative_tempFolder2 = tempDirPath + QStringLiteral( "/alternative_temp_test_two" ); - QgsProcessing::settingsTempPath.setValue( alternative_tempFolder2 ); + settings.setValue( QStringLiteral( "Processing/Configuration/TEMP_PATH2" ), alternative_tempFolder2 ); // check folder and if it's constant constant with alternative temp folder 2 tempFolder = QgsProcessingUtils::tempFolder(); QCOMPARE( tempFolder.left( alternative_tempFolder2.length() ), alternative_tempFolder2 ); @@ -11064,7 +11064,7 @@ void TestQgsProcessing::tempUtils() QVERIFY( alternativeTempFile2.endsWith( "alternative_temptest.txt" ) ); QVERIFY( alternativeTempFile2.startsWith( tempFolder ) ); QVERIFY( alternativeTempFile2.startsWith( alternative_tempFolder2 ) ); - QgsProcessing::settingsTempPath.setValue( QString() ); + settings.setValue( QStringLiteral( "Processing/Configuration/TEMP_PATH2" ), QString() ); } @@ -11529,8 +11529,10 @@ void TestQgsProcessing::defaultExtensionsForProvider() QCOMPARE( context.preferredRasterFormat(), QStringLiteral( "tif" ) ); // unless the user has set a default format, which IS supported by that provider - QgsProcessing::settingsDefaultOutputVectorLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "tab" ) ) ); - QgsProcessing::settingsDefaultOutputRasterLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "sdat" ) ) ); + QgsSettings settings; + + settings.setValue( QStringLiteral( "Processing/Configuration/DefaultOutputVectorLayerExt" ), QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "tab" ) ) ); + settings.setValue( QStringLiteral( "Processing/Configuration/DefaultOutputRasterLayerExt" ), QgsRasterFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "sdat" ) ) ); QCOMPARE( provider.defaultVectorFileExtension( true ), QStringLiteral( "tab" ) ); QCOMPARE( provider.defaultRasterFileExtension(), QStringLiteral( "sdat" ) ); @@ -11541,8 +11543,8 @@ void TestQgsProcessing::defaultExtensionsForProvider() QCOMPARE( context2.preferredRasterFormat(), QStringLiteral( "sdat" ) ); // but if default is not supported by provider, we use a supported format - QgsProcessing::settingsDefaultOutputVectorLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "gpkg" ) ) ); - QgsProcessing::settingsDefaultOutputRasterLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "ecw" ) ) ); + settings.setValue( QStringLiteral( "Processing/Configuration/DefaultOutputVectorLayerExt" ), QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "gpkg" ) ) ); + settings.setValue( QStringLiteral( "Processing/Configuration/DefaultOutputRasterLayerExt" ), QgsRasterFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "ecw" ) ) ); QCOMPARE( provider.defaultVectorFileExtension( true ), QStringLiteral( "mif" ) ); QCOMPARE( provider.defaultRasterFileExtension(), QStringLiteral( "mig" ) ); } diff --git a/tests/src/core/testqgscompositionconverter.cpp b/tests/src/core/testqgscompositionconverter.cpp index 346c211410c7..3a1ab011ef26 100644 --- a/tests/src/core/testqgscompositionconverter.cpp +++ b/tests/src/core/testqgscompositionconverter.cpp @@ -163,7 +163,8 @@ void TestQgsCompositionConverter::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); mReport = QStringLiteral( "

Layout Tests

\n" ); - QgsApplication::settingsSearchPathsForSVG.setValue( QStringList() << QStringLiteral( TEST_DATA_DIR ) ); + QgsSettings settings; + settings.setValue( QStringLiteral( "svg/searchPathsForSVG" ), QStringLiteral( TEST_DATA_DIR ) ) ; } void TestQgsCompositionConverter::cleanupTestCase() diff --git a/tests/src/core/testqgsnetworkaccessmanager.cpp b/tests/src/core/testqgsnetworkaccessmanager.cpp index f8b51c6cd43a..d96627ffa4f2 100644 --- a/tests/src/core/testqgsnetworkaccessmanager.cpp +++ b/tests/src/core/testqgsnetworkaccessmanager.cpp @@ -175,7 +175,7 @@ void TestQgsNetworkAccessManager::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); - QgsNetworkAccessManager::settingsNetworkTimeout.setValue( 5000 ); + QgsSettings().setValue( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), 5000 ); mHttpBinHost = QStringLiteral( "httpbin.org" ); QString overrideHost = qgetenv( "QGIS_HTTPBIN_HOST" ); diff --git a/tests/src/core/testqgsnewsfeedparser.cpp b/tests/src/core/testqgsnewsfeedparser.cpp index 28ba11ad1817..b8369ad5368b 100644 --- a/tests/src/core/testqgsnewsfeedparser.cpp +++ b/tests/src/core/testqgsnewsfeedparser.cpp @@ -111,12 +111,12 @@ void TestQgsNewsFeedParser::testFetch() entries.clear(); // after a fetch, the current timestamp should be saved to avoid refetching these - uint after = QgsNewsFeedParser::settingsFeedLastFetchTime.value( feedKey ); + uint after = QgsSettings().value( feedKey + "/lastFetchTime", 0, QgsSettings::Core ).toUInt(); QVERIFY( after >= beforeTime ); // reset to a standard known last time QgsSettings().remove( feedKey, QgsSettings::Core ); - QgsNewsFeedParser::settingsFeedLastFetchTime.setValue( 1457360008, feedKey ); + QgsSettings().setValue( feedKey + "/lastFetchTime", 1457360008, QgsSettings::Core ); // refetch, only new items should be fetched QgsNewsFeedParser parser2( url ); @@ -230,7 +230,7 @@ void TestQgsNewsFeedParser::testLang() const QString feedKey = QgsNewsFeedParser::keyForFeed( url.toString() ); QgsSettings().remove( feedKey, QgsSettings::Core ); // force to Spanish language - QgsNewsFeedParser::settingsFeedLanguage.setValue( QStringLiteral( "es" ), feedKey ); + QgsSettings().setValue( QStringLiteral( "%1/lang" ).arg( feedKey ), QStringLiteral( "es" ), QgsSettings::Core ); QgsNewsFeedParser parser( url ); QSignalSpy spy( &parser, &QgsNewsFeedParser::entryAdded ); @@ -256,8 +256,8 @@ void TestQgsNewsFeedParser::testGeoFencing() const QUrl url( QUrl::fromLocalFile( QStringLiteral( TEST_DATA_DIR ) + "/newsfeed/feed" ) ); const QString feedKey = QgsNewsFeedParser::keyForFeed( url.toString() ); QgsSettings().remove( feedKey, QgsSettings::Core ); - QgsNewsFeedParser::settingsFeedLatitude.setValue( 37.2343, feedKey ); - QgsNewsFeedParser::settingsFeedLongitude.setValue( -115.8067, feedKey ); + QgsSettings().setValue( QStringLiteral( "%1/latitude" ).arg( feedKey ), 37.2343, QgsSettings::Core ); + QgsSettings().setValue( QStringLiteral( "%1/longitude" ).arg( feedKey ), -115.8067, QgsSettings::Core ); QgsNewsFeedParser parser( url ); QSignalSpy spy( &parser, &QgsNewsFeedParser::entryAdded ); diff --git a/tests/src/core/testqgstranslateproject.cpp b/tests/src/core/testqgstranslateproject.cpp index aa5f674f81ad..f1be8ab0ba68 100644 --- a/tests/src/core/testqgstranslateproject.cpp +++ b/tests/src/core/testqgstranslateproject.cpp @@ -47,6 +47,7 @@ class TestQgsTranslateProject : public QObject void translateProject(); private: + QgsSettings settings; QString original_locale; }; @@ -57,12 +58,12 @@ void TestQgsTranslateProject::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); - original_locale = QgsApplication::settingsLocaleUserLocale.value(); + original_locale = settings.value( QStringLiteral( "locale/userLocale" ), "" ).toString() ; } void TestQgsTranslateProject::cleanupTestCase() { - QgsApplication::settingsLocaleUserLocale.setValue( original_locale ); + settings.setValue( QStringLiteral( "locale/userLocale" ), original_locale ); QgsApplication::exitQgis(); //delete translated project file @@ -91,7 +92,7 @@ void TestQgsTranslateProject::cleanup() void TestQgsTranslateProject::createTsFile() { //open project in english - QgsApplication::settingsLocaleUserLocale.setValue( "en" ); + settings.setValue( QStringLiteral( "locale/userLocale" ), "en" ); QString projectFileName( TEST_DATA_DIR ); projectFileName = projectFileName + "/project_translation/points_translation.qgs"; QgsProject::instance()->read( projectFileName ); @@ -163,7 +164,7 @@ void TestQgsTranslateProject::createTsFile() void TestQgsTranslateProject::translateProject() { //open project in german - QgsApplication::settingsLocaleUserLocale.setValue( "de" ); + settings.setValue( QStringLiteral( "locale/userLocale" ), "de" ); QString projectFileName( TEST_DATA_DIR ); projectFileName = projectFileName + "/project_translation/points_translation.qgs"; QgsProject::instance()->read( projectFileName );