src
qt_gui
settings.py
Go to the documentation of this file.
1
# Copyright (c) 2011, Dirk Thomas, Dorian Scholz, TU Darmstadt
2
# All rights reserved.
3
#
4
# Redistribution and use in source and binary forms, with or without
5
# modification, are permitted provided that the following conditions
6
# are met:
7
#
8
# * Redistributions of source code must retain the above copyright
9
# notice, this list of conditions and the following disclaimer.
10
# * Redistributions in binary form must reproduce the above
11
# copyright notice, this list of conditions and the following
12
# disclaimer in the documentation and/or other materials provided
13
# with the distribution.
14
# * Neither the name of the TU Darmstadt nor the names of its
15
# contributors may be used to endorse or promote products derived
16
# from this software without specific prior written permission.
17
#
18
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
# POSSIBILITY OF SUCH DAMAGE.
30
31
from
python_qt_binding.QtCore
import
QObject, Slot
32
33
34
class
Settings
(QObject):
35
"""Storage of key-value data with a QSettings-like interface."""
36
37
def
__init__
(self, settings_proxy, group):
38
super(Settings, self).
__init__
()
39
self.setObjectName(
'Settings'
)
40
41
self.
_settings_proxy
= settings_proxy
42
self.
_group
= group
43
44
def
get_settings
(self, group):
45
prefix = self.
_group
46
if
prefix !=
''
:
47
prefix +=
'/'
48
return
Settings
(self.
_settings_proxy
, prefix + group)
49
50
@Slot(result=
'QStringList'
)
51
def
all_keys
(self):
52
return
self.
_settings_proxy
.
all_keys
(self.
_group
)
53
54
# def begin_read_array(self):
55
56
# def begin_write_array(self):
57
58
@Slot(result=
'QStringList'
)
59
def
child_groups
(self):
60
return
self.
_settings_proxy
.
child_groups
(self.
_group
)
61
62
@Slot(result=
'QStringList'
)
63
def
child_keys
(self):
64
return
self.
_settings_proxy
.
child_keys
(self.
_group
)
65
66
@Slot(str, result=bool)
67
def
contains
(self, key):
68
return
self.
_settings_proxy
.
contains
(self.
_group
, key)
69
70
# def end_array(self):
71
72
@Slot(str)
73
def
remove
(self, key):
74
self.
_settings_proxy
.
remove
(self.
_group
, key)
75
76
# def set_array_index(self, i):
77
78
@Slot(str,
'QVariant'
)
79
def
set_value
(self, key, value):
80
# work around for NoneType values via DBus
81
if
value
is
None
:
82
value =
'__NoneType__'
83
self.
_settings_proxy
.
set_value
(self.
_group
, key, value)
84
85
@Slot(str,
'QVariant'
, result=
'QVariant'
)
86
def
value
(self, key, default_value=None):
87
# work around for passing NoneType (default_)values via DBus
88
if
default_value
is
None
:
89
default_value =
'__NoneType__'
90
value = self.
_settings_proxy
.
value
(self.
_group
, key, default_value)
91
if
value ==
'__NoneType__'
:
92
value =
None
93
return
value
qt_gui.settings.Settings.remove
def remove(self, key)
Definition:
settings.py:73
qt_gui.settings.Settings.value
def value(self, key, default_value=None)
Definition:
settings.py:86
qt_gui.settings.Settings.contains
def contains(self, key)
Definition:
settings.py:67
qt_gui.settings.Settings.child_keys
def child_keys(self)
Definition:
settings.py:63
qt_gui.settings.Settings.get_settings
def get_settings(self, group)
Definition:
settings.py:44
qt_gui.settings.Settings.all_keys
def all_keys(self)
Definition:
settings.py:51
qt_gui.settings.Settings.child_groups
def child_groups(self)
Definition:
settings.py:59
qt_gui.settings.Settings.set_value
def set_value(self, key, value)
Definition:
settings.py:79
qt_gui.settings.Settings._group
_group
Definition:
settings.py:42
qt_gui.settings.Settings._settings_proxy
_settings_proxy
Definition:
settings.py:41
qt_gui.settings.Settings.__init__
def __init__(self, settings_proxy, group)
Definition:
settings.py:37
qt_gui.settings.Settings
Definition:
settings.py:34
qt_gui
Author(s): Dirk Thomas
autogenerated on Sat Jun 25 2022 02:15:05