Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
1. Setting control

Detailed Description

Functions to handle settings access
This can be used to get and set the addon related values inside his settings.xml.

The settings style is given with installed part on e.g. $HOME/.kodi/addons/myspecial.addon/resources/settings.xml. The related edit becomes then stored inside $HOME/.kodi/userdata/addon_data/myspecial.addon/settings.xml.

Function Documentation

◆ OpenSettings()

bool ATTR_DLL_LOCAL OpenSettings ( )
inline

Opens this Add-Ons settings dialog.

Returns
true if settings were changed and the dialog confirmed, false otherwise.

Example:

#include <kodi/General.h>
..
kodi::OpenSettings();
..

◆ IsSettingUsingDefault()

bool ATTR_DLL_LOCAL IsSettingUsingDefault ( const std::string & settingName)
inline

Check the given setting name is set to default value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
Returns
true if setting is the default

◆ CheckSettingString()

bool ATTR_DLL_LOCAL CheckSettingString ( const std::string & settingName,
std::string & settingValue )
inline

Check and get a string setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[out]settingValueThe given setting value
Returns
true if setting was successfully found and "settingValue" is set
Note
If returns false, the "settingValue" is not changed.

Example:

#include <kodi/General.h>
std::string value;
if (!kodi::CheckSettingString("my_string_value", value))
value = "my_default_if_setting_not_work";

◆ GetSettingString()

std::string ATTR_DLL_LOCAL GetSettingString ( const std::string & settingName,
const std::string & defaultValue = "" )
inline

Get string setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[in]defaultValue[opt] Default value if not found
Returns
The value of setting, empty if not found;

Example:

#include <kodi/General.h>
std::string value = kodi::GetSettingString("my_string_value");

◆ SetSettingString()

void ATTR_DLL_LOCAL SetSettingString ( const std::string & settingName,
const std::string & settingValue )
inline

Set string setting of addon.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of setting
[in]settingValueThe setting value to write

Example:

#include <kodi/General.h>
std::string value = "my_new_name for";
kodi::SetSettingString("my_string_value", value);

◆ CheckSettingInt()

bool ATTR_DLL_LOCAL CheckSettingInt ( const std::string & settingName,
int & settingValue )
inline

Check and get a integer setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[out]settingValueThe given setting value
Returns
true if setting was successfully found and "settingValue" is set
Note
If returns false, the "settingValue" is not changed.

Example:

#include <kodi/General.h>
int value = 0;
if (!kodi::CheckSettingInt("my_integer_value", value))
value = 123; // My default of them

◆ GetSettingInt()

int ATTR_DLL_LOCAL GetSettingInt ( const std::string & settingName,
int defaultValue = 0 )
inline

Get integer setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[in]defaultValue[opt] Default value if not found
Returns
The value of setting, 0 or defaultValue if not found

Example:

#include <kodi/General.h>
int value = kodi::GetSettingInt("my_integer_value");

◆ SetSettingInt()

void ATTR_DLL_LOCAL SetSettingInt ( const std::string & settingName,
int settingValue )
inline

Set integer setting of addon.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of setting
[in]settingValueThe setting value to write

Example:

#include <kodi/General.h>
int value = 123;
kodi::SetSettingInt("my_integer_value", value);

◆ CheckSettingBoolean()

bool ATTR_DLL_LOCAL CheckSettingBoolean ( const std::string & settingName,
bool & settingValue )
inline

Check and get a boolean setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[out]settingValueThe given setting value
Returns
true if setting was successfully found and "settingValue" is set
Note
If returns false, the "settingValue" is not changed.

Example:

#include <kodi/General.h>
bool value = false;
if (!kodi::CheckSettingBoolean("my_boolean_value", value))
value = true; // My default of them

◆ GetSettingBoolean()

bool ATTR_DLL_LOCAL GetSettingBoolean ( const std::string & settingName,
bool defaultValue = false )
inline

Get boolean setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[in]defaultValue[opt] Default value if not found
Returns
The value of setting, false or defaultValue if not found

Example:

#include <kodi/General.h>
bool value = kodi::GetSettingBoolean("my_boolean_value");

◆ SetSettingBoolean()

void ATTR_DLL_LOCAL SetSettingBoolean ( const std::string & settingName,
bool settingValue )
inline

Set boolean setting of addon.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of setting
[in]settingValueThe setting value to write

Example:

#include <kodi/General.h>
bool value = true;
kodi::SetSettingBoolean("my_boolean_value", value);

◆ CheckSettingFloat()

bool ATTR_DLL_LOCAL CheckSettingFloat ( const std::string & settingName,
float & settingValue )
inline

Check and get a floating point setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[out]settingValueThe given setting value
Returns
true if setting was successfully found and "settingValue" is set
Note
If returns false, the "settingValue" is not changed.

Example:

#include <kodi/General.h>
float value = 0.0f;
if (!kodi::CheckSettingBoolean("my_float_value", value))
value = 1.0f; // My default of them

◆ GetSettingFloat()

float ATTR_DLL_LOCAL GetSettingFloat ( const std::string & settingName,
float defaultValue = 0.0f )
inline

Get floating point setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[in]defaultValue[opt] Default value if not found
Returns
The value of setting, 0.0 or defaultValue if not found

Example:

#include <kodi/General.h>
float value = kodi::GetSettingFloat("my_float_value");

◆ SetSettingFloat()

void ATTR_DLL_LOCAL SetSettingFloat ( const std::string & settingName,
float settingValue )
inline

Set floating point setting of addon.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of setting
[in]settingValueThe setting value to write

Example:

#include <kodi/General.h>
float value = 1.0f;
kodi::SetSettingFloat("my_float_value", value);

◆ CheckSettingEnum()

template<typename enumType >
bool ATTR_DLL_LOCAL CheckSettingEnum ( const std::string & settingName,
enumType & settingValue )
inline

Check and get a enum setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[out]settingValueThe given setting value
Returns
true if setting was successfully found and "settingValue" is set
Remarks
The enums are used as integer inside settings.xml.
Note
If returns false, the "settingValue" is not changed.

Example:

#include <kodi/General.h>
{
};
myEnumValue value;
if (!kodi::CheckSettingEnum<myEnumValue>("my_enum_value", value))
value = valueA; // My default of them
Definition PeripheralUtils.h:48

◆ GetSettingEnum()

template<typename enumType >
enumType ATTR_DLL_LOCAL GetSettingEnum ( const std::string & settingName,
enumType defaultValue = static_cast<enumType>(0) )
inline

Get enum setting value.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of asked setting
[in]defaultValue[opt] Default value if not found
Returns
The value of setting, forced to 0 or defaultValue if not found
Remarks
The enums are used as integer inside settings.xml.

Example:

#include <kodi/General.h>
{
};
myEnumValue value = kodi::GetSettingEnum<myEnumValue>("my_enum_value");

◆ SetSettingEnum()

template<typename enumType >
void ATTR_DLL_LOCAL SetSettingEnum ( const std::string & settingName,
enumType settingValue )
inline

Set enum setting of addon.

The setting name relate to names used in his settings.xml file.

Parameters
[in]settingNameThe name of setting
[in]settingValueThe setting value to write
Remarks
The enums are used as integer inside settings.xml.

Example:

#include <kodi/General.h>
{
};
myEnumValue value = valueA;
kodi::SetSettingEnum<myEnumValue>("my_enum_value", value);