27bool QgsSettingsEntryString::checkValuePrivate(
const QString &value )
const
29 if (
value.length() < mMinLength )
31 QgsDebugError( QStringLiteral(
"Can't set value for settings. String length '%1' is shorter than minimum length '%2'." )
32 .arg(
value.length() )
38 &&
value.length() > mMaxLength )
40 QgsDebugError( QStringLiteral(
"Can't set value for settings. String length '%1' is longer than maximum length '%2'." )
41 .arg(
value.length() )
51 return value.toString();
71 return value.toStringList();
82 return value.toBool();
92bool QgsSettingsEntryInteger::checkValuePrivate(
const int &value )
const
94 if (
value < mMinValue )
96 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is less than minimum value '%2'." )
97 .arg( QString::number(
value ) )
98 .arg( QString::number( mMinValue ) ) );
102 if (
value > mMaxValue )
104 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is greater than maximum value '%2'." )
105 .arg( QString::number(
value ) )
106 .arg( QString::number( mMaxValue ) ) );
115 return value.toLongLong();
133bool QgsSettingsEntryInteger64::checkValuePrivate(
const qlonglong &value )
const
135 if (
value < mMinValue )
137 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is less than minimum value '%2'." )
138 .arg( QString::number(
value ) )
139 .arg( QString::number( mMinValue ) ) );
143 if (
value > mMaxValue )
145 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is greater than maximum value '%2'." )
146 .arg( QString::number(
value ) )
147 .arg( QString::number( mMaxValue ) ) );
156 return value.toLongLong();
176bool QgsSettingsEntryDouble::checkValuePrivate(
const double &value )
const
178 if (
value < mMinValue )
180 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is less than minimum value '%2'." )
181 .arg( QString::number(
value ), QString::number( mMinValue ) ) );
185 if (
value > mMaxValue )
187 QgsDebugError( QObject::tr(
"Can't set value for setting. Value '%1' is greater than maximum value '%2'." )
188 .arg( QString::number(
value ), QString::number( mMaxValue ) ) );
197 return value.toDouble();
222 return mDisplayHintDecimals;
227 return value.value<QColor>();
235bool QgsSettingsEntryColor::checkValuePrivate(
const QColor &value )
const
237 if ( !mAllowAlpha &&
value.alpha() != 255 )
239 QgsDebugError( QStringLiteral(
"Setting %1 doesn't allow transparency and the given color has transparency." ).arg(
definitionKey() ) );
249 if ( settings->contains( redKey ) && settings->contains( greenKey ) && settings->contains( blueKey ) && ( alphaKey.isNull() || settings->contains( alphaKey ) ) )
252 if ( alphaKey.isNull() )
253 oldValue = QColor( settings->value( redKey ).toInt(), settings->value( greenKey ).toInt(), settings->value( blueKey ).toInt() );
255 oldValue = QColor( settings->value( redKey ).toInt(), settings->value( greenKey ).toInt(), settings->value( blueKey ).toInt(), settings->value( alphaKey ).toInt() );
257 if ( removeSettingAtKey )
259 settings->remove( redKey );
260 settings->remove( greenKey );
261 settings->remove( blueKey );
262 settings->remove( alphaKey );
265 if (
value() != oldValue )
275 const QColor color =
value();
276 settings->setValue( redKey, color.red() );
277 settings->setValue( greenKey, color.green() );
278 settings->setValue( blueKey, color.blue() );
279 if ( !alphaKey.isNull() )
280 settings->setValue( alphaKey, color.alpha() );
285 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
Returns settings value.
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.
virtual 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.
virtual 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.
virtual 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.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
int minValue() const
Returns the minimum value.
virtual 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.
virtual 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.
virtual 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.
virtual 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.
virtual Qgis::SettingsType settingsType() const override
Returns the settings entry type.
static QgsSettingsProxy get()
Returns a proxy for a QgsSettings object.
#define QgsDebugError(str)