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 <KAboutData>
19 #include <KLocalizedString>
20 #include <KPluginMetaData>
21 #include <KWidgetItemDelegate>
22 // Qt
23 #include <QGuiApplication>
24 #include <QTabWidget>
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  }
35 
37 
38 public:
39  KAboutPluginDialog *const q;
40 
41  const KPluginMetaData pluginMetaData;
42  const KAboutLicense pluginLicense;
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()) : qApp->windowIcon();
69  QWidget *titleWidget = createTitleWidget(pluginIcon, pluginMetaData.name(), pluginMetaData.version(), q);
70 
71  // Then the tab bar...
72  QTabWidget *tabWidget = new QTabWidget;
73  tabWidget->setUsesScrollButtons(false);
74 
75  QString extraInformation;
76 #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 87)
77  QT_WARNING_PUSH
78  QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
79  QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
80  extraInformation = pluginMetaData.extraInformation();
81  QT_WARNING_POP
82 #endif
83  // Set up the first page...
84  QWidget *aboutWidget = createAboutWidget(pluginMetaData.description(), //
85  extraInformation,
86  pluginMetaData.copyrightText(),
87  pluginMetaData.website(),
88  {pluginLicense},
89  q);
90 
91  tabWidget->addTab(aboutWidget, i18nc("@title:tab", "About"));
92 
93  // And here we go, authors page...
94  const int authorCount = pluginMetaData.authors().count();
95  if (authorCount) {
96  // TODO: add bug report address to plugin metadata
97  QWidget *authorWidget = createAuthorsWidget(pluginMetaData.authors(), false, QString(), QString(), q);
98 
99  const QString authorPageTitle = i18ncp("@title:tab", "Author", "Authors", authorCount);
100  tabWidget->addTab(authorWidget, authorPageTitle);
101  }
102 
103  // And credits page...
104  if (!pluginMetaData.otherContributors().isEmpty()) {
105  QWidget *creditWidget = createCreditWidget(pluginMetaData.otherContributors(), q);
106  tabWidget->addTab(creditWidget, i18nc("@title:tab", "Thanks To"));
107  }
108 
109  // Finally, the optional translators page...
110  if (!(opt & KAboutPluginDialog::HideTranslators) && !pluginMetaData.translators().isEmpty()) {
111  QWidget *translatorWidget = createTranslatorsWidget(pluginMetaData.translators(), q);
112  tabWidget->addTab(translatorWidget, i18nc("@title:tab", "Translation"));
113  }
114 
115  createForm(titleWidget, tabWidget, q);
116 }
QCA_EXPORT void init()
KAboutPluginDialog(const KPluginMetaData &pluginMetaData, Options options, QWidget *parent=nullptr)
Constructor.
QIcon fromTheme(const QString &name)
QString i18ncp(const char *context, const char *singular, const char *plural, const TYPE &arg...)
Standard "About Plugin" dialog box.
@ HideTranslators
Don't show the translators tab.
void setUsesScrollButtons(bool useButtons)
int addTab(QWidget *page, const QString &label)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Nov 27 2022 04:06:44 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.