/usr/share/kde4/apps/kajongg/config.py is in kajongg 4:4.13.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | # -*- coding: utf-8 -*-
"""
Copyright (C) 2008-2014 Wolfgang Rohdewald <wolfgang@rohdewald.de>
partially based on C++ code from:
Copyright (C) 2006 Mauricio Piacentini <mauricio@tabuleiro.com>
Kajongg is free software you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
from qt import QString
from kde import KConfigSkeleton
from log import logException
from common import Internal
class Parameter(object):
"""helper class for defining configuration parameters"""
def __init__(self, group, name, default=None):
"""configuration group, parameter name, default value"""
self.group = group
self.name = name
self.default = default
self.item = None
def itemValue(self):
"""returns the value of this item"""
return self.item.value()
class StringParameter(Parameter):
"""helper class for defining string parameters"""
def __init__(self, group, name, default=None):
if default is None:
default = ''
Parameter.__init__(self, group, name, default)
self.value = QString()
def add(self, skeleton):
"""add tis parameter to the skeleton"""
self.item = skeleton.addItemString(self.name, self.value, QString(self.default or ''))
def itemValue(self):
"""returns the value of this item"""
return str(self.item.value())
class BoolParameter(Parameter):
"""helper class for defining boolean parameters"""
def __init__(self, group, name, default=None):
if default is None:
default = False
Parameter.__init__(self, group, name, default)
self.value = default
def add(self, skeleton):
"""add tis parameter to the skeleton"""
self.item = skeleton.addItemBool(self.name, self.value, self.default)
class IntParameter(Parameter):
"""helper class for defining integer parameters"""
def __init__(self, group, name, default=None, minValue=None, maxValue=None):
"""minValue and maxValue are also used by the edit widget"""
if default is None:
default = 0
Parameter.__init__(self, group, name, default)
self.value = default
self.minValue = minValue
self.maxValue = maxValue
def add(self, skeleton):
"""add this parameter to the skeleton"""
self.item = skeleton.addItemInt(self.name, self.value, self.default)
if self.minValue is not None:
self.item.setMinValue(self.minValue)
if self.maxValue is not None:
self.item.setMaxValue(self.maxValue)
class SetupPreferences(KConfigSkeleton):
"""Holds all Kajongg options. Only instantiate this once"""
_Parameters = {}
def __init__(self): # pylint: disable=super-init-not-called
if Internal.Preferences:
logException('Preferences is not None')
Internal.Preferences = self
KConfigSkeleton.__init__(self)
self.addString('General', 'tilesetName', 'default')
self.addString('General', 'windTilesetName', 'traditional')
self.addString('General', 'backgroundName', 'wood_light')
self.addBool('Display', 'showShadows', True)
self.addBool('Display', 'rearrangeMelds', False)
self.addBool('Display', 'showOnlyPossibleActions', True)
self.addBool('Display', 'propose', True)
self.addInteger('Display', 'animationSpeed', 70, 0, 99)
self.addBool('Display', 'useSounds', True)
self.addBool('Display', 'uploadVoice', False)
def __getattr__(self, name):
"""undefined attributes might be parameters"""
if not name in SetupPreferences._Parameters:
return self.__getattribute__(name)
par = SetupPreferences._Parameters[name]
return par.itemValue()
def __setattr__(self, name, value):
"""undefined attributes might be parameters"""
if not name in SetupPreferences._Parameters:
KConfigSkeleton.__setattr__(self, name, value)
return
par = SetupPreferences._Parameters[name]
par.item.setValue(value)
def __getitem__(self, key):
return self.__getattr__(key)
def __setitem__(self, key, value):
self.__setattr__(key, value)
def __delitem__(self, key):
"""pylint wants this for a complete container, but we do not need it"""
del SetupPreferences._Parameters[key]
def __len__(self):
"""pylint wants this for a complete container, but we do not need it"""
return len(SetupPreferences._Parameters)
def addParameter(self, par):
"""add a parameter to the skeleton"""
if par.name not in SetupPreferences._Parameters:
SetupPreferences._Parameters[par.name] = par
self.setCurrentGroup(par.group)
par.add(self)
def addString(self, group, name, default=None):
"""add a string parameter to the skeleton"""
self.addParameter(StringParameter(group, name, default))
def addBool(self, group, name, default=None):
"""add a string parameter to the skeleton"""
self.addParameter(BoolParameter(group, name, default))
def addInteger(self, group, name, default=None, minValue=None, maxValue=None):
"""add a string parameter to the skeleton"""
self.addParameter(IntParameter(group, name, default, minValue, maxValue))
def animationDuration(self):
"""in milliseconds"""
return (99 - self.animationSpeed) * 100 // 4
|