28bool QgsSettingsEntryString::checkValuePrivate(
const QString &value )
const
30 if (
value.length() < mMinLength )
32 QgsDebugError( QStringLiteral(
"Can't set value for settings. String length '%1' is shorter than minimum length '%2'." )
33 .arg(
value.length() )
39 &&
value.length() > mMaxLength )
41 QgsDebugError( QStringLiteral(
"Can't set value for settings. String length '%1' is longer than maximum length '%2'." )
42 .arg(
value.length() )
52 return value.toString();
72 return value.toStringList();
83 return value.toBool();
93bool QgsSettingsEntryInteger::checkValuePrivate(
const int &value )
const
95 if (
value < mMinValue )
97 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is less than minimum value '%2'." )
98 .arg( QString::number(
value ) )
99 .arg( QString::number( mMinValue ) ) );
103 if (
value > mMaxValue )
105 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is greater than maximum value '%2'." )
106 .arg( QString::number(
value ) )
107 .arg( QString::number( mMaxValue ) ) );
116 return value.toLongLong();
134bool QgsSettingsEntryInteger64::checkValuePrivate(
const qlonglong &value )
const
136 if (
value < mMinValue )
138 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is less than minimum value '%2'." )
139 .arg( QString::number(
value ) )
140 .arg( QString::number( mMinValue ) ) );
144 if (
value > mMaxValue )
146 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is greater than maximum value '%2'." )
147 .arg( QString::number(
value ) )
148 .arg( QString::number( mMaxValue ) ) );
157 return value.toLongLong();
177bool QgsSettingsEntryDouble::checkValuePrivate(
const double &value )
const
179 if (
value < mMinValue )
181 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is less than minimum value '%2'." )
182 .arg( QString::number(
value ), QString::number( mMinValue ) ) );
186 if (
value > mMaxValue )
188 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is greater than maximum value '%2'." )
189 .arg( QString::number(
value ), QString::number( mMaxValue ) ) );
198 return value.toDouble();
223 return mDisplayHintDecimals;
228 return value.value<QColor>();
236bool QgsSettingsEntryColor::checkValuePrivate(
const QColor &value )
const
238 if ( !mAllowAlpha &&
value.alpha() != 255 )
240 QgsDebugError( QStringLiteral(
"Setting %1 doesn't allow transparency and the given color has transparency." ).arg(
definitionKey() ) );
250 if ( settings->contains( redKey ) && settings->contains( greenKey ) && settings->contains( blueKey ) && ( alphaKey.isNull() || settings->contains( alphaKey ) ) )
253 if ( alphaKey.isNull() )
254 oldValue = QColor( settings->value( redKey ).toInt(), settings->value( greenKey ).toInt(), settings->value( blueKey ).toInt() );
256 oldValue = QColor( settings->value( redKey ).toInt(), settings->value( greenKey ).toInt(), settings->value( blueKey ).toInt(), settings->value( alphaKey ).toInt() );
258 if ( removeSettingAtKey )
260 settings->remove( redKey );
261 settings->remove( greenKey );
262 settings->remove( blueKey );
263 settings->remove( alphaKey );
266 if (
value() != oldValue )
276 const QColor color =
value();
277 settings->setValue( redKey, color.red() );
278 settings->setValue( greenKey, color.green() );
279 settings->setValue( blueKey, color.blue() );
280 if ( !alphaKey.isNull() )
281 settings->setValue( alphaKey, color.alpha() );
286 return value.value<QVariantMap>();
SettingsType
Types of settings entries.
@ Variant
Generic variant.
@ StringList
List of strings.
@ VariantMap
Map of strings.
@ Double
Double precision number.
QString value(const QString &dynamicKeyPart=QString()) const
bool setVariantValue(const QVariant &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
QString definitionKey() const
Returns settings entry defining key.
bool convertFromVariant(const QVariant &value) const override
Converts the variant value to the value type of the setting.
Qgis::SettingsType settingsType() const override
Returns the settings entry type.
QColor convertFromVariant(const QVariant &value) const override
Converts the variant value to the value type of the setting.
Qgis::SettingsType settingsType() const override
Returns the settings entry type.
bool copyValueFromKeys(const QString &redKey, const QString &greenKey, const QString &blueKey, const QString &alphaKey=QString(), bool removeSettingAtKey=false) const
Copies the value from the given keys if they exist.
void copyValueToKeys(const QString &redKey, const QString &greenKey, const QString &blueKey, const QString &alphaKey=QString()) const
Copies the settings to the given keys.
void setDisplayHintDecimals(int displayHintDecimals)
Set the display hint decimals.
int displayHintDecimals() const
Returns how much decimals should be shown in the Gui.
double minValue() const
Returns the minimum value.
double convertFromVariant(const QVariant &value) const override
Converts the variant value to the value type of the setting.
double maxValue() const
Returns the maximum value.
Qgis::SettingsType settingsType() const override
Returns the settings entry type.
qlonglong maxValue() const
Returns the maximum value.
qlonglong minValue() const
Returns the minimum value.
qlonglong convertFromVariant(const QVariant &value) const override
Converts the variant value to the value type of the setting.
Qgis::SettingsType settingsType() const override
Returns the settings entry type.
int minValue() const
Returns the minimum value.
Qgis::SettingsType settingsType() const override
Returns the settings entry type.
int maxValue() const
Returns the maximum value.
int convertFromVariant(const QVariant &value) const override
Converts the variant value to the value type of the setting.
Qgis::SettingsType settingsType() const override
Returns the settings entry type.
QStringList convertFromVariant(const QVariant &value) const override
Converts the variant value to the value type of the setting.
int maxLength() const
Returns the string maximum length.
int minLength() const
Returns the string minimum length.
Qgis::SettingsType settingsType() const override
Returns the settings entry type.
QString convertFromVariant(const QVariant &value) const override
Converts the variant value to the value type of the setting.
Qgis::SettingsType settingsType() const override
Returns the settings entry type.
QVariantMap convertFromVariant(const QVariant &value) const override
Converts the variant value to the value type of the setting.
Qgis::SettingsType settingsType() const override
Returns the settings entry type.
static QgsSettingsProxy get()
Returns a proxy for a QgsSettings object.
#define QgsDebugError(str)