-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpasswordview.cpp
31 lines (29 loc) · 943 Bytes
/
passwordview.cpp
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
#include "passwordview.h"
#include <QSizePolicy>
#include <QFontMetrics>
#include <QStringList>
PasswordView::PasswordView(QWidget *parent) : QLabel(parent)
{
setAlignment(Qt::AlignCenter);
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
setTextInteractionFlags(Qt::TextSelectableByMouse);
setFrameShape(QFrame::Panel);
setFrameShadow(QFrame::Sunken);
}
void PasswordView::displayPassword(const Password &password)
{
if (password.size() == 0) {
setText("libsodium 初始化失败\n"
"无法生成安全的密码……");
return;
}
QStringList codeList, zhList;
for (auto iter = password.begin(); iter != password.end(); ++iter) {
codeList.append(iter->first);
zhList.append(iter->second);
}
setText(codeList.join("") + "\n" +
codeList.join(" ") + "\n" +
codeList.join("-") + "\n" +
zhList.join("-"));
}