Removed settings struct

This commit is contained in:
Damiano 2021-04-15 17:32:59 +02:00
parent 00a7936389
commit 95dfe0f45c
37 changed files with 176 additions and 191 deletions

View File

@ -321,6 +321,7 @@ The contents of the reply will be returned after the request is completed or an
.. versionadded:: 3.6
%End
<<<<<<< HEAD
void requestAuthOpenBrowser( const QUrl &url ) const;
%Docstring
Forwards an external browser login ``url`` opening request to the authentication handler.
@ -342,6 +343,9 @@ Forwards an external browser login closure request to the authentication handler
.. versionadded:: 3.20
%End
=======
const QgsSettingsEntryInteger settingsNetworkTimeout;
>>>>>>> 2087a7f4f8 (Removed settings struct)
signals:

View File

@ -93,13 +93,10 @@ Returns the authentication configuration for the parser.
Returns the settings key used for a feed with the given ``baseUrl``.
%End
struct Settings
{
const QgsSettingsEntryInteger feedLastFetchTime;
const QgsSettingsEntryString feedLanguage;
const QgsSettingsEntryDouble feedLatitude;
const QgsSettingsEntryDouble feedLongitude;
};
const QgsSettingsEntryInteger settingsFeedLastFetchTime;
const QgsSettingsEntryString settingsFeedLanguage;
const QgsSettingsEntryDouble settingsFeedLatitude;
const QgsSettingsEntryDouble settingsFeedLongitude;
public slots:

View File

