# HG changeset patch # User Dirk Olmes # Date 1273989264 -7200 # Node ID 03358c1131703e9bb0ac13b2b83a0770df822f6f # Parent 0604e374c1d6a9d183a2735d63ed4d13a10d0751 Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value diff -r 0604e374c1d6 -r 03358c113170 Preferences.py --- a/Preferences.py Fri May 14 15:24:51 2010 +0200 +++ b/Preferences.py Sun May 16 07:54:24 2010 +0200 @@ -15,7 +15,7 @@ else: pref = Preference.forKey(key, self.session) if pref is None: - pref = Preference(key, defaultValue) + pref = Preference(key, str(defaultValue)) self.session.add(pref) self.cache[key] = pref return pref @@ -25,9 +25,5 @@ return util.str2bool(pref.value) def setStartMaximized(self, flag): - """ Convert flag to boolean so that a defined value is stored in the DB """ - boolValue = False - if flag: - boolValue = True pref = self._cachedPreference(START_MAXIMIZED) - pref.value = boolValue + pref.value = util.bool2str(flag) diff -r 0604e374c1d6 -r 03358c113170 PreferencesDialog.py --- a/PreferencesDialog.py Fri May 14 15:24:51 2010 +0200 +++ b/PreferencesDialog.py Sun May 16 07:54:24 2010 +0200 @@ -17,7 +17,10 @@ self.ui.startMaximized.setChecked(maximized) def startMaximizedChanged(self, change): - self.preferences.setStartMaximized(change) + if change: + self.preferences.setStartMaximized(True) + else: + self.preferences.setStartMaximized(False) def accept(self): self.session.commit() diff -r 0604e374c1d6 -r 03358c113170 util.py --- a/util.py Fri May 14 15:24:51 2010 +0200 +++ b/util.py Sun May 16 07:54:24 2010 +0200 @@ -28,3 +28,9 @@ def str2bool(string): return string.lower() in ["yes", "true", "t", "1"] + +def bool2str(bool): + if bool: + return "True" + else: + return "False"