-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
102 lines (81 loc) · 2.09 KB
/
mainwindow.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
#include "mainwindow.h"
#include"ui_mainwindow.h"
#include<QGraphicsOpacityEffect>
#include<QPropertyAnimation>
#include<QMessageBox>
#include"datas.h"
using namespace std;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowTitle("ورود");
setFixedSize(701,481);
fadeitem(ui->logo,800,0,1);
fadeitem(ui->codana,1200,0,1);
fadeitem(ui->bank,1600,0,1);
ui->nousername->hide();
ui->nopassword->hide();
datas::getReady();
qDebug()<< "salam";
}
MainWindow::~MainWindow()
{
qDebug()<< "khodafez";
datas::writeToFile();
delete ui;
}
void MainWindow::fadeitem(QGraphicsView* obj,int du,int start,int end)
{
QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(this);
obj->setGraphicsEffect(eff);
QPropertyAnimation *a = new QPropertyAnimation(eff,"opacity");
a->setDuration(du);
a->setStartValue(start);
a->setEndValue(end);
a->setEasingCurve(QEasingCurve::InBack);
a->start(QPropertyAnimation::DeleteWhenStopped);
}
void MainWindow::setAdmin(admin& _admin)
{
myadmin=_admin;
}
void MainWindow::setUser(user& _user)
{
myuser=_user;
}
void MainWindow::clearfields()
{
ui->passwordled->clear();
ui->usernameled->clear();
}
void MainWindow::on_loginpbn_clicked()
{
ui->nousername->hide();
ui->nopassword->hide();
if(ui->usernameled->text()=="")
{
ui->nousername->show();
}
else if(ui->passwordled->text()=="")
{
ui->nopassword->show();
}
else
{
int status=datas::login(ui->usernameled->text(),ui->passwordled->text(),this);
if(!status)
{
QMessageBox::information(this,"خطا در ورود","نام کاربری یا رمز عبور اشتباه می باشد",QMessageBox::Ok,QMessageBox::Ok);
}
else if(status==1)
{
this->hide();
}
else if(status==2)
{
this->hide();
}
}
}