@ -53,13 +53,10 @@ Converts a source ``type`` to a string representation.
static const QString TEMPORARY_OUTPUT;
struct Settings
{
const QgsSettingsEntryBool preferFilenameAsLayerName;
const QgsSettingsEntryString tempPath;
const QgsSettingsEntryInteger defaultOutputVectorLayerExt;
const QgsSettingsEntryInteger defaultOutputRasterLayerExt;
};
const QgsSettingsEntryBool settingsPreferFilenameAsLayerName;
const QgsSettingsEntryString settingsTempPath;
const QgsSettingsEntryInteger settingsDefaultOutputVectorLayerExt;
const QgsSettingsEntryInteger settingsDefaultOutputRasterLayerExt;
};
/************************************************************************

View File

@ -1003,14 +1003,11 @@ Emits the signal to collect all the strings of .qgs to be included in ts file
.. versionadded:: 3.4
%End
struct Settings
{
const QgsSettingsEntryString localeUserLocale;
const QgsSettingsEntryBool localeOverrideFlag;
const QgsSettingsEntryString localeGlobalLocale;
const QgsSettingsEntryBool localeShowGroupSeparator;
const QgsSettingsEntryStringList searchPathsForSVG;
};
const QgsSettingsEntryString settingsLocaleUserLocale;
const QgsSettingsEntryBool settingsLocaleOverrideFlag;
const QgsSettingsEntryString settingsLocaleGlobalLocale;
const QgsSettingsEntryBool settingsLocaleShowGroupSeparator;
const QgsSettingsEntryStringList settingsSearchPathsForSVG;
%If (ANDROID)
//dummy method to workaround sip generation issue

View File

@ -118,10 +118,7 @@ Read the geometry options from ``node``.
.. versionadded:: 3.4
%End
struct Settings
{
const QgsSettingsEntryString geometryValidationDefaultChecks;
};
const QgsSettingsEntryString settingsGeometryValidationDefaultChecks;
signals:

View File

@ -60,10 +60,7 @@ Since the paths are stored by order of preference, lower positions in the list t
Unregisters a localized path
%End
struct Settings
{
const QgsSettingsEntryStringList localizedDataPaths;
};
const QgsSettingsEntryStringList settingsLocalizedDataPaths;
private:
QgsLocalizedDataPathRegistry( const QgsLocalizedDataPathRegistry &other );

View File

@ -157,11 +157,7 @@ Returns map settings with which this job was started.
struct Settings
{
const QgsSettingsEntryBool logCanvasRefreshEvent;
};
const QgsSettingsEntryBool settingsLogCanvasRefreshEvent;
signals:

View File

@ -84,6 +84,7 @@ Get settings entry key.
The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key.
%End
<<<<<<< HEAD
bool keyIsValid( const QString &key ) const;
%Docstring
Returns ``True`` if the provided key match the settings entry.
@ -95,6 +96,8 @@ defined with the key "NewsFeed/%1/%2/content"
The ``key`` to check
%End
=======
>>>>>>> 7b8aad6203 (Removed settings struct)
QString definitionKey() const;
%Docstring
Returns settings entry defining key.
@ -116,7 +119,11 @@ The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
bool exists( const QStringList &dynamicKeyPartList ) const;
%Docstring
<<<<<<< HEAD
Returns ``True`` if the settings is contained in the underlying QSettings.
=======
Returns true if the settings is contained in the underlying QSettings.
>>>>>>> 7b8aad6203 (Removed settings struct)
The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key.
%End
@ -297,11 +304,19 @@ The ``description`` argument specifies a description for the settings entry.
bool setValue( const QString &value, const QString &dynamicKeyPart = QString() ) const;
%Docstring
Set settings value.
<<<<<<< HEAD
The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End
=======
The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End
>>>>>>> 7b8aad6203 (Removed settings struct)
bool setValue( const QString &value, const QStringList &dynamicKeyPartList ) const;
%Docstring
Set settings value.
@ -396,11 +411,19 @@ The ``description`` argument specifies a description for the settings entry.
bool setValue( const QStringList &value, const QString &dynamicKeyPart = QString() ) const;
%Docstring
Set settings value.
<<<<<<< HEAD
The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End
=======
The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End
>>>>>>> 7b8aad6203 (Removed settings struct)
bool setValue( const QStringList &value, const QStringList &dynamicKeyPartList ) const;
%Docstring
Set settings value.
@ -645,11 +668,19 @@ The ``description`` argument specifies a description for the settings entry.
bool setValue( double value, const QString &dynamicKeyPart = QString() ) const;
%Docstring
Set settings value.
<<<<<<< HEAD
The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End
=======
The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End
>>>>>>> 7b8aad6203 (Removed settings struct)
bool setValue( double value, const QStringList &dynamicKeyPartList ) const;
%Docstring
Set settings value.

View File

@ -31,6 +31,7 @@ Constructor for QgsSettingsRegistry.
virtual ~QgsSettingsRegistry();
<<<<<<< HEAD
QList<const QgsSettingsEntryBase *> getChildSettingsEntries() const;
%Docstring
Returns the list of registered :py:class:`QgsSettingsEntryBase`.
@ -55,6 +56,13 @@ Returns the list of registered child QgsSettingsRegistry.
protected:
=======
const QgsSettingsEntryBase *getSettingsEntry( const QString &key );
%Docstring
Returns the :py:class:`QgsSettingsEntry` with the given ``key`` or None if not found.
%End
>>>>>>> 7b8aad6203 (Removed settings struct)
void addSettingsEntry( const QgsSettingsEntryBase *settingsEntry );
%Docstring
Add ``settingsEntry`` to the register.

View File

@ -968,16 +968,16 @@ int main( int argc, char *argv[] )
{
/* Translation file for QGIS.
*/
QString myUserTranslation = QgsApplication::Settings::localeUserLocale.value();
QString myGlobalLocale = QgsApplication::Settings::localeGlobalLocale.value();
QString myUserTranslation = QgsApplication::settingsLocaleUserLocale.value();
QString myGlobalLocale = QgsApplication::settingsLocaleGlobalLocale.value();
bool myShowGroupSeparatorFlag = false; // Default to false
bool myLocaleOverrideFlag = QgsApplication::Settings::localeOverrideFlag.value();
bool myLocaleOverrideFlag = QgsApplication::settingsLocaleOverrideFlag.value();
// Override Show Group Separator if the global override flag is set
if ( myLocaleOverrideFlag )
{
// Default to false again
myShowGroupSeparatorFlag = QgsApplication::Settings::localeShowGroupSeparator.value();
myShowGroupSeparatorFlag = QgsApplication::settingsLocaleShowGroupSeparator.value();
}
//
@ -991,7 +991,7 @@ int main( int argc, char *argv[] )
//
if ( !translationCode.isNull() && !translationCode.isEmpty() )
{
QgsApplication::Settings::localeUserLocale.setValue( translationCode );
QgsApplication::settingsLocaleUserLocale.setValue( translationCode );
}
else
{
@ -1000,7 +1000,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::Settings::localeUserLocale.setValue( translationCode );
QgsApplication::settingsLocaleUserLocale.setValue( translationCode );
}
else
{

View File

@ -475,7 +475,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
cmbScanZipInBrowser->setCurrentIndex( index );
// log rendering events, for userspace debugging
mLogCanvasRefreshChkBx->setChecked( QgsMapRendererJob::Settings::logCanvasRefreshEvent.value() );
mLogCanvasRefreshChkBx->setChecked( QgsMapRendererJob::settingsLogCanvasRefreshEvent.value() );
//set the default projection behavior radio buttons
const QgsOptions::UnknownLayerCrsBehavior mode = QgsSettings().enumValue( QStringLiteral( "/projections/unknownCrsBehavior" ), QgsOptions::UnknownLayerCrsBehavior::NoAction, QgsSettings::App );
@ -1015,9 +1015,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
//
QString currentLocale = QLocale().name();
lblSystemLocale->setText( tr( "Detected active locale on your system: %1" ).arg( currentLocale ) );
QString userLocale = QgsApplication::Settings::localeUserLocale.value();
bool showGroupSeparator = QgsApplication::Settings::localeShowGroupSeparator.value();
QString globalLocale = QgsApplication::Settings::localeGlobalLocale.value();
QString userLocale = QgsApplication::settingsLocaleUserLocale.value();
bool showGroupSeparator = QgsApplication::settingsLocaleShowGroupSeparator.value();
QString globalLocale = QgsApplication::settingsLocaleGlobalLocale.value();
const QStringList language18nList( i18nList() );
for ( const auto &l : language18nList )
{
@ -1044,7 +1044,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
cboTranslation->setCurrentIndex( cboTranslation->findData( userLocale ) );
cboGlobalLocale->setCurrentIndex( cboGlobalLocale->findData( globalLocale ) );
grpLocale->setChecked( QgsApplication::Settings::localeOverrideFlag.value() );
grpLocale->setChecked( QgsApplication::settingsLocaleOverrideFlag.value() );
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::Settings::logCanvasRefreshEvent.setValue( mLogCanvasRefreshChkBx->isChecked() );
QgsMapRendererJob::settingsLogCanvasRefreshEvent.setValue( 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::Settings::localeUserLocale.setValue( cboTranslation->currentData().toString() );
QgsApplication::Settings::localeOverrideFlag.setValue( grpLocale->isChecked() );
QgsApplication::Settings::localeGlobalLocale.setValue( cboGlobalLocale->currentData( ).toString() );
QgsApplication::settingsLocaleUserLocale.setValue( cboTranslation->currentData().toString() );
QgsApplication::settingsLocaleOverrideFlag.setValue( grpLocale->isChecked() );
QgsApplication::settingsLocaleGlobalLocale.setValue( cboGlobalLocale->currentData( ).toString() );
// Number settings
QgsApplication::Settings::localeShowGroupSeparator.setValue( cbShowGroupSeparator->isChecked( ) );
QgsApplication::settingsLocaleShowGroupSeparator.setValue( cbShowGroupSeparator->isChecked( ) );
QgsLocalDefaultSettings::setBearingFormat( mBearingFormat.get() );

View File

@ -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::Settings::localeUserLocale.value() ) );
cbtsLocale->setCurrentIndex( cbtsLocale->findData( QgsApplication::settingsLocaleUserLocale.value() ) );
connect( generateTsFileButton, &QPushButton::clicked, this, &QgsProjectProperties::onGenerateTsFileButton );

View File

@ -674,12 +674,12 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache( Qt::ConnectionType conn
int QgsNetworkAccessManager::timeout()
{
return Settings::networkTimeout.value();
return settingsNetworkTimeout.value();
}
void QgsNetworkAccessManager::setTimeout( const int time )
{
Settings::networkTimeout.setValue( time );
settingsNetworkTimeout.setValue( time );
}
QgsNetworkReplyContent QgsNetworkAccessManager::blockingGet( QNetworkRequest &request, const QString &authCfg, bool forceRefresh, QgsFeedback *feedback )

View File

@ -530,6 +530,10 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
*/
void requestAuthCloseBrowser() const;
//! Settings entry network timeout
static const inline QgsSettingsEntryInteger settingsNetworkTimeout = QgsSettingsEntryInteger( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), QgsSettings::NoSection, 60000, QObject::tr( "Network timeout" ) );
signals:
/**

View File

@ -40,22 +40,22 @@ QgsNewsFeedParser::QgsNewsFeedParser( const QUrl &feedUrl, const QString &authcf
QUrlQuery query( feedUrl );
const qint64 after = Settings::feedLastFetchTime.value( mSettingsKey );
const qint64 after = settingsFeedLastFetchTime.value( mSettingsKey );
if ( after > 0 )
query.addQueryItem( QStringLiteral( "after" ), qgsDoubleToString( after, 0 ) );
QString feedLanguage = Settings::feedLanguage.value( mSettingsKey );
QString feedLanguage = settingsFeedLanguage.value( mSettingsKey );
if ( feedLanguage.isEmpty() )
{
feedLanguage = QgsSettings().value( QgsApplication::Settings::localeUserLocale.key(), QStringLiteral( "en_US" ) ).toString().left( 2 );
feedLanguage = QgsSettings().value( QgsApplication::settingsLocaleUserLocale.key(), QStringLiteral( "en_US" ) ).toString().left( 2 );
}
if ( !feedLanguage.isEmpty() && feedLanguage != QLatin1String( "C" ) )
query.addQueryItem( QStringLiteral( "lang" ), feedLanguage );
if ( Settings::feedLatitude.exists( mSettingsKey ) && Settings::feedLongitude.exists( mSettingsKey ) )
if ( settingsFeedLatitude.exists( mSettingsKey ) && settingsFeedLongitude.exists( mSettingsKey ) )
{
const double feedLat = Settings::feedLatitude.value( mSettingsKey );
const double feedLong = Settings::feedLongitude.value( mSettingsKey );
const double feedLat = settingsFeedLatitude.value( mSettingsKey );
const double feedLong = settingsFeedLongitude.value( mSettingsKey );
// hack to allow testing using local files
if ( feedUrl.isLocalFile() )
@ -169,7 +169,7 @@ void QgsNewsFeedParser::fetch()
void QgsNewsFeedParser::onFetch( const QString &content )
{
Settings::feedLastFetchTime.setValue( mFetchStartTime, mSettingsKey );
settingsFeedLastFetchTime.setValue( mFetchStartTime, mSettingsKey );
const QVariant json = QgsJsonUtils::parseJson( content );

View File

@ -111,21 +111,14 @@ class CORE_EXPORT QgsNewsFeedParser : public QObject
*/
static QString keyForFeed( const QString &baseUrl );
/**
* Contains QgsNewsFeedParser settings
* \since QGIS 3.20
*/
struct Settings
{
//! Settings entry last fetch time
static const inline QgsSettingsEntryInteger feedLastFetchTime = QgsSettingsEntryInteger( QStringLiteral( "%/lastFetchTime" ), QgsSettings::Core, 0, QObject::tr( "Feed last fetch time" ), 0 );
//! Settings entry feed language
static const inline QgsSettingsEntryString feedLanguage = QgsSettingsEntryString( QStringLiteral( "%/lang" ), QgsSettings::Core, QString(), QObject::tr( "Feed language" ) );
//! Settings entry feed latitude
static const inline QgsSettingsEntryDouble feedLatitude = QgsSettingsEntryDouble( QStringLiteral( "%/latitude" ), QgsSettings::Core, 0.0, QObject::tr( "Feed latitude" ) );
//! Settings entry feed longitude
static const inline QgsSettingsEntryDouble feedLongitude = QgsSettingsEntryDouble( QStringLiteral( "%/longitude" ), QgsSettings::Core, 0.0, QObject::tr( "Feed longitude" ) );
};
//! Settings entry last fetch time
static const inline QgsSettingsEntryInteger settingsFeedLastFetchTime = QgsSettingsEntryInteger( QStringLiteral( "%/lastFetchTime" ), QgsSettings::Core, 0, QObject::tr( "Feed last fetch time" ), 0 );
//! Settings entry feed language
static const inline QgsSettingsEntryString settingsFeedLanguage = QgsSettingsEntryString( QStringLiteral( "%/lang" ), QgsSettings::Core, QString(), QObject::tr( "Feed language" ) );
//! Settings entry feed latitude
static const inline QgsSettingsEntryDouble settingsFeedLatitude = QgsSettingsEntryDouble( QStringLiteral( "%/latitude" ), QgsSettings::Core, 0.0, QObject::tr( "Feed latitude" ) );
//! Settings entry feed longitude
static const inline QgsSettingsEntryDouble settingsFeedLongitude = QgsSettingsEntryDouble( QStringLiteral( "%/longitude" ), QgsSettings::Core, 0.0, QObject::tr( "Feed longitude" ) );
public slots:

View File

@ -99,21 +99,14 @@ class CORE_EXPORT QgsProcessing
*/
static const QString TEMPORARY_OUTPUT;
/**
* Contains QgsProcessing settings
* \since QGIS 3.20
*/
struct Settings
{
//! Settings entry prefer filename as layer name
static const inline QgsSettingsEntryBool preferFilenameAsLayerName = 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 tempPath = QgsSettingsEntryString( QStringLiteral( "Processing/Configuration/TEMP_PATH2" ), QgsSettings::NoSection, QString() );
//! Settings entry default output vector layer ext
static const inline QgsSettingsEntryInteger defaultOutputVectorLayerExt = QgsSettingsEntryInteger( QStringLiteral( "Processing/Configuration/DefaultOutputVectorLayerExt" ), QgsSettings::NoSection, -1 );
//! Settings entry default output raster layer ext
static const inline QgsSettingsEntryInteger defaultOutputRasterLayerExt = QgsSettingsEntryInteger( QStringLiteral( "Processing/Configuration/DefaultOutputRasterLayerExt" ), QgsSettings::NoSection, -1 );
};
//! 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

View File

@ -197,7 +197,7 @@ void QgsProcessingContext::LayerDetails::setOutputLayerName( QgsMapLayer *layer
if ( !layer )
return;
const bool preferFilenameAsLayerName = QgsProcessing::Settings::preferFilenameAsLayerName.value();
const bool preferFilenameAsLayerName = QgsProcessing::settingsPreferFilenameAsLayerName.value();
// 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() )

View File

@ -954,7 +954,7 @@ QString QgsProcessingUtils::tempFolder()
static QString sFolder;
static QMutex sMutex;
QMutexLocker locker( &sMutex );
const QString basePath = QgsProcessing::Settings::tempPath.value();
const QString basePath = QgsProcessing::settingsTempPath.value();
if ( basePath.isEmpty() )
{
// default setting -- automatically create a temp folder
@ -1211,7 +1211,7 @@ QgsFields QgsProcessingUtils::indicesToFields( const QList<int> &indices, const
QString QgsProcessingUtils::defaultVectorExtension()
{
const int setting = QgsProcessing::Settings::defaultOutputVectorLayerExt.value();
const int setting = QgsProcessing::settingsDefaultOutputVectorLayerExt.value();
if ( setting == -1 )
return QStringLiteral( "gpkg" );
return QgsVectorFileWriter::supportedFormatExtensions().value( setting, QStringLiteral( "gpkg" ) );
@ -1219,7 +1219,7 @@ QString QgsProcessingUtils::defaultVectorExtension()
QString QgsProcessingUtils::defaultRasterExtension()
{
const int setting = QgsProcessing::Settings::defaultOutputRasterLayerExt.value();
const int setting = QgsProcessing::settingsDefaultOutputRasterLayerExt.value();
if ( setting == -1 )
return QStringLiteral( "tif" );
return QgsRasterFileWriter::supportedFormatExtensions().value( setting, QStringLiteral( "tif" ) );

View File

@ -1353,7 +1353,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::Settings::localeUserLocale.value() );
QString localeFileName = QStringLiteral( "%1_%2" ).arg( QFileInfo( projectFile.fileName() ).baseName(), QgsApplication::settingsLocaleUserLocale.value() );
if ( QFile( QStringLiteral( "%1/%2.qm" ).arg( QFileInfo( projectFile.fileName() ).absolutePath(), localeFileName ) ).exists() )
{

View File

@ -1063,7 +1063,7 @@ QString QgsApplication::srsDatabaseFilePath()
void QgsApplication::setSvgPaths( const QStringList &svgPaths )
{
Settings::searchPathsForSVG.setValue( svgPaths );
settingsSearchPathsForSVG.setValue( svgPaths );
members()->mSvgPathCacheValid = false;
}
@ -1082,7 +1082,7 @@ 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 = Settings::searchPathsForSVG.value();
const QStringList pathList = settingsSearchPathsForSVG.value();
// maintain user set order while stripping duplicates
QStringList paths;
@ -1224,9 +1224,9 @@ QString QgsApplication::platform()
QString QgsApplication::locale()
{
if ( Settings::localeOverrideFlag.value() )
if ( settingsLocaleOverrideFlag.value() )
{
QString locale = Settings::localeUserLocale.value();
QString locale = settingsLocaleUserLocale.value();
// don't differentiate en_US and en_GB
if ( locale.startsWith( QLatin1String( "en" ), Qt::CaseInsensitive ) )
{

View File

@ -944,23 +944,16 @@ class CORE_EXPORT QgsApplication : public QApplication
*/
void collectTranslatableObjects( QgsTranslationContext *translationContext );
/**
* Contains QgsApplication settings
* \since QGIS 3.20
*/
struct Settings
{
//! Settings entry locale user locale
static const inline QgsSettingsEntryString localeUserLocale = QgsSettingsEntryString( QStringLiteral( "locale/userLocale" ), QgsSettings::NoSection, QString() );
//! Settings entry locale override flag
static const inline QgsSettingsEntryBool localeOverrideFlag = QgsSettingsEntryBool( QStringLiteral( "locale/overrideFlag" ), QgsSettings::NoSection, false );
//! Settings entry locale global locale
static const inline QgsSettingsEntryString localeGlobalLocale = QgsSettingsEntryString( QStringLiteral( "locale/globalLocale" ), QgsSettings::NoSection, QString() );
//! Settings entry locale show group separator
static const inline QgsSettingsEntryBool localeShowGroupSeparator = QgsSettingsEntryBool( QStringLiteral( "locale/showGroupSeparator" ), QgsSettings::NoSection, false );
//! Settings entry search path for SVG
static const inline QgsSettingsEntryStringList searchPathsForSVG = QgsSettingsEntryStringList( QStringLiteral( "svg/searchPathsForSVG" ), QgsSettings::NoSection, QStringList() );
};
//! 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 )

View File

@ -23,7 +23,7 @@
QgsGeometryOptions::QgsGeometryOptions()
{
mGeometryChecks = Settings::geometryValidationDefaultChecks.value().split( ',' ) ;
mGeometryChecks = settingsGeometryValidationDefaultChecks.value().split( ',' ) ;
}
bool QgsGeometryOptions::removeDuplicateNodes() const

View File

@ -132,15 +132,8 @@ class CORE_EXPORT QgsGeometryOptions : public QObject
*/
void readXml( const QDomNode &node );
/**
* Contains QgsGeometryOptions settings
* \since QGIS 3.20
*/
struct Settings
{
//! Settings entry search path for templates
static const inline QgsSettingsEntryString geometryValidationDefaultChecks = QgsSettingsEntryString( QStringLiteral( "geometry_validation/default_checks" ), QgsSettings::NoSection, QString() );
};
//! Settings entry search path for templates
static const inline QgsSettingsEntryString settingsGeometryValidationDefaultChecks = QgsSettingsEntryString( QStringLiteral( "geometry_validation/default_checks" ), QgsSettings::NoSection, QString() );
signals:

View File

@ -105,10 +105,10 @@ void QgsLocalizedDataPathRegistry::unregisterPath( const QString &path )
void QgsLocalizedDataPathRegistry::readFromSettings()
{
setPaths( Settings::localizedDataPaths.value() );
setPaths( settingsLocalizedDataPaths.value() );
}
void QgsLocalizedDataPathRegistry::writeToSettings()
{
Settings::localizedDataPaths.setValue( paths() );
settingsLocalizedDataPaths.setValue( paths() );
}

View File

@ -66,15 +66,8 @@ class CORE_EXPORT QgsLocalizedDataPathRegistry
//! Unregisters a localized path
void unregisterPath( const QString &path );
/**
* Contains QgsLocalizedDataPathRegistry settings
* \since QGIS 3.20
*/
struct Settings
{
//! Settings entry localized data paths
static const inline QgsSettingsEntryStringList localizedDataPaths = QgsSettingsEntryStringList( QStringLiteral( "/qgis/localized_data_paths" ), QgsSettings::NoSection, QStringList() );
};
//! Settings entry localized data paths
static const inline QgsSettingsEntryStringList settingsLocalizedDataPaths = QgsSettingsEntryStringList( QStringLiteral( "/qgis/localized_data_paths" ), QgsSettings::NoSection, QStringList() );
private:
#ifdef SIP_RUN

View File

@ -977,7 +977,7 @@ void QgsMapRendererJob::composeSecondPass( LayerRenderJobs &secondPassJobs, Labe
void QgsMapRendererJob::logRenderingTime( const LayerRenderJobs &jobs, const LayerRenderJobs &secondPassJobs, const LabelRenderJob &labelJob )
{
if ( !Settings::logCanvasRefreshEvent.value() )
if ( !settingsLogCanvasRefreshEvent.value() )
return;
QMultiMap<int, QString> elapsed;

View File

@ -344,16 +344,8 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
*/
static const QString LABEL_PREVIEW_CACHE_ID SIP_SKIP;
/**
* Contains QgsMapRendererJob settings
* \since QGIS 3.20
*/
struct Settings
{
//! Settings entry log canvas refresh event
static const inline QgsSettingsEntryBool logCanvasRefreshEvent = QgsSettingsEntryBool( QStringLiteral( "Map/logCanvasRefreshEvent" ), QgsSettings::NoSection, false );
};
//! Settings entry log canvas refresh event
static const inline QgsSettingsEntryBool settingsLogCanvasRefreshEvent = QgsSettingsEntryBool( QStringLiteral( "Map/logCanvasRefreshEvent" ), QgsSettings::NoSection, false );
signals:

View File

@ -34,29 +34,29 @@ QgsSettingsRegistryCore::QgsSettingsRegistryCore()
addSettingsEntry( &QgsLocator::settingsLocatorFilterDefault );
addSettingsEntry( &QgsLocator::settingsLocatorFilterPrefix );
addSettingsEntry( &QgsNetworkAccessManager::Settings::networkTimeout );
addSettingsEntry( &QgsNetworkAccessManager::settingsNetworkTimeout );
addSettingsEntry( &QgsNewsFeedParser::Settings::feedLastFetchTime );
addSettingsEntry( &QgsNewsFeedParser::Settings::feedLanguage );
addSettingsEntry( &QgsNewsFeedParser::Settings::feedLatitude );
addSettingsEntry( &QgsNewsFeedParser::Settings::feedLongitude );
addSettingsEntry( &QgsNewsFeedParser::settingsFeedLastFetchTime );
addSettingsEntry( &QgsNewsFeedParser::settingsFeedLanguage );
addSettingsEntry( &QgsNewsFeedParser::settingsFeedLatitude );
addSettingsEntry( &QgsNewsFeedParser::settingsFeedLongitude );
addSettingsEntry( &QgsProcessing::Settings::preferFilenameAsLayerName );
addSettingsEntry( &QgsProcessing::Settings::tempPath );
addSettingsEntry( &QgsProcessing::Settings::defaultOutputVectorLayerExt );
addSettingsEntry( &QgsProcessing::Settings::defaultOutputRasterLayerExt );
addSettingsEntry( &QgsProcessing::settingsPreferFilenameAsLayerName );
addSettingsEntry( &QgsProcessing::settingsTempPath );
addSettingsEntry( &QgsProcessing::settingsDefaultOutputVectorLayerExt );
addSettingsEntry( &QgsProcessing::settingsDefaultOutputRasterLayerExt );
addSettingsEntry( &QgsApplication::Settings::localeUserLocale );
addSettingsEntry( &QgsApplication::Settings::localeOverrideFlag );
addSettingsEntry( &QgsApplication::Settings::localeGlobalLocale );
addSettingsEntry( &QgsApplication::Settings::localeShowGroupSeparator );
addSettingsEntry( &QgsApplication::Settings::searchPathsForSVG );
addSettingsEntry( &QgsApplication::settingsLocaleUserLocale );
addSettingsEntry( &QgsApplication::settingsLocaleOverrideFlag );
addSettingsEntry( &QgsApplication::settingsLocaleGlobalLocale );
addSettingsEntry( &QgsApplication::settingsLocaleShowGroupSeparator );
addSettingsEntry( &QgsApplication::settingsSearchPathsForSVG );
addSettingsEntry( &QgsGeometryOptions::Settings::geometryValidationDefaultChecks );
addSettingsEntry( &QgsGeometryOptions::settingsGeometryValidationDefaultChecks );
addSettingsEntry( &QgsLocalizedDataPathRegistry::Settings::localizedDataPaths );
addSettingsEntry( &QgsLocalizedDataPathRegistry::settingsLocalizedDataPaths );
addSettingsEntry( &QgsMapRendererJob::Settings::logCanvasRefreshEvent );
addSettingsEntry( &QgsMapRendererJob::settingsLogCanvasRefreshEvent );
}
QgsSettingsRegistryCore::~QgsSettingsRegistryCore()

View File

@ -136,7 +136,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::Settings::localeUserLocale.key(), "en_US" ).toString() );
root.setAttribute( QStringLiteral( "locale" ), settings.value( QgsApplication::settingsLocaleUserLocale.key(), "en_US" ).toString() );
doc.appendChild( root );
settings.beginGroup( mManager->settingsPath() );
@ -205,10 +205,10 @@ void QgsConfigureShortcutsDialog::loadShortcuts()
QString currentLocale;
bool localeOverrideFlag = QgsApplication::Settings::localeOverrideFlag.value();
bool localeOverrideFlag = QgsApplication::settingsLocaleOverrideFlag.value();
if ( localeOverrideFlag )
{
currentLocale = QgsSettings().value( QgsApplication::Settings::localeUserLocale.key(), "en_US" ).toString();
currentLocale = QgsApplication::settingsLocaleUserLocale.value( QString(), true, "en_US" );
}
else // use QGIS locale
{

View File

@ -174,7 +174,7 @@ void QgsGui::setWindowManager( QgsWindowManagerInterface *manager )
QgsGui::HigFlags QgsGui::higFlags()
{
if ( QgsApplication::Settings::localeUserLocale.value().startsWith( QLatin1String( "en" ) ) )
if ( QgsApplication::settingsLocaleUserLocale.value().startsWith( QLatin1String( "en" ) ) )
{
return HigMenuTextIsTitleCase | HigDialogTitleIsTitleCase;
}

View File

@ -706,7 +706,7 @@ void QgsMapCanvas::rendererJobFinished()
QPainter p( &img );
emit renderComplete( &p );
if ( QgsMapRendererJob::Settings::logCanvasRefreshEvent.value() )
if ( QgsMapRendererJob::settingsLogCanvasRefreshEvent.value() )
{
QString logMsg = tr( "Canvas refresh: %1 ms" ).arg( mJob->renderingTime() );
QgsMessageLog::logMessage( logMsg, tr( "Rendering" ) );

View File

@ -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::Settings::preferFilenameAsLayerName.setValue( false );
QgsProcessing::settingsPreferFilenameAsLayerName.setValue( 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::Settings::preferFilenameAsLayerName.setValue( true );
QgsProcessing::settingsPreferFilenameAsLayerName.setValue( 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::Settings::tempPath.setValue( alternative_tempFolder1 );
QgsProcessing::settingsTempPath.setValue( 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::Settings::tempPath.setValue( alternative_tempFolder2 );
QgsProcessing::settingsTempPath.setValue( 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::Settings::tempPath.setValue( QString() );
QgsProcessing::settingsTempPath.setValue( QString() );
}
@ -11529,8 +11529,8 @@ void TestQgsProcessing::defaultExtensionsForProvider()
QCOMPARE( context.preferredRasterFormat(), QStringLiteral( "tif" ) );
// unless the user has set a default format, which IS supported by that provider
QgsProcessing::Settings::defaultOutputVectorLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "tab" ) ) );
QgsProcessing::Settings::defaultOutputRasterLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "sdat" ) ) );
QgsProcessing::settingsDefaultOutputVectorLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "tab" ) ) );
QgsProcessing::settingsDefaultOutputRasterLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "sdat" ) ) );
QCOMPARE( provider.defaultVectorFileExtension( true ), QStringLiteral( "tab" ) );
QCOMPARE( provider.defaultRasterFileExtension(), QStringLiteral( "sdat" ) );
@ -11541,8 +11541,8 @@ void TestQgsProcessing::defaultExtensionsForProvider()
QCOMPARE( context2.preferredRasterFormat(), QStringLiteral( "sdat" ) );
// but if default is not supported by provider, we use a supported format
QgsProcessing::Settings::defaultOutputVectorLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "gpkg" ) ) );
QgsProcessing::Settings::defaultOutputRasterLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "ecw" ) ) );
QgsProcessing::settingsDefaultOutputVectorLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "gpkg" ) ) );
QgsProcessing::settingsDefaultOutputRasterLayerExt.setValue( QgsVectorFileWriter::supportedFormatExtensions().indexOf( QLatin1String( "ecw" ) ) );
QCOMPARE( provider.defaultVectorFileExtension( true ), QStringLiteral( "mif" ) );
QCOMPARE( provider.defaultRasterFileExtension(), QStringLiteral( "mig" ) );
}

