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 "version.h"
30 #include "wadseeker/wadseekerversioninfo.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->versionAbi->setText(QString("(ABI: %1)").arg(DOOMSEEKER_ABI_VERSION));
51  d->lblRevision->setText(QString::number(Version::revisionNumber()));
52  d->logo->setPixmap(QPixmap(":/logo.png"));
53  d->pteCopyrightNotice->setPlainText(copyrightVerboseNotice());
54 
55  // Wadseeker
56  d->wadseekerAuthor->setText(WadseekerVersionInfo::author());
57  d->wadseekerDescription->setText(WadseekerVersionInfo::description());
58  d->wadseekerVersion->setText(WadseekerVersionInfo::version());
59  d->wadseekerYearSpan->setText(WadseekerVersionInfo::yearSpan());
60 
61  // Populate plugins dialog
62  for (unsigned i = 0; i < gPlugins->numPlugins(); ++i)
63  d->pluginBox->addItem( gPlugins->plugin(i)->info()->data()->name);
64  connect(d->pluginBox, SIGNAL(currentIndexChanged(int)), SLOT(changePlugin(int)));
65  changePlugin(0);
66 
67  d->jsonLayout->setAlignment(d->btnJsonLicense, Qt::AlignTop);
68  adjustSize();
69 }
70 
71 AboutDialog::~AboutDialog()
72 {
73 }
74 
75 void AboutDialog::changePlugin(int pluginIndex)
76 {
77  if (static_cast<unsigned>(pluginIndex) >= gPlugins->numPlugins())
78  return; // Invalid plugin.
79 
80  const EnginePlugin *plug = gPlugins->plugin(pluginIndex)->info();
81 
82  if (plug->data()->aboutProvider.isNull())
83  d->pluginDescription->setPlainText("");
84  else
85  d->pluginDescription->setPlainText(plug->data()->aboutProvider->provide());
86  d->pluginAuthor->setText(plug->data()->author);
87  d->pluginVersion->setText(QString("Version: %1").arg(plug->data()->version));
88  d->pluginAbiVersion->setText(QString("(ABI: %1)").arg(plug->data()->abiVersion));
89 }
90 
91 QString AboutDialog::copyrightVerboseNotice() const
92 {
93  // This text is split into separate strings to simplify translation.
94  // Whenever a single paragraph needs to be changed or a new text needs
95  // to be added, it won't invalidate all existing translations.
96  QStringList paragraphs;
97 
98  // Unicode chars
99  QChar copyrightChar(0x00a9);
100  QChar smallAGraveChar(0x00e0);
101 
102  // License
103  paragraphs << tr("Copyright %1 %2 The Doomseeker Team")
104  .arg(copyrightChar).arg(Version::yearSpan());
105  paragraphs << tr("This program is distributed under the terms of the LGPL v2.1 or later.");
106 
107  // Translations
108  paragraphs << tr("Doomseeker translations contributed by:\n")
109  + tr("- Polish: Zalewa") + "\n"
110  + tr("- Spanish: Pol Marcet Sard%1").arg(smallAGraveChar) + "\n"
111  + tr("- Catalan: Pol Marcet Sard%1").arg(smallAGraveChar);
112 
113  // GeoLite2
114  paragraphs << tr("This program uses GeoLite2 data for IP-to-Country (IP2C) purposes, "
115  "available from https://www.maxmind.com") + "\n" +
116  tr("Database and Contents Copyright (c) 2018 MaxMind, Inc.");
117  paragraphs << tr("GeoLite2 License:\n"
118  "This work is licensed under the Creative Commons Attribution - ShareAlike 4.0 Unported License. "
119  "To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.");
120  paragraphs << tr("GeoLite2 available at:\n"
121  "https://dev.maxmind.com/geoip/geoip2/geolite2/");
122 
123  // Icons
124  QStringList icons;
125  icons << tr("- Aha-Soft");
126  icons << tr("- Crystal Clear by Everaldo Coelho");
127  icons << tr("- Fugue Icons (C) 2013 Yusuke Kamiyamane. All rights reserved.");
128  icons << tr("- Nuvola 1.0 (KDE 3.x icon set)");
129  icons << tr("- Oxygen Icons 4.3.1 (KDE)");
130  icons << tr("- Silk Icon Set (C) Mark James (famfamfam.com)");
131  icons << tr("- Tango Icon Library / Tango Desktop Project");
132  paragraphs << tr("This program uses icons (or derivates of) from following sources:\n") + icons.join("\n");
133 
134  return paragraphs.join("\n\n");
135 }
136 
137 void AboutDialog::showJsonLicense()
138 {
139  QResource license("LICENSE-json");
140  QString licenseText = QString::fromUtf8(
141  reinterpret_cast<const char *>(license.data()),
142  license.size());
143  CopyTextDlg dialog(licenseText, tr("JSON library license"), this);
144  dialog.resize(550, dialog.height());
145  dialog.exec();
146 }