# HG changeset patch # User Dirk Olmes # Date 1301534139 -7200 # Node ID c17a224bc251773f8991aaa4e3b069e7d844da5f # Parent 43c234c8fe87c5382cebcc7cc62b583e1bec3af1 make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings diff -r 43c234c8fe87 -r c17a224bc251 Preferences.py --- a/Preferences.py Wed Mar 30 02:59:22 2011 +0200 +++ b/Preferences.py Thu Mar 31 03:15:39 2011 +0200 @@ -19,7 +19,9 @@ return self.cache[key] else: pref = Preference.forKey(key, self.session) - if pref is None and addIfMissing: + if pref is not None: + self.cache[key] = pref + elif pref is None and addIfMissing: pref = Preference(key, str(defaultValue)) self.session.add(pref) self.cache[key] = pref @@ -54,16 +56,28 @@ return pref.value def setProxyHost(self, hostname): - pref = self._cachedPreference(PROXY_HOST) - pref.value = hostname + if hostname is None: + pref = self._cachedPreference(PROXY_HOST, addIfMissing=False) + if pref is not None: + self.session.delete(pref) + del(self.cache[PROXY_HOST]) + else: + pref = self._cachedPreference(PROXY_HOST) + pref.value = str(hostname) def proxyPort(self): pref = self._cachedPreference(PROXY_PORT, 3128) return int(pref.value) def setProxyPort(self, port): - pref = self._cachedPreference(PROXY_PORT) - pref.value = str(port) + if port is None: + pref = self._cachedPreference(PROXY_PORT, addIfMissing=False) + if pref is not None: + self.session.delete(pref) + del(self.cache[PROXY_PORT]) + else: + pref = self._cachedPreference(PROXY_PORT) + pref.value = str(port) def isProxyConfigured(self): pref = self._cachedPreference(PROXY_HOST, addIfMissing=False) @@ -72,3 +86,7 @@ def daysToKeepFeedEntries(self): pref = self._cachedPreference(DAYS_TO_KEEP_FEED_ENTRIES, 90, addIfMissing=True) return int(pref.value) + + def setDaysToKeepFeedEntries(self, dayString): + pref = self._cachedPreference(DAYS_TO_KEEP_FEED_ENTRIES) + pref.value = dayString diff -r 43c234c8fe87 -r c17a224bc251 PreferencesDialog.py --- a/PreferencesDialog.py Wed Mar 30 02:59:22 2011 +0200 +++ b/PreferencesDialog.py Thu Mar 31 03:15:39 2011 +0200 @@ -13,22 +13,33 @@ self.fillUi() def fillUi(self): + self.fillMaximized() + self.fillHideReadFeedEntries() + self.fillShowOnlyUnreadFeeds() + self.fillProxySettings() + self.fillDaysToKeepFeedEntries() + + def fillMaximized(self): maximized = self.preferences.startMaximized() self.ui.startMaximized.setChecked(maximized) + def fillHideReadFeedEntries(self): hideRead = self.preferences.hideReadFeedEntries() self.ui.hideReadFeedEntries.setChecked(hideRead) + def fillShowOnlyUnreadFeeds(self): 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 fillDaysToKeepFeedEntries(self): + days = self.preferences.daysToKeepFeedEntries() + self.ui.daysToKeepFeedEntries.setText(str(days)) + def startMaximizedChanged(self, change): if change: self.preferences.setStartMaximized(True) @@ -48,12 +59,22 @@ self.preferences.setShowOnlyUnreadFeeds(False) def storeProxySettings(self): - proxyHost = str(self.ui.proxyHost.text()) + proxyHost = self.ui.proxyHost.text() + if proxyHost.isEmpty(): + proxyHost = None self.preferences.setProxyHost(proxyHost) - proxyPort = int(self.ui.proxyPort.text()) + proxyPort = self.ui.proxyPort.text() + if proxyPort.isEmpty(): + proxyPort = None self.preferences.setProxyPort(proxyPort) + def daysToKeepFeedEntriesFinishedEditing(self): + text = self.ui.daysToKeepFeedEntries.text() + if not text.isEmpty(): + text = str(text) + self.preferences.setDaysToKeepFeedEntries(text) + def accept(self): self.storeProxySettings() self.session.commit() diff -r 43c234c8fe87 -r c17a224bc251 Ui_Preferences.ui --- a/Ui_Preferences.ui Wed Mar 30 02:59:22 2011 +0200 +++ b/Ui_Preferences.ui Thu Mar 31 03:15:39 2011 +0200 @@ -7,7 +7,7 @@ 0 0 390 - 247 + 277 @@ -21,7 +21,7 @@ 10 - 210 + 240 160 27 @@ -84,7 +84,7 @@ Web Proxy - + 6 @@ -117,6 +117,45 @@ + + + + 11 + 205 + 136 + 17 + + + + Keep feed entries for + + + + + + 150 + 200 + 31 + 23 + + + + + + + + + + 190 + 205 + 31 + 17 + + + + days + + @@ -202,10 +241,27 @@ + + daysToKeepFeedEntries + editingFinished() + Preferences + daysToKeepFeedEntriesFinishedEditing() + + + 165 + 211 + + + 194 + 138 + + + startMaximizedChanged() hideReadFeedEntriesChanged() showOnlyFeedsWithUnreadEntries() + daysToKeepFeedEntriesFinishedEditing()