View File

@ -163,7 +163,7 @@ void TestQgsCompositionConverter::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
mReport = QStringLiteral( "<h1>Layout Tests</h1>\n" );
QgsApplication::Settings::searchPathsForSVG.setValue( QStringLiteral( TEST_DATA_DIR ) );
QgsApplication::settingsSearchPathsForSVG.setValue( QStringList() << QStringLiteral( TEST_DATA_DIR ) );
}
void TestQgsCompositionConverter::cleanupTestCase()

View File

@ -175,7 +175,7 @@ void TestQgsNetworkAccessManager::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
QgsNetworkAccessManager::Settings::networkTimeout.setValue( 5000 );
QgsNetworkAccessManager::settingsNetworkTimeout.setValue( 5000 );
mHttpBinHost = QStringLiteral( "httpbin.org" );
QString overrideHost = qgetenv( "QGIS_HTTPBIN_HOST" );

View File

@ -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::Settings::feedLastFetchTime.value( feedKey );
uint after = QgsNewsFeedParser::settingsFeedLastFetchTime.value( feedKey );
QVERIFY( after >= beforeTime );
// reset to a standard known last time
QgsSettings().remove( feedKey, QgsSettings::Core );
QgsNewsFeedParser::Settings::feedLastFetchTime.setValue( 1457360008, feedKey );
QgsNewsFeedParser::settingsFeedLastFetchTime.setValue( 1457360008, feedKey );
// 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::Settings::feedLanguage.setValue( QStringLiteral( "es" ), feedKey );
QgsNewsFeedParser::settingsFeedLanguage.setValue( QStringLiteral( "es" ), feedKey );
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::Settings::feedLatitude.setValue( 37.2343, feedKey );
QgsNewsFeedParser::Settings::feedLongitude.setValue( -115.8067, feedKey );
QgsNewsFeedParser::settingsFeedLatitude.setValue( 37.2343, feedKey );
QgsNewsFeedParser::settingsFeedLongitude.setValue( -115.8067, feedKey );
QgsNewsFeedParser parser( url );
QSignalSpy spy( &parser, &QgsNewsFeedParser::entryAdded );

