-
Notifications
You must be signed in to change notification settings - Fork 0
/
loginwindow.cpp
48 lines (40 loc) · 1.31 KB
/
loginwindow.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
#include "loginwindow.h"
#include "ui_loginwindow.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "userdatabasemanager.h"
#include <QDebug>
LoginWindow::LoginWindow(QWidget *parent) : QWidget(parent), ui(new Ui::LoginWindow)
{
ui->setupUi(this);
connect(ui->userNameLineEdit, SIGNAL(returnPressed()), ui->loginButton, SIGNAL(clicked()));
connect(ui->passWordLineEdit, SIGNAL(returnPressed()), ui->loginButton, SIGNAL(clicked()));
}
LoginWindow::~LoginWindow()
{
delete ui;
}
void LoginWindow::on_loginSingupButton_clicked()
{
emit signUpSignal();
}
void LoginWindow::on_loginButton_clicked()
{
userNameEntry = ui->userNameLineEdit->text();
passWordEntry = ui->passWordLineEdit->text();
loginQuery = loginDataBaseManager.userDataBaseRetrieve(userNameEntry, passWordEntry);
qDebug() << loginQuery.executedQuery();
if(loginQuery.first()){
QString userIdString = loginQuery.value(0).toString();
int id = userIdString.toInt();
userIdString.number(id);
qDebug() << "LoginWindow::on_loginButton_clicked - ID: " + userIdString;
emit correctUser(id);
}else{
ui->outPutLabel->setText(loginDataBaseManager.NOT_PERSON_FOUND);
}
}
void LoginWindow::on_loginRemoveButton_clicked()
{
loginDataBaseManager.userDatabaseDeleteAll();
}