Mercurial > hg > Feedworm
changeset 194:2c91b5653878
enable/disable using the proxy via a preference setting
author | dirk |
---|---|
date | Fri, 07 Oct 2011 07:00:44 +0200 |
parents | c345a26febc2 |
children | 66d1efcb8e8a |
files | PreferencesDialog.py Ui_Preferences.ui backend/couchdb/Preferences.py feedworm.py |
diffstat | 4 files changed, 31 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/PreferencesDialog.py Sat Sep 24 08:07:23 2011 +0200 +++ b/PreferencesDialog.py Fri Oct 07 07:00:44 2011 +0200 @@ -32,6 +32,7 @@ def fillProxySettings(self): if self.preferences.isProxyConfigured(): + self.ui.useProxy.setChecked(self.preferences.useProxy()) self.ui.proxyHost.setText(self.preferences.proxyHost()) port = self.preferences.proxyPort() if port is not None: @@ -61,6 +62,7 @@ def storeProxySettings(self): proxyHost = self.ui.proxyHost.text() + self.preferences.setUseProxy(self.ui.useProxy.isChecked()) if proxyHost.isEmpty(): self.preferences.setProxyHost(None) else:
--- a/Ui_Preferences.ui Sat Sep 24 08:07:23 2011 +0200 +++ b/Ui_Preferences.ui Fri Oct 07 07:00:44 2011 +0200 @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>390</width> - <height>277</height> + <width>373</width> + <height>288</height> </rect> </property> <property name="windowTitle"> @@ -21,7 +21,7 @@ <property name="geometry"> <rect> <x>10</x> - <y>240</y> + <y>250</y> <width>160</width> <height>27</height> </rect> @@ -78,7 +78,7 @@ <x>10</x> <y>100</y> <width>353</width> - <height>96</height> + <height>106</height> </rect> </property> <property name="title"> @@ -88,32 +88,39 @@ <property name="geometry"> <rect> <x>6</x> - <y>18</y> + <y>20</y> <width>336</width> - <height>71</height> + <height>78</height> </rect> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="1" column="0"> + <item row="2" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> <string>Port</string> </property> </widget> </item> - <item row="0" column="1"> + <item row="1" column="1"> <widget class="QLineEdit" name="proxyHost"/> </item> - <item row="1" column="1"> + <item row="2" column="1"> <widget class="QLineEdit" name="proxyPort"/> </item> - <item row="0" column="0"> + <item row="1" column="0"> <widget class="QLabel" name="label"> <property name="text"> <string>Host</string> </property> </widget> </item> + <item row="0" column="1"> + <widget class="QCheckBox" name="useProxy"> + <property name="text"> + <string>Use proxy</string> + </property> + </widget> + </item> </layout> </widget> </widget> @@ -121,7 +128,7 @@ <property name="geometry"> <rect> <x>11</x> - <y>205</y> + <y>215</y> <width>136</width> <height>17</height> </rect> @@ -134,7 +141,7 @@ <property name="geometry"> <rect> <x>150</x> - <y>200</y> + <y>210</y> <width>31</width> <height>23</height> </rect> @@ -147,7 +154,7 @@ <property name="geometry"> <rect> <x>190</x> - <y>205</y> + <y>215</y> <width>31</width> <height>17</height> </rect>
--- a/backend/couchdb/Preferences.py Sat Sep 24 08:07:23 2011 +0200 +++ b/backend/couchdb/Preferences.py Fri Oct 07 07:00:44 2011 +0200 @@ -7,6 +7,7 @@ PROXY_PORT = "proxyPort" SHOW_ONLY_UNREAD_FEEDS = "showOnlyUnreadFeeds" START_MAXIMIZED = "startMaximized" +USE_PROXY = "useProxy" class Preferences(object): def __init__(self, database): @@ -40,6 +41,12 @@ def proxyHost(self): return self._documentValue(PROXY_HOST) + def useProxy(self): + return self._documentValue(USE_PROXY, True) + + def setUseProxy(self, value): + self._setDocumentValue(USE_PROXY, value) + def setProxyHost(self, hostname): if hostname is None: if PROXY_HOST in self.document.keys():
--- a/feedworm.py Sat Sep 24 08:07:23 2011 +0200 +++ b/feedworm.py Fri Oct 07 07:00:44 2011 +0200 @@ -7,12 +7,12 @@ import sys def setupProxy(preferences): - if preferences.isProxyConfigured(): + if preferences.isProxyConfigured() and preferences.useProxy(): proxyHost = preferences.proxyHost() proxyPort = preferences.proxyPort() proxy = QNetworkProxy(QNetworkProxy.HttpProxy, proxyHost, proxyPort) QNetworkProxy.setApplicationProxy(proxy) - + if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) backend = BackendFactory.createBackend()