KXmlGui

kaboutplugindialog.cpp
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2007 Urs Wolfer <uwolfer at kde.org>
4  SPDX-FileCopyrightText: 2008, 2019 Friedrich W. H. Kossebau <[email protected]>
5  SPDX-FileCopyrightText: 2010 Teo Mrnjavac <[email protected]>
6 
7  Parts of this class have been take from the KAboutApplication class, which was
8  SPDX-FileCopyrightText: 2000 Waldo Bastian <[email protected]>
9  SPDX-FileCopyrightText: 2000 Espen Sand <[email protected]>
10 
11  SPDX-License-Identifier: LGPL-2.0-only
12 */
13 
14 #include "kaboutplugindialog.h"
15 
16 #include "kabstractaboutdialog_p.h"
17 // KF
18 #include <KWidgetItemDelegate>
19 #include <KLocalizedString>
20 #include <KPluginMetaData>
21 #include <KAboutData>
22 // Qt
23 #include <QTabWidget>
24 #include <QGuiApplication>
25 
26 class KAboutPluginDialogPrivate : public KAbstractAboutDialogPrivate
27 {
28 public:
29  KAboutPluginDialogPrivate(const KPluginMetaData &pluginMetaData, KAboutPluginDialog *parent)
30  : q(parent)
31  , pluginMetaData(pluginMetaData)
32  , pluginLicense(KAboutLicense::byKeyword(pluginMetaData.license()))
33  {}
34 
36 
37 public:
38  KAboutPluginDialog * const q;
39 
40  const KPluginMetaData pluginMetaData;
41  const KAboutLicense pluginLicense;
42 };
43 
44 
46  : KAboutPluginDialog(pluginMetaData, NoOptions, parent)
47 {
48 }
49 
51  : QDialog(parent)
52  , d(new KAboutPluginDialogPrivate(pluginMetaData,this))
53 {
54  d->init(opt);
55 }
56 
57 KAboutPluginDialog::~KAboutPluginDialog()
58 {
59  // The delegates want to be deleted before the items it created
60  qDeleteAll(findChildren<KWidgetItemDelegate *>());
61 }
62 
63 void KAboutPluginDialogPrivate::init(KAboutPluginDialog::Options opt)
64 {
65  q->setWindowTitle(i18nc("@title:window", "About %1", pluginMetaData.name()));
66 
67  //Set up the title widget...
68  const QIcon pluginIcon = !pluginMetaData.iconName().isEmpty() ? QIcon::fromTheme(pluginMetaData.iconName()) :
69  qApp->windowIcon();
70  QWidget *titleWidget = createTitleWidget(pluginIcon,
71  pluginMetaData.name(), pluginMetaData.version(), q);
72 
73  //Then the tab bar...
74  QTabWidget *tabWidget = new QTabWidget;
75  tabWidget->setUsesScrollButtons(false);
76 
77  //Set up the first page...
78  QWidget *aboutWidget = createAboutWidget(pluginMetaData.description(), pluginMetaData.extraInformation(),
79  pluginMetaData.copyrightText(), pluginMetaData.website(),
80  {pluginLicense}, q);
81 
82  tabWidget->addTab(aboutWidget, i18nc("@title:tab", "About"));
83 
84  //And here we go, authors page...
85  const int authorCount = pluginMetaData.authors().count();
86  if (authorCount) {
87  // TODO: add bug report address to plugin metadata
88  QWidget *authorWidget = createAuthorsWidget(pluginMetaData.authors(), QString(),
89  false,
90  QString(),
91  QString(), q);
92 
93  const QString authorPageTitle = i18ncp("@title:tab", "Author", "Authors", authorCount);
94  tabWidget->addTab(authorWidget, authorPageTitle);
95  }
96 
97  //And credits page...
98  if (!pluginMetaData.otherContributors().isEmpty()) {
99  QWidget *creditWidget = createCreditWidget(pluginMetaData.otherContributors(), QString(), q);
100  tabWidget->addTab(creditWidget, i18nc("@title:tab", "Thanks To"));
101  }
102 
103  //Finally, the optional translators page...
104  if (!(opt & KAboutPluginDialog::HideTranslators) && !pluginMetaData.translators().isEmpty()) {
105  QWidget *translatorWidget = createTranslatorsWidget(pluginMetaData.translators(), QString(), q);
106  tabWidget->addTab(translatorWidget, i18nc("@title:tab", "Translation"));
107  }
108 
109  createForm(titleWidget, tabWidget, q);
110 }
KAboutPluginDialog(const KPluginMetaData &pluginMetaData, Options options, QWidget *parent=nullptr)
Constructor.
Don&#39;t show the translators tab.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18ncp(const char *context, const char *singular, const char *plural, const TYPE &arg...)
QCA_EXPORT void init()
void setUsesScrollButtons(bool useButtons)
QString name() const const
Standard "About Plugin" dialog box.
QIcon fromTheme(const QString &name)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 12 2020 22:50:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.