-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
163 lines (132 loc) · 4.24 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
160
161
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QTimer>
#include <QMessageBox>
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include<QGraphicsDropShadowEffect>
#include "notepad.h"
#include "shapes.h"
#include "gamewindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setFixedSize(600,360);
this->setWindowTitle("Play Store");
setImaages();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionQuit_triggered()
{
qDebug() << "Quit event triggerd";
statusBar()->showMessage("App store will close in 3 seonds...");
QTimer::singleShot(3000,this,SLOT(quitApplication()));
}
void MainWindow::quitApplication()
{
QApplication::quit();
}
void MainWindow::on_actionAbout_triggered()
{
QMessageBox::about(this,"About me",
"This is a Play Store app that contains multiple apps For day today uses.\n"
" Have fun with using those");
}
void MainWindow::on_actionAbout_Qt_triggered()
{
QApplication::aboutQt();
}
void MainWindow::on_actionLicense_triggered()
{
try {
QFile file(":/new/text/resource/text/text/license2.txt");
QString license;
if(file.open(QIODevice::ReadOnly | QIODevice::Text)){
QTextStream in(&file);
license = in.readAll();
}
QMessageBox::about(this,"License",
license);
} catch (...) {
qDebug() << "Something went wrong with the file read";
}
}
void MainWindow::setImaages()
{
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(1);
effect->setOffset(3,3);
ui->notePadBtn->setGraphicsEffect(effect);
ui->notePadlblimg->setGraphicsEffect(effect);
QPixmap pixmap(":/new/images/resource/images/notePadimg.jpg");
this->ui->notePadlblimg->setPixmap(pixmap.scaled(180,200));
ui->pushButton->setGraphicsEffect(effect);
ui->shapesImg->setGraphicsEffect(effect);
QPixmap pixmap2(":/new/images/resource/images/shapes.jpg");
this->ui->shapesImg->setPixmap(pixmap2.scaled(180,200));
ui->pushButton_2->setGraphicsEffect(effect);
ui->fightImg->setGraphicsEffect(effect);
QPixmap pixmap3(":/new/images/resource/images/lastFight.jpg");
this->ui->fightImg->setPixmap(pixmap3.scaled(180,200));
}
void MainWindow::on_notePadBtn_clicked()
{
NotePad *notePad = new NotePad(this);
notePad->raise();
notePad->activateWindow();
notePad->show();
// connect(notePad,&QObject::ab,
// [=] (){
// ui->progressBar->setValue(ui->horizontalSlider->value());
// });
// connect(notePad,&NotePad::closeEvent,
// [=](){
// qDebug() << "sample one 1";
// delete notePad;
// qDebug() << "sample one 2";
// });
}
void MainWindow::on_pushButton_clicked()
{
Shapes *shapes = new Shapes(this);
shapes ->raise();
shapes -> activateWindow();
shapes -> show();
// connect(shapes,SIGNAL(aboutToQuit()),this,SLOT(quitMyApp(){
// delete shapes
// shapes=NULL;
// }));
}
void MainWindow::on_pushButton_2_clicked()
{
GameWindow *gw = new GameWindow();
// connect(gw,SIGNAL(aboutToQuit()),this,SLOT(quitMyApp(){
// delete gw
// gw=NULL;
// }));
}
void MainWindow::closeEvent(QCloseEvent *bar)
{
QMessageBox::StandardButton resBtn = QMessageBox::question( this, "Play Store",
tr("Are you sure?\n"),
QMessageBox::Cancel | QMessageBox::No | QMessageBox::Yes,
QMessageBox::Yes);
if (resBtn != QMessageBox::Yes) {
bar->ignore();
} else {
this->close();
bar->accept();
}
}
void MainWindow::quitMyApp(NotePad *note)
{
delete note;
qDebug() << "sample";
}