eric6/E5Network/E5SslCertificateSelectionDialog.py

changeset 7253
50dbe65a1334
parent 7229
53054eb5b15a
child 7360
9190402e4505
equal deleted inserted replaced
7252:c5e3705073eb 7253:50dbe65a1334
13 try: 13 try:
14 from PyQt5.QtNetwork import QSslCertificate 14 from PyQt5.QtNetwork import QSslCertificate
15 except ImportError: 15 except ImportError:
16 pass 16 pass
17 17
18 from .Ui_E5SslCertificateSelectionDialog import \ 18 from .Ui_E5SslCertificateSelectionDialog import (
19 Ui_E5SslCertificateSelectionDialog 19 Ui_E5SslCertificateSelectionDialog
20 )
20 21
21 import Utilities 22 import Utilities
22 import UI.PixmapCache 23 import UI.PixmapCache
23 24
24 25
98 @pyqtSlot() 99 @pyqtSlot()
99 def on_certificatesTree_itemSelectionChanged(self): 100 def on_certificatesTree_itemSelectionChanged(self):
100 """ 101 """
101 Private slot to handle the selection of an item. 102 Private slot to handle the selection of an item.
102 """ 103 """
103 enable = len(self.certificatesTree.selectedItems()) > 0 and \ 104 enable = (
105 len(self.certificatesTree.selectedItems()) > 0 and
104 self.certificatesTree.selectedItems()[0].parent() is not None 106 self.certificatesTree.selectedItems()[0].parent() is not None
107 )
105 self.buttonBox.button(QDialogButtonBox.OK).setEnabled(enable) 108 self.buttonBox.button(QDialogButtonBox.OK).setEnabled(enable)
106 self.viewButton.setEnabled(enable) 109 self.viewButton.setEnabled(enable)
107 110
108 @pyqtSlot() 111 @pyqtSlot()
109 def on_viewButton_clicked(self): 112 def on_viewButton_clicked(self):
110 """ 113 """
111 Private slot to show data of the selected certificate. 114 Private slot to show data of the selected certificate.
112 """ 115 """
113 try: 116 try:
114 from E5Network.E5SslCertificatesInfoDialog import \ 117 from E5Network.E5SslCertificatesInfoDialog import (
115 E5SslCertificatesInfoDialog 118 E5SslCertificatesInfoDialog
119 )
116 cert = QSslCertificate.fromData( 120 cert = QSslCertificate.fromData(
117 self.certificatesTree.selectedItems()[0].data( 121 self.certificatesTree.selectedItems()[0].data(
118 0, self.CertRole)) 122 0, self.CertRole))
119 dlg = E5SslCertificatesInfoDialog(cert, self) 123 dlg = E5SslCertificatesInfoDialog(cert, self)
120 dlg.exec_() 124 dlg.exec_()
126 Public method to get the selected certificate. 130 Public method to get the selected certificate.
127 131
128 @return selected certificate 132 @return selected certificate
129 @rtype QSslCertificate 133 @rtype QSslCertificate
130 """ 134 """
131 valid = len(self.certificatesTree.selectedItems()) > 0 and \ 135 valid = (
136 len(self.certificatesTree.selectedItems()) > 0 and
132 self.certificatesTree.selectedItems()[0].parent() is not None 137 self.certificatesTree.selectedItems()[0].parent() is not None
138 )
133 139
134 if valid: 140 if valid:
135 certificate = QSslCertificate.fromData( 141 certificate = QSslCertificate.fromData(
136 self.certificatesTree.selectedItems()[0].data( 142 self.certificatesTree.selectedItems()[0].data(
137 0, self.CertRole)) 143 0, self.CertRole))

eric ide

mercurial