-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.cpp
73 lines (66 loc) · 2.03 KB
/
login.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
#include "login.h"
login::login(QWidget *parent)
: QWidget(parent)
{
this->setWindowTitle("Login");
this->resize(300,150);
user = new QLabel("insert your username :",this);
user->setGeometry(10,20,120,20);
pass = new QLabel("insert your password :",this);
pass->setGeometry(10,50,120,20);
inuser = new QLineEdit(this);
inuser->setGeometry(130,20,150,20);
inpass = new QLineEdit(this);
inpass->setGeometry(130,50,150,20);
inpass->setEchoMode(QLineEdit :: Password);
showpass = new QCheckBox("show password",this);
showpass->setGeometry(130,80,100,15);
connect(showpass,SIGNAL(stateChanged(int)),this,SLOT(showpassword()));
ok = new QPushButton("login",this);
ok->setGeometry(125,110,50,25);
reg = new QPushButton("quit",this);
reg->setGeometry(180,110,50,25);
connect(reg,SIGNAL(clicked()),this,SLOT(close()));
connect(ok,SIGNAL(clicked()),this,SLOT(checkpass()));
/*if(inuser->text() == "nazem" && inpass->text() == "1234"){
connect(ok,SIGNAL(clicked()),this,SLOT(open_npage()));
}
else if(inuser->text() == "teacher" && inpass->text() == "12345"){
connect(ok,SIGNAL(clicked()),this,SLOT(open_tpage()));
}*/
}
void login :: checkpass()
{
message = new QMessageBox;
if(inuser->text() == "nazem" && inpass->text() == "1234"){
message->warning(this,"Entered","you are logged in as Provost");
this->n.show();
this->close();
}
else if(inuser->text() == "teacher" && inpass->text() == "12345"){
message->warning(this,"Entered","you are logged in as Teacher");
this->t.show();
this->close();
}
else{
message->warning(this,"warning","the username or password is incorrect");
}
}
void login :: showpassword()
{
inpass->setEchoMode(showpass->checkState()==Qt::Checked ? QLineEdit::Normal : QLineEdit::Password);
}
/*void login :: open_tpage()
{
this->t.show();
this->close();
}
void login :: open_npage()
{
this->n.show();
this->close();
}
*/
login::~login()
{
}