1 | #include "sistema.h" |
---|
2 | #include "ui_sistema.h" |
---|
3 | #include <QDebug> |
---|
4 | #include "QMessageBox" |
---|
5 | #include "criptosistemas.h" |
---|
6 | |
---|
7 | Sistema::Sistema(QWidget *parent) : |
---|
8 | QMainWindow(parent), |
---|
9 | ui(new Ui::Sistema) |
---|
10 | { |
---|
11 | ui->setupUi(this); |
---|
12 | setWindowTitle("**** Criptosistema ****"); |
---|
13 | |
---|
14 | setWindowFlags(Qt::Window|Qt::MSWindowsFixedSizeDialogHint|Qt::WindowMinimizeButtonHint); |
---|
15 | //this->ui->pass->placeholderText(); |
---|
16 | |
---|
17 | connect(ui->pushButton_2,SIGNAL(clicked()),this,SLOT(Autenticate())); |
---|
18 | |
---|
19 | } |
---|
20 | |
---|
21 | Sistema::~Sistema() |
---|
22 | { |
---|
23 | delete ui; |
---|
24 | } |
---|
25 | |
---|
26 | void Sistema::Autenticate() |
---|
27 | { |
---|
28 | |
---|
29 | QString user = ui->user->text(); |
---|
30 | QString pass = ui->pass->text(); |
---|
31 | |
---|
32 | qDebug() << user; |
---|
33 | qDebug() << pass; |
---|
34 | |
---|
35 | //bool ok = user == "admin" && pass == "123" ? true: false; |
---|
36 | |
---|
37 | if (user == ""){ |
---|
38 | |
---|
39 | QString style = "QLabel{ color: #DF0101; font-size: 11px; font-style: italic; margin-left: 10px; }"; |
---|
40 | this->ui->label_6->setText("Este campo es obigatorio"); |
---|
41 | ui->label_6->setStyleSheet(style); |
---|
42 | |
---|
43 | if (pass != "") { |
---|
44 | |
---|
45 | this->ui->label_7->setText(""); |
---|
46 | |
---|
47 | QString stylee = "QLabel{ background-color: #fffff; }"; |
---|
48 | this->ui->label_8->setText(""); |
---|
49 | ui->label_8->setStyleSheet(stylee); |
---|
50 | } |
---|
51 | } |
---|
52 | if (pass == ""){ |
---|
53 | |
---|
54 | QString style = "QLabel{ color: #DF0101; font-size: 11px; font-style: italic; margin-left: 10px; }"; |
---|
55 | this->ui->label_7->setText("Este campo es obigatorio"); |
---|
56 | ui->label_7->setStyleSheet(style); |
---|
57 | |
---|
58 | if (user != "") { |
---|
59 | this->ui->label_6->setText(""); |
---|
60 | |
---|
61 | QString stylee = "QLabel{ background-color: #fffff; }"; |
---|
62 | this->ui->label_8->setText(""); |
---|
63 | ui->label_8->setStyleSheet(stylee); |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | if (user != "" && pass != ""){ |
---|
68 | |
---|
69 | if (user == "admin" && pass == "123"){ |
---|
70 | CriptoSistemas *app = new CriptoSistemas; |
---|
71 | app->show(); |
---|
72 | close(); |
---|
73 | } |
---|
74 | else{ |
---|
75 | |
---|
76 | QString style = "QLabel{ background-color: #FCDFDF; font-size: 13px; font-style: italic; margin-left: 10px; }"; |
---|
77 | this->ui->label_8->setText("El usuario no es válido"); |
---|
78 | this->ui->label_7->setText(""); |
---|
79 | this->ui->label_6->setText(""); |
---|
80 | ui->label_8->setStyleSheet(style); |
---|
81 | } |
---|
82 | } |
---|
83 | } |
---|