DtkCore
DTK Core module
Dtk::Core::DSettingsBackend类 参考abstract

DSettingsBackend is interface of DSettings storage class. 更多...

类 Dtk::Core::DSettingsBackend 继承关系图:
Dtk::Core::DSettingsDConfigBackend Dtk::Core::GSettingsBackend Dtk::Core::QSettingBackend

信号

void optionChanged (const QString &key, const QVariant &value)
 emitted when option value changed. 更多...
 
void sync ()
 private signal, please do not use it. 更多...
 
void setOption (const QString &key, const QVariant &value)
 private signal, please do not use it. 更多...
 

Public 成员函数

 DSettingsBackend (QObject *parent=Q_NULLPTR)
 
virtual QStringList keys () const =0
 return all key of storage. 更多...
 
virtual QVariant getOption (const QString &key) const =0
 get value by key. 更多...
 
virtual void doSync ()=0
 do the real sync action. 更多...
 

Protected 成员函数

virtual void doSetOption (const QString &key, const QVariant &value)=0
 write key / value to storage. 更多...
 

详细描述

DSettingsBackend is interface of DSettings storage class.

\inmodule dtkcore

Simaple example:

{
"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": ""
}
]
}
]
}]
}
How to read/write key and value:

\code
// init a storage backend
QTemporaryFile tmpFile;
tmpFile.open();
auto backend = new Dtk::Core::QSettingBackend(tmpFile.fileName());

// read settings from json
auto settings = Dtk::Core::DSettings::fromJsonFile(":/resources/data/dfm-settings.json");
settings->setBackend(backend);

// read value
auto opt = settings->option("base.new_tab_windows.new_window_path");
qDebug() << opt->value();

// modify value
opt->setValue("Test")
qDebug() << opt->value();
参见
Dtk::Core::DSettingsOption
Dtk::Core::DSettingsGroup
Dtk::Core::DSettingsBackend
Dtk::Widget::DSettingsWidgetFactory
Dtk::Widget::DSettingsDialog

成员函数说明

◆ doSetOption()

void Dtk::Core::DSettingsBackend::doSetOption ( const QString &  key,
const QVariant &  value 
)
protectedpure virtual

write key / value to storage.

设置key对应的值,并使用存储后端进行存储。

◆ doSync()

void Dtk::Core::DSettingsBackend::doSync ( )
pure virtual

do the real sync action.

开始进行同步。

◆ getOption()

QVariant Dtk::Core::DSettingsBackend::getOption ( const QString &  key) const
pure virtual

get value by key.

获取 key 对应的值。

Dtk::Core::DSettingsDConfigBackend, Dtk::Core::GSettingsBackend , 以及 Dtk::Core::QSettingBackend 内被实现.

◆ keys()

QStringList Dtk::Core::DSettingsBackend::keys ( ) const
pure virtual

return all key of storage.

返回全部键值。

Dtk::Core::DSettingsDConfigBackend, Dtk::Core::GSettingsBackend , 以及 Dtk::Core::QSettingBackend 内被实现.

◆ optionChanged

void Dtk::Core::DSettingsBackend::optionChanged ( const QString &  key,
const QVariant &  value 
)
signal

emitted when option value changed.

DSettingsOption的值发生变化时发出的信号.

key 发生改变的 option 键,value 对应键的值.

◆ setOption

void Dtk::Core::DSettingsBackend::setOption ( const QString &  key,
const QVariant &  value 
)
signal

private signal, please do not use it.

私有信号,请勿使用.

◆ sync

void Dtk::Core::DSettingsBackend::sync ( )
signal

private signal, please do not use it.

私有信号,请勿使用。


该类的文档由以下文件生成: