forked from torinkwok/wxNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetPasswordDialog.cpp
More file actions
141 lines (118 loc) · 6.82 KB
/
Copy pathGetPasswordDialog.cpp
File metadata and controls
141 lines (118 loc) · 6.82 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
///:
/*****************************************************************************
** **
** .======. **
** | INRI | **
** | | **
** | | **
** .========' '========. **
** | _ xxxx _ | **
** | /_;-.__ / _\ _.-;_\ | **
** | `-._`'`_/'`.-' | **
** '========.`\ /`========' **
** | | / | **
** |/-.( | **
** |\_._\ | **
** | \ \`;| **
** | > |/| **
** | / // | **
** | |// | **
** | \(\ | **
** | `` | **
** | | **
** | | **
** | | **
** | | **
** \\ _ _\\| \// |//_ _ \// _ **
** ^ `^`^ ^`` `^ ^` ``^^` `^^` `^ `^ **
** **
** Copyright © 1997-2013 by Tong G. **
** ALL RIGHTS RESERVED. **
** **
****************************************************************************/
#include "wxNote_Gui/wxNote_Dialog/GetPasswordDialog.h"
#include "wxNote_Gui/wxNote_Dialog/CommonDialog.h"
#include "wxNote_Global.h"
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QCheckBox>
#include <QRegExp>
#include <QLayout>
#include <QValidator>
#include <QMessageBox>
#include <QDialogButtonBox>
//.._GetPasswordDialog类实现
/* 构造函数实现 */
_GetPasswordDialog::_GetPasswordDialog(QWidget *_Parent)
: QDialog(_Parent, Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint)
{
m_GetPasswordLabel = new QLabel(tr("请输入解锁密码(&I):"));
m_UnlockFailedLabel = new QLabel("<img src=\":/wxNote_Icons/passwordWrong.png\">"
"\t解锁失败!键入的密码不正确。");
m_UnlockFailedLabel->setHidden(true);
QRegExp _PasswordFormat("[A-Za-z0-9,./?_!@#$%^&*()-+=~`]{0,16}");
m_GetPasswordLineEdit = new QLineEdit;
m_GetPasswordLineEdit->setValidator(new QRegExpValidator(_PasswordFormat, this));
m_GetPasswordLineEdit->setEchoMode(QLineEdit::Password);
m_GetPasswordLabel->setBuddy(m_GetPasswordLineEdit);
m_VisiblePasswordCheckBox = new QCheckBox(tr("显示密码(&V)"));
connect(m_VisiblePasswordCheckBox, SIGNAL(toggled(bool)),
this, SLOT(_VisiblePasswordChangeSlot(bool)));
m_ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel);
m_ButtonBox->button(QDialogButtonBox::Ok)->setText(tr("好的"));
m_ButtonBox->button(QDialogButtonBox::Cancel)->setText(tr("离开"));
connect(m_ButtonBox, SIGNAL(accepted()), this, SLOT(_ValidatePassword()));
connect(m_ButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
QHBoxLayout* _CheckBoxLayout = new QHBoxLayout;
_CheckBoxLayout->addStretch();
_CheckBoxLayout->addWidget(m_VisiblePasswordCheckBox);
QVBoxLayout* _MainLayout = new QVBoxLayout;
_MainLayout->addWidget(m_GetPasswordLabel);
_MainLayout->addWidget(m_GetPasswordLineEdit);
_MainLayout->addWidget(m_UnlockFailedLabel);
_MainLayout->addLayout(_CheckBoxLayout);
_MainLayout->addStretch();
_MainLayout->addWidget(m_ButtonBox);
setLayout(_MainLayout);
setWindowTitle(tr("笔记解锁"));
setWindowIcon(QIcon(":/wxNote_Icons/notlock.png"));
setFont(wxNote::g_StandardFont);
setFixedSize(QSize(sizeHint().width() + 72, 155));
}
/////////////////////////////////////////////////////////////////////////
//..protected部分
/* _CheckPasswordWhenClickedOkSlot()槽实现 */
void _GetPasswordDialog::_VisiblePasswordChangeSlot(bool _IsVisibled)
{
m_GetPasswordLineEdit->setEchoMode(_IsVisibled ? QLineEdit::Normal
: QLineEdit::Password);
}
/* _ValidatePassword()槽实现 */
void _GetPasswordDialog::_ValidatePassword()
{
using namespace wxNote;
g_Settings.beginGroup("TextEditor");
QString _Password = g_Settings.value("NotePassWord").toString();
g_Settings.endGroup();
if (m_GetPasswordLineEdit->text() == _Password)
accept();
else
_SetFailedUnlockLabelHidden(false);
}
////////////////////////////////////////////////////////////////////////////
/***************************************************************************
** **
** _________ _______ **
** |___ ___| / ______ \ **
** | | _______ _______ _______ | / |_| **
** | | || || || || || || | | _ __ **
** | | || || || || || || | | |__ \ **
** | | || || || || || || | \_ _ __| | _ **
** |_| ||_____|| || || ||_____|| \________/ |_| **
** || **
** ||_____|| **
** **
***************************************************************************/
///:~