/
mainwindow.cpp
159 lines (133 loc) · 4.03 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
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include"bai1.h"
#include"bai2.h"
#include"bai3.h"
#include<QString>
#include<QMessageBox>
#include<QDebug>
#include<QTimer>
#include<QInputDialog>
#include<QMovie>
#include<QPixmap>
bool test=false;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->pushButton1->setAutoFillBackground(true);
ui->pushButton_2->setAutoFillBackground(true);
ui->pushButton_3->setAutoFillBackground(true);
ui->pushButton1->setStyleSheet("background-color: rgb(252,218,213);color: rgb(223,0,41);");
ui->pushButton_2->setStyleSheet("background-color: rgb(252,218,213);color: rgb(223,0,41);");
ui->pushButton_3->setStyleSheet("background-color: rgb(252,218,213);color: rgb(223,0,41);");
setWindowTitle(QString::fromUtf8("Bài tập lập trình môn toán rời rạc! by Hieukoy vs Tranharo"));
QMovie *movie = new QMovie("tuyetroi.gif");
ui->label_2->setMovie(movie);
movie->start();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionUs_triggered()
{
QString s=QString::fromUtf8("Về chúng tôi");
QMessageBox::about(this, tr("%1").arg(s),
QString::fromUtf8(
"<center><h2>ZzZ</h2>"
"Bài tập bộ môn toán rời rạc"
"<br><br>"
"<b>- Đại Học Thủy lợi - TLU</b>"
"<br><br>"
"<b>Trưởng nhóm:</b> Hoàng Trần Hảo"
"<br><br>"
"<b>Thành viên của nhóm:</b> Trần Hán Hiếu"
"<br><br>"
"<b>Hà Nội ,2016</b>"
"<br>"
"<b>GitHub của tôi:</b> <a href='https://github.com/hoanghaockpt195'>https://github.com/hoanghaockpt195</a>"
"<br></br>"
"<br>......</br>"
"<br></br>"
"<br></br>"
"<b>Facebook của Hảo:</b> <a href='https://fb.com/hoangtranhao95'>https://fb.com/hoangtranhao95</a>"
"<br></br>"
"<br></br>"
"<br></br>"
"<b>Facebook của Hiếu:</b> <a href='https://fb.com/hanhieu97'>https://fb.com/hanhieu97</a>"
"<br><br></center>"
));
}
void MainWindow::on_actionQT_triggered()
{
qApp->aboutQt();
}
int MainWindow::getInputValue(QString name)
{ bool ok=false;
QString s=QString::fromUtf8("Xin nhập...");
int value = QInputDialog::getInt(this, tr("%1").arg(s),name, 2,1,3,1,&ok);
if(ok)
return value;
else
return -1;
}
void MainWindow::noticeBox()
{
int value=getInputValue(QString::fromUtf8("Nhập vào bài tập bạn muốn 1->3 "));
if(value==1)
on_actionB_i_1_triggered();
else
if(value==2)
on_actionB_i_2_triggered();
if(value==3)
on_actionB_i_3_triggered();
if(value==-1)
QMessageBox::critical(this,QString::fromUtf8("Lỗi"),QString::fromUtf8("Xin nhập lại!"),QMessageBox::Ok);
}
void MainWindow::kiemTraNguoiDung()
{
if(test==false)
{
QTimer *timer;
timer=new QTimer(this);
timer->setSingleShot(true);
//sau 6,5 giây tự động bắt chọn chương trình!
timer->singleShot(6500,this,SLOT(noticeBox()));
}
}
void MainWindow::on_actionB_i_1_triggered()
{
Bai1 a;
a.exec();
test=true;
}
void MainWindow::on_actionB_i_2_triggered()
{
Bai2 a;
a.exec();
test=true;
}
void MainWindow::on_actionB_i_3_triggered()
{
Bai3 a;
a.exec();
test=true;
}
void MainWindow::on_pushButton1_clicked()
{
on_actionB_i_1_triggered();
}
void MainWindow::on_pushButton_2_clicked()
{
on_actionB_i_2_triggered();
}
void MainWindow::on_pushButton_3_clicked()
{
on_actionB_i_3_triggered();
}
void MainWindow::on_actionExit_2_triggered()
{
this->close();
}