Namespace sh::configuration

namespace sh::configuration

Configuration, so everything you see in ‘Finetuning’, and some other data (e.g. get shallot program directory).

Enums

enum ConfigurationCategory

Categories of Configursh::configuration::ConfigurationValuentations. They are used for grouping them in the dialogs. There is no difference in behavior implied by this choice.

Values:

enumerator CategoryNone = 0

No category.

enumerator CategoryGUI = 1

User interface category.

enumerator CategoryBehavior = 2

Behavioral configuration category.

enumerator CategoryExternalTools = 3

External tools category.

class ConfigurationManager : public QObject, public sh::base::Singleton
#include <configurationmanager.h>

Manages the Shallot configuration.

This is the more static part of Shallot. Much more stuff, i.e. everything you see in ‘Manage saved settings’, is in sh::settings::SettingsManager.

Public Functions

std::shared_ptr<ConfigurationValue> registerConfigValue(QString name, QVariant deflt, ConfigurationValueType *valuetype = 0, QString desc = "", ConfigurationCategory cat = CategoryNone, QString longdesc = "", QString changehint = "")

Creates and registers a new ConfigurationValue. This is typically done once at the beginning. Each registered instance is shown in the ‘Tuning’ dialog and can be set (for making changes) and observed (for applying changes) in code as well. Useful e.g. for some internal bookkeeping or for exotic machine-wide configuration values (path to some tool, …).

QList<std::shared_ptr<ConfigurationValue>> getAllConfigurationValues()

Returns a list of all registered configuration value instances.

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

Returns if this singleton is alive (true until its shutdown begins).

Private Functions

QVariant getFixedConfigValue(QString key)

Returns a non-null value if ‘key’ was set in a fixed way (e.g. via command line).

ConfigurationManager()

Private Members

QHash<QString, std::shared_ptr<ConfigurationValue>> _configvalues
QHash<QString, QVariant> _fixed_configvalues
bool _fixed_configvalues_initialized = false
QMutex _mutex
class ConfigurationValueImpl : public sh::configuration::ConfigurationValue

Public Functions

ConfigurationValueImpl(QString name, QVariant deflt, QString desc, QString longdesc, ConfigurationCategory cat, ConfigurationValueType *valuetype, QString changehint, ConfigurationManager *mgr)
void setConfigValue(QVariant value) override

Sets a new configuration value.

QVariant getConfigValueVariant() override

Returns the current value of this instance as variant.

bool mayChange() override

Returns if changes are allowed.

int getConfigValueInt()

Returns the current value of this instance as integer.

double getConfigValueFloat()

Returns the current value of this instance as floating point number.

bool getConfigValueBool()

Returns the current value of this instance as boolean.

QString getConfigValueString()

Returns the current value of this instance as string.

void consumeValue(QObject *o, std::function<void()> h)

Adds a consumer function, triggered directly and whenever the value changes.

Parameters
  • o: For lifetime monitoring.

QString name()

Returns the internal name of this configuration.

QString description()

Returns the short description of this configuration.

QString longDescription()

Returns the long description of this configuration.

ConfigurationCategory category()

Returns the category of this configuration (mainly for UI structuring).

QString changeHint()

Returns the change hint text of this configuration.

QVariant defaultValue()

Returns the default value of this configuration.

ConfigurationValueType *valueType()

Returns the value type of this configuration.

Public Static Functions

ConfigurationValueType *valueTypeString()

Returns the string type for configuration values.

ConfigurationValueType *valueTypeInteger()

Returns the integer type for configuration values.

ConfigurationValueType *valueTypeFloat()

Returns the floating point number type for configuration values.

ConfigurationValueType *valueTypeBoolean()

Returns the boolean type for configuration values.

ConfigurationValueType *valueTypeLocalFilePath()

Returns the filepath type for configuration values.

Private Members

ConfigurationManager *mgr
class ConfigurationValue
#include <configurationvalue.h>

