src/eric7/Plugins/VcsPlugins/vcsMercurial/HgUserConfigDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
18 from EricWidgets import EricMessageBox 18 from EricWidgets import EricMessageBox
19 19
20 import Globals 20 import Globals
21 21
22 from .HgUtilities import getConfigPath 22 from .HgUtilities import getConfigPath
23 from .HgUserConfigHostFingerprintDialog import ( 23 from .HgUserConfigHostFingerprintDialog import HgUserConfigHostFingerprintDialog
24 HgUserConfigHostFingerprintDialog 24 from .HgUserConfigHostMinimumProtocolDialog import HgUserConfigHostMinimumProtocolDialog
25 )
26 from .HgUserConfigHostMinimumProtocolDialog import (
27 HgUserConfigHostMinimumProtocolDialog
28 )
29 25
30 from .Ui_HgUserConfigDialog import Ui_HgUserConfigDialog 26 from .Ui_HgUserConfigDialog import Ui_HgUserConfigDialog
31 27
32 import UI.PixmapCache 28 import UI.PixmapCache
33 29
34 30
35 class HgUserConfigDialog(QDialog, Ui_HgUserConfigDialog): 31 class HgUserConfigDialog(QDialog, Ui_HgUserConfigDialog):
36 """ 32 """
37 Class implementing a dialog to enter some user data. 33 Class implementing a dialog to enter some user data.
38 """ 34 """
35
39 def __init__(self, version=(0, 0, 0), parent=None): 36 def __init__(self, version=(0, 0, 0), parent=None):
40 """ 37 """
41 Constructor 38 Constructor
42 39
43 @param version Mercurial version info 40 @param version Mercurial version info
44 @type tuple of three integers 41 @type tuple of three integers
45 @param parent reference to the parent widget 42 @param parent reference to the parent widget
46 @type QWidget 43 @type QWidget
47 """ 44 """
48 super().__init__(parent) 45 super().__init__(parent)
49 self.setupUi(self) 46 self.setupUi(self)
50 47
51 self.__version = version 48 self.__version = version
52 49
53 self.__minimumProtocols = { 50 self.__minimumProtocols = {
54 "tls1.0": self.tr("TLS 1.0"), 51 "tls1.0": self.tr("TLS 1.0"),
55 "tls1.1": self.tr("TLS 1.1"), 52 "tls1.1": self.tr("TLS 1.1"),
56 "tls1.2": self.tr("TLS 1.2"), 53 "tls1.2": self.tr("TLS 1.2"),
57 } 54 }
58 55
59 self.lfUserCachePicker.setMode(EricPathPickerModes.DIRECTORY_MODE) 56 self.lfUserCachePicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
60 if Globals.isLinuxPlatform(): 57 if Globals.isLinuxPlatform():
61 self.lfUserCachePicker.setDefaultDirectory(os.path.expanduser( 58 self.lfUserCachePicker.setDefaultDirectory(
62 "~/.cache/largefiles")) 59 os.path.expanduser("~/.cache/largefiles")
60 )
63 elif Globals.isMacPlatform(): 61 elif Globals.isMacPlatform():
64 self.lfUserCachePicker.setDefaultDirectory(os.path.expanduser( 62 self.lfUserCachePicker.setDefaultDirectory(
65 "~/Library/Caches/largefiles")) 63 os.path.expanduser("~/Library/Caches/largefiles")
66 else: 64 )
67 self.lfUserCachePicker.setDefaultDirectory(os.path.expanduser( 65 else:
68 "~\\AppData\\Local\\largefiles")) 66 self.lfUserCachePicker.setDefaultDirectory(
69 67 os.path.expanduser("~\\AppData\\Local\\largefiles")
68 )
69
70 self.fpAddButton.setIcon(UI.PixmapCache.getIcon("plus")) 70 self.fpAddButton.setIcon(UI.PixmapCache.getIcon("plus"))
71 self.fpDeleteButton.setIcon(UI.PixmapCache.getIcon("minus")) 71 self.fpDeleteButton.setIcon(UI.PixmapCache.getIcon("minus"))
72 self.fpEditButton.setIcon(UI.PixmapCache.getIcon("edit")) 72 self.fpEditButton.setIcon(UI.PixmapCache.getIcon("edit"))
73 73
74 self.protocolAddButton.setIcon(UI.PixmapCache.getIcon("plus")) 74 self.protocolAddButton.setIcon(UI.PixmapCache.getIcon("plus"))
75 self.protocolDeleteButton.setIcon(UI.PixmapCache.getIcon("minus")) 75 self.protocolDeleteButton.setIcon(UI.PixmapCache.getIcon("minus"))
76 self.protocolEditButton.setIcon(UI.PixmapCache.getIcon("edit")) 76 self.protocolEditButton.setIcon(UI.PixmapCache.getIcon("edit"))
77 77
78 self.minimumProtocolComboBox.addItem(self.tr("Default"), "") 78 self.minimumProtocolComboBox.addItem(self.tr("Default"), "")
79 for protocol in sorted(self.__minimumProtocols.keys()): 79 for protocol in sorted(self.__minimumProtocols.keys()):
80 self.minimumProtocolComboBox.addItem( 80 self.minimumProtocolComboBox.addItem(
81 self.__minimumProtocols[protocol], protocol) 81 self.__minimumProtocols[protocol], protocol
82 82 )
83
83 self.fingerprintsList.headerItem().setText( 84 self.fingerprintsList.headerItem().setText(
84 self.fingerprintsList.columnCount(), "") 85 self.fingerprintsList.columnCount(), ""
85 self.protocolsList.headerItem().setText( 86 )
86 self.protocolsList.columnCount(), "") 87 self.protocolsList.headerItem().setText(self.protocolsList.columnCount(), "")
87 88
88 if self.__version < (3, 9, 0): 89 if self.__version < (3, 9, 0):
89 self.disableTls10WarningCheckBox.setEnabled(False) 90 self.disableTls10WarningCheckBox.setEnabled(False)
90 self.minimumProtocolComboBox.setEnabled(False) 91 self.minimumProtocolComboBox.setEnabled(False)
91 self.minimumProtcolGroupBox.setEnabled(False) 92 self.minimumProtcolGroupBox.setEnabled(False)
92 93
93 self.tabWidget.setCurrentIndex(0) 94 self.tabWidget.setCurrentIndex(0)
94 95
95 self.__editor = None 96 self.__editor = None
96 97
97 self.__config = None 98 self.__config = None
98 self.readUserConfig() 99 self.readUserConfig()
99 100
100 self.__updateFingerprintsButtons() 101 self.__updateFingerprintsButtons()
101 self.__updateProtocolsButtons() 102 self.__updateProtocolsButtons()
102 103
103 def writeUserConfig(self): 104 def writeUserConfig(self):
104 """ 105 """
105 Public method to write the user configuration file. 106 Public method to write the user configuration file.
106 """ 107 """
107 if self.__config is None: 108 if self.__config is None:
108 self.__config = ConfigParser() 109 self.__config = ConfigParser()
109 110
110 ################################################################### 111 ###################################################################
111 ## ui section 112 ## ui section
112 ################################################################### 113 ###################################################################
113 if "ui" not in self.__config: 114 if "ui" not in self.__config:
114 self.__config["ui"] = {} 115 self.__config["ui"] = {}
119 ################################################################### 120 ###################################################################
120 ## extensions section 121 ## extensions section
121 ################################################################### 122 ###################################################################
122 if "extensions" not in self.__config: 123 if "extensions" not in self.__config:
123 self.__config["extensions"] = {} 124 self.__config["extensions"] = {}
124 125
125 if self.gpgCheckBox.isChecked(): 126 if self.gpgCheckBox.isChecked():
126 self.__config["extensions"]["gpg"] = "" 127 self.__config["extensions"]["gpg"] = ""
127 else: 128 else:
128 if "gpg" in self.__config["extensions"]: 129 if "gpg" in self.__config["extensions"]:
129 del self.__config["extensions"]["gpg"] 130 del self.__config["extensions"]["gpg"]
130 self.__config["extensions"]["#gpg"] = "" 131 self.__config["extensions"]["#gpg"] = ""
131 132
132 if self.purgeCheckBox.isChecked(): 133 if self.purgeCheckBox.isChecked():
133 self.__config["extensions"]["purge"] = "" 134 self.__config["extensions"]["purge"] = ""
134 else: 135 else:
135 if "purge" in self.__config["extensions"]: 136 if "purge" in self.__config["extensions"]:
136 del self.__config["extensions"]["purge"] 137 del self.__config["extensions"]["purge"]
137 self.__config["extensions"]["#purge"] = "" 138 self.__config["extensions"]["#purge"] = ""
138 139
139 if self.queuesCheckBox.isChecked(): 140 if self.queuesCheckBox.isChecked():
140 self.__config["extensions"]["mq"] = "" 141 self.__config["extensions"]["mq"] = ""
141 else: 142 else:
142 if "mq" in self.__config["extensions"]: 143 if "mq" in self.__config["extensions"]:
143 del self.__config["extensions"]["mq"] 144 del self.__config["extensions"]["mq"]
144 self.__config["extensions"]["#mq"] = "" 145 self.__config["extensions"]["#mq"] = ""
145 146
146 if self.rebaseCheckBox.isChecked(): 147 if self.rebaseCheckBox.isChecked():
147 self.__config["extensions"]["rebase"] = "" 148 self.__config["extensions"]["rebase"] = ""
148 else: 149 else:
149 if "rebase" in self.__config["extensions"]: 150 if "rebase" in self.__config["extensions"]:
150 del self.__config["extensions"]["rebase"] 151 del self.__config["extensions"]["rebase"]
151 self.__config["extensions"]["#rebase"] = "" 152 self.__config["extensions"]["#rebase"] = ""
152 153
153 if self.shelveCheckBox.isChecked(): 154 if self.shelveCheckBox.isChecked():
154 self.__config["extensions"]["shelve"] = "" 155 self.__config["extensions"]["shelve"] = ""
155 else: 156 else:
156 if "shelve" in self.__config["extensions"]: 157 if "shelve" in self.__config["extensions"]:
157 del self.__config["extensions"]["shelve"] 158 del self.__config["extensions"]["shelve"]
158 self.__config["extensions"]["#shelve"] = "" 159 self.__config["extensions"]["#shelve"] = ""
159 160
160 if self.stripCheckBox.isChecked(): 161 if self.stripCheckBox.isChecked():
161 self.__config["extensions"]["strip"] = "" 162 self.__config["extensions"]["strip"] = ""
162 else: 163 else:
163 if "strip" in self.__config["extensions"]: 164 if "strip" in self.__config["extensions"]:
164 del self.__config["extensions"]["strip"] 165 del self.__config["extensions"]["strip"]
165 self.__config["extensions"]["#strip"] = "" 166 self.__config["extensions"]["#strip"] = ""
166 167
167 if self.histeditCheckBox.isChecked(): 168 if self.histeditCheckBox.isChecked():
168 self.__config["extensions"]["histedit"] = "" 169 self.__config["extensions"]["histedit"] = ""
169 else: 170 else:
170 if "histedit" in self.__config["extensions"]: 171 if "histedit" in self.__config["extensions"]:
171 del self.__config["extensions"]["histedit"] 172 del self.__config["extensions"]["histedit"]
172 self.__config["extensions"]["#histedit"] = "" 173 self.__config["extensions"]["#histedit"] = ""
173 174
174 if self.largefilesCheckBox.isChecked(): 175 if self.largefilesCheckBox.isChecked():
175 self.__config["extensions"]["largefiles"] = "" 176 self.__config["extensions"]["largefiles"] = ""
176 ############################################################### 177 ###############################################################
177 ## largefiles section 178 ## largefiles section
178 ############################################################### 179 ###############################################################
179 if "largefiles" not in self.__config: 180 if "largefiles" not in self.__config:
180 self.__config["largefiles"] = {} 181 self.__config["largefiles"] = {}
181 self.__config["largefiles"]["minsize"] = ( 182 self.__config["largefiles"]["minsize"] = str(self.lfFileSizeSpinBox.value())
182 str(self.lfFileSizeSpinBox.value())
183 )
184 lfFilePatterns = self.lfFilePatternsEdit.text() 183 lfFilePatterns = self.lfFilePatternsEdit.text()
185 if lfFilePatterns: 184 if lfFilePatterns:
186 self.__config["largefiles"]["patterns"] = lfFilePatterns 185 self.__config["largefiles"]["patterns"] = lfFilePatterns
187 elif "patterns" in self.__config["largefiles"]: 186 elif "patterns" in self.__config["largefiles"]:
188 del self.__config["largefiles"]["patterns"] 187 del self.__config["largefiles"]["patterns"]
193 del self.__config["largefiles"]["usercache"] 192 del self.__config["largefiles"]["usercache"]
194 else: 193 else:
195 if "largefiles" in self.__config["extensions"]: 194 if "largefiles" in self.__config["extensions"]:
196 del self.__config["extensions"]["largefiles"] 195 del self.__config["extensions"]["largefiles"]
197 self.__config["extensions"]["#largefiles"] = "" 196 self.__config["extensions"]["#largefiles"] = ""
198 197
199 if self.closeheadCheckBox.isChecked() and self.__version >= (4, 8, 0): 198 if self.closeheadCheckBox.isChecked() and self.__version >= (4, 8, 0):
200 self.__config["extensions"]["closehead"] = "" 199 self.__config["extensions"]["closehead"] = ""
201 else: 200 else:
202 if "closehead" in self.__config["extensions"]: 201 if "closehead" in self.__config["extensions"]:
203 del self.__config["extensions"]["closehead"] 202 del self.__config["extensions"]["closehead"]
207 ################################################################### 206 ###################################################################
208 if self.proxyHostEdit.text(): 207 if self.proxyHostEdit.text():
209 self.__config["http_proxy"] = { 208 self.__config["http_proxy"] = {
210 "host": self.proxyHostEdit.text(), 209 "host": self.proxyHostEdit.text(),
211 "user": self.proxyUserEdit.text(), 210 "user": self.proxyUserEdit.text(),
212 "passwd": self.proxyPasswordEdit.text() 211 "passwd": self.proxyPasswordEdit.text(),
213 } 212 }
214 if self.proxyBypassEdit.text(): 213 if self.proxyBypassEdit.text():
215 self.__config["http_proxy"]["no"] = ( 214 self.__config["http_proxy"]["no"] = self.proxyBypassEdit.text()
216 self.proxyBypassEdit.text()
217 )
218 else: 215 else:
219 if "http_proxy" in self.__config: 216 if "http_proxy" in self.__config:
220 del self.__config["http_proxy"] 217 del self.__config["http_proxy"]
221 ################################################################### 218 ###################################################################
222 ## hostfingerprints/hostsecurity section 219 ## hostfingerprints/hostsecurity section
225 # 222 #
226 # delete hostsecurity section 223 # delete hostsecurity section
227 # 224 #
228 if "hostsecurity" in self.__config: 225 if "hostsecurity" in self.__config:
229 del self.__config["hostsecurity"] 226 del self.__config["hostsecurity"]
230 227
231 # 228 #
232 # hostfingerprints section 229 # hostfingerprints section
233 # 230 #
234 if self.fingerprintsList.topLevelItemCount() > 0: 231 if self.fingerprintsList.topLevelItemCount() > 0:
235 self.__config["hostfingerprints"] = {} 232 self.__config["hostfingerprints"] = {}
236 for row in range(self.fingerprintsList.topLevelItemCount()): 233 for row in range(self.fingerprintsList.topLevelItemCount()):
237 itm = self.fingerprintsList.topLevelItem(row) 234 itm = self.fingerprintsList.topLevelItem(row)
238 fingerprint = itm.text(1) 235 fingerprint = itm.text(1)
239 if fingerprint.startswith("sha1:"): 236 if fingerprint.startswith("sha1:"):
240 fingerprint = fingerprint[5:] 237 fingerprint = fingerprint[5:]
241 self.__config["hostfingerprints"][itm.text(0)] = ( 238 self.__config["hostfingerprints"][itm.text(0)] = fingerprint
242 fingerprint
243 )
244 else: 239 else:
245 if "hostfingerprints" in self.__config: 240 if "hostfingerprints" in self.__config:
246 del self.__config["hostfingerprints"] 241 del self.__config["hostfingerprints"]
247 else: 242 else:
248 # 243 #
249 # delete hostfingerprints section 244 # delete hostfingerprints section
250 # 245 #
251 if "hostfingerprints" in self.__config: 246 if "hostfingerprints" in self.__config:
252 del self.__config["hostfingerprints"] 247 del self.__config["hostfingerprints"]
253 248
254 # 249 #
255 # hostsecurity section 250 # hostsecurity section
256 # 251 #
257 if "hostsecurity" not in self.__config: 252 if "hostsecurity" not in self.__config:
258 self.__config["hostsecurity"] = {} 253 self.__config["hostsecurity"] = {}
259 254
260 if self.fingerprintsList.topLevelItemCount() > 0: 255 if self.fingerprintsList.topLevelItemCount() > 0:
261 self.__clearFingerprints() 256 self.__clearFingerprints()
262 fingerprints = self.__assembleFingerprints() 257 fingerprints = self.__assembleFingerprints()
263 for host in fingerprints: 258 for host in fingerprints:
264 key = "{0}:fingerprints".format(host) 259 key = "{0}:fingerprints".format(host)
265 self.__config["hostsecurity"][key] = ( 260 self.__config["hostsecurity"][key] = ", ".join(fingerprints[host])
266 ", ".join(fingerprints[host])
267 )
268 else: 261 else:
269 self.__clearFingerprints() 262 self.__clearFingerprints()
270 263
271 if self.disableTls10WarningCheckBox.isChecked(): 264 if self.disableTls10WarningCheckBox.isChecked():
272 disabletls10warning = "true" 265 disabletls10warning = "true"
273 else: 266 else:
274 disabletls10warning = "false" 267 disabletls10warning = "false"
275 self.__config["hostsecurity"]["disabletls10warning"] = ( 268 self.__config["hostsecurity"]["disabletls10warning"] = disabletls10warning
276 disabletls10warning 269
277 )
278
279 if self.minimumProtocolComboBox.currentIndex() == 0: 270 if self.minimumProtocolComboBox.currentIndex() == 0:
280 self.__config.remove_option("hostsecurity", "minimumprotocol") 271 self.__config.remove_option("hostsecurity", "minimumprotocol")
281 else: 272 else:
282 minimumProtocol = self.minimumProtocolComboBox.itemData( 273 minimumProtocol = self.minimumProtocolComboBox.itemData(
283 self.minimumProtocolComboBox.currentIndex()) 274 self.minimumProtocolComboBox.currentIndex()
284 self.__config["hostsecurity"]["minimumprotocol"] = (
285 minimumProtocol
286 ) 275 )
287 276 self.__config["hostsecurity"]["minimumprotocol"] = minimumProtocol
277
288 if self.protocolsList.topLevelItemCount() > 0: 278 if self.protocolsList.topLevelItemCount() > 0:
289 self.__clearMinimumProtocols() 279 self.__clearMinimumProtocols()
290 minimumProtocols = self.__assembleMinimumProtocols() 280 minimumProtocols = self.__assembleMinimumProtocols()
291 for host in minimumProtocols: 281 for host in minimumProtocols:
292 key = "{0}:minimumprotocol".format(host) 282 key = "{0}:minimumprotocol".format(host)
293 self.__config["hostsecurity"][key] = minimumProtocols[host] 283 self.__config["hostsecurity"][key] = minimumProtocols[host]
294 else: 284 else:
295 self.__clearMinimumProtocols() 285 self.__clearMinimumProtocols()
296 286
297 if len(self.__config.options("hostsecurity")) == 0: 287 if len(self.__config.options("hostsecurity")) == 0:
298 del self.__config["hostsecurity"] 288 del self.__config["hostsecurity"]
299 ################################################################### 289 ###################################################################
300 290
301 cfgFile = getConfigPath() 291 cfgFile = getConfigPath()
302 with open(cfgFile, "w") as configFile: 292 with open(cfgFile, "w") as configFile:
303 self.__config.write(configFile) 293 self.__config.write(configFile)
304 294
305 def readUserConfig(self): 295 def readUserConfig(self):
306 """ 296 """
307 Public method to read the user configuration file. 297 Public method to read the user configuration file.
308 """ 298 """
309 cfgFile = getConfigPath() 299 cfgFile = getConfigPath()
310 300
311 self.__config = ConfigParser(delimiters=("=",)) 301 self.__config = ConfigParser(delimiters=("=",))
312 if self.__config.read(cfgFile): 302 if self.__config.read(cfgFile):
313 # step 1: extract user name and email 303 # step 1: extract user name and email
314 with contextlib.suppress(KeyError): 304 with contextlib.suppress(KeyError):
315 username = self.__config["ui"]["username"].strip() 305 username = self.__config["ui"]["username"].strip()
318 else: 308 else:
319 name = username 309 name = username
320 email = "" 310 email = ""
321 self.userNameEdit.setText(name.strip()), 311 self.userNameEdit.setText(name.strip()),
322 self.emailEdit.setText(email.strip()), 312 self.emailEdit.setText(email.strip()),
323 313
324 # step 2: extract extensions information 314 # step 2: extract extensions information
325 if "extensions" in self.__config: 315 if "extensions" in self.__config:
326 self.gpgCheckBox.setChecked( 316 self.gpgCheckBox.setChecked("gpg" in self.__config["extensions"])
327 "gpg" in self.__config["extensions"]) 317 self.purgeCheckBox.setChecked("purge" in self.__config["extensions"])
328 self.purgeCheckBox.setChecked( 318 self.queuesCheckBox.setChecked("mq" in self.__config["extensions"])
329 "purge" in self.__config["extensions"]) 319 self.rebaseCheckBox.setChecked("rebase" in self.__config["extensions"])
330 self.queuesCheckBox.setChecked( 320 self.shelveCheckBox.setChecked("shelve" in self.__config["extensions"])
331 "mq" in self.__config["extensions"])
332 self.rebaseCheckBox.setChecked(
333 "rebase" in self.__config["extensions"])
334 self.shelveCheckBox.setChecked(
335 "shelve" in self.__config["extensions"])
336 self.largefilesCheckBox.setChecked( 321 self.largefilesCheckBox.setChecked(
337 "largefiles" in self.__config["extensions"]) 322 "largefiles" in self.__config["extensions"]
338 self.stripCheckBox.setChecked( 323 )
339 "strip" in self.__config["extensions"]) 324 self.stripCheckBox.setChecked("strip" in self.__config["extensions"])
340 self.histeditCheckBox.setChecked( 325 self.histeditCheckBox.setChecked(
341 "histedit" in self.__config["extensions"]) 326 "histedit" in self.__config["extensions"]
327 )
342 self.closeheadCheckBox.setChecked( 328 self.closeheadCheckBox.setChecked(
343 "closehead" in self.__config["extensions"]) 329 "closehead" in self.__config["extensions"]
330 )
344 self.closeheadCheckBox.setEnabled(self.__version >= (4, 8, 0)) 331 self.closeheadCheckBox.setEnabled(self.__version >= (4, 8, 0))
345 332
346 # step 3: extract large files information 333 # step 3: extract large files information
347 if "largefiles" in self.__config: 334 if "largefiles" in self.__config:
348 if "minsize" in self.__config["largefiles"]: 335 if "minsize" in self.__config["largefiles"]:
349 self.lfFileSizeSpinBox.setValue( 336 self.lfFileSizeSpinBox.setValue(
350 self.__config.getint("largefiles", "minsize")) 337 self.__config.getint("largefiles", "minsize")
338 )
351 if "patterns" in self.__config["largefiles"]: 339 if "patterns" in self.__config["largefiles"]:
352 self.lfFilePatternsEdit.setText( 340 self.lfFilePatternsEdit.setText(
353 self.__config["largefiles"]["patterns"]) 341 self.__config["largefiles"]["patterns"]
342 )
354 if "usercache" in self.__config["largefiles"]: 343 if "usercache" in self.__config["largefiles"]:
355 self.lfUserCachePicker.setText( 344 self.lfUserCachePicker.setText(
356 self.__config["largefiles"]["usercache"]) 345 self.__config["largefiles"]["usercache"]
357 346 )
347
358 # step 4: extract http proxy information 348 # step 4: extract http proxy information
359 if "http_proxy" in self.__config: 349 if "http_proxy" in self.__config:
360 if "host" in self.__config["http_proxy"]: 350 if "host" in self.__config["http_proxy"]:
361 self.proxyHostEdit.setText( 351 self.proxyHostEdit.setText(self.__config["http_proxy"]["host"])
362 self.__config["http_proxy"]["host"])
363 if "user" in self.__config["http_proxy"]: 352 if "user" in self.__config["http_proxy"]:
364 self.proxyUserEdit.setText( 353 self.proxyUserEdit.setText(self.__config["http_proxy"]["user"])
365 self.__config["http_proxy"]["user"])
366 if "passwd" in self.__config["http_proxy"]: 354 if "passwd" in self.__config["http_proxy"]:
367 self.proxyPasswordEdit.setText( 355 self.proxyPasswordEdit.setText(
368 self.__config["http_proxy"]["passwd"]) 356 self.__config["http_proxy"]["passwd"]
357 )
369 if "no" in self.__config["http_proxy"]: 358 if "no" in self.__config["http_proxy"]:
370 self.proxyBypassEdit.setText( 359 self.proxyBypassEdit.setText(self.__config["http_proxy"]["no"])
371 self.__config["http_proxy"]["no"]) 360
372
373 # step 5a: extract host fingerprints 361 # step 5a: extract host fingerprints
374 if "hostfingerprints" in self.__config: 362 if "hostfingerprints" in self.__config:
375 for host in self.__config.options("hostfingerprints"): 363 for host in self.__config.options("hostfingerprints"):
376 if self.__version < (3, 9, 0): 364 if self.__version < (3, 9, 0):
377 QTreeWidgetItem(self.fingerprintsList, [ 365 QTreeWidgetItem(
378 host, 366 self.fingerprintsList,
379 self.__config["hostfingerprints"][host] 367 [host, self.__config["hostfingerprints"][host]],
380 ]) 368 )
381 else: 369 else:
382 # convert to hostsecurity fingerprint 370 # convert to hostsecurity fingerprint
383 QTreeWidgetItem(self.fingerprintsList, [ 371 QTreeWidgetItem(
384 host, 372 self.fingerprintsList,
385 "sha1:" + self.__config["hostfingerprints"][host] 373 [host, "sha1:" + self.__config["hostfingerprints"][host]],
386 ]) 374 )
387 375
388 # step 5b: extract hostsecurity fingerprints 376 # step 5b: extract hostsecurity fingerprints
389 if "hostsecurity" in self.__config: 377 if "hostsecurity" in self.__config:
390 for key in self.__config.options("hostsecurity"): 378 for key in self.__config.options("hostsecurity"):
391 if key.endswith(":fingerprints"): 379 if key.endswith(":fingerprints"):
392 host = key.replace(":fingerprints", "") 380 host = key.replace(":fingerprints", "")
393 fingerprints = ( 381 fingerprints = self.__config["hostsecurity"][key].split(",")
394 self.__config["hostsecurity"][key].split(",")
395 )
396 for fingerprint in fingerprints: 382 for fingerprint in fingerprints:
397 if self.__version < (3, 9, 0): 383 if self.__version < (3, 9, 0):
398 # downgrade from a newer version 384 # downgrade from a newer version
399 if fingerprint.startswith("sha1:"): 385 if fingerprint.startswith("sha1:"):
400 fingerprint = fingerprint[5:] 386 fingerprint = fingerprint[5:]
401 else: 387 else:
402 # Mercurial < 3.9.0 supports sha1 388 # Mercurial < 3.9.0 supports sha1
403 # fingerprints only 389 # fingerprints only
404 continue 390 continue
405 QTreeWidgetItem(self.fingerprintsList, [ 391 QTreeWidgetItem(
406 host, 392 self.fingerprintsList,
407 fingerprint.replace("\\", "").strip() 393 [host, fingerprint.replace("\\", "").strip()],
408 ]) 394 )
409 395
410 elif key == "disabletls10warning": 396 elif key == "disabletls10warning":
411 self.disableTls10WarningCheckBox.setChecked( 397 self.disableTls10WarningCheckBox.setChecked(
412 self.__config.getboolean( 398 self.__config.getboolean(
413 "hostsecurity", "disabletls10warning")) 399 "hostsecurity", "disabletls10warning"
414 400 )
401 )
402
415 elif key == "minimumprotocol": 403 elif key == "minimumprotocol":
416 minimumProtocol = self.__config["hostsecurity"][key] 404 minimumProtocol = self.__config["hostsecurity"][key]
417 index = self.minimumProtocolComboBox.findData( 405 index = self.minimumProtocolComboBox.findData(minimumProtocol)
418 minimumProtocol)
419 if index == -1: 406 if index == -1:
420 index = 0 407 index = 0
421 self.minimumProtocolComboBox.setCurrentIndex(index) 408 self.minimumProtocolComboBox.setCurrentIndex(index)
422 409
423 elif key.endswith(":minimumprotocol"): 410 elif key.endswith(":minimumprotocol"):
424 host = key.replace(":minimumprotocol", "") 411 host = key.replace(":minimumprotocol", "")
425 protocol = self.__config["hostsecurity"][key].strip() 412 protocol = self.__config["hostsecurity"][key].strip()
426 if protocol in self.__minimumProtocols: 413 if protocol in self.__minimumProtocols:
427 itm = QTreeWidgetItem(self.protocolsList, [ 414 itm = QTreeWidgetItem(
428 host, 415 self.protocolsList,
429 self.__minimumProtocols[protocol] 416 [host, self.__minimumProtocols[protocol]],
430 ]) 417 )
431 itm.setData(1, Qt.ItemDataRole.UserRole, protocol) 418 itm.setData(1, Qt.ItemDataRole.UserRole, protocol)
432 419
433 self.__finalizeFingerprintsColumns() 420 self.__finalizeFingerprintsColumns()
434 self.__finalizeProtocolsColumns() 421 self.__finalizeProtocolsColumns()
435 422
436 @pyqtSlot() 423 @pyqtSlot()
437 def accept(self): 424 def accept(self):
438 """ 425 """
439 Public slot to accept the dialog. 426 Public slot to accept the dialog.
440 """ 427 """
441 self.writeUserConfig() 428 self.writeUserConfig()
442 429
443 super().accept() 430 super().accept()
444 431
445 def __clearDialog(self): 432 def __clearDialog(self):
446 """ 433 """
447 Private method to clear the data of the dialog. 434 Private method to clear the data of the dialog.
448 """ 435 """
449 self.userNameEdit.clear() 436 self.userNameEdit.clear()
450 self.emailEdit.clear() 437 self.emailEdit.clear()
451 438
452 self.gpgCheckBox.setChecked(False) 439 self.gpgCheckBox.setChecked(False)
453 self.purgeCheckBox.setChecked(False) 440 self.purgeCheckBox.setChecked(False)
454 self.queuesCheckBox.setChecked(False) 441 self.queuesCheckBox.setChecked(False)
455 self.rebaseCheckBox.setChecked(False) 442 self.rebaseCheckBox.setChecked(False)
456 self.shelveCheckBox.setChecked(False) 443 self.shelveCheckBox.setChecked(False)
457 self.stripCheckBox.setChecked(False) 444 self.stripCheckBox.setChecked(False)
458 self.largefilesCheckBox.setChecked(False) 445 self.largefilesCheckBox.setChecked(False)
459 self.lfFileSizeSpinBox.setValue(10) 446 self.lfFileSizeSpinBox.setValue(10)
460 self.lfFilePatternsEdit.clear() 447 self.lfFilePatternsEdit.clear()
461 self.lfUserCachePicker.clear() 448 self.lfUserCachePicker.clear()
462 449
463 self.proxyHostEdit.clear() 450 self.proxyHostEdit.clear()
464 self.proxyUserEdit.clear() 451 self.proxyUserEdit.clear()
465 self.proxyPasswordEdit.clear() 452 self.proxyPasswordEdit.clear()
466 self.proxyBypassEdit.clear() 453 self.proxyBypassEdit.clear()
467 454
468 self.fingerprintsList.clear() 455 self.fingerprintsList.clear()
469 self.__finalizeFingerprintsColumns() 456 self.__finalizeFingerprintsColumns()
470 self.__updateFingerprintsButtons() 457 self.__updateFingerprintsButtons()
471 458
472 self.protocolsList.clear() 459 self.protocolsList.clear()
473 self.__finalizeProtocolsColumns() 460 self.__finalizeProtocolsColumns()
474 self.__updateProtocolsButtons() 461 self.__updateProtocolsButtons()
475 462
476 ####################################################################### 463 #######################################################################
477 ## Methods and slots for the host fingerprint handling below 464 ## Methods and slots for the host fingerprint handling below
478 ####################################################################### 465 #######################################################################
479 466
480 def __clearFingerprints(self): 467 def __clearFingerprints(self):
481 """ 468 """
482 Private method to clear the fingerprints from the hostsecurity section. 469 Private method to clear the fingerprints from the hostsecurity section.
483 """ 470 """
484 if "hostsecurity" in self.__config: 471 if "hostsecurity" in self.__config:
485 for key in self.__config.options("hostsecurity"): 472 for key in self.__config.options("hostsecurity"):
486 if key.endswith(":fingerprints"): 473 if key.endswith(":fingerprints"):
487 self.__config.remove_option("hostsecurity", key) 474 self.__config.remove_option("hostsecurity", key)
488 475
489 def __assembleFingerprints(self): 476 def __assembleFingerprints(self):
490 """ 477 """
491 Private method to assemble a list of host fingerprints. 478 Private method to assemble a list of host fingerprints.
492 479
493 @return dictionary with list of fingerprints per host 480 @return dictionary with list of fingerprints per host
494 @rtype dict with str as key and list of str as value 481 @rtype dict with str as key and list of str as value
495 """ 482 """
496 hostFingerprints = {} 483 hostFingerprints = {}
497 for row in range(self.fingerprintsList.topLevelItemCount()): 484 for row in range(self.fingerprintsList.topLevelItemCount()):
501 if host in hostFingerprints: 488 if host in hostFingerprints:
502 hostFingerprints[host].append(fingerprint) 489 hostFingerprints[host].append(fingerprint)
503 else: 490 else:
504 hostFingerprints[host] = [fingerprint] 491 hostFingerprints[host] = [fingerprint]
505 return hostFingerprints 492 return hostFingerprints
506 493
507 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) 494 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
508 def on_fingerprintsList_currentItemChanged(self, current, previous): 495 def on_fingerprintsList_currentItemChanged(self, current, previous):
509 """ 496 """
510 Private slot handling a change of the current fingerprints item. 497 Private slot handling a change of the current fingerprints item.
511 498
512 @param current reference to the current item 499 @param current reference to the current item
513 @type QTreeWidgetItem 500 @type QTreeWidgetItem
514 @param previous reference to the previous current item 501 @param previous reference to the previous current item
515 @type QTreeWidgetItem 502 @type QTreeWidgetItem
516 """ 503 """
517 self.__updateFingerprintsButtons() 504 self.__updateFingerprintsButtons()
518 505
519 @pyqtSlot() 506 @pyqtSlot()
520 def on_fpAddButton_clicked(self): 507 def on_fpAddButton_clicked(self):
521 """ 508 """
522 Private slot to add a fingerprints entry. 509 Private slot to add a fingerprints entry.
523 """ 510 """
526 host, fingerprint = dlg.getData() 513 host, fingerprint = dlg.getData()
527 itm = QTreeWidgetItem(self.fingerprintsList, [host, fingerprint]) 514 itm = QTreeWidgetItem(self.fingerprintsList, [host, fingerprint])
528 self.__finalizeFingerprintsColumns() 515 self.__finalizeFingerprintsColumns()
529 self.fingerprintsList.setCurrentItem(itm) 516 self.fingerprintsList.setCurrentItem(itm)
530 self.fingerprintsList.scrollToItem(itm) 517 self.fingerprintsList.scrollToItem(itm)
531 518
532 @pyqtSlot() 519 @pyqtSlot()
533 def on_fpDeleteButton_clicked(self): 520 def on_fpDeleteButton_clicked(self):
534 """ 521 """
535 Private slot to delete the current fingerprints item. 522 Private slot to delete the current fingerprints item.
536 """ 523 """
538 if itm is not None: 525 if itm is not None:
539 host = itm.text(0) 526 host = itm.text(0)
540 yes = EricMessageBox.yesNo( 527 yes = EricMessageBox.yesNo(
541 self, 528 self,
542 self.tr("Delete Host Fingerprint"), 529 self.tr("Delete Host Fingerprint"),
543 self.tr("""<p>Shall the fingerprint for host <b>{0}</b>""" 530 self.tr(
544 """ really be deleted?</p>""").format(host)) 531 """<p>Shall the fingerprint for host <b>{0}</b>"""
532 """ really be deleted?</p>"""
533 ).format(host),
534 )
545 if yes: 535 if yes:
546 self.fingerprintsList.takeTopLevelItem( 536 self.fingerprintsList.takeTopLevelItem(
547 self.fingerprintsList.indexOfTopLevelItem(itm)) 537 self.fingerprintsList.indexOfTopLevelItem(itm)
538 )
548 del itm 539 del itm
549 self.__finalizeFingerprintsColumns() 540 self.__finalizeFingerprintsColumns()
550 541
551 @pyqtSlot() 542 @pyqtSlot()
552 def on_fpEditButton_clicked(self): 543 def on_fpEditButton_clicked(self):
553 """ 544 """
554 Private slot to edit the current fingerprints item. 545 Private slot to edit the current fingerprints item.
555 """ 546 """
556 itm = self.fingerprintsList.currentItem() 547 itm = self.fingerprintsList.currentItem()
557 if itm is not None: 548 if itm is not None:
558 host = itm.text(0) 549 host = itm.text(0)
559 fingerprint = itm.text(1) 550 fingerprint = itm.text(1)
560 dlg = HgUserConfigHostFingerprintDialog(self, host, fingerprint, 551 dlg = HgUserConfigHostFingerprintDialog(
561 version=self.__version) 552 self, host, fingerprint, version=self.__version
553 )
562 if dlg.exec() == QDialog.DialogCode.Accepted: 554 if dlg.exec() == QDialog.DialogCode.Accepted:
563 host, fingerprint = dlg.getData() 555 host, fingerprint = dlg.getData()
564 itm.setText(0, host) 556 itm.setText(0, host)
565 itm.setText(1, fingerprint) 557 itm.setText(1, fingerprint)
566 self.__finalizeFingerprintsColumns() 558 self.__finalizeFingerprintsColumns()
567 self.fingerprintsList.scrollToItem(itm) 559 self.fingerprintsList.scrollToItem(itm)
568 560
569 def __finalizeFingerprintsColumns(self): 561 def __finalizeFingerprintsColumns(self):
570 """ 562 """
571 Private method to resize and sort the host fingerprints columns. 563 Private method to resize and sort the host fingerprints columns.
572 """ 564 """
573 for col in range(self.fingerprintsList.columnCount()): 565 for col in range(self.fingerprintsList.columnCount()):
574 self.fingerprintsList.resizeColumnToContents(col) 566 self.fingerprintsList.resizeColumnToContents(col)
575 self.fingerprintsList.sortItems(0, Qt.SortOrder.AscendingOrder) 567 self.fingerprintsList.sortItems(0, Qt.SortOrder.AscendingOrder)
576 568
577 def __updateFingerprintsButtons(self): 569 def __updateFingerprintsButtons(self):
578 """ 570 """
579 Private slot to update the host fingerprints edit buttons. 571 Private slot to update the host fingerprints edit buttons.
580 """ 572 """
581 enable = self.fingerprintsList.currentItem() is not None 573 enable = self.fingerprintsList.currentItem() is not None
582 self.fpDeleteButton.setEnabled(enable) 574 self.fpDeleteButton.setEnabled(enable)
583 self.fpEditButton.setEnabled(enable) 575 self.fpEditButton.setEnabled(enable)
584 576
585 ####################################################################### 577 #######################################################################
586 ## Methods and slots for the host minimum protocol handling below 578 ## Methods and slots for the host minimum protocol handling below
587 ####################################################################### 579 #######################################################################
588 580
589 def __clearMinimumProtocols(self): 581 def __clearMinimumProtocols(self):
590 """ 582 """
591 Private method to clear the minimum protocols from the hostsecurity 583 Private method to clear the minimum protocols from the hostsecurity
592 section. 584 section.
593 """ 585 """
594 if "hostsecurity" in self.__config: 586 if "hostsecurity" in self.__config:
595 for key in self.__config.options("hostsecurity"): 587 for key in self.__config.options("hostsecurity"):
596 if key.endswith(":minimumprotocol"): 588 if key.endswith(":minimumprotocol"):
597 self.__config.remove_option("hostsecurity", key) 589 self.__config.remove_option("hostsecurity", key)
598 590
599 def __assembleMinimumProtocols(self): 591 def __assembleMinimumProtocols(self):
600 """ 592 """
601 Private method to assemble a list of host minimum protocols. 593 Private method to assemble a list of host minimum protocols.
602 594
603 @return dictionary with list of minimum protocol per host 595 @return dictionary with list of minimum protocol per host
604 @rtype dict with str as key and str as value 596 @rtype dict with str as key and str as value
605 """ 597 """
606 minimumProtocols = {} 598 minimumProtocols = {}
607 for row in range(self.protocolsList.topLevelItemCount()): 599 for row in range(self.protocolsList.topLevelItemCount()):
608 itm = self.protocolsList.topLevelItem(row) 600 itm = self.protocolsList.topLevelItem(row)
609 host = itm.text(0) 601 host = itm.text(0)
610 minimumProtocol = itm.data(1, Qt.ItemDataRole.UserRole) 602 minimumProtocol = itm.data(1, Qt.ItemDataRole.UserRole)
611 minimumProtocols[host] = minimumProtocol 603 minimumProtocols[host] = minimumProtocol
612 return minimumProtocols 604 return minimumProtocols
613 605
614 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) 606 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
615 def on_protocolsList_currentItemChanged(self, current, previous): 607 def on_protocolsList_currentItemChanged(self, current, previous):
616 """ 608 """
617 Private slot handling a change of the current minimum protocol item. 609 Private slot handling a change of the current minimum protocol item.
618 610
619 @param current reference to the current item 611 @param current reference to the current item
620 @type QTreeWidgetItem 612 @type QTreeWidgetItem
621 @param previous reference to the previous current item 613 @param previous reference to the previous current item
622 @type QTreeWidgetItem 614 @type QTreeWidgetItem
623 """ 615 """
624 self.__updateProtocolsButtons() 616 self.__updateProtocolsButtons()
625 617
626 @pyqtSlot() 618 @pyqtSlot()
627 def on_protocolAddButton_clicked(self): 619 def on_protocolAddButton_clicked(self):
628 """ 620 """
629 Private slot to add a minimum protocol entry. 621 Private slot to add a minimum protocol entry.
630 """ 622 """
631 dlg = HgUserConfigHostMinimumProtocolDialog(self.__minimumProtocols, 623 dlg = HgUserConfigHostMinimumProtocolDialog(self.__minimumProtocols, self)
632 self)
633 if dlg.exec() == QDialog.DialogCode.Accepted: 624 if dlg.exec() == QDialog.DialogCode.Accepted:
634 host, protocol = dlg.getData() 625 host, protocol = dlg.getData()
635 itm = QTreeWidgetItem(self.protocolsList, [ 626 itm = QTreeWidgetItem(
636 host, 627 self.protocolsList, [host, self.__minimumProtocols[protocol]]
637 self.__minimumProtocols[protocol] 628 )
638 ])
639 itm.setData(1, Qt.ItemDataRole.UserRole, protocol) 629 itm.setData(1, Qt.ItemDataRole.UserRole, protocol)
640 self.__finalizeProtocolsColumns() 630 self.__finalizeProtocolsColumns()
641 self.protocolsList.setCurrentItem(itm) 631 self.protocolsList.setCurrentItem(itm)
642 self.protocolsList.scrollToItem(itm) 632 self.protocolsList.scrollToItem(itm)
643 633
644 @pyqtSlot() 634 @pyqtSlot()
645 def on_protocolDeleteButton_clicked(self): 635 def on_protocolDeleteButton_clicked(self):
646 """ 636 """
647 Private slot to delete the current minimum protocol item. 637 Private slot to delete the current minimum protocol item.
648 """ 638 """
650 if itm is not None: 640 if itm is not None:
651 host = itm.text(0) 641 host = itm.text(0)
652 yes = EricMessageBox.yesNo( 642 yes = EricMessageBox.yesNo(
653 self, 643 self,
654 self.tr("Delete Host Minimum Protocol"), 644 self.tr("Delete Host Minimum Protocol"),
655 self.tr("""<p>Shall the minimum protocol entry for host""" 645 self.tr(
656 """ <b>{0}</b> really be deleted?</p>""").format(host)) 646 """<p>Shall the minimum protocol entry for host"""
647 """ <b>{0}</b> really be deleted?</p>"""
648 ).format(host),
649 )
657 if yes: 650 if yes:
658 self.protocolsList.takeTopLevelItem( 651 self.protocolsList.takeTopLevelItem(
659 self.protocolsList.indexOfTopLevelItem(itm)) 652 self.protocolsList.indexOfTopLevelItem(itm)
653 )
660 del itm 654 del itm
661 self.__finalizeProtocolsColumns() 655 self.__finalizeProtocolsColumns()
662 656
663 @pyqtSlot() 657 @pyqtSlot()
664 def on_protocolEditButton_clicked(self): 658 def on_protocolEditButton_clicked(self):
665 """ 659 """
666 Private slot to edit the current minimum protocol item. 660 Private slot to edit the current minimum protocol item.
667 """ 661 """
668 itm = self.protocolsList.currentItem() 662 itm = self.protocolsList.currentItem()
669 if itm is not None: 663 if itm is not None:
670 host = itm.text(0) 664 host = itm.text(0)
671 protocol = itm.data(1, Qt.ItemDataRole.UserRole) 665 protocol = itm.data(1, Qt.ItemDataRole.UserRole)
672 dlg = HgUserConfigHostMinimumProtocolDialog( 666 dlg = HgUserConfigHostMinimumProtocolDialog(
673 self.__minimumProtocols, self, host, protocol) 667 self.__minimumProtocols, self, host, protocol
668 )
674 if dlg.exec() == QDialog.DialogCode.Accepted: 669 if dlg.exec() == QDialog.DialogCode.Accepted:
675 host, protocol = dlg.getData() 670 host, protocol = dlg.getData()
676 itm.setText(0, host) 671 itm.setText(0, host)
677 itm.setText(1, self.__minimumProtocols[protocol]) 672 itm.setText(1, self.__minimumProtocols[protocol])
678 itm.setData(1, Qt.ItemDataRole.UserRole, protocol) 673 itm.setData(1, Qt.ItemDataRole.UserRole, protocol)
679 self.__finalizeProtocolsColumns() 674 self.__finalizeProtocolsColumns()
680 self.protocolsList.scrollToItem(itm) 675 self.protocolsList.scrollToItem(itm)
681 676
682 def __finalizeProtocolsColumns(self): 677 def __finalizeProtocolsColumns(self):
683 """ 678 """
684 Private method to resize and sort the host fingerprints columns. 679 Private method to resize and sort the host fingerprints columns.
685 """ 680 """
686 for col in range(self.protocolsList.columnCount()): 681 for col in range(self.protocolsList.columnCount()):
687 self.protocolsList.resizeColumnToContents(col) 682 self.protocolsList.resizeColumnToContents(col)
688 self.protocolsList.sortItems(0, Qt.SortOrder.AscendingOrder) 683 self.protocolsList.sortItems(0, Qt.SortOrder.AscendingOrder)
689 684
690 def __updateProtocolsButtons(self): 685 def __updateProtocolsButtons(self):
691 """ 686 """
692 Private slot to update the host minimum protocol edit buttons. 687 Private slot to update the host minimum protocol edit buttons.
693 """ 688 """
694 enable = self.protocolsList.currentItem() is not None 689 enable = self.protocolsList.currentItem() is not None
695 self.protocolDeleteButton.setEnabled(enable) 690 self.protocolDeleteButton.setEnabled(enable)
696 self.protocolEditButton.setEnabled(enable) 691 self.protocolEditButton.setEnabled(enable)
697 692
698 ####################################################################### 693 #######################################################################
699 ## Slot to edit the user configuration in an editor below 694 ## Slot to edit the user configuration in an editor below
700 ####################################################################### 695 #######################################################################
701 696
702 @pyqtSlot() 697 @pyqtSlot()
703 def on_editorButton_clicked(self): 698 def on_editorButton_clicked(self):
704 """ 699 """
705 Private slot to open the user configuration file in a text editor. 700 Private slot to open the user configuration file in a text editor.
706 """ 701 """
707 from QScintilla.MiniEditor import MiniEditor 702 from QScintilla.MiniEditor import MiniEditor
703
708 cfgFile = getConfigPath() 704 cfgFile = getConfigPath()
709 705
710 yes = EricMessageBox.yesNo( 706 yes = EricMessageBox.yesNo(
711 self, 707 self,
712 self.tr("Edit User Configuration"), 708 self.tr("Edit User Configuration"),
713 self.tr("""You will loose all changes made in this dialog.""" 709 self.tr(
714 """ Shall the data be saved first?"""), 710 """You will loose all changes made in this dialog."""
711 """ Shall the data be saved first?"""
712 ),
715 icon=EricMessageBox.Warning, 713 icon=EricMessageBox.Warning,
716 yesDefault=True) 714 yesDefault=True,
715 )
717 if yes: 716 if yes:
718 self.writeUserConfig() 717 self.writeUserConfig()
719 718
720 self.__editor = MiniEditor(cfgFile, "Properties", self) 719 self.__editor = MiniEditor(cfgFile, "Properties", self)
721 self.__editor.setWindowModality(Qt.WindowModality.WindowModal) 720 self.__editor.setWindowModality(Qt.WindowModality.WindowModal)
722 self.__editor.installEventFilter(self) 721 self.__editor.installEventFilter(self)
723 self.__editor.show() 722 self.__editor.show()
724 723
725 def eventFilter(self, watched, event): 724 def eventFilter(self, watched, event):
726 """ 725 """
727 Public method called to filter the event queue. 726 Public method called to filter the event queue.
728 727
729 @param watched reference to the object being watched 728 @param watched reference to the object being watched
730 @type QObject 729 @type QObject
731 @param event event to be handled 730 @param event event to be handled
732 @type QEvent 731 @type QEvent
733 @return flag indicating, if we handled the event 732 @return flag indicating, if we handled the event
737 self.__editor.closeEvent(event) 736 self.__editor.closeEvent(event)
738 if event.isAccepted(): 737 if event.isAccepted():
739 self.__clearDialog() 738 self.__clearDialog()
740 self.readUserConfig() 739 self.readUserConfig()
741 return True 740 return True
742 741
743 return False 742 return False

eric ide

mercurial