-
Notifications
You must be signed in to change notification settings - Fork 1
/
updategameform.cpp
107 lines (85 loc) · 3.39 KB
/
updategameform.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
#include "updategameform.h"
#include "qmessagebox.h"
#include "ui_updategameform.h"
#include <QDir>
#include <QFileDialog>
#include <QFileInfo>
#include "dbmanager.h"
#include "util.h"
UpdateGameForm::UpdateGameForm(int _gameId, QString _gameName, QString _gameExeLocation, QWidget *parent) : QWidget(parent),
ui(new Ui::UpdateGameForm)
{
ui->setupUi(this);
UpdateGameForm::setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
ui->gameName->setText(_gameName);
gameExePath = _gameExeLocation;
gameId = _gameId;
}
UpdateGameForm::~UpdateGameForm()
{
delete ui;
}
void UpdateGameForm::on_updateBtn_clicked()
{
if (ui->gameName->text().isEmpty() || gameExePath.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
gameExePath.replace("/", "\\");
Util *util = new Util();
// Get image url
QString imageUrl = util->getGameImage(ui->gameName->text());
// Instance db conn
DbManager *db = new DbManager(path);
// Inser into games table
db->updateGame(imageUrl, ui->gameName->text(), util->removeDataFromLasBackSlash(gameExePath), util->findLastBackSlashWord(gameExePath.toStdString()), gameId);
delete db;
emit gameUpdated();
this->close();
this->deleteLater();
}
}
void UpdateGameForm::on_searchGameExeBtn_clicked()
{
QString filePath = QFileDialog::getOpenFileName(this, "Get Game EXE");
QDir d = QFileInfo(filePath).absoluteDir();
QString absolute = d.absoluteFilePath(filePath);
gameExePath = absolute;
}
void UpdateGameForm::on_closeBtn_clicked()
{
this->close();
this->deleteLater();
}