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  def all_keys(self):
51  return self._settings_proxy.all_keys(self._group)
52 
53 # def begin_read_array(self):
54 
55 # def begin_write_array(self):
56 
57  def child_groups(self):
58  return self._settings_proxy.child_groups(self._group)
59 
60  def child_keys(self):
61  return self._settings_proxy.child_keys(self._group)
62 
63  @Slot(str, result=bool)
64  def contains(self, key):
65  return self._settings_proxy.contains(self._group, key)
66 
67 # def end_array(self):
68 
69  @Slot(str)
70  def remove(self, key):
71  self._settings_proxy.remove(self._group, key)
72 
73 # def set_array_index(self, i):
74 
75  @Slot(str, 'QVariant')
76  def set_value(self, key, value):
77  # work around for NoneType values via DBus
78  if value is None:
79  value = '__NoneType__'
80  self._settings_proxy.set_value(self._group, key, value)
81 
82  @Slot(str, 'QVariant', result='QVariant')
83  def value(self, key, default_value=None):
84  # work around for passing NoneType (default_)values via DBus
85  if default_value is None:
86  default_value = '__NoneType__'
87  value = self._settings_proxy.value(self._group, key, default_value)
88  if value == '__NoneType__':
89  value = None
90  return value
def get_settings(self, group)
Definition: settings.py:44
def set_value(self, key, value)
Definition: settings.py:76
def child_groups(self)
Definition: settings.py:57
def __init__(self, settings_proxy, group)
Definition: settings.py:37
def contains(self, key)
Definition: settings.py:64
def value(self, key, default_value=None)
Definition: settings.py:83
def remove(self, key)
Definition: settings.py:70


qt_gui
Author(s): Dirk Thomas
autogenerated on Thu Jun 6 2019 19:54:27