Mercurial > hg > Feedworm
changeset 43:12ed8b5fa08c
first system preference: configure app to stat maximized.
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Fri, 14 May 2010 08:31:46 +0200 |
parents | 0c0d1760b737 |
children | be990ac6e478 |
files | Mapping.py Preference.py Preferences.py PreferencesDialog.py feedworm-gui.py util.py |
diffstat | 6 files changed, 55 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Mapping.py Fri May 14 08:08:17 2010 +0200 +++ b/Mapping.py Fri May 14 08:31:46 2010 +0200 @@ -1,6 +1,7 @@ from Feed import Feed from FeedEntry import FeedEntry +from Preference import Preference from sqlalchemy import Column from sqlalchemy import DateTime from sqlalchemy import ForeignKey @@ -45,6 +46,12 @@ Column("updated", DateTime), Column("feed_id", Integer, ForeignKey("feed.pk")) ) + + preferencesTable = Table("preference", metadata, + Column("pk", Integer, primary_key=True), + Column("key", String(255), nullable=False), + Column("value", String(255), nullable=False) + ) metadata.create_all() @@ -54,3 +61,4 @@ "entries" : relation(FeedEntry, backref="feed") } ) + mapper(Preference, preferencesTable)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Preference.py Fri May 14 08:31:46 2010 +0200 @@ -0,0 +1,16 @@ + +class Preference(object): + @staticmethod + def valueForKey(key, session): + pref = session.query(Preference).filter(Preference.key == key).first() + if pref is not None: + return pref.value + else: + return None + + def __init__(self, key, value): + self.key = key + self.value = value + + def __repr__(self): + return "<Preference %s = %s>" % (self.key, self.value)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Preferences.py Fri May 14 08:31:46 2010 +0200 @@ -0,0 +1,16 @@ + +from Preference import Preference +import util + +START_MAXIMIZED = "START_MAXIMIZED" + +class Preferences(object): + def __init__(self, session): + self.session = session + + def startMaximized(self): + value = Preference.valueForKey(START_MAXIMIZED, self.session) + if value is not None: + return util.str2bool(value) + else: + return False
--- a/PreferencesDialog.py Fri May 14 08:08:17 2010 +0200 +++ b/PreferencesDialog.py Fri May 14 08:31:46 2010 +0200 @@ -1,4 +1,5 @@ +from Preferences import Preferences from PyQt4 import QtGui from Ui_Preferences import Ui_Preferences @@ -6,13 +7,14 @@ def __init__(self, session=None): QtGui.QWidget.__init__(self, None) self.session = session + self.preferences = Preferences(session) self.ui = Ui_Preferences() self.ui.setupUi(self) self.fillUi() def fillUi(self): - #self.ui.startMaximized.setChecked() - pass + maximized = self.preferences.startMaximized() + self.ui.startMaximized.setChecked(maximized) def startMaximizedChanged(self, change): print("start maximized: " + str(change))
--- a/feedworm-gui.py Fri May 14 08:08:17 2010 +0200 +++ b/feedworm-gui.py Fri May 14 08:31:46 2010 +0200 @@ -1,6 +1,7 @@ import Database from MainWindow import MainWindow +from Preferences import Preferences from PyQt4 import QtGui import sys import util @@ -11,5 +12,11 @@ app = QtGui.QApplication(sys.argv) mainWindow = MainWindow(session) - mainWindow.showMaximized() + + maximized = Preferences(session).startMaximized() + if maximized: + mainWindow.showMaximized() + else: + mainWindow.show() + sys.exit(app.exec_())