-
Notifications
You must be signed in to change notification settings - Fork 0
/
authinput.cpp
76 lines (65 loc) · 1.72 KB
/
authinput.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
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
#include "authinput.h"
#include <QFileDialog>
#include "openfile.h"
#include "log.h"
//AuthInput::AuthInput(QPlainTextEdit *loginsinp, QPlainTextEdit *passwordsinp)
//{
// this->logins_input = loginsinp;
// this->passwords_input = passwordsinp;
//}
AuthInput::AuthInput()
{
}
void AuthInput::addLogins()
{
QString loginstext = dialogGetContents("Load logins", "TXT file (*.txt)");
if(loginstext.length() <2){
return;
}
this->logins_input->appendPlainText(loginstext.replace(" ", ""));
Log::appendLogs("Logins loaded");
}
void AuthInput::addPasswords()
{
QString passwords = dialogGetContents("Load passwords","TXT file (*.txt)");
if(passwords.length() <2){
return;
}
this->passwords_input->appendPlainText(passwords.replace(" ", ""));
Log::appendLogs("Passwords loaded");
}
QStringList AuthInput::getLogins()
{
QStringList logins;
QStringList loginstemp = this->logins_input->toPlainText().split("\n");
for (int i = 0; i < loginstemp.length(); i++) {
if(AuthInput::isValid(loginstemp[i])){
logins.append(loginstemp[i]);
}
}
return logins;
}
QStringList AuthInput::getPasswords()
{
QStringList passwords;
QStringList passwordstemp = this->passwords_input->toPlainText().split("\n");
for (int i = 0; i < passwordstemp.length(); i++) {
if(AuthInput::isValid(passwordstemp[i])){
passwords.append(passwordstemp[i]);
}
}
passwords.append("");
return passwords;
}
bool AuthInput::isValid(QString text)
{
return text.length()>1 && text.length() < 33;
}
void AuthInput::eraseLogins()
{
this->logins_input->clear();
}
void AuthInput::erasePasswords()
{
this->passwords_input->clear();
}