MCPcopy Create free account
hub / github.com/PyQt5/PyQtClient / LoginDialog

Class LoginDialog

Widgets/Dialogs/LoginDialog.py:26–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26class LoginDialog(MoveDialog, TwinkleDialog, Ui_FormLoginDialog):
27
28 def __init__(self, *args, **kwargs):
29 super(LoginDialog, self).__init__(*args, **kwargs)
30 self.setupUi(self)
31 # 设置闪烁的目标控件
32 self.setTarget(self.widgetLogin)
33 # 关闭后自动销毁
34 self.setAttribute(Qt.WA_DeleteOnClose, True)
35 # 背景透明
36 self.setAttribute(Qt.WA_TranslucentBackground, True)
37 # 无边框
38 self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
39 # 加载鼠标样式
40 ThemeManager.loadCursor(self)
41 # 加载鼠标样式
42 ThemeManager.loadCursor(self.buttonHead, ThemeManager.CursorPointer)
43 # 是否正在登录
44 self._isLogin = False
45 Signals.loginErrored.connect(self.onLoginErrored)
46 Signals.loginSuccessed.connect(self.onLoginSuccessed)
47 QTimer.singleShot(100, self.initAccount)
48
49 def initAccount(self):
50 # 自动填充账号密码
51 self._accounts = Setting.value('accounts', {}, QVariant)
52 completer = QCompleter(self._accounts.keys(), self.lineEditAccount)
53 completer.setCaseSensitivity(Qt.CaseInsensitive)
54 # 在内部自动填充完成
55 completer.setCompletionMode(QCompleter.InlineCompletion)
56 # 设置objectName用于设置样式
57 # completer.popup().setObjectName('lineEditAccountAuto')
58 self.lineEditAccount.setCompleter(completer)
59
60 # 读取储存的账号密码
61 account = Setting.value('account', '', str)
62 self.lineEditAccount.setText(account)
63
64 def on_lineEditAccount_textChanged(self, account):
65 """输入框编辑完成信号,寻找头像文件是否存在
66 """
67 if account not in self._accounts: # 不存在
68 return
69 # 填充密码
70 try:
71 self.lineEditPassword.setText(
72 base64.b85decode(self._accounts[account][1].encode()).decode())
73 except Exception as e:
74 self.lineEditPassword.setText('')
75 AppLog.exception(e)
76 # 更新头像
77 path = os.path.join(Constants.ImageDir,
78 self._accounts[account][0]).replace('\\',
79 '/') + '.jpg'
80 if os.path.exists(path) and self.buttonHead.image != path:
81 # 更换头像
82 self.buttonHead.image = path
83

Callers 1

initLoginMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected