eric6/Plugins/VcsPlugins/vcsPySvn/SvnDialogMixin.py

changeset 7771
787a6b3f8c9f
parent 7759
51aa6c6b66f7
child 7923
91e843545d9a
equal deleted inserted replaced
7770:49f3377aebf1 7771:787a6b3f8c9f
6 """ 6 """
7 Module implementing a dialog mixin class providing common callback methods for 7 Module implementing a dialog mixin class providing common callback methods for
8 the pysvn client. 8 the pysvn client.
9 """ 9 """
10 10
11 from PyQt5.QtWidgets import QApplication, QDialog, QWidget
11 12
12 from PyQt5.QtCore import Qt 13 from E5Gui.E5OverrideCursor import E5OverridenCursor
13 from PyQt5.QtWidgets import QApplication, QDialog, QWidget
14 14
15 15
16 class SvnDialogMixin(object): 16 class SvnDialogMixin(object):
17 """ 17 """
18 Class implementing a dialog mixin providing common callback methods for 18 Class implementing a dialog mixin providing common callback methods for
61 by subversion, username and password contain the relevant data 61 by subversion, username and password contain the relevant data
62 as strings and save is a flag indicating, that username and 62 as strings and save is a flag indicating, that username and
63 password should be saved. 63 password should be saved.
64 """ 64 """
65 from .SvnLoginDialog import SvnLoginDialog 65 from .SvnLoginDialog import SvnLoginDialog
66 cursor = QApplication.overrideCursor() 66
67 if cursor is not None: 67 with E5OverridenCursor():
68 QApplication.restoreOverrideCursor() 68 parent = isinstance(self, QWidget) and self or None
69 parent = isinstance(self, QWidget) and self or None 69 dlg = SvnLoginDialog(realm, username, may_save, parent)
70 dlg = SvnLoginDialog(realm, username, may_save, parent) 70 res = dlg.exec()
71 res = dlg.exec() 71
72 if cursor is not None:
73 QApplication.setOverrideCursor(Qt.WaitCursor)
74 if res == QDialog.Accepted: 72 if res == QDialog.Accepted:
75 loginData = dlg.getData() 73 loginData = dlg.getData()
76 return (True, loginData[0], loginData[1], loginData[2]) 74 return (True, loginData[0], loginData[1], loginData[2])
77 else: 75 else:
78 return (False, "", "", False) 76 return (False, "", "", False)
88 acceptedFailures should indicate the accepted certificate failures 86 acceptedFailures should indicate the accepted certificate failures
89 and save should be True, if subversion should save the certificate. 87 and save should be True, if subversion should save the certificate.
90 """ 88 """
91 from E5Gui import E5MessageBox 89 from E5Gui import E5MessageBox
92 90
93 cursor = QApplication.overrideCursor() 91 with E5OverridenCursor():
94 if cursor is not None: 92 parent = isinstance(self, QWidget) and self or None
95 QApplication.restoreOverrideCursor() 93 msgBox = E5MessageBox.E5MessageBox(
96 parent = isinstance(self, QWidget) and self or None 94 E5MessageBox.Question,
97 msgBox = E5MessageBox.E5MessageBox( 95 self.tr("Subversion SSL Server Certificate"),
98 E5MessageBox.Question, 96 self.tr("""<p>Accept the following SSL certificate?</p>"""
99 self.tr("Subversion SSL Server Certificate"), 97 """<table>"""
100 self.tr("""<p>Accept the following SSL certificate?</p>""" 98 """<tr><td>Realm:</td><td>{0}</td></tr>"""
101 """<table>""" 99 """<tr><td>Hostname:</td><td>{1}</td></tr>"""
102 """<tr><td>Realm:</td><td>{0}</td></tr>""" 100 """<tr><td>Fingerprint:</td><td>{2}</td></tr>"""
103 """<tr><td>Hostname:</td><td>{1}</td></tr>""" 101 """<tr><td>Valid from:</td><td>{3}</td></tr>"""
104 """<tr><td>Fingerprint:</td><td>{2}</td></tr>""" 102 """<tr><td>Valid until:</td><td>{4}</td></tr>"""
105 """<tr><td>Valid from:</td><td>{3}</td></tr>""" 103 """<tr><td>Issuer name:</td><td>{5}</td></tr>"""
106 """<tr><td>Valid until:</td><td>{4}</td></tr>""" 104 """</table>""")
107 """<tr><td>Issuer name:</td><td>{5}</td></tr>""" 105 .format(trust_dict["realm"],
108 """</table>""") 106 trust_dict["hostname"],
109 .format(trust_dict["realm"], 107 trust_dict["finger_print"],
110 trust_dict["hostname"], 108 trust_dict["valid_from"],
111 trust_dict["finger_print"], 109 trust_dict["valid_until"],
112 trust_dict["valid_from"], 110 trust_dict["issuer_dname"]),
113 trust_dict["valid_until"], 111 modal=True, parent=parent)
114 trust_dict["issuer_dname"]), 112 permButton = msgBox.addButton(self.tr("&Permanent accept"),
115 modal=True, parent=parent) 113 E5MessageBox.AcceptRole)
116 permButton = msgBox.addButton(self.tr("&Permanent accept"), 114 tempButton = msgBox.addButton(self.tr("&Temporary accept"),
117 E5MessageBox.AcceptRole) 115 E5MessageBox.AcceptRole)
118 tempButton = msgBox.addButton(self.tr("&Temporary accept"), 116 msgBox.addButton(self.tr("&Reject"), E5MessageBox.RejectRole)
119 E5MessageBox.AcceptRole) 117 msgBox.exec()
120 msgBox.addButton(self.tr("&Reject"), E5MessageBox.RejectRole) 118
121 msgBox.exec()
122 if cursor is not None:
123 QApplication.setOverrideCursor(Qt.WaitCursor)
124 if msgBox.clickedButton() == permButton: 119 if msgBox.clickedButton() == permButton:
125 return (True, trust_dict["failures"], True) 120 return (True, trust_dict["failures"], True)
126 elif msgBox.clickedButton() == tempButton: 121 elif msgBox.clickedButton() == tempButton:
127 return (True, trust_dict["failures"], False) 122 return (True, trust_dict["failures"], False)
128 else: 123 else:

eric ide

mercurial