view PreferencesDialog.py @ 95:9bceb1bd3f33

do not display a vertical header in the feed entries table
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 28 Dec 2010 03:38:38 +0100
parents 48d1d7bba548
children c17a224bc251
line wrap: on
line source


from Preferences import Preferences
from PyQt4 import QtGui
from Ui_Preferences import Ui_Preferences

class PreferencesDialog(QtGui.QDialog):
    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):
        maximized = self.preferences.startMaximized()
        self.ui.startMaximized.setChecked(maximized)

        hideRead = self.preferences.hideReadFeedEntries()
        self.ui.hideReadFeedEntries.setChecked(hideRead)

        showOnlyUnreadFeeds = self.preferences.showOnlyUnreadFeeds()
        self.ui.showOnlyUnreadFeeds.setChecked(showOnlyUnreadFeeds)

        self.fillProxySettings()

    def fillProxySettings(self):
        if self.preferences.isProxyConfigured():
            self.ui.proxyHost.setText(self.preferences.proxyHost())
            self.ui.proxyPort.setText(str(self.preferences.proxyPort()))

    def startMaximizedChanged(self, change):
        if change:
            self.preferences.setStartMaximized(True)
        else:
            self.preferences.setStartMaximized(False)

    def hideReadFeedEntriesChanged(self, change):
        if change:
            self.preferences.setHideReadFeedEntries(True)
        else:
            self.preferences.setHideReadFeedEntries(False)

    def showOnlyFeedsWithUnreadEntries(self, change):
        if change:
            self.preferences.setShowOnlyUnreadFeeds(True)
        else:
            self.preferences.setShowOnlyUnreadFeeds(False)

    def storeProxySettings(self):
        proxyHost = str(self.ui.proxyHost.text())
        self.preferences.setProxyHost(proxyHost)

        proxyPort = int(self.ui.proxyPort.text())
        self.preferences.setProxyPort(proxyPort)

    def accept(self):
        self.storeProxySettings()
        self.session.commit()
        QtGui.QDialog.accept(self)

    def reject(self):
        self.session.rollback()
        QtGui.QDialog.reject(self)