-
Notifications
You must be signed in to change notification settings - Fork 7
/
credentials_dialog.py
83 lines (63 loc) · 2.25 KB
/
credentials_dialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"""
/**
* Copyright (C) 2017 Oslandia <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
"""
# -*- coding: utf-8 -*-
import os
from PyQt5 import uic
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QDialog
FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'credentials_dialog.ui'))
# Display a dialog for user credentials input.
class CredentialsDialog(QDialog, FORM_CLASS):
def setErrorText(self, text):
self.errorText.setText(text)
def setDomainText(self, text):
self.domainText.setText(text)
def setUserText(self, text):
self.userText.setText(text)
def setPasswordText(self, text):
self.passwordText.setText(text)
def getUserText(self):
return self.userText.text()
def getPasswordText(self):
return self.passwordText.text()
def hasUserCanceled(self):
return self.userHasCancel
#
# Internal members.
#
userHasCancel = False
def __init__(self, parent):
super(CredentialsDialog, self).__init__(parent)
self.setupUi(self)
self.retryButton.clicked.connect(self.onValidation)
self.cancelButton.clicked.connect(self.onCancel)
def onValidation(self):
self.close()
self.userHasCancel = False
def onCancel(self):
self.userHasCancel = True
self.close()
def closeEvent(self, event):
self.userHasCancel = True
def keyPressEvent(self, event):
if not event.key() == Qt.Key_Escape:
super(QDialog, self).keyPressEvent(event)
else:
self.onCancel()