2018-01-16 00:13:08 +01:00
|
|
|
/*****************************************************************************
|
2018-05-24 22:32:00 +02:00
|
|
|
* gta5view Grand Theft Auto V Profile Viewer
|
2018-01-16 00:13:08 +01:00
|
|
|
* 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/>.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2017-10-09 08:35:48 +02:00
|
|
|
#include "SavegameDialog.h"
|
|
|
|
#include "ui_SavegameDialog.h"
|
|
|
|
#include "SavegameCopy.h"
|
|
|
|
#include "AppEnv.h"
|
|
|
|
#include <QMessageBox>
|
2017-12-17 13:03:43 +01:00
|
|
|
#include <QDebug>
|
2017-10-09 08:35:48 +02:00
|
|
|
|
|
|
|
SavegameDialog::SavegameDialog(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::SavegameDialog)
|
|
|
|
{
|
|
|
|
// Set Window Flags
|
2021-02-15 23:12:44 +01:00
|
|
|
#if QT_VERSION >= 0x050900
|
|
|
|
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
|
|
|
#else
|
2017-10-09 08:35:48 +02:00
|
|
|
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
|
2021-02-15 23:12:44 +01:00
|
|
|
#endif
|
2017-10-09 08:35:48 +02:00
|
|
|
|
|
|
|
// Setup User Interface
|
|
|
|
ui->setupUi(this);
|
2018-01-16 00:13:08 +01:00
|
|
|
ui->cmdClose->setFocus();
|
2017-10-09 08:35:48 +02:00
|
|
|
savegameLabStr = ui->labSavegameText->text();
|
|
|
|
|
2018-01-17 00:59:40 +01:00
|
|
|
// Set Icon for Close Button
|
2017-10-09 08:35:48 +02:00
|
|
|
if (QIcon::hasThemeIcon("dialog-close"))
|
|
|
|
{
|
|
|
|
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
|
|
|
|
}
|
2018-01-17 00:59:40 +01:00
|
|
|
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"));
|
|
|
|
}
|
2018-01-24 16:26:54 +01:00
|
|
|
else if (QIcon::hasThemeIcon("document-save"))
|
|
|
|
{
|
|
|
|
ui->cmdCopy->setIcon(QIcon::fromTheme("document-save"));
|
|
|
|
}
|
2017-10-09 08:35:48 +02:00
|
|
|
|
2017-12-17 13:03:43 +01:00
|
|
|
refreshWindowSize();
|
2017-10-09 08:35:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SavegameDialog::~SavegameDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-12-17 13:03:43 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-10-09 08:35:48 +02:00
|
|
|
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()));
|
2017-12-17 13:03:43 +01:00
|
|
|
refreshWindowSize();
|
2017-10-09 08:35:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SavegameDialog::on_cmdClose_clicked()
|
|
|
|
{
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SavegameDialog::on_cmdCopy_clicked()
|
|
|
|
{
|
|
|
|
SavegameCopy::copySavegame(this, sgdPath);
|
|
|
|
}
|