src/eric7/Preferences/ConfigurationPages/NetworkPage.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
21 21
22 class NetworkPage(ConfigurationPageBase, Ui_NetworkPage): 22 class NetworkPage(ConfigurationPageBase, Ui_NetworkPage):
23 """ 23 """
24 Class implementing the Network configuration page. 24 Class implementing the Network configuration page.
25 """ 25 """
26
26 def __init__(self, configDialog): 27 def __init__(self, configDialog):
27 """ 28 """
28 Constructor 29 Constructor
29 30
30 @param configDialog reference to the configuration dialog 31 @param configDialog reference to the configuration dialog
31 (ConfigurationDialog) 32 (ConfigurationDialog)
32 """ 33 """
33 super().__init__() 34 super().__init__()
34 self.setupUi(self) 35 self.setupUi(self)
35 self.setObjectName("NetworkPage") 36 self.setObjectName("NetworkPage")
36 37
37 self.__configDlg = configDialog 38 self.__configDlg = configDialog
38 self.__displayMode = None 39 self.__displayMode = None
39 self.__webEngine = False 40 self.__webEngine = False
40 41
41 self.downloadDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) 42 self.downloadDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
42 43
43 self.ftpProxyTypeCombo.addItem( 44 self.ftpProxyTypeCombo.addItem(
44 self.tr("No FTP Proxy"), 45 self.tr("No FTP Proxy"), EricFtpProxyType.NO_PROXY.value
45 EricFtpProxyType.NO_PROXY.value) 46 )
46 self.ftpProxyTypeCombo.addItem( 47 self.ftpProxyTypeCombo.addItem(
47 self.tr("No Proxy Authentication required"), 48 self.tr("No Proxy Authentication required"),
48 EricFtpProxyType.NON_AUTHORIZING.value) 49 EricFtpProxyType.NON_AUTHORIZING.value,
49 self.ftpProxyTypeCombo.addItem( 50 )
50 self.tr("User@Server"), 51 self.ftpProxyTypeCombo.addItem(
51 EricFtpProxyType.USER_SERVER.value) 52 self.tr("User@Server"), EricFtpProxyType.USER_SERVER.value
52 self.ftpProxyTypeCombo.addItem( 53 )
53 self.tr("SITE"), 54 self.ftpProxyTypeCombo.addItem(self.tr("SITE"), EricFtpProxyType.SITE.value)
54 EricFtpProxyType.SITE.value) 55 self.ftpProxyTypeCombo.addItem(self.tr("OPEN"), EricFtpProxyType.OPEN.value)
55 self.ftpProxyTypeCombo.addItem(
56 self.tr("OPEN"),
57 EricFtpProxyType.OPEN.value)
58 self.ftpProxyTypeCombo.addItem( 56 self.ftpProxyTypeCombo.addItem(
59 self.tr("User@Proxyuser@Server"), 57 self.tr("User@Proxyuser@Server"),
60 EricFtpProxyType.USER_PROXYUSER_SERVER.value) 58 EricFtpProxyType.USER_PROXYUSER_SERVER.value,
61 self.ftpProxyTypeCombo.addItem( 59 )
62 self.tr("Proxyuser@Server"), 60 self.ftpProxyTypeCombo.addItem(
63 EricFtpProxyType.PROXYUSER_SERVER.value) 61 self.tr("Proxyuser@Server"), EricFtpProxyType.PROXYUSER_SERVER.value
64 self.ftpProxyTypeCombo.addItem( 62 )
65 self.tr("AUTH and RESP"), 63 self.ftpProxyTypeCombo.addItem(
66 EricFtpProxyType.AUTH_RESP.value) 64 self.tr("AUTH and RESP"), EricFtpProxyType.AUTH_RESP.value
67 self.ftpProxyTypeCombo.addItem( 65 )
68 self.tr("Bluecoat Proxy"), 66 self.ftpProxyTypeCombo.addItem(
69 EricFtpProxyType.BLUECOAT.value) 67 self.tr("Bluecoat Proxy"), EricFtpProxyType.BLUECOAT.value
70 68 )
69
71 # set initial values 70 # set initial values
72 self.dynamicOnlineCheckBox.setChecked( 71 self.dynamicOnlineCheckBox.setChecked(Preferences.getUI("DynamicOnlineCheck"))
73 Preferences.getUI("DynamicOnlineCheck")) 72
74
75 self.downloadDirPicker.setText(Preferences.getUI("DownloadPath")) 73 self.downloadDirPicker.setText(Preferences.getUI("DownloadPath"))
76 self.requestFilenameCheckBox.setChecked( 74 self.requestFilenameCheckBox.setChecked(
77 Preferences.getUI("RequestDownloadFilename")) 75 Preferences.getUI("RequestDownloadFilename")
78 76 )
77
79 # HTTP proxy 78 # HTTP proxy
80 self.httpProxyHostEdit.setText( 79 self.httpProxyHostEdit.setText(Preferences.getUI("ProxyHost/Http"))
81 Preferences.getUI("ProxyHost/Http")) 80 self.httpProxyPortSpin.setValue(Preferences.getUI("ProxyPort/Http"))
82 self.httpProxyPortSpin.setValue( 81
83 Preferences.getUI("ProxyPort/Http"))
84
85 # HTTPS proxy 82 # HTTPS proxy
86 self.httpsProxyHostEdit.setText( 83 self.httpsProxyHostEdit.setText(Preferences.getUI("ProxyHost/Https"))
87 Preferences.getUI("ProxyHost/Https")) 84 self.httpsProxyPortSpin.setValue(Preferences.getUI("ProxyPort/Https"))
88 self.httpsProxyPortSpin.setValue( 85
89 Preferences.getUI("ProxyPort/Https"))
90
91 # FTP proxy 86 # FTP proxy
92 self.ftpProxyHostEdit.setText( 87 self.ftpProxyHostEdit.setText(Preferences.getUI("ProxyHost/Ftp"))
93 Preferences.getUI("ProxyHost/Ftp")) 88 self.ftpProxyPortSpin.setValue(Preferences.getUI("ProxyPort/Ftp"))
94 self.ftpProxyPortSpin.setValue(
95 Preferences.getUI("ProxyPort/Ftp"))
96 self.ftpProxyTypeCombo.setCurrentIndex( 89 self.ftpProxyTypeCombo.setCurrentIndex(
97 self.ftpProxyTypeCombo.findData( 90 self.ftpProxyTypeCombo.findData(Preferences.getUI("ProxyType/Ftp").value)
98 Preferences.getUI("ProxyType/Ftp").value)) 91 )
99 self.ftpProxyUserEdit.setText( 92 self.ftpProxyUserEdit.setText(Preferences.getUI("ProxyUser/Ftp"))
100 Preferences.getUI("ProxyUser/Ftp")) 93 self.ftpProxyPasswordEdit.setText(Preferences.getUI("ProxyPassword/Ftp"))
101 self.ftpProxyPasswordEdit.setText( 94 self.ftpProxyAccountEdit.setText(Preferences.getUI("ProxyAccount/Ftp"))
102 Preferences.getUI("ProxyPassword/Ftp")) 95
103 self.ftpProxyAccountEdit.setText( 96 self.httpProxyForAllCheckBox.setChecked(Preferences.getUI("UseHttpProxyForAll"))
104 Preferences.getUI("ProxyAccount/Ftp"))
105
106 self.httpProxyForAllCheckBox.setChecked(
107 Preferences.getUI("UseHttpProxyForAll"))
108 if not Preferences.getUI("UseProxy"): 97 if not Preferences.getUI("UseProxy"):
109 self.noProxyButton.setChecked(True) 98 self.noProxyButton.setChecked(True)
110 elif Preferences.getUI("UseSystemProxy"): 99 elif Preferences.getUI("UseSystemProxy"):
111 self.systemProxyButton.setChecked(True) 100 self.systemProxyButton.setChecked(True)
112 else: 101 else:
113 self.manualProxyButton.setChecked(True) 102 self.manualProxyButton.setChecked(True)
114 103
115 self.exceptionsEdit.setText( 104 self.exceptionsEdit.setText(
116 ", ".join(Preferences.getUI("ProxyExceptions").split(","))) 105 ", ".join(Preferences.getUI("ProxyExceptions").split(","))
117 106 )
107
118 def setMode(self, displayMode): 108 def setMode(self, displayMode):
119 """ 109 """
120 Public method to perform mode dependent setups. 110 Public method to perform mode dependent setups.
121 111
122 @param displayMode mode of the configuration dialog 112 @param displayMode mode of the configuration dialog
123 (ConfigurationMode.DEFAULTMODE, 113 (ConfigurationMode.DEFAULTMODE,
124 ConfigurationMode.WEBBROWSERMODE) 114 ConfigurationMode.WEBBROWSERMODE)
125 """ 115 """
126 from ..ConfigurationDialog import ConfigurationMode 116 from ..ConfigurationDialog import ConfigurationMode
117
127 if displayMode in ( 118 if displayMode in (
128 ConfigurationMode.DEFAULTMODE, 119 ConfigurationMode.DEFAULTMODE,
129 ConfigurationMode.WEBBROWSERMODE 120 ConfigurationMode.WEBBROWSERMODE,
130 ): 121 ):
131 self.__displayMode = displayMode 122 self.__displayMode = displayMode
132 if not self.__configDlg.isUsingWebEngine(): 123 if not self.__configDlg.isUsingWebEngine():
133 self.cleanupGroup.hide() 124 self.cleanupGroup.hide()
134 self.displayGroup.hide() 125 self.displayGroup.hide()
135 else: 126 else:
136 policy = Preferences.getWebBrowser( 127 policy = Preferences.getWebBrowser("DownloadManagerRemovePolicy")
137 "DownloadManagerRemovePolicy")
138 from WebBrowser.Download.DownloadManager import DownloadManager 128 from WebBrowser.Download.DownloadManager import DownloadManager
129
139 if policy == DownloadManager.RemoveNever: 130 if policy == DownloadManager.RemoveNever:
140 self.cleanupNeverButton.setChecked(True) 131 self.cleanupNeverButton.setChecked(True)
141 elif policy == DownloadManager.RemoveExit: 132 elif policy == DownloadManager.RemoveExit:
142 self.cleanupExitButton.setChecked(True) 133 self.cleanupExitButton.setChecked(True)
143 else: 134 else:
144 self.cleanupSuccessfulButton.setChecked(True) 135 self.cleanupSuccessfulButton.setChecked(True)
145 self.openOnStartCheckBox.setChecked( 136 self.openOnStartCheckBox.setChecked(
146 Preferences.getWebBrowser("DownloadManagerAutoOpen")) 137 Preferences.getWebBrowser("DownloadManagerAutoOpen")
138 )
147 self.closeOnFinishedCheckBox.setChecked( 139 self.closeOnFinishedCheckBox.setChecked(
148 Preferences.getWebBrowser("DownloadManagerAutoClose")) 140 Preferences.getWebBrowser("DownloadManagerAutoClose")
141 )
149 self.__webEngine = True 142 self.__webEngine = True
150 143
151 def save(self): 144 def save(self):
152 """ 145 """
153 Public slot to save the Networj configuration. 146 Public slot to save the Networj configuration.
154 """ 147 """
155 Preferences.setUI( 148 Preferences.setUI("DynamicOnlineCheck", self.dynamicOnlineCheckBox.isChecked())
156 "DynamicOnlineCheck", 149 Preferences.setUI("DownloadPath", self.downloadDirPicker.text())
157 self.dynamicOnlineCheckBox.isChecked()) 150 Preferences.setUI(
158 Preferences.setUI( 151 "RequestDownloadFilename", self.requestFilenameCheckBox.isChecked()
159 "DownloadPath", 152 )
160 self.downloadDirPicker.text())
161 Preferences.setUI(
162 "RequestDownloadFilename",
163 self.requestFilenameCheckBox.isChecked())
164 if self.__webEngine: 153 if self.__webEngine:
165 from WebBrowser.Download.DownloadManager import DownloadManager 154 from WebBrowser.Download.DownloadManager import DownloadManager
155
166 if self.cleanupNeverButton.isChecked(): 156 if self.cleanupNeverButton.isChecked():
167 policy = DownloadManager.RemoveNever 157 policy = DownloadManager.RemoveNever
168 elif self.cleanupExitButton.isChecked(): 158 elif self.cleanupExitButton.isChecked():
169 policy = DownloadManager.RemoveExit 159 policy = DownloadManager.RemoveExit
170 else: 160 else:
171 policy = DownloadManager.RemoveSuccessFullDownload 161 policy = DownloadManager.RemoveSuccessFullDownload
172 Preferences.setWebBrowser("DownloadManagerRemovePolicy", policy) 162 Preferences.setWebBrowser("DownloadManagerRemovePolicy", policy)
173 Preferences.setWebBrowser( 163 Preferences.setWebBrowser(
174 "DownloadManagerAutoOpen", 164 "DownloadManagerAutoOpen", self.openOnStartCheckBox.isChecked()
175 self.openOnStartCheckBox.isChecked()) 165 )
176 Preferences.setWebBrowser( 166 Preferences.setWebBrowser(
177 "DownloadManagerAutoClose", 167 "DownloadManagerAutoClose", self.closeOnFinishedCheckBox.isChecked()
178 self.closeOnFinishedCheckBox.isChecked()) 168 )
179 169
180 Preferences.setUI( 170 Preferences.setUI("UseProxy", not self.noProxyButton.isChecked())
181 "UseProxy", 171 Preferences.setUI("UseSystemProxy", self.systemProxyButton.isChecked())
182 not self.noProxyButton.isChecked()) 172 Preferences.setUI(
183 Preferences.setUI( 173 "UseHttpProxyForAll", self.httpProxyForAllCheckBox.isChecked()
184 "UseSystemProxy", 174 )
185 self.systemProxyButton.isChecked()) 175
186 Preferences.setUI(
187 "UseHttpProxyForAll",
188 self.httpProxyForAllCheckBox.isChecked())
189
190 Preferences.setUI( 176 Preferences.setUI(
191 "ProxyExceptions", 177 "ProxyExceptions",
192 ",".join( 178 ",".join([h.strip() for h in self.exceptionsEdit.text().split(",")]),
193 [h.strip() for h in self.exceptionsEdit.text().split(",")])) 179 )
194 180
195 # HTTP proxy 181 # HTTP proxy
196 Preferences.setUI( 182 Preferences.setUI("ProxyHost/Http", self.httpProxyHostEdit.text())
197 "ProxyHost/Http", 183 Preferences.setUI("ProxyPort/Http", self.httpProxyPortSpin.value())
198 self.httpProxyHostEdit.text()) 184
199 Preferences.setUI(
200 "ProxyPort/Http",
201 self.httpProxyPortSpin.value())
202
203 # HTTPS proxy 185 # HTTPS proxy
204 Preferences.setUI( 186 Preferences.setUI("ProxyHost/Https", self.httpsProxyHostEdit.text())
205 "ProxyHost/Https", 187 Preferences.setUI("ProxyPort/Https", self.httpsProxyPortSpin.value())
206 self.httpsProxyHostEdit.text()) 188
207 Preferences.setUI(
208 "ProxyPort/Https",
209 self.httpsProxyPortSpin.value())
210
211 # FTP proxy 189 # FTP proxy
212 Preferences.setUI( 190 Preferences.setUI("ProxyHost/Ftp", self.ftpProxyHostEdit.text())
213 "ProxyHost/Ftp", 191 Preferences.setUI("ProxyPort/Ftp", self.ftpProxyPortSpin.value())
214 self.ftpProxyHostEdit.text()) 192 Preferences.setUI(
215 Preferences.setUI( 193 "ProxyType/Ftp", EricFtpProxyType(self.ftpProxyTypeCombo.currentData())
216 "ProxyPort/Ftp", 194 )
217 self.ftpProxyPortSpin.value()) 195 Preferences.setUI("ProxyUser/Ftp", self.ftpProxyUserEdit.text())
218 Preferences.setUI( 196 Preferences.setUI("ProxyPassword/Ftp", self.ftpProxyPasswordEdit.text())
219 "ProxyType/Ftp", 197 Preferences.setUI("ProxyAccount/Ftp", self.ftpProxyAccountEdit.text())
220 EricFtpProxyType(self.ftpProxyTypeCombo.currentData())) 198
221 Preferences.setUI(
222 "ProxyUser/Ftp",
223 self.ftpProxyUserEdit.text())
224 Preferences.setUI(
225 "ProxyPassword/Ftp",
226 self.ftpProxyPasswordEdit.text())
227 Preferences.setUI(
228 "ProxyAccount/Ftp",
229 self.ftpProxyAccountEdit.text())
230
231 @pyqtSlot() 199 @pyqtSlot()
232 def on_clearProxyPasswordsButton_clicked(self): 200 def on_clearProxyPasswordsButton_clicked(self):
233 """ 201 """
234 Private slot to clear the saved HTTP(S) proxy passwords. 202 Private slot to clear the saved HTTP(S) proxy passwords.
235 """ 203 """
236 Preferences.setUI("ProxyPassword/Http", "") 204 Preferences.setUI("ProxyPassword/Http", "")
237 Preferences.setUI("ProxyPassword/Https", "") 205 Preferences.setUI("ProxyPassword/Https", "")
238 206
239 @pyqtSlot(int) 207 @pyqtSlot(int)
240 def on_ftpProxyTypeCombo_currentIndexChanged(self, index): 208 def on_ftpProxyTypeCombo_currentIndexChanged(self, index):
241 """ 209 """
242 Private slot handling the selection of a proxy type. 210 Private slot handling the selection of a proxy type.
243 211
244 @param index index of the selected item (integer) 212 @param index index of the selected item (integer)
245 """ 213 """
246 proxyType = EricFtpProxyType(self.ftpProxyTypeCombo.itemData(index)) 214 proxyType = EricFtpProxyType(self.ftpProxyTypeCombo.itemData(index))
247 self.ftpProxyHostEdit.setEnabled( 215 self.ftpProxyHostEdit.setEnabled(proxyType != EricFtpProxyType.NO_PROXY)
248 proxyType != EricFtpProxyType.NO_PROXY) 216 self.ftpProxyPortSpin.setEnabled(proxyType != EricFtpProxyType.NO_PROXY)
249 self.ftpProxyPortSpin.setEnabled(
250 proxyType != EricFtpProxyType.NO_PROXY)
251 self.ftpProxyUserEdit.setEnabled( 217 self.ftpProxyUserEdit.setEnabled(
252 proxyType not in [EricFtpProxyType.NO_PROXY, 218 proxyType
253 EricFtpProxyType.NON_AUTHORIZING]) 219 not in [EricFtpProxyType.NO_PROXY, EricFtpProxyType.NON_AUTHORIZING]
220 )
254 self.ftpProxyPasswordEdit.setEnabled( 221 self.ftpProxyPasswordEdit.setEnabled(
255 proxyType not in [EricFtpProxyType.NO_PROXY, 222 proxyType
256 EricFtpProxyType.NON_AUTHORIZING]) 223 not in [EricFtpProxyType.NO_PROXY, EricFtpProxyType.NON_AUTHORIZING]
224 )
257 self.ftpProxyAccountEdit.setEnabled( 225 self.ftpProxyAccountEdit.setEnabled(
258 proxyType not in [EricFtpProxyType.NO_PROXY, 226 proxyType
259 EricFtpProxyType.NON_AUTHORIZING]) 227 not in [EricFtpProxyType.NO_PROXY, EricFtpProxyType.NON_AUTHORIZING]
260 228 )
229
261 230
262 def create(dlg): 231 def create(dlg):
263 """ 232 """
264 Module function to create the configuration page. 233 Module function to create the configuration page.
265 234
266 @param dlg reference to the configuration dialog 235 @param dlg reference to the configuration dialog
267 @return reference to the instantiated page (ConfigurationPageBase) 236 @return reference to the instantiated page (ConfigurationPageBase)
268 """ 237 """
269 page = NetworkPage(dlg) 238 page = NetworkPage(dlg)
270 return page 239 return page

eric ide

mercurial