1 // For license of this file, see <project-root-folder>/LICENSE.md.
2 
3 #include "gui/dialogs/formabout.h"
4 
5 #include "database/databasedriver.h"
6 #include "database/databasefactory.h"
7 #include "definitions/definitions.h"
8 #include "exceptions/applicationexception.h"
9 #include "gui/guiutilities.h"
10 #include "miscellaneous/application.h"
11 #include "miscellaneous/iconfactory.h"
12 #include "miscellaneous/settingsproperties.h"
13 #include "miscellaneous/textfactory.h"
14 
15 #include <QFile>
16 #include <QTextStream>
17 
FormAbout(QWidget * parent)18 FormAbout::FormAbout(QWidget* parent) : QDialog(parent) {
19   m_ui.setupUi(this);
20   m_ui.m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH));
21   GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("help-about")), tr("About %1").arg(QSL(APP_NAME)));
22   loadLicenseAndInformation();
23   loadSettingsAndPaths();
24 }
25 
~FormAbout()26 FormAbout::~FormAbout() {}
27 
loadSettingsAndPaths()28 void FormAbout::loadSettingsAndPaths() {
29   if (qApp->settings()->type() == SettingsProperties::SettingsType::Portable) {
30     m_ui.m_txtPathsSettingsType->setText(tr("FULLY portable"));
31   }
32   else if (qApp->settings()->type() == SettingsProperties::SettingsType::Custom) {
33     m_ui.m_txtPathsSettingsType->setText(tr("CUSTOM"));
34   }
35   else {
36     m_ui.m_txtPathsSettingsType->setText(tr("NOT portable"));
37   }
38 
39   m_ui.m_txtPathsDatabaseRoot->setText(qApp->database()->driver()->location());
40   m_ui.m_txtPathsSettingsFile->setText(QDir::toNativeSeparators(qApp->settings()->fileName()));
41   m_ui.m_txtPathsSkinsRoot->setText(QDir::toNativeSeparators(qApp->skins()->customSkinBaseFolder()));
42 }
43 
loadLicenseAndInformation()44 void FormAbout::loadLicenseAndInformation() {
45   try {
46     m_ui.m_txtLicenseGnu->setText(IOFactory::readFile(APP_INFO_PATH + QL1S("/COPYING_GNU_GPL_HTML")));
47   }
48   catch (...) {
49     m_ui.m_txtLicenseGnu->setText(tr("License not found."));
50   }
51 
52   try {
53     m_ui.m_txtLicenseGnu->setText(IOFactory::readFile(APP_INFO_PATH + QL1S("/COPYING_GNU_GPL_HTML")));
54   }
55   catch (...) {
56     m_ui.m_txtLicenseGnu->setText(tr("License not found."));
57   }
58 
59   try {
60     m_ui.m_txtChangelog->setText(IOFactory::readFile(APP_INFO_PATH + QL1S("/CHANGELOG")));
61   }
62   catch (...) {
63     m_ui.m_txtChangelog->setText(tr("Changelog not found."));
64   }
65 
66   try {
67     m_ui.m_txtLicenseMit->setText(IOFactory::readFile(APP_INFO_PATH + QL1S("/COPYING_MIT")));
68   }
69   catch (...) {
70     m_ui.m_txtLicenseMit->setText(tr("License not found."));
71   }
72 
73   // Set other informative texts.
74   m_ui.m_lblDesc->setText(tr("<b>%8</b><br>" "<b>Version:</b> %1 (built on %2/%3)<br>" "<b>Revision:</b> %4<br>" "<b>Build date:</b> %5<br>"
75                                                                                                                  "<b>Qt:</b> %6 (compiled against %7)<br>").arg(
76                             qApp->applicationVersion(), QSL(APP_SYSTEM_NAME),
77                             QSL(APP_SYSTEM_VERSION), QSL(APP_REVISION),
78                             QLocale().toString(TextFactory::parseDateTime(QSL("%1 %2").arg(__DATE__, __TIME__)),
79                                                QLocale::FormatType::ShortFormat),
80                             qVersion(), QSL(QT_VERSION_STR),
81                             QSL(APP_NAME)));
82   m_ui.m_txtInfo->setText(tr("<body>%5 is a (very) tiny feed reader."
83                              "<br><br>This software is distributed under the terms of GNU General Public License, version 3."
84                              "<br><br>Contacts:"
85                              "<ul><li><a href=\"mailto://%1\">%1</a> ~e-mail</li>"
86                              "<li><a href=\"%2\">%2</a> ~website</li></ul>"
87                              "You can obtain source code for %5 from its website."
88                              "<br><br><br>Copyright (C) 2011-%3 %4</body>").arg(QSL(APP_EMAIL), QSL(APP_URL),
89                                                                                 QString::number(QDateTime::currentDateTime()
90                                                                                                 .date()
91                                                                                                 .year()),
92                                                                                 QSL(APP_AUTHOR), QSL(APP_NAME)));
93 }
94