Open Source Snapmatic picture and Savegame viewer/editor for GTA V https://gta5view.syping.de/

AboutDialog.cpp 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*****************************************************************************
  2. * gta5view Grand Theft Auto V Profile Viewer
  3. * Copyright (C) 2016-2018 Syping
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *****************************************************************************/
  18. #include <QDesktopServices>
  19. #include <QStringBuilder>
  20. #include <QMessageBox>
  21. #include "AboutDialog.h"
  22. #include "ui_AboutDialog.h"
  23. #include "AppEnv.h"
  24. #include "config.h"
  25. AboutDialog::AboutDialog(QWidget *parent) :
  26. QDialog(parent),
  27. ui(new Ui::AboutDialog)
  28. {
  29. // Set Window Flags
  30. setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
  31. // Build Strings
  32. QString appVersion = qApp->applicationVersion();
  33. QString buildType = tr(GTA5SYNC_BUILDTYPE);
  34. buildType.replace("_", " ");
  35. QString projectBuild = AppEnv::getBuildDateTime();
  36. QString buildStr = GTA5SYNC_BUILDSTRING;
  37. #ifndef GTA5SYNC_BUILDTYPE_REL
  38. #ifdef GTA5SYNC_COMMIT
  39. if (!appVersion.contains("-")) { appVersion = appVersion % "-" % GTA5SYNC_COMMIT; }
  40. #endif
  41. #endif
  42. // Translator Comments
  43. //: Translated by translator, example Translated by Syping
  44. QString translatedByStr = tr("Translated by %1");
  45. //: Insert your name here and profile here in following scheme, First Translator,First Profile\\nSecond Translator\\nThird Translator,Second Profile
  46. QString translatorVal = tr("TRANSLATOR");
  47. QStringList translatorContent;
  48. if (translatorVal != "TRANSLATOR")
  49. {
  50. const QStringList translatorList = translatorVal.split('\n');
  51. for (const QString &translatorStr : translatorList)
  52. {
  53. QStringList translatorStrList = translatorStr.split(',');
  54. QString translatorName = translatorStrList.at(0);
  55. translatorStrList.removeFirst();
  56. QString translatorProfile = translatorStrList.join(QString());
  57. if (!translatorProfile.isEmpty())
  58. {
  59. translatorContent += QString("<a href=\"%1\">%2</a>").arg(translatorProfile, translatorName);
  60. }
  61. else
  62. {
  63. translatorContent += translatorName;
  64. }
  65. }
  66. }
  67. // Project Description
  68. QString projectDes = tr("A project for viewing Grand Theft Auto V Snapmatic<br/>\nPictures and Savegames");
  69. // Copyright Description
  70. QString copyrightDes1 = tr("Copyright &copy; <a href=\"%1\">%2</a> %3");
  71. copyrightDes1 = copyrightDes1.arg(GTA5SYNC_APPVENDORLINK, GTA5SYNC_APPVENDOR, GTA5SYNC_COPYRIGHT);
  72. QString copyrightDes2 = tr("%1 is licensed under <a href=\"https://www.gnu.org/licenses/gpl-3.0.html#content\">GNU GPLv3</a>");
  73. copyrightDes2 = copyrightDes2.arg(GTA5SYNC_APPSTR);
  74. QString copyrightDesA;
  75. if (!translatorContent.isEmpty())
  76. {
  77. copyrightDesA = copyrightDes1 % "<br/>" % translatedByStr.arg(translatorContent.join(", ")) % "<br/>" % copyrightDes2;
  78. }
  79. else
  80. {
  81. copyrightDesA = copyrightDes1 % "<br/>" % copyrightDes2;
  82. }
  83. // Setup User Interface
  84. ui->setupUi(this);
  85. aboutStr = ui->labAbout->text();
  86. titleStr = this->windowTitle();
  87. ui->labAbout->setText(aboutStr.arg(GTA5SYNC_APPSTR, projectDes, appVersion % " (" % buildType % ")", projectBuild, buildStr, qVersion(), copyrightDesA));
  88. this->setWindowTitle(titleStr.arg(GTA5SYNC_APPSTR));
  89. // Set Icon for Close Button
  90. if (QIcon::hasThemeIcon("dialog-close"))
  91. {
  92. ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
  93. }
  94. else if (QIcon::hasThemeIcon("gtk-close"))
  95. {
  96. ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
  97. }
  98. // DPI calculation
  99. qreal screenRatio = AppEnv::screenRatio();
  100. if (!translatorContent.isEmpty())
  101. {
  102. resize(375 * screenRatio, 270 * screenRatio);
  103. }
  104. else
  105. {
  106. resize(375 * screenRatio, 260 * screenRatio);
  107. }
  108. }
  109. AboutDialog::~AboutDialog()
  110. {
  111. delete ui;
  112. }
  113. void AboutDialog::on_labAbout_linkActivated(const QString &link)
  114. {
  115. if (link.left(12) == "g5e://about?")
  116. {
  117. QStringList aboutStrList = QString(link).remove(0, 12).split(":");
  118. QMessageBox::information(this, QString::fromUtf8(QByteArray::fromBase64(aboutStrList.at(0).toUtf8())), QString::fromUtf8(QByteArray::fromBase64(aboutStrList.at(1).toUtf8())));
  119. }
  120. else
  121. {
  122. QDesktopServices::openUrl(QUrl(link));
  123. }
  124. }