-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogonmenu.cpp
181 lines (112 loc) · 4.55 KB
/
logonmenu.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include "logonmenu.h"
#include "ui_logonmenu.h"
LogonMenu::LogonMenu(QWidget *parent) :
QDialog(parent),
ui(new Ui::LogonMenu)
{
ui->setupUi(this);
load_main_settings();
}
LogonMenu::~LogonMenu()
{
delete ui;
}
//All functions are implemented below...
void LogonMenu::on_LoginButton_clicked() // enter in the main menu if the filled information is correct
{
start_rubik();
check_login();
}
void LogonMenu::load_main_settings() // load main settings for this dialog
{
this->setWindowTitle("Вписване в ПГЕЕ Бургас");
this->setFixedSize(this->width(),this->height());
this->setWindowIcon(QIcon(QPixmap(":/Icons/MainResources/PGEE_Control_Version.png")));
ui->UsernameLine->setMaxLength(16);
ui->PasswordLine->setMaxLength(16);
connect(ui->CloseButton,SIGNAL(clicked()),this,SLOT(close()));
setMask((new QPixmap(":/Images/MainResources/FinalPadlock.png"))->mask());
newPalette = new QPalette();
newPalette->setBrush(QPalette::Background,QBrush(QPixmap(":/Images/MainResources/FinalPadlock.png")));
setPalette(*newPalette);
}
void LogonMenu::check_login() // chech login if it is successful or not
{
username = ui->UsernameLine->text();
password = ui->PasswordLine->text();
if(username == "1" && password == "2"){
MainWindow *window1 = new MainWindow(this);
ui->UsernameLine->setEnabled(false);
ui->PasswordLine->setEnabled(false);
ui->LoginButton->setEnabled(false);
window1->show();
}
else{
QMessageBox::critical(this, "Грешно въведена информация", "Грещно въведено потребителско име или парола!");
ui->UsernameLine->clear();
ui->PasswordLine->clear();
}
}
void LogonMenu::start_rubik() // start rubiks cube animation
{
for(int i = 0; i <= 35; i++)
{
QString string = ":/rubik/MainResources/rubiks/tumble_cube_slow-.png";
string.insert(46,QString::number(i));
QApplication::setOverrideCursor(QCursor(QPixmap(string)));
Sleep(20);
}
for(int i = 0; i <= 35; i++)
{
QApplication::restoreOverrideCursor();
}
}
void LogonMenu::mouseMoveEvent(QMouseEvent *event) // this makes available the movement of the padlock
{
if ( event->buttons() & Qt::LeftButton )
{
move( event->globalPos() - dragPosition );
event->accept();
}
}
void LogonMenu::mousePressEvent(QMouseEvent *event) // this makes available the movement of the padlock with left button
{
if ( event->button() == Qt::LeftButton )
{
dragPosition = event->globalPos() - frameGeometry().topLeft();
event->accept();
}
}
void LogonMenu::on_UsernameLine_textChanged(const QString &arg1) // real time check of the login information and play sounds and animation
{
if(ui->UsernameLine->text() == "1" && ui->PasswordLine->text() == "2")
{
setMask((new QPixmap(":/Images/MainResources/FinalPadlock2.png"))->mask());
newPalette->setBrush(QPalette::Background,QBrush(QPixmap(":/Images/MainResources/FinalPadlock2.png")));
setPalette(*newPalette);
padlockSound->play(":/sounds/MainResources/door-lock-1.wav");
}
else
{
setMask((new QPixmap(":/Images/MainResources/FinalPadlock.png"))->mask());
newPalette->setBrush(QPalette::Background,QBrush(QPixmap(":/Images/MainResources/FinalPadlock.png")));
setPalette(*newPalette);
}
}
void LogonMenu::on_PasswordLine_textChanged(const QString &arg1) // real time check of the login information and play sounds and animation
{
if(ui->UsernameLine->text() == "1" && ui->PasswordLine->text() == "2")
{
setMask((new QPixmap(":/Images/MainResources/FinalPadlock2.png"))->mask());
newPalette->setBrush(QPalette::Background,QBrush(QPixmap(":/Images/MainResources/FinalPadlock2.png")));
setPalette(*newPalette);
padlockSound->play(":/sounds/MainResources/door-lock-1.wav");
}
else
{
setMask((new QPixmap(":/Images/MainResources/FinalPadlock.png"))->mask());
newPalette->setBrush(QPalette::Background,QBrush(QPixmap(":/Images/MainResources/FinalPadlock.png")));
setPalette(*newPalette);
padlockSound->play(":/sounds/MainResources/door-lock-2.wav");
}
}