Mercurial > hg > Feedworm
annotate PreferencesDialog.py @ 231:16fa9f090c36
hard-code python2
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Thu, 25 Sep 2014 08:06:51 +0200 |
parents | f0b5bdce1189 |
children | e34c53a3e407 |
rev | line source |
---|---|
217
bb3c851b18b1
add source file endcoding header
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
194
diff
changeset
|
1 # -*- coding: utf-8 -*- |
218
699d8f1cebd4
unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
217
diff
changeset
|
2 from PyQt4.QtGui import QDialog |
40 | 3 from Ui_Preferences import Ui_Preferences |
4 | |
218
699d8f1cebd4
unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
217
diff
changeset
|
5 class PreferencesDialog(QDialog): |
120
e830fa1cc7a2
re-enabled PreferencesDialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
111
diff
changeset
|
6 def __init__(self, backend=None): |
218
699d8f1cebd4
unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
217
diff
changeset
|
7 super(PreferencesDialog, self).__init__(None) |
120
e830fa1cc7a2
re-enabled PreferencesDialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
111
diff
changeset
|
8 self.backend = backend |
e830fa1cc7a2
re-enabled PreferencesDialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
111
diff
changeset
|
9 self.preferences = backend.preferences() |
40 | 10 self.ui = Ui_Preferences() |
11 self.ui.setupUi(self) | |
42
0c0d1760b737
Rename Preferences to PreferencesDialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
41
diff
changeset
|
12 self.fillUi() |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
13 |
42
0c0d1760b737
Rename Preferences to PreferencesDialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
41
diff
changeset
|
14 def fillUi(self): |
111
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
15 self.fillMaximized() |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
16 self.fillHideReadFeedEntries() |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
17 self.fillShowOnlyUnreadFeeds() |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
18 self.fillProxySettings() |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
19 self.fillDaysToKeepFeedEntries() |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
20 |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
21 def fillMaximized(self): |
43
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
42
diff
changeset
|
22 maximized = self.preferences.startMaximized() |
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
42
diff
changeset
|
23 self.ui.startMaximized.setChecked(maximized) |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
24 |
111
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
25 def fillHideReadFeedEntries(self): |
61
db35ab7753f0
add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
46
diff
changeset
|
26 hideRead = self.preferences.hideReadFeedEntries() |
db35ab7753f0
add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
46
diff
changeset
|
27 self.ui.hideReadFeedEntries.setChecked(hideRead) |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
28 |
111
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
29 def fillShowOnlyUnreadFeeds(self): |
72
e8c2730eb444
control the display of unread feeds/all feeds via Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
61
diff
changeset
|
30 showOnlyUnreadFeeds = self.preferences.showOnlyUnreadFeeds() |
e8c2730eb444
control the display of unread feeds/all feeds via Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
61
diff
changeset
|
31 self.ui.showOnlyUnreadFeeds.setChecked(showOnlyUnreadFeeds) |
40 | 32 |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
33 def fillProxySettings(self): |
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
34 if self.preferences.isProxyConfigured(): |
194
2c91b5653878
enable/disable using the proxy via a preference setting
dirk
parents:
158
diff
changeset
|
35 self.ui.useProxy.setChecked(self.preferences.useProxy()) |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
36 self.ui.proxyHost.setText(self.preferences.proxyHost()) |
158
e8bb107a74e1
all preferences are stored in a single JSON document in the couchdb backend. PreferencesDialog converts QString to a proper Python datatybe before sending it to the backend.
dirk
parents:
120
diff
changeset
|
37 port = self.preferences.proxyPort() |
e8bb107a74e1
all preferences are stored in a single JSON document in the couchdb backend. PreferencesDialog converts QString to a proper Python datatybe before sending it to the backend.
dirk
parents:
120
diff
changeset
|
38 if port is not None: |
e8bb107a74e1
all preferences are stored in a single JSON document in the couchdb backend. PreferencesDialog converts QString to a proper Python datatybe before sending it to the backend.
dirk
parents:
120
diff
changeset
|
39 self.ui.proxyPort.setText(str(port)) |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
40 |
111
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
41 def fillDaysToKeepFeedEntries(self): |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
42 days = self.preferences.daysToKeepFeedEntries() |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
43 self.ui.daysToKeepFeedEntries.setText(str(days)) |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
44 |
40 | 45 def startMaximizedChanged(self, change): |
46
03358c113170
Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
44
diff
changeset
|
46 if change: |
03358c113170
Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
44
diff
changeset
|
47 self.preferences.setStartMaximized(True) |
03358c113170
Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
44
diff
changeset
|
48 else: |
03358c113170
Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
44
diff
changeset
|
49 self.preferences.setStartMaximized(False) |
41
9fa1e33b67da
use Qt resources for window icons
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
40
diff
changeset
|
50 |
61
db35ab7753f0
add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
46
diff
changeset
|
51 def hideReadFeedEntriesChanged(self, change): |
db35ab7753f0
add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
46
diff
changeset
|
52 if change: |
db35ab7753f0
add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
46
diff
changeset
|
53 self.preferences.setHideReadFeedEntries(True) |
db35ab7753f0
add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
46
diff
changeset
|
54 else: |
db35ab7753f0
add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
46
diff
changeset
|
55 self.preferences.setHideReadFeedEntries(False) |
db35ab7753f0
add a preference to hide read feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
46
diff
changeset
|
56 |
72
e8c2730eb444
control the display of unread feeds/all feeds via Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
61
diff
changeset
|
57 def showOnlyFeedsWithUnreadEntries(self, change): |
e8c2730eb444
control the display of unread feeds/all feeds via Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
61
diff
changeset
|
58 if change: |
e8c2730eb444
control the display of unread feeds/all feeds via Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
61
diff
changeset
|
59 self.preferences.setShowOnlyUnreadFeeds(True) |
e8c2730eb444
control the display of unread feeds/all feeds via Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
61
diff
changeset
|
60 else: |
e8c2730eb444
control the display of unread feeds/all feeds via Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
61
diff
changeset
|
61 self.preferences.setShowOnlyUnreadFeeds(False) |
e8c2730eb444
control the display of unread feeds/all feeds via Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
61
diff
changeset
|
62 |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
63 def storeProxySettings(self): |
111
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
64 proxyHost = self.ui.proxyHost.text() |
194
2c91b5653878
enable/disable using the proxy via a preference setting
dirk
parents:
158
diff
changeset
|
65 self.preferences.setUseProxy(self.ui.useProxy.isChecked()) |
229
f0b5bdce1189
fix the preferences dialog after update to the new style api
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
218
diff
changeset
|
66 if len(proxyHost) == 0: |
158
e8bb107a74e1
all preferences are stored in a single JSON document in the couchdb backend. PreferencesDialog converts QString to a proper Python datatybe before sending it to the backend.
dirk
parents:
120
diff
changeset
|
67 self.preferences.setProxyHost(None) |
e8bb107a74e1
all preferences are stored in a single JSON document in the couchdb backend. PreferencesDialog converts QString to a proper Python datatybe before sending it to the backend.
dirk
parents:
120
diff
changeset
|
68 else: |
229
f0b5bdce1189
fix the preferences dialog after update to the new style api
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
218
diff
changeset
|
69 self.preferences.setProxyHost(proxyHost) |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
70 |
111
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
71 proxyPort = self.ui.proxyPort.text() |
229
f0b5bdce1189
fix the preferences dialog after update to the new style api
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
218
diff
changeset
|
72 if len(proxyPort) == 0: |
158
e8bb107a74e1
all preferences are stored in a single JSON document in the couchdb backend. PreferencesDialog converts QString to a proper Python datatybe before sending it to the backend.
dirk
parents:
120
diff
changeset
|
73 self.preferences.setProxyPort(None) |
e8bb107a74e1
all preferences are stored in a single JSON document in the couchdb backend. PreferencesDialog converts QString to a proper Python datatybe before sending it to the backend.
dirk
parents:
120
diff
changeset
|
74 else: |
e8bb107a74e1
all preferences are stored in a single JSON document in the couchdb backend. PreferencesDialog converts QString to a proper Python datatybe before sending it to the backend.
dirk
parents:
120
diff
changeset
|
75 self.preferences.setProxyPort(int(proxyPort)) |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
76 |
111
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
77 def daysToKeepFeedEntriesFinishedEditing(self): |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
78 text = self.ui.daysToKeepFeedEntries.text() |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
79 if not text.isEmpty(): |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
80 text = str(text) |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
81 self.preferences.setDaysToKeepFeedEntries(text) |
c17a224bc251
make the keep interval for feeds configurable via the GUI. Fix saving the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
88
diff
changeset
|
82 |
41
9fa1e33b67da
use Qt resources for window icons
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
40
diff
changeset
|
83 def accept(self): |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
84 self.storeProxySettings() |
120
e830fa1cc7a2
re-enabled PreferencesDialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
111
diff
changeset
|
85 self.preferences.commit(); |
218
699d8f1cebd4
unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
217
diff
changeset
|
86 super(PreferencesDialog, self).accept() |
88
48d1d7bba548
UI for setting the proxy settings
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
72
diff
changeset
|
87 |
41
9fa1e33b67da
use Qt resources for window icons
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
40
diff
changeset
|
88 def reject(self): |
120
e830fa1cc7a2
re-enabled PreferencesDialog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
111
diff
changeset
|
89 self.preferences.rollback() |
218
699d8f1cebd4
unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
217
diff
changeset
|
90 super(PreferencesDialog, self).reject() |