class ConfigElement(object):
def __init__(self):
self.saved_value = None
+ self.save_forced = False
self.last_value = None
self.save_disabled = False
self.__notifiers = None
# you need to override this if str(self.value) doesn't work
def save(self):
- if self.save_disabled or self.value == self.default:
+ if self.save_disabled or (self.value == self.default and not self.save_forced):
self.saved_value = None
else:
self.saved_value = self.tostring(self.value)
float = property(getFloat)
+#### vuplus
+#Normal, LShift(42), RAlt(100), LShift+RAlt(100+42)/LArt(56)
+vukeymap_us_de = {
+ 2:[u"1", u"!", None, None]
+ , 3:[u"2", u"@", None, None]
+ , 4:[u"3", u"#", None, '\xc2\xa3']
+ , 5:[u"4", u"$", '\xc3\xa7', None]
+ , 6:[u"5", u"%", '\xc3\xbc', '\xe2\x82\xac']
+ , 7:[u"6", u"^", '\xc3\xb6', None]
+ , 8:[u"7", u"&", '\xc3\xa4', None]
+ , 9:[u"8", u"*", '\xc3\xa0', None]
+ ,10:[u"9", u"(", '\xc3\xa8', None]
+ ,11:[u"0", u")", '\xc3\xa9', None]
+ ,12:[u"-", u"_", None, None]
+ ,13:[u"=", u"+", "~", None]
+ ,16:[u"q", u"Q", None, None]
+ ,17:[u"w", u"W", None, None]
+ ,18:[u"e", u"E", '\xe2\x82\xac', None]
+ ,19:[u"r", u"R", None, None]
+ ,20:[u"t", u"T", None, None]
+ ,21:[u"y", u"Y", None, None]
+ ,22:[u"u", u"U", None, None]
+ ,23:[u"i", u"I", None, None]
+ ,24:[u"o", u"O", None, None]
+ ,25:[u"p", u"P", None, None]
+ ,26:[u"[", u"{", None, None]
+ ,27:[u"]", u"}", None, None]
+ ,30:[u"a", u"A", None, None]
+ ,31:[u"s", u"S", '\xc3\x9f', None]
+ ,32:[u"d", u"D", None, None]
+ ,33:[u"f", u"F", None, None]
+ ,34:[u"g", u"G", None, None]
+ ,35:[u"h", u"H", None, None]
+ ,36:[u"j", u"J", None, None]
+ ,37:[u"k", u"K", None, None]
+ ,38:[u"l", u"L", None, None]
+ ,39:[u";", u":", None, None]
+ ,40:[u"\'", u"\"", None, None]
+ ,41:['\xc2\xa7', '\xc2\xb0', '\xc2\xac', None]
+ ,43:[u"\\", u"|", None, None]
+ ,44:[u"z", u"Z", None, u"<"]
+ ,45:[u"x", u"X", None, u">"]
+ ,46:[u"c", u"C", '\xc2\xa2', None]
+ ,47:[u"v", u"V", None, None]
+ ,48:[u"b", u"B", None, None]
+ ,49:[u"n", u"N", None, None]
+ ,50:[u"m", u"M", '\xc2\xb5', None]
+ ,51:[u",", "<", None, None]
+ ,52:[u".", ">", None, None]
+ ,53:[u"/", u"?", None, None]
+ ,57:[u" ", None, None, None]
+}
+vumapidx = 0
+vukeymap = vukeymap_us_de
+rckeyboard_enable = False
+if file("/proc/stb/info/vumodel").read().strip() not in ["bm750", "solo", "uno"]:
+ rckeyboard_enable = True
+
+def getCharValue(code):
+ global vumapidx
+ global vukeymap
+ global rckeyboard_enable
+ print "got ascii code : %d [%d]"%(code, vumapidx)
+ if rckeyboard_enable:
+ if code == 0:
+ vumapidx = 0
+ return None
+ elif code == 42:
+ vumapidx += 1
+ return None
+ elif code == 56:
+ vumapidx += 3
+ return None
+ elif code == 100:
+ vumapidx += 2
+ return None
+ try:
+ return vukeymap[code][vumapidx]
+ except:
+ return None
+ else:
+ return unichr(getPrevAsciiCode())
+#### vuplus
+
# an editable text...
class ConfigText(ConfigElement, NumericalTextInput):
def __init__(self, default = "", fixed_size = True, visible_width = False):
self.overwrite = not self.overwrite
elif key == KEY_ASCII:
self.timeout()
- newChar = unichr(getPrevAsciiCode())
- if not self.useableChars or newChar in self.useableChars:
+ #### vuplus
+ #newChar = unichr(getPrevAsciiCode())
+ #if not self.useableChars or newChar in self.useableChars:
+ newChar = getCharValue(getPrevAsciiCode())
+ if (newChar is not None) and (not self.useableChars or newChar in self.useableChars):
+ #### vuplus
if self.allmarked:
self.deleteAllChars()
self.allmarked = False
if session is not None:
from Screens.NumericalTextInputHelpDialog import NumericalTextInputHelpDialog
self.help_window = session.instantiateDialog(NumericalTextInputHelpDialog, self)
+ self.help_window.setAnimationMode(0)
self.help_window.show()
def onDeselect(self, session):
step += stepwidth
ConfigSelection.__init__(self, choices, default)
-
+
def getValue(self):
- return int(self.text)
+ return int(ConfigSelection.getValue(self))
def setValue(self, val):
- self.text = str(val)
-
+ ConfigSelection.setValue(self, str(val))
+
def handleKey(self, key):
if not self.wraparound:
if key == KEY_RIGHT:
if self.choices.index(self.value) == 0:
return
ConfigSelection.handleKey(self, key)
-
-
class ConfigNumber(ConfigText):
def __init__(self, default = 0):
else:
return ConfigText.getMulti(self, selected)
+ def onSelect(self, session):
+ self.allmarked = (self.value != "")
+
# a slider.
class ConfigSlider(ConfigElement):
def __init__(self, default = 0, increment = 1, limits = (0, 100)):
self.pickle_this("config", self.saved_value, result)
return ''.join(result)
- def unpickle(self, lines):
+ def unpickle(self, lines, base_file=True):
tree = { }
for l in lines:
if not l or l[0] == '#':
continue
n = l.find('=')
+ name = l[:n]
val = l[n+1:].strip()
- names = l[:n].split('.')
+ names = name.split('.')
# if val.find(' ') != -1:
# val = val[:val.find(' ')]
base[names[-1]] = val
+ if not base_file: # not the initial config file..
+ #update config.x.y.value when exist
+ try:
+ configEntry = eval(name)
+ if configEntry is not None:
+ configEntry.value = val
+ except (SyntaxError, KeyError):
+ pass
+
# we inherit from ConfigSubsection, so ...
#object.__setattr__(self, "saved_value", tree["config"])
if "config" in tree:
def saveToFile(self, filename):
text = self.pickle()
- f = open(filename, "w")
- f.write(text)
- f.close()
+ try:
+ f = open(filename, "w")
+ f.write(text)
+ f.close()
+ except IOError:
+ print "Config: Couldn't write %s" % filename
- def loadFromFile(self, filename):
+ def loadFromFile(self, filename, base_file=False):
f = open(filename, "r")
- self.unpickle(f.readlines())
+ self.unpickle(f.readlines(), base_file)
f.close()
config = Config()
def load(self):
try:
- config.loadFromFile(self.CONFIG_FILE)
+ config.loadFromFile(self.CONFIG_FILE, True)
except IOError, e:
print "unable to load config (%s), assuming defaults..." % str(e)