43 |
43 |
44 self.__version = version |
44 self.__version = version |
45 |
45 |
46 self.hashComboBox.addItem("") |
46 self.hashComboBox.addItem("") |
47 self.hashComboBox.addItems(HgUserConfigHostFingerprintDialog.supportedHashes) |
47 self.hashComboBox.addItems(HgUserConfigHostFingerprintDialog.supportedHashes) |
48 if self.__version < (3, 9, 0): |
48 if fingerprint and fingerprint.startswith("sha"): |
49 self.hashLabel.setEnabled(False) |
49 hashType, fingerprint = fingerprint.split(":", 1) |
50 self.hashComboBox.setEnabled(False) |
|
51 hashType = "sha1" |
|
52 else: |
50 else: |
53 if fingerprint and fingerprint.startswith("sha"): |
51 hashType = "" |
54 hashType, fingerprint = fingerprint.split(":", 1) |
|
55 else: |
|
56 hashType = "" |
|
57 |
52 |
58 index = self.hashComboBox.findText(hashType) |
53 index = self.hashComboBox.findText(hashType) |
59 self.hashComboBox.setCurrentIndex(index) |
54 self.hashComboBox.setCurrentIndex(index) |
60 self.hostEdit.setText(host) |
55 self.hostEdit.setText(host) |
61 self.fingerprintEdit.setText(fingerprint) |
56 self.fingerprintEdit.setText(fingerprint) |
68 def __updateOkButton(self): |
63 def __updateOkButton(self): |
69 """ |
64 """ |
70 Private method to update the status of the Ok button. |
65 Private method to update the status of the Ok button. |
71 """ |
66 """ |
72 enabled = bool(self.hostEdit.text()) and bool(self.fingerprintEdit.text()) |
67 enabled = bool(self.hostEdit.text()) and bool(self.fingerprintEdit.text()) |
73 if self.__version >= (3, 9, 0): |
68 |
74 hashType = self.hashComboBox.currentText() |
69 hashType = self.hashComboBox.currentText() |
75 enabled &= bool(hashType) |
70 enabled &= bool(hashType) |
76 if hashType: |
71 if hashType: |
77 enabled &= ( |
72 enabled &= ( |
78 len(self.fingerprintEdit.text().replace(":", "")) |
73 len(self.fingerprintEdit.text().replace(":", "")) |
79 == HgUserConfigHostFingerprintDialog.fingerprintLength[hashType] |
74 == HgUserConfigHostFingerprintDialog.fingerprintLength[hashType] |
80 ) |
75 ) |
81 |
76 |
82 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
77 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
83 |
78 |
84 @pyqtSlot(str) |
79 @pyqtSlot(str) |
85 def on_hostEdit_textChanged(self, txt): |
80 def on_hostEdit_textChanged(self, txt): |
131 Public method to retrieve the data. |
126 Public method to retrieve the data. |
132 |
127 |
133 @return tuple containig the host name and the fingerprint |
128 @return tuple containig the host name and the fingerprint |
134 @rtype tuple of two str |
129 @rtype tuple of two str |
135 """ |
130 """ |
136 fingerprint = ( |
131 fingerprint = "{0}:{1}".format( |
137 self.fingerprintEdit.text() |
132 self.hashComboBox.currentText(), self.fingerprintEdit.text().strip() |
138 if self.__version < (3, 9, 0) |
|
139 else "{0}:{1}".format( |
|
140 self.hashComboBox.currentText(), self.fingerprintEdit.text().strip() |
|
141 ) |
|
142 ) |
133 ) |
143 |
134 |
144 return self.hostEdit.text().strip(), fingerprint |
135 return self.hostEdit.text().strip(), fingerprint |