dsettings_zh
2022-04-18 16:18:31

Class::DSettings

暂无该属性


Detailed Description

  • ~chinese *

DSettings 是设计上为Dtk的应用程序提供统一的配置存储以及界面生成工具的基础库。 * DSetting使用json作为应用配置程序的描述文件。简单来说,应用查询的配置分为组/键值二个基础层级, * 对于一个标准的Dtk配置控件,一般只包含组/子组/键值三个层级,对于超过三个层级的键值,可以通过 * DSettings 的API接口进行读取和写入,但是不能在标准的DSettingsDialogs上显示出来。 * * 一个简单的配置文件如下: json { "groups": [{ "key": "base", "name": "Basic settings", "groups": [{ "key": "open_action", "name": "Open Action", "options": [{ "key": "alway_open_on_new", "type": "checkbox", "text": "Always Open On New Windows", "default": true }, { "key": "open_file_action", "name": "Open File:", "type": "combobox", "default": "" } ] }, { "key": "new_tab_windows", "name": "New Tab & Window", "options": [{ "key": "new_window_path", "name": "New Window Open:", "type": "combobox", "default": "" }, { "key": "new_tab_path", "name": "New Tab Open:", "type": "combobox", "default": "" } ] } ] }] }

  • 改组中包含一个base的root组,两个子组: open_action/new_tab_windows,每个子组有包含若干选项。 * 对于"New Window Open:"这个配置,其完整的访问id为base.new_tab_windows.new_window_path。 * 读取/设置其值的示例如下:

// 从json中初始化配置 auto settings = Dtk::Core::DSettings::fromJsonFile(":/resources/data/dfm-settings.json"); settings-> [setBackend](#setBackend) (backend);

// 读取配置 auto opt = settings->option("base.new_tab_windows.new_window_path"); qDebug() << opt-> [value()](#value) ;

// 修改配置 opt->setValue("Test") qDebug() << opt-> [value()](#value) ; ``` *

*

*

*

*

**See also** Dtk::Core::DSettingsOptionDtk::Core::DSettingsGroupDtk::Core::DSettingsBackendDtk::Widget::DSettingsWidgetFactoryDtk::Widget::DSettingsDialog

# DSettings::metaObject

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green">virtual</font>]

const QMetaObject * metaObject() const



# DSettings::qt_metacast

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green">virtual</font>]

void * qt_metacast(const char *)



# DSettings::qt_metacall

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green">virtual</font>]

int qt_metacall(QMetaObject::Call , int , void **)



# DSettings::tr

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green">static</font>&nbsp;<font color="green"></font>]

QString tr(const char *s, const char *c, int n)



# DSettings::trUtf8

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green">static</font>&nbsp;<font color="green"></font>]

QString trUtf8(const char *s, const char *c, int n)



# DSettings::qt_static_metacall

<a id="name"></a>
[<font color="green">private</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green">static</font>&nbsp;<font color="green"></font>]

void qt_static_metacall(QObject *, QMetaObject::Call , int , void **)


# Class::QPrivateSignal


### DSettings::QPrivateSignal

 <hr />


# Detailed Description


# DSettings::DSettings

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">constructor</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

DSettings(QObject *parent)



# DSettings::~DSettings

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">destructor</font>&nbsp;<font color="green"></font>&nbsp;<font color="green">virtual</font>]

~DSettings()



# DSettings::setBackend

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

void setBackend(DSettingsBackend *backend)



# DSettings::fromJson

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green">static</font>&nbsp;<font color="green"></font>]

QPointer<DSettings> fromJson(const QByteArray &json)



# DSettings::fromJsonFile

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green">static</font>&nbsp;<font color="green"></font>]

QPointer<DSettings> fromJsonFile(const QString &filepath)



# DSettings::meta

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

QJsonObject meta() const



# DSettings::keys

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

QStringList keys() const



# DSettings::options

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

QList<QPointer<DSettingsOption> > options() const



# DSettings::option

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

QPointer<DSettingsOption> option(const QString &key) const
**See also**  [setOption()](#setOption) 


# DSettings::value

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

QVariant value(const QString &key) const



# DSettings::groupKeys

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

QStringList groupKeys() const



# DSettings::groups

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

QList<QPointer<DSettingsGroup> > groups() const



# DSettings::group

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

QPointer<DSettingsGroup> group(const QString &key) const

 will recurrence find childGroup *key* Returns



# DSettings::getOption

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

QVariant getOption(const QString &key) const



# DSettings::valueChanged

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">signal</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

void valueChanged(const QString &key, const QVariant &value)



# DSettings::sync

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">slot</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

void sync()



# DSettings::setOption

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">slot</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

void setOption(const QString &key, const QVariant &value)
**See also**  [option()](#option) 


# DSettings::reset

<a id="name"></a>
[<font color="green">public</font>&nbsp;<font color="green">slot</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

void reset()



# DSettings::parseJson

<a id="name"></a>
[<font color="green">private</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

void parseJson(const QByteArray &json)



# DSettings::loadValue

<a id="name"></a>
[<font color="green">private</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

void loadValue()



# DSettings::d_func

<a id="name"></a>
[<font color="green">private</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

DSettingsPrivate * d_func()



# DSettings::d_func

<a id="name"></a>
[<font color="green">private</font>&nbsp;<font color="green">plain</font>&nbsp;<font color="green"></font>&nbsp;<font color="green"></font>]

const DSettingsPrivate * d_func() const