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 #include "ui_aboutdialog.h"
25 
26 #include "gui/commongui.h"
27 #include "gui/copytextdlg.h"
28 #include "ip2c/ip2c.h"
29 #include "plugins/engineplugin.h"
30 #include "plugins/pluginloader.h"
31 #include "localization.h"
32 #include "strings.hpp"
33 #include "version.h"
34 #include <wadseeker/wadseekerversioninfo.h>
35 #include <QPixmap>
36 #include <QResource>
37 #include <QString>
38 
39 DClass<AboutDialog> : public Ui::AboutDialog
40 {
41 };
42 
43 DPointered(AboutDialog)
44 
45 AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
46 {
47  d->setupUi(this);
49 
50  connect(d->buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(close()));
51 
52  // Doomseeker
53  d->versionChangeset->setText(Version::changeset());
54  d->versionNumber->setText(Version::versionRevision());
55  d->versionAbi->setText(QString("(ABI: %1)").arg(DOOMSEEKER_ABI_VERSION));
56  d->lblRevision->setText(QString::number(Version::revisionNumber()));
57  d->logo->setPixmap(QPixmap(":/logo.png"));
58  d->pteCopyrightNotice->setPlainText(copyrightVerboseNotice());
59 
60  // Don't trust the IP2C DB completely. Sanitize the URL a bit
61  // before displaying it.
62  QString url = IP2C::instance()->urlDatabase();
63  static const int REASONABLE_URL_LENGTH = 10240;
64  static const int REASONABLE_URL_DISPLAY_LENGTH = 120;
65  if (url.length() > REASONABLE_URL_LENGTH || url.trimmed().isEmpty() || !Strings::isUrlSafe(url)) {
66  d->linkIP2Cdatabase->setText(AboutDialog::tr("<i>No URL available</i>"));
67  } else {
68  url = url.toHtmlEscaped();
69  QString displayUrl = Strings::middleEllipsis(url,
70  REASONABLE_URL_DISPLAY_LENGTH / 2 + (REASONABLE_URL_DISPLAY_LENGTH % 2),
71  REASONABLE_URL_DISPLAY_LENGTH / 2);
72  d->linkIP2Cdatabase->setText(QString("<a href=\"").append(url).append("\">").append(displayUrl).append("</a>"));
73  }
74 
75  // Wadseeker
76  d->wadseekerAuthor->setText(WadseekerVersionInfo::author());
77  d->wadseekerDescription->setText(WadseekerVersionInfo::description());
78  d->wadseekerVersion->setText(WadseekerVersionInfo::version());
79  d->wadseekerYearSpan->setText(WadseekerVersionInfo::yearSpan());
80 
81  // Populate plugins dialog
82  for (unsigned i = 0; i < gPlugins->numPlugins(); ++i)
83  d->pluginBox->addItem( gPlugins->plugin(i)->info()->data()->name);
84  connect(d->pluginBox, SIGNAL(currentIndexChanged(int)), SLOT(changePlugin(int)));
85  changePlugin(0);
86 
87  adjustSize();
88 }
89 
90 AboutDialog::~AboutDialog()
91 {
92 }
93 
94 void AboutDialog::changePlugin(int pluginIndex)
95 {
96  if (static_cast<unsigned>(pluginIndex) >= gPlugins->numPlugins())
97  return; // Invalid plugin.
98 
99  const EnginePlugin *plug = gPlugins->plugin(pluginIndex)->info();
100 
101  if (plug->data()->aboutProvider.isNull())
102  d->pluginDescription->setPlainText("");
103  else
104  d->pluginDescription->setPlainText(plug->data()->aboutProvider->provide());
105  d->pluginAuthor->setText(plug->data()->author);
106  d->pluginVersion->setText(QString("Version: %1").arg(plug->data()->version));
107  d->pluginAbiVersion->setText(QString("(ABI: %1)").arg(plug->data()->abiVersion));
108 }
109 
110 QString AboutDialog::copyrightVerboseNotice() const
111 {
112  // This text is split into separate strings to simplify translation.
113  // Whenever a single paragraph needs to be changed or a new text needs
114  // to be added, it won't invalidate all existing translations.
115  QStringList paragraphs;
116 
117  // Unicode chars
118  QChar copyrightChar(0x00a9);
119  QChar smallAGraveChar(0x00e0);
120 
121  // License
122  paragraphs << tr("Copyright %1 %2 The Doomseeker Team")
123  .arg(copyrightChar).arg(Version::yearSpan());
124  paragraphs << tr("This program is distributed under the terms of the LGPL v2.1 or later.");
125 
126  // Translations
127  paragraphs << tr("Doomseeker translations contributed by:\n")
128  + tr("- Polish: Zalewa") + "\n"
129  + tr("- Spanish: Pol Marcet Sard%1").arg(smallAGraveChar) + "\n"
130  + tr("- Catalan: Pol Marcet Sard%1").arg(smallAGraveChar);
131 
132  // GeoLite2
133  const auto &licences = IP2C::instance()->licenceNotice();
134  auto it = licences.find(Localization::get()->currentLocalization().localeName);
135  if (it == licences.end())
136  it = licences.find("");
137  if (it != licences.end())
138  paragraphs << it.value();
139 
140  // Icons
141  QStringList icons;
142  icons << tr("- Aha-Soft");
143  icons << tr("- Crystal Clear by Everaldo Coelho");
144  icons << tr("- Fugue Icons (C) 2013 Yusuke Kamiyamane. All rights reserved.");
145  icons << tr("- Nuvola 1.0 (KDE 3.x icon set)");
146  icons << tr("- Oxygen Icons 4.3.1 (KDE)");
147  icons << tr("- Silk Icon Set (C) Mark James (famfamfam.com)");
148  icons << tr("- Tango Icon Library / Tango Desktop Project");
149  paragraphs << tr("This program uses icons (or derivates of) from following sources:\n") + icons.join("\n");
150 
151  return paragraphs.join("\n\n");
152 }