127 static void unregisterPluginTreeElement(
const QString &pluginName );
134 const QString &application = QString(), QObject *parent =
nullptr );
150 QgsSettings( QSettings::Scope scope,
const QString &organization,
151 const QString &application = QString(), QObject *parent =
nullptr );
167 QgsSettings( QSettings::Format format, QSettings::Scope scope,
const QString &organization,
168 const QString &application = QString(), QObject *parent =
nullptr );
190 QgsSettings(
const QString &fileName, QSettings::Format format, QObject *parent =
nullptr );
220 QString group()
const;
223 QStringList allKeys()
const;
225 QStringList childKeys()
const;
229 QStringList globalChildGroups()
const;
231 static QString globalSettingsPath();
233 static bool setGlobalSettingsPath(
const QString &path );
235 int beginReadArray(
const QString &prefix );
242 void beginWriteArray(
const QString &prefix,
int size = -1 );
250 void setArrayIndex(
int i );
272 QVariant value(
const QString &key,
const QVariant &defaultValue = QVariant(),
273 Section section = NoSection )
const;
275 SIP_PYOBJECT value(
const QString &key,
const QVariant &defaultValue = QVariant(),
276 SIP_PYOBJECT type = 0,
279 typedef PyObject *( *pyqt5_from_qvariant_by_type )( QVariant &value, PyObject *type );
283 Py_BEGIN_ALLOW_THREADS
284 value = sipCpp->value( *a0, *a1, a3 );
287 pyqt5_from_qvariant_by_type f = ( pyqt5_from_qvariant_by_type ) sipImportSymbol(
"pyqt5_from_qvariant_by_type" );
288 sipRes = f( value, a2 );
309 const Section section = NoSection )
311 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
312 Q_ASSERT( metaEnum.isValid() );
313 if ( !metaEnum.isValid() )
315 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
321 if ( metaEnum.isValid() )
324 QByteArray ba = value( key, metaEnum.valueToKey(
static_cast<const int>( defaultValue ) ), section ).toString().toUtf8();
325 const char *vs = ba.data();
326 v =
static_cast<T
>( metaEnum.keyToValue( vs, &ok ) );
334 v =
static_cast<T
>( value( key,
static_cast<const int>( defaultValue ), section ).toInt( &ok ) );
335 if ( metaEnum.isValid() )
337 if ( !ok || !metaEnum.valueToKey(
static_cast<int>( v ) ) )
345 setEnumValue( key, v, section );
361 const Section section = NoSection )
363 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
364 Q_ASSERT( metaEnum.isValid() );
365 if ( metaEnum.isValid() )
367 setValue( key, metaEnum.valueToKey(
static_cast<const int>( value ) ), section );
371 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
387 const Section section = NoSection )
389 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
390 Q_ASSERT( metaEnum.isValid() );
391 if ( !metaEnum.isValid() )
393 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
399 if ( metaEnum.isValid() )
402 QByteArray ba = value( key, metaEnum.valueToKeys(
static_cast< const int >( defaultValue ) ) ).toString().toUtf8();
403 const char *vs = ba.data();
404 v =
static_cast<T
>( metaEnum.keysToValue( vs, &ok ) );
409 const int intValue = value( key,
static_cast<const int>( defaultValue ), section ).toInt( &ok );
410 if ( metaEnum.isValid() )
416 const QByteArray keys = metaEnum.valueToKeys( intValue );
417 const int intValueCheck = metaEnum.keysToValue( keys );
418 if ( intValue != intValueCheck )
429 setFlagValue( key, v );
451 const Section section = NoSection )
453 const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
454 Q_ASSERT( metaEnum.isValid() );
455 if ( metaEnum.isValid() )
457 setValue( key, metaEnum.valueToKeys(
static_cast< const int >( value ) ), section );
461 QgsDebugMsg( QStringLiteral(
"Invalid metaenum. Enum probably misses Q_ENUM or Q_FLAG declaration." ) );
472 QString fileName()
const;
490 QString sanitizeKey(
const QString &key )
const;
491 QSettings *mUserSettings =
nullptr;
492 QSettings *mGlobalSettings =
nullptr;
493 bool mUsingGlobalArray =
false;
SettingsOrigin
The setting origin describes where a setting is stored.
QgsSettingsTreeNode is a tree element for the settings registry to help organizing and introspecting ...
QgsSettingsTreeNode * createChildElement(const QString &key) SIP_THROW(QgsSettingsException)
Creates a normal tree element It will return the existing child element if it exists at the given key...
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.