|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2008 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the authentication dialog for the help browser. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtWidgets import QDialog, QStyle |
|
11 |
|
12 from .Ui_EricAuthenticationDialog import Ui_EricAuthenticationDialog |
|
13 |
|
14 |
|
15 # TODO: move to EricWidgets |
|
16 class EricAuthenticationDialog(QDialog, Ui_EricAuthenticationDialog): |
|
17 """ |
|
18 Class implementing the authentication dialog for the help browser. |
|
19 """ |
|
20 |
|
21 def __init__(self, info, username, showSave=False, saveIt=False, parent=None): |
|
22 """ |
|
23 Constructor |
|
24 |
|
25 @param info information to be shown |
|
26 @type str |
|
27 @param username username as supplied by subversion |
|
28 @type str |
|
29 @param showSave flag to indicate to show the save checkbox |
|
30 @type bool |
|
31 @param saveIt flag indicating the value for the save checkbox |
|
32 @type bool |
|
33 @param parent reference to the parent widget |
|
34 @type QWidget |
|
35 """ |
|
36 super().__init__(parent) |
|
37 self.setupUi(self) |
|
38 |
|
39 self.infoLabel.setText(info) |
|
40 self.usernameEdit.setText(username) |
|
41 self.saveCheckBox.setVisible(showSave) |
|
42 self.saveCheckBox.setChecked(saveIt) |
|
43 |
|
44 self.iconLabel.setText("") |
|
45 self.iconLabel.setPixmap( |
|
46 self.style() |
|
47 .standardIcon(QStyle.StandardPixmap.SP_MessageBoxQuestion) |
|
48 .pixmap(32, 32) |
|
49 ) |
|
50 |
|
51 msh = self.minimumSizeHint() |
|
52 self.resize(max(self.width(), msh.width()), msh.height()) |
|
53 |
|
54 def setData(self, username, password): |
|
55 """ |
|
56 Public method to set the login data. |
|
57 |
|
58 @param username username |
|
59 @type str |
|
60 @param password password |
|
61 @type str |
|
62 """ |
|
63 self.usernameEdit.setText(username) |
|
64 self.passwordEdit.setText(password) |
|
65 |
|
66 def getData(self): |
|
67 """ |
|
68 Public method to retrieve the login data. |
|
69 |
|
70 @return tuple containing the user name and password |
|
71 @rtype tuple of (str, str) |
|
72 """ |
|
73 return (self.usernameEdit.text(), self.passwordEdit.text()) |
|
74 |
|
75 def shallSave(self): |
|
76 """ |
|
77 Public method to check, if the login data shall be saved. |
|
78 |
|
79 @return flag indicating that the login data shall be saved |
|
80 @rtype bool |
|
81 """ |
|
82 return self.saveCheckBox.isChecked() |