Preferences/ConfigurationPages/NetworkPage.py

changeset 2074
5cb87968aad5
parent 1509
c0b5e693b0eb
child 2190
abd65b78425e
equal deleted inserted replaced
2071:136eb25e4314 2074:5cb87968aad5
11 11
12 from PyQt4.QtCore import pyqtSlot 12 from PyQt4.QtCore import pyqtSlot
13 13
14 from E5Gui.E5Completers import E5DirCompleter 14 from E5Gui.E5Completers import E5DirCompleter
15 from E5Gui import E5FileDialog 15 from E5Gui import E5FileDialog
16 from E5Network.E5Ftp import E5FtpProxyType
16 17
17 from .ConfigurationPageBase import ConfigurationPageBase 18 from .ConfigurationPageBase import ConfigurationPageBase
18 from .Ui_NetworkPage import Ui_NetworkPage 19 from .Ui_NetworkPage import Ui_NetworkPage
19 20
20 from Helpviewer.Download.DownloadManager import DownloadManager 21 from Helpviewer.Download.DownloadManager import DownloadManager
34 super().__init__() 35 super().__init__()
35 self.setupUi(self) 36 self.setupUi(self)
36 self.setObjectName("NetworkPage") 37 self.setObjectName("NetworkPage")
37 38
38 self.downloadDirCompleter = E5DirCompleter(self.downloadDirEdit) 39 self.downloadDirCompleter = E5DirCompleter(self.downloadDirEdit)
40
41 self.ftpProxyTypeCombo.addItem(self.trUtf8("No FTP Proxy"),
42 E5FtpProxyType.NoProxy)
43 self.ftpProxyTypeCombo.addItem(self.trUtf8("No Proxy Authentication required"),
44 E5FtpProxyType.NonAuthorizing)
45 self.ftpProxyTypeCombo.addItem(self.trUtf8("User@Server"),
46 E5FtpProxyType.UserAtServer)
47 self.ftpProxyTypeCombo.addItem(self.trUtf8("SITE"),
48 E5FtpProxyType.Site)
49 self.ftpProxyTypeCombo.addItem(self.trUtf8("OPEN"),
50 E5FtpProxyType.Open)
51 self.ftpProxyTypeCombo.addItem(self.trUtf8("User@Proxyuser@Server"),
52 E5FtpProxyType.UserAtProxyuserAtServer)
53 self.ftpProxyTypeCombo.addItem(self.trUtf8("Proxyuser@Server"),
54 E5FtpProxyType.ProxyuserAtServer)
55 self.ftpProxyTypeCombo.addItem(self.trUtf8("AUTH and RESP"),
56 E5FtpProxyType.AuthResp)
57 self.ftpProxyTypeCombo.addItem(self.trUtf8("Bluecoat Proxy"),
58 E5FtpProxyType.Bluecoat)
39 59
40 # set initial values 60 # set initial values
41 self.downloadDirEdit.setText(Preferences.getUI("DownloadPath")) 61 self.downloadDirEdit.setText(Preferences.getUI("DownloadPath"))
42 self.requestFilenameCheckBox.setChecked( 62 self.requestFilenameCheckBox.setChecked(
43 Preferences.getUI("RequestDownloadFilename")) 63 Preferences.getUI("RequestDownloadFilename"))
47 elif policy == DownloadManager.RemoveExit: 67 elif policy == DownloadManager.RemoveExit:
48 self.cleanupExitButton.setChecked(True) 68 self.cleanupExitButton.setChecked(True)
49 else: 69 else:
50 self.cleanupSuccessfulButton.setChecked(True) 70 self.cleanupSuccessfulButton.setChecked(True)
51 71
52 self.proxyGroup.setChecked( 72 # HTTP proxy
53 Preferences.getUI("UseProxy")) 73 self.httpProxyHostEdit.setText(
74 Preferences.getUI("ProxyHost/Http"))
75 self.httpProxyPortSpin.setValue(
76 Preferences.getUI("ProxyPort/Http"))
77
78 # HTTPS proxy
79 self.httpsProxyHostEdit.setText(
80 Preferences.getUI("ProxyHost/Https"))
81 self.httpsProxyPortSpin.setValue(
82 Preferences.getUI("ProxyPort/Https"))
83
84 # FTP proxy
85 self.ftpProxyHostEdit.setText(
86 Preferences.getUI("ProxyHost/Ftp"))
87 self.ftpProxyPortSpin.setValue(
88 Preferences.getUI("ProxyPort/Ftp"))
89 self.ftpProxyTypeCombo.setCurrentIndex(
90 self.ftpProxyTypeCombo.findData(
91 Preferences.getUI("ProxyType/Ftp")))
92 self.ftpProxyUserEdit.setText(
93 Preferences.getUI("ProxyUser/Ftp"))
94 self.ftpProxyPasswordEdit.setText(
95 Preferences.getUI("ProxyPassword/Ftp"))
96 self.ftpProxyAccountEdit.setText(
97 Preferences.getUI("ProxyAccount/Ftp"))
98
99 self.httpProxyForAllCheckBox.setChecked(
100 Preferences.getUI("UseHttpProxyForAll"))
54 if Preferences.getUI("UseSystemProxy"): 101 if Preferences.getUI("UseSystemProxy"):
55 self.systemProxyButton.setChecked(True) 102 self.systemProxyButton.setChecked(True)
56 else: 103 else:
57 self.manualProxyButton.setChecked(True) 104 self.manualProxyButton.setChecked(True)
58 self.httpProxyForAllCheckBox.setChecked( 105 self.proxyGroup.setChecked(
59 Preferences.getUI("UseHttpProxyForAll")) 106 Preferences.getUI("UseProxy"))
60 self.httpProxyHostEdit.setText( 107
61 Preferences.getUI("ProxyHost/Http"))
62 self.httpsProxyHostEdit.setText(
63 Preferences.getUI("ProxyHost/Https"))
64 self.ftpProxyHostEdit.setText(
65 Preferences.getUI("ProxyHost/Ftp"))
66 self.httpProxyPortSpin.setValue(
67 Preferences.getUI("ProxyPort/Http"))
68 self.httpsProxyPortSpin.setValue(
69 Preferences.getUI("ProxyPort/Https"))
70 self.ftpProxyPortSpin.setValue(
71 Preferences.getUI("ProxyPort/Ftp"))
72
73 def save(self): 108 def save(self):
74 """ 109 """
75 Public slot to save the Application configuration. 110 Public slot to save the Application configuration.
76 """ 111 """
77 Preferences.setUI("DownloadPath", 112 Preferences.setUI("DownloadPath",
90 self.proxyGroup.isChecked()) 125 self.proxyGroup.isChecked())
91 Preferences.setUI("UseSystemProxy", 126 Preferences.setUI("UseSystemProxy",
92 self.systemProxyButton.isChecked()) 127 self.systemProxyButton.isChecked())
93 Preferences.setUI("UseHttpProxyForAll", 128 Preferences.setUI("UseHttpProxyForAll",
94 self.httpProxyForAllCheckBox.isChecked()) 129 self.httpProxyForAllCheckBox.isChecked())
130
131 # HTTP proxy
95 Preferences.setUI("ProxyHost/Http", 132 Preferences.setUI("ProxyHost/Http",
96 self.httpProxyHostEdit.text()) 133 self.httpProxyHostEdit.text())
134 Preferences.setUI("ProxyPort/Http",
135 self.httpProxyPortSpin.value())
136
137 # HTTPS proxy
97 Preferences.setUI("ProxyHost/Https", 138 Preferences.setUI("ProxyHost/Https",
98 self.httpsProxyHostEdit.text()) 139 self.httpsProxyHostEdit.text())
140 Preferences.setUI("ProxyPort/Https",
141 self.httpsProxyPortSpin.value())
142
143 # FTP proxy
99 Preferences.setUI("ProxyHost/Ftp", 144 Preferences.setUI("ProxyHost/Ftp",
100 self.ftpProxyHostEdit.text()) 145 self.ftpProxyHostEdit.text())
101 Preferences.setUI("ProxyPort/Http",
102 self.httpProxyPortSpin.value())
103 Preferences.setUI("ProxyPort/Https",
104 self.httpsProxyPortSpin.value())
105 Preferences.setUI("ProxyPort/Ftp", 146 Preferences.setUI("ProxyPort/Ftp",
106 self.ftpProxyPortSpin.value()) 147 self.ftpProxyPortSpin.value())
148 Preferences.setUI("ProxyType/Ftp",
149 self.ftpProxyTypeCombo.itemData(
150 self.ftpProxyTypeCombo.currentIndex()))
151 Preferences.setUI("ProxyUser/Ftp",
152 self.ftpProxyUserEdit.text())
153 Preferences.setUI("ProxyPassword/Ftp",
154 self.ftpProxyPasswordEdit.text())
155 Preferences.setUI("ProxyAccount/Ftp",
156 self.ftpProxyAccountEdit.text())
107 157
108 @pyqtSlot() 158 @pyqtSlot()
109 def on_downloadDirButton_clicked(self): 159 def on_downloadDirButton_clicked(self):
110 """ 160 """
111 Private slot to handle the directory selection via dialog. 161 Private slot to handle the directory selection via dialog.
123 self.downloadDirEdit.setText(dn) 173 self.downloadDirEdit.setText(dn)
124 174
125 @pyqtSlot() 175 @pyqtSlot()
126 def on_clearProxyPasswordsButton_clicked(self): 176 def on_clearProxyPasswordsButton_clicked(self):
127 """ 177 """
128 Private slot to clear the saved proxy passwords. 178 Private slot to clear the saved HTTP(S) proxy passwords.
129 """ 179 """
130 Preferences.setUI("ProxyPassword/Http", "") 180 Preferences.setUI("ProxyPassword/Http", "")
131 Preferences.setUI("ProxyPassword/Https", "") 181 Preferences.setUI("ProxyPassword/Https", "")
132 Preferences.setUI("ProxyPassword/Ftp", "") 182
183 @pyqtSlot(int)
184 def on_ftpProxyTypeCombo_currentIndexChanged(self, index):
185 """
186 Private slot handling the selection of a proxy type.
187
188 @param index index of the selected item (integer)
189 """
190 proxyType = self.ftpProxyTypeCombo.itemData(index)
191 self.ftpProxyHostEdit.setEnabled(proxyType != E5FtpProxyType.NoProxy)
192 self.ftpProxyPortSpin.setEnabled(proxyType != E5FtpProxyType.NoProxy)
193 self.ftpProxyUserEdit.setEnabled(
194 proxyType not in [E5FtpProxyType.NoProxy, E5FtpProxyType.NonAuthorizing])
195 self.ftpProxyPasswordEdit.setEnabled(
196 proxyType not in [E5FtpProxyType.NoProxy, E5FtpProxyType.NonAuthorizing])
197 self.ftpProxyAccountEdit.setEnabled(
198 proxyType not in [E5FtpProxyType.NoProxy, E5FtpProxyType.NonAuthorizing])
133 199
134 200
135 def create(dlg): 201 def create(dlg):
136 """ 202 """
137 Module function to create the configuration page. 203 Module function to create the configuration page.

eric ide

mercurial