aboutdialog.cpp
1 //------------------------------------------------------------------------------
2 // aboutdialog.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 Braden "Blzut3" Obrzut <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 #include "aboutdialog.h"
24 
25 #include "gui/copytextdlg.h"
26 #include "plugins/engineplugin.h"
27 #include "plugins/pluginloader.h"
28 #include "ui_aboutdialog.h"
29 #include "wadseeker/wadseekerversioninfo.h"
30 #include "version.h"
31 #include <QPixmap>
32 #include <QResource>
33 #include <QString>
34 
35 DClass<AboutDialog> : public Ui::AboutDialog
36 {
37 };
38 
39 DPointered(AboutDialog)
40 
41 AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent)
42 {
43  d->setupUi(this);
44 
45  connect(d->buttonBox, SIGNAL( clicked(QAbstractButton *) ), SLOT( close() ));
46 
47  // Doomseeker
48  d->versionChangeset->setText(Version::changeset());
49  d->versionNumber->setText(Version::versionRevision());
50  d->lblRevision->setText(QString::number(Version::revisionNumber()));
51  d->logo->setPixmap(QPixmap(":/logo.png"));
52  d->pteCopyrightNotice->setPlainText(copyrightVerboseNotice());
53 
54  // Wadseeker
55  d->wadseekerAuthor->setText(WadseekerVersionInfo::author());
56  d->wadseekerDescription->setText(WadseekerVersionInfo::description());
57  d->wadseekerVersion->setText(WadseekerVersionInfo::version());
58  d->wadseekerYearSpan->setText(WadseekerVersionInfo::yearSpan());
59 
60  // Populate plugins dialog
61  for(unsigned i = 0; i < gPlugins->numPlugins(); ++i)
62  {
63  d->pluginBox->addItem( gPlugins->plugin(i)->info()->data()->name);
64  }
65  connect(d->pluginBox, SIGNAL( currentIndexChanged(int) ), SLOT( changePlugin(int) ));
66  changePlugin(0);
67 
68  d->jsonLayout->setAlignment(d->btnJsonLicense, Qt::AlignTop);
69  adjustSize();
70 }
71 
72 AboutDialog::~AboutDialog()
73 {
74 }
75 
76 void AboutDialog::changePlugin(int pluginIndex)
77 {
78  if(static_cast<unsigned> (pluginIndex) >= gPlugins->numPlugins())
79  return; // Invalid plugin.
80 
81  const EnginePlugin* plug = gPlugins->plugin(pluginIndex)->info();
82 
83  (plug->data()->aboutProvider.isNull()) ?
84  d->pluginDescription->setPlainText("") :
85  d->pluginDescription->setPlainText(plug->data()->aboutProvider->provide());
86  d->pluginAuthor->setText(plug->data()->author);
87  d->pluginVersion->setText(QString("Version: %1.%2").arg(plug->data()->abiVersion).arg(plug->data()->version));
88 }
89 
90 QString AboutDialog::copyrightVerboseNotice() const
91 {
92  // This text is split into separate strings to simplify translation.
93  // Whenever a single paragraph needs to be changed or a new text needs
94  // to be added, it won't invalidate all existing translations.
95  QStringList paragraphs;
96 
97  // Unicode chars
98  QChar copyrightChar(0x00a9);
99  QChar smallAGraveChar(0x00e0);
100 
101  // License
102  paragraphs << tr("Copyright %1 %2 The Doomseeker Team")
103  .arg(copyrightChar).arg(Version::yearSpan());
104  paragraphs << tr("This program is distributed under the terms of the LGPL v2.1 or later.");
105 
106  // Translations
107  paragraphs << tr("Doomseeker translations contributed by:\n")
108  + tr("- Polish: Zalewa") + "\n"
109  + tr("- Spanish: Pol Marcet Sard%1").arg(smallAGraveChar);
110 
111  // GeoLite2
112  paragraphs << tr("This program uses GeoLite2 data for IP-to-Country (IP2C) purposes, "
113  "available from https://www.maxmind.com") + "\n" +
114  tr("Database and Contents Copyright (c) 2018 MaxMind, Inc.");
115  paragraphs << tr("GeoLite2 License:\n"
116  "This work is licensed under the Creative Commons Attribution - ShareAlike 4.0 Unported License. "
117  "To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.");
118  paragraphs << tr("GeoLite2 available at:\n"
119  "https://dev.maxmind.com/geoip/geoip2/geolite2/");
120 
121  // Icons
122  QStringList icons;
123  icons << tr("- Aha-Soft");
124  icons << tr("- Crystal Clear by Everaldo Coelho");
125  icons << tr("- Fugue Icons (C) 2013 Yusuke Kamiyamane. All rights reserved.");
126  icons << tr("- Nuvola 1.0 (KDE 3.x icon set)");
127  icons << tr("- Oxygen Icons 4.3.1 (KDE)");
128  icons << tr("- Silk Icon Set (C) Mark James (famfamfam.com)");
129  icons << tr("- Tango Icon Library / Tango Desktop Project");
130  paragraphs << tr("This program uses icons (or derivates of) from following sources:\n") + icons.join("\n");
131 
132  return paragraphs.join("\n\n");
133 }
134 
135 void AboutDialog::showJsonLicense()
136 {
137  QResource license("LICENSE.json");
138  QString licenseText = QString::fromUtf8(
139  reinterpret_cast<const char*>(license.data()),
140  license.size());
141  CopyTextDlg dialog(licenseText, tr("JSON library license"), this);
142  dialog.resize(550, dialog.height());
143  dialog.exec();
144 }
QScopedPointer< TextProvider > aboutProvider
Description of the plugin, intended to be displayed in the "About" dialog.
Definition: engineplugin.h:292
static QString versionRevision()
Combines version and revision strings.
Definition: version.cpp:74
static QString changeset()
Definition: version.cpp:26