90 static const inline char *APP_GEOREFERENCER =
"app/georeferencer";
91 static const inline char *CORE =
"core";
92 static const inline char *CORE_LAYOUT =
"core/Layout";
93 static const inline char *GEOMETRYVALIDATION =
"geometry_validation";
94 static const inline char *GPS =
"gps";
95 static const inline char *GUI_LOCATORFILTERS =
"gui/locator_filters";
96 static const inline char *GUI_QGIS =
"gui/qgis";
97 static const inline char *LOCALE =
"locale";
98 static const inline char *MAP =
"Map";
99 static const inline char *PLUGINS =
"plugins";
100 static const inline char *PROCESSING_CONFIGURATION =
"Processing/Configuration";
101 static const inline char *
QGIS =
"qgis";
102 static const inline char *QGIS_DIGITIZING =
"qgis/digitizing";
103 static const inline char *QGIS_DIGITIZING_SHAPEMAPTOOLS =
"qgis/digitizing/shape-map-tools";
104 static const inline char *QGIS_NETWORKANDPROXY =
"qgis/networkAndProxy";
105 static const inline char *SVG =
"svg";
106 static const inline char *ELEVATION_PROFILE =
"elevation-profile";
107 static const inline char *CORE_LAYERTREE =
"core/layer-tree";
108 static const inline char *STYLE_MANAGER =
"app/style-manager";
109 static const inline char *FONTS =
"fonts";
110 static const inline char *WMS =
"wms";
118 const QString &application = QString(), QObject *parent =
nullptr );
134 QgsSettings( QSettings::Scope scope,
const QString &organization,
135 const QString &application = QString(), QObject *parent =
nullptr );
151 QgsSettings( QSettings::Format format, QSettings::Scope scope,
const QString &organization,
152 const QString &application = QString(), QObject *parent =
nullptr );
174 QgsSettings(
const QString &fileName, QSettings::Format format, QObject *parent =
nullptr );
204 QString group()
const;
207 QStringList allKeys()
const;
209 QStringList childKeys()
const;
211 QStringList childGroups()
const;
213 QStringList globalChildGroups()
const;
215 static QString globalSettingsPath();
217 static bool setGlobalSettingsPath(
const QString &path );
219 int beginReadArray(
const QString &prefix );
226 void beginWriteArray(
const QString &prefix,
int size = -1 );
234 void setArrayIndex(
int i );
249 QVariant value(
const QString &key,
const QVariant &defaultValue = QVariant(),
250 Section section = NoSection )
const;
252 SIP_PYOBJECT value(
const QString &key,
const QVariant &defaultValue = QVariant(),
253 SIP_PYOBJECT type = 0,
256 typedef PyObject *( *pyqt5_from_qvariant_by_type )( QVariant &value, PyObject *type );
260 Py_BEGIN_ALLOW_THREADS
261 value = sipCpp->value( *a0, *a1, a3 );
264 pyqt5_from_qvariant_by_type f = ( pyqt5_from_qvariant_by_type ) sipImportSymbol(
"pyqt5_from_qvariant_by_type" );
265 sipRes = f( value, a2 );
285 const Section section = NoSection )
287 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
288 Q_ASSERT( metaEnum.isValid() );
289 if ( !metaEnum.isValid() )
291 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
297 if ( metaEnum.isValid() )
300 QByteArray ba = value( key, metaEnum.valueToKey(
static_cast<const int>( defaultValue ) ), section ).toString().toUtf8();
301 const char *vs = ba.data();
302 v =
static_cast<T
>( metaEnum.keyToValue( vs, &ok ) );
310 v =
static_cast<T
>( value( key,
static_cast<const int>( defaultValue ), section ).toInt( &ok ) );
311 if ( metaEnum.isValid() )
313 if ( !ok || !metaEnum.valueToKey(
static_cast<int>( v ) ) )
321 setEnumValue( key, v, section );
337 const Section section = NoSection )
339 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
340 Q_ASSERT( metaEnum.isValid() );
341 if ( metaEnum.isValid() )
343 setValue( key, metaEnum.valueToKey(
static_cast<const int>( value ) ), section );
347 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
363 const Section section = NoSection )
365 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
366 Q_ASSERT( metaEnum.isValid() );
367 if ( !metaEnum.isValid() )
369 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
375 if ( metaEnum.isValid() )
378 QByteArray ba = value( key, metaEnum.valueToKeys(
static_cast< const int >( defaultValue ) ) ).toString().toUtf8();
379 const char *vs = ba.data();
380 v =
static_cast<T
>( metaEnum.keysToValue( vs, &ok ) );
385 const int intValue = value( key,
static_cast<const int>( defaultValue ), section ).toInt( &ok );
386 if ( metaEnum.isValid() )
392 const QByteArray keys = metaEnum.valueToKeys( intValue );
393 const int intValueCheck = metaEnum.keysToValue( keys );
394 if ( intValue != intValueCheck )
405 setFlagValue( key, v );
427 const Section section = NoSection )
429 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
430 Q_ASSERT( metaEnum.isValid() );
431 if ( metaEnum.isValid() )
433 setValue( key, metaEnum.valueToKeys(
static_cast< const int >( value ) ), section );
437 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
448 QString fileName()
const;
466 QString sanitizeKey(
const QString &key )
const;
467 QSettings *mUserSettings =
nullptr;
468 QSettings *mGlobalSettings =
nullptr;
469 bool mUsingGlobalArray =
false;
Prefixes for the settings keys.
This class is a composition of two QSettings instances:
T flagValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on a flag.
void setFlagValue(const QString &key, const T &value, const Section section=NoSection)
Set the value of a setting based on a flag.
void setEnumValue(const QString &key, const T &value, const Section section=NoSection)
Set the value of a setting based on an enum.
Section
Sections for namespaced settings.
@ Gps
GPS section, since QGIS 3.22.
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
As part of the API refactoring and improvements which landed in QGIS