kwave  18.07.70
AboutDialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  AboutDialog.cpp - dialog for Kwave's "Help-About"
3  -------------------
4  begin : Sun Feb 10 2002
5  copyright : (C) 2002 by Ralf Waspe & Gilles Caulier
6  email : rwaspe@web.de / caulier.gilles@free.fr
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <algorithm>
21 #include <new>
22 
23 #include <QApplication>
24 #include <QAbstractScrollArea>
25 #include <QHBoxLayout>
26 #include <QLabel>
27 #include <QList>
28 #include <QListIterator>
29 #include <QString>
30 #include <QTreeWidget>
31 #include <QTreeWidgetItem>
32 #include <QVBoxLayout>
33 #include <QtAlgorithms>
34 
35 #include <KAboutData>
36 #include <KLocalizedString>
37 #include <KTextEdit>
38 #include <KUrlLabel>
39 #include <kxmlgui_version.h>
40 
41 #include "libkwave/String.h"
42 
43 #include "AboutContainer.h"
44 #include "AboutDialog.h"
45 #include "LogoWidget.h"
46 
47 #define NAME_OF_TRANSLATORS "Your names"
48 #define EMAIL_OF_TRANSLATORS "Your emails"
49 
50 //***************************************************************************
54 {
55  return info1.m_description.toLower() < info2.m_description.toLower();
56 }
57 
58 //***************************************************************************
60  QWidget *parent,
61  const QList<Kwave::PluginManager::PluginModule> &plugin_info
62 )
63  :QDialog(parent), Ui::AboutDialogBase()
64 {
65  setupUi(this);
66 
67  /* get the about data defined in main() */
68  KAboutData about_data = KAboutData::applicationData();
69 
70  /* display version information in the header */
71  QString kde_version = QString::fromLatin1(KXMLGUI_VERSION_STRING);
72  QString kwave_version = about_data.componentName()+
73  _(" ") + about_data.version() + _(" ");
74  QString header_text = _("<h2>") + kwave_version +
75  i18n("(built with KDE Frameworks %1)", kde_version) + _("</h2>");
76  header->setText(header_text);
77 
78  /* the frame containing the developer information */
80  foreach (const KAboutPerson &author, about_data.authors()) {
81  about->addPerson(
82  author.name(),
83  author.emailAddress(),
84  author.webAddress(),
85  author.task()
86  );
87  }
88  authorframe->setWidget(about);
89  authorframe->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
90 
91  /* the frame containing the thanks to ... */
92  Kwave::AboutContainer *contrib = new Kwave::AboutContainer(this);
93  foreach (const KAboutPerson &credit, about_data.credits()) {
94  contrib->addPerson(
95  credit.name(),
96  credit.emailAddress(),
97  credit.webAddress(),
98  credit.task()
99  );
100  }
101  thanksframe->setWidget(contrib);
102  thanksframe->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
103 
104  /* the frame containing the plugins info */
105  QTreeWidget *pluginsinfo = new QTreeWidget(pluginsinfoframe);
106  QVBoxLayout *plugins_layout = new QVBoxLayout(pluginsinfoframe);
107  plugins_layout->addWidget(pluginsinfo);
108  pluginsinfoframe->setLayout(plugins_layout);
109 
110  pluginsinfo->setColumnCount(3);
111  pluginsinfo->setSizePolicy(QSizePolicy::MinimumExpanding,
112  QSizePolicy::Expanding);
113  pluginsinfo->setSelectionMode(QAbstractItemView::NoSelection);
114  QStringList headers;
115  headers << i18n("name") << i18n("version") << i18n("authors");
116  pluginsinfo->setHeaderLabels(headers);
117  pluginsinfo->setAllColumnsShowFocus( false );
118  pluginsinfo->setItemsExpandable(false);
119  pluginsinfo->setRootIsDecorated(false);
120 
121  QList<QTreeWidgetItem *> plugins;
122 
123  QList<Kwave::PluginManager::PluginModule> list = plugin_info;
124  if (!list.isEmpty()) {
125  std::sort(list.begin(), list.end(), pluginInfoDescriptionLessThan);
126  foreach (const Kwave::PluginManager::PluginModule &info, list) {
127  QStringList item;
128  item << info.m_description
129  << info.m_version
130  << info.m_author;
131  plugins.append(new QTreeWidgetItem(
132  static_cast<QTreeWidget *>(Q_NULLPTR), item));
133  }
134  pluginsinfo->insertTopLevelItems(0, plugins);
135  }
136  pluginsinfo->resizeColumnToContents(1);
137  pluginsinfo->resizeColumnToContents(0);
138 
139  QString num_plugins = i18n("Plugins found: %1", plugins.count());
140  pluginsnumval->setText(num_plugins);
141  pluginsinfoframe->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
142 
143  /* set the url of the kwave homepage */
144  kwave_url_label->setText(_("<a href=\"") +
145  about_data.homepage() + _("\">") +
146  about_data.homepage() + _("</a>"));
147  kwave_url_label->setOpenExternalLinks(true);
148  kwave_url_label->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
149 
150  /* the frame containing the translators */
151  Kwave::AboutContainer *trans = new Kwave::AboutContainer(this);
152  QList<KAboutPerson> translators = about_data.translators();
153 
154  /* ----------- begin workaround KDE #345320 ----------- */
155  /*
156  * workaround for KF5 bug #345320:
157  * do the translation of the translator names on our own, as the
158  * code in kaboutdata.cpp uses QCoreApplication::translate(...) which
159  * relies on a Qt style translation file - that we do not have, we are
160  * using message catalogs.
161  */
162  if (translators.isEmpty()) {
163  about_data.setTranslator(
164  ki18nc("NAME OF TRANSLATORS", NAME_OF_TRANSLATORS).toString(),
165  ki18nc("EMAIL OF TRANSLATORS", EMAIL_OF_TRANSLATORS).toString()
166  );
167  translators = about_data.translators();
168  }
169  /* ------------ end workaround KDE #345320 ------------ */
170 
171  if (translators.isEmpty() || ((translators.count() == 1) &&
172  (translators.first().name() == _(NAME_OF_TRANSLATORS))) ) {
173  tabwidget->removeTab(4);
174  } else {
175  foreach (const KAboutPerson &translator, translators) {
176  QString website = translator.webAddress();
177 
178  // if the translator is already listed in the "authors" section,
179  // give him the same web address
180  foreach (const KAboutPerson &author, about_data.authors())
181  if (author.name() == translator.name()) {
182  website = author.webAddress();
183  break;
184  }
185 
186  // if the translator is already listed in the "credits" section,
187  // give him the same web address
188  foreach (const KAboutPerson &credit, about_data.credits())
189  if (credit.name() == translator.name()) {
190  website = credit.webAddress();
191  break;
192  }
193 
194  trans->addPerson(
195  translator.name(),
196  translator.emailAddress(),
197  website,
198  translator.task()
199  );
200  }
201 
202  QString about_team = about_data.aboutTranslationTeam();
203  if (!about_team.isEmpty()) {
204  about_team.prepend(_("<br>"));
205  trans->addWidget(new(std::nothrow) QLabel(about_team, trans));
206  }
207 
208  translatorsframe->setWidget(trans);
209  translatorsframe->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
210  }
211 
212  /* the frame containing the license(s) */
213  licenseframe->setReadOnly(true);
214  QString licenses;
215  foreach (const KAboutLicense &license, about_data.licenses()) {
216  licenses += license.text();
217  }
218  licenseframe->setText(licenses);
219 
220  // set the focus onto the "OK" button
221  buttonBox->setFocus();
222 }
223 
224 //***************************************************************************
226 {
227 }
228 
229 //***************************************************************************
230 //***************************************************************************
virtual ~AboutDialog()
AboutDialog(QWidget *parent, const QList< Kwave::PluginManager::PluginModule > &plugin_info)
Definition: AboutDialog.cpp:59
#define EMAIL_OF_TRANSLATORS
Definition: AboutDialog.cpp:48
void addWidget(QWidget *widget)
#define _(m)
Definition: memcpy.c:66
static bool pluginInfoDescriptionLessThan(const Kwave::PluginManager::PluginModule &info1, const Kwave::PluginManager::PluginModule &info2)
Definition: AboutDialog.cpp:51
void addPerson(const QString &name, const QString &email, const QString &url, const QString &task)
#define NAME_OF_TRANSLATORS
Definition: AboutDialog.cpp:47