summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-09-08 10:27:30 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-09-08 16:33:03 +0300
commitaf1eff03c9e839914aab4109970c4a9f6fac8a99 (patch)
treeae11034560b0e1c270614077ffd8f0f7485c7381 /scripts
parentAdd RekonqWindow tests (diff)
downloadrekonq-af1eff03c9e839914aab4109970c4a9f6fac8a99.tar.xz
RekonqSettings: add resetValue and remove value's defaultValue parameter
- generate default rekonqrc and include it in libsettings - Settings uses :/settings/rekonqrc to provide default values - Add Settings::path() to get the default settings location
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/rekonf.py52
1 files changed, 32 insertions, 20 deletions
diff --git a/scripts/rekonf.py b/scripts/rekonf.py
index 941c29c7..6bb5d084 100755
--- a/scripts/rekonf.py
+++ b/scripts/rekonf.py
@@ -13,42 +13,42 @@ import sys
from xml.etree import ElementTree
-def write_int_entry(obj, name, default):
- """Add a QSpinBox connected to an Int (obj, name, default)"""
+def write_int_entry(obj, name):
+ """Add a QSpinBox connected to an Int"""
print(f' auto* { obj } = new QSpinBox(this);')
- print(f' { obj }->setValue(s->value("{ obj }", { default }).toInt());')
+ print(f' { obj }->setValue(s->value("{ obj }").toInt());')
print(f' connect({ obj }, &QSpinBox::valueChanged, this, [this]() {{ emit changed(); }});')
print(f' formLayout->addRow(tr("{ name }"), { obj });')
-def write_bool_entry(obj, name, default):
- """Add a QCheckBox connected to a Bool (obj, name, default)"""
+def write_bool_entry(obj, name):
+ """Add a QCheckBox connected to a Bool"""
print(f' auto* { obj } = new QCheckBox(tr("{ name }"), this);')
- print(f' { obj }->setChecked(s->value("{ obj }", { default }).toBool());')
+ print(f' { obj }->setChecked(s->value("{ obj }").toBool());')
print(f' connect({ obj }, &QCheckBox::stateChanged, this, [this]() {{ emit changed(); }});')
print(f' formLayout->addRow(QString(), { obj });')
-def write_string_entry(obj, name, default):
- """Add a QLineEdit connected to a String (obj, name, default)"""
+def write_string_entry(obj, name):
+ """Add a QLineEdit connected to a String"""
print(f' auto* {obj} = new QLineEdit(this);')
- print(f' { obj }->setText(s->value("{ obj }", "{ default }").toString());')
+ print(f' { obj }->setText(s->value("{ obj }").toString());')
print(f' connect({ obj }, &QLineEdit::textChanged, this, [this]() {{ emit changed(); }});')
print(f' formLayout->addRow(tr("{ name }"), { obj });')
-def write_font_entry(obj, name, default):
- """Add a QFontComboBox connected to a Font (obj, name, default)"""
+def write_font_entry(obj, name):
+ """Add a QFontComboBox connected to a Font"""
print(f' auto* { obj } = new QFontComboBox(this);')
- print(f' { obj }->setCurrentFont(s->value("{ obj }", "{ default }").toString());')
+ print(f' { obj }->setCurrentFont(s->value("{ obj }").toString());')
print(f' connect({ obj }, &QFontComboBox::currentFontChanged, this, [this]() {{ emit changed(); }});')
print(f' formLayout->addRow(tr("{ name }"), { obj });')
-def write_shortcut_entry(obj, name, default):
- """Add a QKeySequenceEdit connected to a Shortcut (obj, name, default)"""
+def write_shortcut_entry(obj, name):
+ """Add a QKeySequenceEdit connected to a Shortcut"""
print(f' auto* { obj } = new QKeySequenceEdit(this);')
- print(f' { obj }->setKeySequence(s->value("{ obj }", "{ default }").toString());')
+ print(f' { obj }->setKeySequence(s->value("{ obj }").toString());')
print(f' connect({ obj }, &QKeySequenceEdit::keySequenceChanged, this, [this]() {{ emit changed(); }});')
print(f' formLayout->addRow(tr("{ name }"), { obj });')
@@ -69,7 +69,6 @@ def generate_group_widget(root, group):
# includes
print('// Includes')
print('#include "settingswidgets.hpp"')
- print('#include "helpers.hpp"')
print('#include <QFormLayout>')
print('#include <QLineEdit>')
print('#include <QSpinBox>')
@@ -97,16 +96,29 @@ def generate_group_widget(root, group):
else:
obj = entry.attrib['key']
name = entry.attrib["name"]
- default = entry.find('{*}default').text
- write_entry_fn.get(entry.attrib['type'])(obj, name, default)
+ write_entry_fn.get(entry.attrib['type'])(obj, name)
print(f' { obj }->setObjectName("{ obj }");')
- print(f' { obj }->setProperty("defaultValue", "{ default }");')
print('')
if class_group != 'General':
- print(' s->endGroup();')
+ print(' m_settings->endGroup();')
print('}\n')
+ # reset
+ print(f'void { class_name }::reset() {{')
+ if class_group != 'General':
+ print(f' m_settings->beginGroup("{ class_group }");')
+
+ for entry in group.findall('{http://www.kde.org/standards/kcfg/1.0}entry'):
+ if entry.attrib.get("hidden") == "true":
+ print(f' // hidden entry { entry.attrib.get("name") }')
+ else:
+ key = entry.attrib['key']
+ print(f' m_settings->resetValue("{ key }");')
+
+ if class_group != 'General':
+ print(' m_settings->endGroup();')
+ print('}\n')
def generate_group_ini(group):
"""Generate settings in ini format for group"""