Abstract base class for a configuration value which is managed in the Tuning dialog.

Each instance can get and set the value associated to it.

You should typically not need to override it. See sh::configuration::ConfigurationManager. See Shallot documentation for more details.

Subclassed by sh::configuration::ConfigurationManager::ConfigurationValueImpl

Public Functions

ConfigurationValue(QString name, QVariant deflt, QString desc, QString longdesc, ConfigurationCategory cat, ConfigurationValueType *valuetype, QString changehint)
int getConfigValueInt()

Returns the current value of this instance as integer.

double getConfigValueFloat()

Returns the current value of this instance as floating point number.

bool getConfigValueBool()

Returns the current value of this instance as boolean.

QString getConfigValueString()

Returns the current value of this instance as string.

QVariant getConfigValueVariant() = 0

Returns the current value of this instance as variant.

void setConfigValue(QVariant value) = 0

Sets a new configuration value.

bool mayChange() = 0

Returns if changes are allowed.

void consumeValue(QObject *o, std::function<void()> h)

Adds a consumer function, triggered directly and whenever the value changes.

Parameters
  • o: For lifetime monitoring.

QString name()

Returns the internal name of this configuration.

QString description()

Returns the short description of this configuration.

QString longDescription()

Returns the long description of this configuration.

ConfigurationCategory category()

Returns the category of this configuration (mainly for UI structuring).

QString changeHint()

Returns the change hint text of this configuration.

QVariant defaultValue()

Returns the default value of this configuration.

ConfigurationValueType *valueType()

Returns the value type of this configuration.

Public Static Functions

ConfigurationValueType *valueTypeString()

Returns the string type for configuration values.

ConfigurationValueType *valueTypeInteger()

Returns the integer type for configuration values.

ConfigurationValueType *valueTypeFloat()

Returns the floating point number type for configuration values.

ConfigurationValueType *valueTypeBoolean()

Returns the boolean type for configuration values.

ConfigurationValueType *valueTypeLocalFilePath()

Returns the filepath type for configuration values.

Friends

friend class ConfigurationManager
friend class ConfigurationValueType
class ConfigurationValueType
#include <configurationvaluetype.h>

Abstract base class for a configuration value type.

Each subclass implements support for a certain type of configuration values (e.g. string, integer, …).

Subclassed by sh::configuration::ConfigurationValueTypeBoolean, sh::configuration::ConfigurationValueTypeFloat, sh::configuration::ConfigurationValueTypeInteger, sh::configuration::ConfigurationValueTypeLocalFilePath, sh::configuration::ConfigurationValueTypeString

Public Functions

QString valueDescription(QVariant v)
QVariant parse(QString input)
class ConfigurationValueTypeBoolean : public sh::configuration::ConfigurationValueType
#include <configurationvaluetype.h>

Configuration value type ‘boolean’.

Public Functions

QString valueDescription(QVariant v)
QVariant parse(QString input)
class ConfigurationValueTypeFloat : public sh::configuration::ConfigurationValueType
#include <configurationvaluetype.h>

Configuration value type ‘float’.

Public Functions

QString valueDescription(QVariant v)
QVariant parse(QString input)
class ConfigurationValueTypeInteger : public sh::configuration::ConfigurationValueType
#include <configurationvaluetype.h>

Configuration value type ‘integer’.

Public Functions

QString valueDescription(QVariant v)
QVariant parse(QString input)
class ConfigurationValueTypeLocalFilePath : public sh::configuration::ConfigurationValueType
#include <configurationvaluetype.h>

Configuration value type ‘file path’.

Public Functions

QString valueDescription(QVariant v)
QVariant parse(QString input)
class ConfigurationValueTypeString : public sh::configuration::ConfigurationValueType
#include <configurationvaluetype.h>

Configuration value type ‘string’.

Public Functions

QString valueDescription(QVariant v)
QVariant parse(QString input)