eric6/Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostFingerprintDialog.py

Tue, 02 Mar 2021 17:17:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 02 Mar 2021 17:17:09 +0100
changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
permissions
-rw-r--r--

Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.

5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to edit a host fingerprint.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
10 from PyQt5.QtCore import pyqtSlot
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 from .Ui_HgUserConfigHostFingerprintDialog import (
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 Ui_HgUserConfigHostFingerprintDialog
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 )
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class HgUserConfigHostFingerprintDialog(
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 QDialog, Ui_HgUserConfigHostFingerprintDialog):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Class implementing a dialog to edit a host fingerprint.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
23 supportedHashes = ("sha1", "sha256", "sha512")
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
24 fingerprintLength = {
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
25 "sha1": 40,
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
26 "sha256": 64,
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
27 "sha512": 128,
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
28 }
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
29
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
30 def __init__(self, parent=None, host="", fingerprint="",
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
31 version=(0, 0, 0)):
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 Constructor
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param parent reference to the parent widget
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @type QWidget
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @param host host name
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @type str
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @param fingerprint fingerprint for the host
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @type str
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
41 @param version Mercurial version info
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
42 @type tuple of three integers
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 super(HgUserConfigHostFingerprintDialog, self).__init__(parent)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.setupUi(self)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
47 self.__version = version
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
48
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
49 self.hashComboBox.addItem("")
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
50 self.hashComboBox.addItems(
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
51 HgUserConfigHostFingerprintDialog.supportedHashes)
5295
87f1f8056814 Fixed a few issues in the new code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5292
diff changeset
52 if self.__version < (3, 9, 0):
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
53 self.hashLabel.setEnabled(False)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
54 self.hashComboBox.setEnabled(False)
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
55 hashType = "sha1"
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
56 else:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
57 if fingerprint and fingerprint.startswith("sha"):
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
58 hashType, fingerprint = fingerprint.split(":", 1)
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
59 else:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
60 hashType = ""
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
61
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
62 index = self.hashComboBox.findText(hashType)
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
63 self.hashComboBox.setCurrentIndex(index)
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.hostEdit.setText(host)
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.fingerprintEdit.setText(fingerprint)
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
66
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
67 msh = self.minimumSizeHint()
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
68 self.resize(max(self.width(), msh.width()), msh.height())
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
69
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
70 self.__updateOkButton()
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
71
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
72 def __updateOkButton(self):
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
73 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
74 Private method to update the status of the Ok button.
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
75 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
76 enabled = (
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
77 bool(self.hostEdit.text()) and
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
78 bool(self.fingerprintEdit.text())
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
79 )
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
80 if self.__version >= (3, 9, 0):
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
81 hashType = self.hashComboBox.currentText()
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
82 enabled &= bool(hashType)
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
83 if hashType:
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
84 enabled &= (
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
85 len(self.fingerprintEdit.text().replace(":", "")) ==
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
86 HgUserConfigHostFingerprintDialog.fingerprintLength[
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
87 hashType])
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
88
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
89 self.buttonBox.button(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
90 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
91
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
92 @pyqtSlot(str)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
93 def on_hostEdit_textChanged(self, txt):
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
94 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
95 Private slot to handle changes of the host edit.
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
96
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
97 @param txt current text
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
98 @type str
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
99 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
100 self.__updateOkButton()
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
101
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
102 @pyqtSlot(int)
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
103 def on_hashComboBox_currentIndexChanged(self, index):
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
104 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
105 Private slot to handle changes of the hash combo.
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
106
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
107 @param index current index
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
108 @type int
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
109 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
110 self.__updateOkButton()
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
111
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
112 @pyqtSlot(str)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
113 def on_fingerprintEdit_textChanged(self, txt):
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
114 """
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
115 Private slot to handle changes of the fingerprint edit.
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
116
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
117 @param txt current text
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
118 @type str
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
119 """
5441
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
120 if txt != txt.strip():
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
121 # get rid of whitespace
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
122 txt = txt.strip()
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
123 self.fingerprintEdit.setText(txt)
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
124
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
125 if txt.startswith(tuple(
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
126 h + ":" for h in
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5441
diff changeset
127 HgUserConfigHostFingerprintDialog.supportedHashes)):
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
128 parts = txt.split(":", 1)
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
129 if len(parts) == 2:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
130 self.fingerprintEdit.setText(parts[1])
5441
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
131 hashIndex = self.hashComboBox.findText(parts[0].strip())
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
132 if hashIndex > -1:
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
133 self.hashComboBox.setCurrentIndex(hashIndex)
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
134
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
135 self.__updateOkButton()
5264
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 def getData(self):
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 Public method to retrieve the data.
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 @return tuple containig the host name and the fingerprint
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 @rtype tuple of two str
8bc23ecb4ea3 Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 """
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
144 if self.__version < (3, 9, 0):
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
145 fingerprint = self.fingerprintEdit.text()
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
146 else:
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
147 fingerprint = "{0}:{1}".format(
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
148 self.hashComboBox.currentText(),
5441
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
149 self.fingerprintEdit.text().strip()
5292
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
150 )
ac8b476ba122 Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5264
diff changeset
151
5441
cd5343be7d72 Some little enhancements for the Mercurial host fingerprint dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
152 return self.hostEdit.text().strip(), fingerprint

eric ide

mercurial