-
Notifications
You must be signed in to change notification settings - Fork 1
/
newgame.cpp
90 lines (74 loc) · 2.69 KB
/
newgame.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
#include "newgame.h"
#include "qmessagebox.h"
#include "ui_newgame.h"
#include <QDir>
#include <QFileDialog>
#include <QFileInfo>
NewGame::NewGame(QWidget *parent) : QDialog(parent),
ui(new Ui::NewGame)
{
ui->setupUi(this);
NewGame::setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
}
QString gameExe;
NewGame::~NewGame()
{
delete ui;
}
void NewGame::on_addBtn_clicked()
{
if (ui->gameName->text().isEmpty() || gameExe.isEmpty())
{
QMessageBox msgBox;
msgBox.setWindowFlags(Qt::FramelessWindowHint);
msgBox.setStyleSheet("QMessageBox{background-color: rgb(22, 22, 22);} QMessageBox QLabel {color: white; font: 900 10pt 'Arial Black';}");
msgBox.setText("Please fill in all the fields");
QPushButton *yesButton = msgBox.addButton(" Ok ", QMessageBox::ActionRole);
yesButton->setStyleSheet("QPushButton {"
"background-color: transparent;"
"font: 900 10pt 'Arial Black';"
"color: rgb(255, 255, 255);"
"border: 1px;"
"border-color: rgb(255, 255, 255);"
"border-style: outset;"
"border-radius: 10px;"
"}"
"QPushButton::hover{ "
" background-color: rgb(252, 196, 25);"
"font: 900 10pt 'Arial Black';"
"color: rgb(255, 255, 255);"
" border: 0px;"
"}"
"QPushButton::focus:pressed{ "
"background-color: rgb(252, 72, 25);"
"font: 900 10pt 'Arial Black';"
"color: rgb(255, 255, 255);"
"border: 0px;"
"}");
msgBox.exec();
if (msgBox.clickedButton() == yesButton)
{
}
}
else
{
// Replace forward slashes with backslashes
gameExe.replace("/", "\\");
emit gameAdded(ui->gameName->text(), gameExe);
this->close();
this->deleteLater();
}
}
void NewGame::on_searchGameExeBtn_clicked()
{
QString filePath = QFileDialog::getOpenFileName(this, "Get Game EXE");
QDir d = QFileInfo(filePath).absoluteDir();
QString absolute = d.absoluteFilePath(filePath);
gameExe = absolute;
// qDebug() << gameExe;
}
void NewGame::on_closeBtn_clicked()
{
this->close();
this->deleteLater();
}