gta5view/AboutDialog.cpp

122 lines
4.4 KiB
C++
Raw Normal View History

/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016-2017 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/>.
*****************************************************************************/
2016-04-15 22:48:26 +02:00
#include <QStringBuilder>
#include "AboutDialog.h"
#include "ui_AboutDialog.h"
#include "AppEnv.h"
2016-04-15 22:48:26 +02:00
#include "config.h"
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
2017-03-01 15:19:40 +01:00
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
// Build Strings
2016-04-15 22:48:26 +02:00
QString appVersion = qApp->applicationVersion();
QString buildType = GTA5SYNC_BUILDTYPE;
2016-04-17 06:30:03 +02:00
buildType.replace("_", " ");
2017-02-11 04:21:55 +01:00
QString projectBuild = GTA5SYNC_BUILDDATETIME;
QString buildStr = GTA5SYNC_BUILDSTRING;
2017-06-05 18:16:17 +02:00
// Additional Content
QString usingStr = tr("Using %1 %2", "Exp. Using libmyfuck");
QString translatedByStr = tr("Translated by %1", "Exp. Translated by Syping");
QString translatedByVal = tr("NAME_OF_TRANSLATOR", "Your Name (The person behind your screen looking at this text!)");
QString translatorProfile = tr("TRANSLATOR_PROFILE", "mailto: http:// https:// Exp. https://github.com/Syping/");
QString additionalContent = "";
if (translatedByVal != "NAME_OF_TRANSLATOR")
{
if (translatorProfile != "TRANSLATOR_PROFILE")
{
additionalContent.append(translatedByStr.arg(QString("<a href=\"%1\">%2</a>").arg(translatorProfile, translatedByVal)));
}
else
{
additionalContent.append(translatedByStr.arg(translatedByVal));
}
}
#ifdef WITH_LIBJPEGTURBO // DONT USE IT FOR NOW
bool additionalContentClip = false;
if (!additionalContent.isEmpty())
{
additionalContentClip = true;
additionalContent.append(" (");
}
additionalContent.append(usingStr.arg("libjpegturbo", WITH_LIBJPEGTURBO));
if (additionalContentClip)
{
additionalContent.append(")");
}
#else
Q_UNUSED(usingStr)
#endif
// Project Description
2017-01-27 01:53:14 +01:00
#ifdef GTA5SYNC_ENABLED
2017-06-05 18:16:17 +02:00
QString projectDes = tr("A project for viewing and sync Grand Theft Auto V Snapmatic<br/>\nPictures and Savegames");
2017-01-27 01:53:14 +01:00
#else
2017-06-05 18:16:17 +02:00
QString projectDes = tr("A project for viewing Grand Theft Auto V Snapmatic<br/>\nPictures and Savegames");
2017-01-27 01:53:14 +01:00
#endif
2017-03-01 15:19:40 +01:00
2017-06-05 18:16:17 +02:00
// Copyright Description
QString copyrightDes1 = tr("Copyright &copy; <a href=\"%1\">%2</a> %3");
copyrightDes1 = copyrightDes1.arg(GTA5SYNC_APPVENDORLINK, GTA5SYNC_APPVENDOR, GTA5SYNC_COPYRIGHT);
QString copyrightDes2 = tr("%1 is licensed under <a href=\"https://www.gnu.org/licenses/gpl-3.0.html#content\">GNU GPLv3</a>");
copyrightDes2 = copyrightDes2.arg(GTA5SYNC_APPSTR);
QString copyrightDesA;
if (!additionalContent.isEmpty())
{
copyrightDesA = copyrightDes1 % "<br/>" % additionalContent % "<br/>" % copyrightDes2;
}
else
{
copyrightDesA = copyrightDes1 % "<br/>" % copyrightDes2;
}
2017-03-01 15:19:40 +01:00
// Setup User Interface
ui->setupUi(this);
aboutStr = ui->labAbout->text();
titleStr = this->windowTitle();
2017-06-05 18:16:17 +02:00
ui->labAbout->setText(aboutStr.arg(GTA5SYNC_APPSTR, projectDes, appVersion % " (" % buildType % ")", projectBuild, buildStr, qVersion(), copyrightDesA));
this->setWindowTitle(titleStr.arg(GTA5SYNC_APPSTR));
2017-02-11 04:21:55 +01:00
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
}
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
2017-06-05 18:16:17 +02:00
if (!additionalContent.isEmpty())
{
resize(375 * screenRatio, 270 * screenRatio);
}
else
{
resize(375 * screenRatio, 260 * screenRatio);
}
}
AboutDialog::~AboutDialog()
{
delete ui;
}