View File

@ -57,12 +57,12 @@ void TestQgsTranslateProject::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
original_locale = QgsApplication::Settings::localeUserLocale.value();
original_locale = QgsApplication::settingsLocaleUserLocale.value();
}
void TestQgsTranslateProject::cleanupTestCase()
{
QgsApplication::Settings::localeUserLocale.setValue( original_locale );
QgsApplication::settingsLocaleUserLocale.setValue( original_locale );
QgsApplication::exitQgis();
//delete translated project file
@ -91,7 +91,7 @@ void TestQgsTranslateProject::cleanup()
void TestQgsTranslateProject::createTsFile()
{
//open project in english
QgsApplication::Settings::localeUserLocale.setValue( "en" );
QgsApplication::settingsLocaleUserLocale.setValue( "en" );
QString projectFileName( TEST_DATA_DIR );
projectFileName = projectFileName + "/project_translation/points_translation.qgs";
QgsProject::instance()->read( projectFileName );
@ -163,7 +163,7 @@ void TestQgsTranslateProject::createTsFile()
void TestQgsTranslateProject::translateProject()
{
//open project in german
QgsApplication::Settings::localeUserLocale.setValue( "de" );
QgsApplication::settingsLocaleUserLocale.setValue( "de" );
QString projectFileName( TEST_DATA_DIR );
projectFileName = projectFileName + "/project_translation/points_translation.qgs";
QgsProject::instance()->read( projectFileName );