-
Notifications
You must be signed in to change notification settings - Fork 12
/
SavegameDialog.cpp
104 lines (93 loc) · 2.99 KB
/
SavegameDialog.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
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "SavegameDialog.h"
#include "ui_SavegameDialog.h"
#include "SavegameCopy.h"
#include "AppEnv.h"
#include <QMessageBox>
#include <QDebug>
SavegameDialog::SavegameDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SavegameDialog)
{
// Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
// Setup User Interface
ui->setupUi(this);
ui->cmdClose->setFocus();
savegameLabStr = ui->labSavegameText->text();
// Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
}
else if (QIcon::hasThemeIcon("gtk-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
}
// Set Icon for Export Button
if (QIcon::hasThemeIcon("document-export"))
{
ui->cmdCopy->setIcon(QIcon::fromTheme("document-export"));
}
else if (QIcon::hasThemeIcon("document-save"))
{
ui->cmdCopy->setIcon(QIcon::fromTheme("document-save"));
}
refreshWindowSize();
}
SavegameDialog::~SavegameDialog()
{
delete ui;
}
void SavegameDialog::refreshWindowSize()
{
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
int dpiWindowWidth = 400 * screenRatio;
int dpiWindowHeight = 105 * screenRatio;
if (dpiWindowHeight < heightForWidth(dpiWindowWidth))
{
dpiWindowHeight = heightForWidth(dpiWindowWidth);
}
resize(dpiWindowWidth, dpiWindowHeight);
}
void SavegameDialog::setSavegameData(SavegameData *savegame, QString savegamePath, bool readOk)
{
// Showing error if reading error
if (!readOk)
{
QMessageBox::warning(this,tr("Savegame Viewer"),tr("Failed at %1").arg(savegame->getLastStep()));
return;
}
sgdPath = savegamePath;
ui->labSavegameText->setText(savegameLabStr.arg(savegame->getSavegameStr()));
refreshWindowSize();
}
void SavegameDialog::on_cmdClose_clicked()
{
this->close();
}
void SavegameDialog::on_cmdCopy_clicked()
{
SavegameCopy::copySavegame(this, sgdPath);
}