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 <kossebau@kde.org>
5 SPDX-FileCopyrightText: 2010 Teo Mrnjavac <teo@kde.org>
6
7 Parts of this class have been take from the KAboutApplication class, which was
8 SPDX-FileCopyrightText: 2000 Waldo Bastian <bastian@kde.org>
9 SPDX-FileCopyrightText: 2000 Espen Sand <espen@kde.org>
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
26class KAboutPluginDialogPrivate : public KAbstractAboutDialogPrivate
27{
28public:
29 KAboutPluginDialogPrivate(const KPluginMetaData &pluginMetaData, KAboutPluginDialog *parent)
30 : q(parent)
31 , pluginMetaData(pluginMetaData)
32 , pluginLicense(KAboutLicense::byKeyword(keyword: pluginMetaData.license()))
33 {
34 }
35
36 void init(KAboutPluginDialog::Options opt);
37
38public:
39 KAboutPluginDialog *const q;
40
41 const KPluginMetaData pluginMetaData;
42 const KAboutLicense pluginLicense;
43};
44
45KAboutPluginDialog::KAboutPluginDialog(const KPluginMetaData &pluginMetaData, QWidget *parent)
46 : KAboutPluginDialog(pluginMetaData, NoOptions, parent)
47{
48}
49
50KAboutPluginDialog::KAboutPluginDialog(const KPluginMetaData &pluginMetaData, Options opt, QWidget *parent)
51 : QDialog(parent)
52 , d(new KAboutPluginDialogPrivate(pluginMetaData, this))
53{
54 d->init(opt);
55}
56
57KAboutPluginDialog::~KAboutPluginDialog()
58{
59 // The delegates want to be deleted before the items it created
60 qDeleteAll(c: findChildren<KWidgetItemDelegate *>());
61}
62
63void 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(name: pluginMetaData.iconName()) : qApp->windowIcon();
69 QWidget *titleWidget = createTitleWidget(icon: pluginIcon, displayName: pluginMetaData.name(), version: pluginMetaData.version(), parent: q);
70
71 // Then the tab bar...
72 QTabWidget *tabWidget = new QTabWidget;
73 tabWidget->setUsesScrollButtons(false);
74
75 QString extraInformation;
76 // Set up the first page...
77 QWidget *aboutWidget = createAboutWidget(shortDescription: pluginMetaData.description(), //
78 otherText: extraInformation,
79 copyrightStatement: pluginMetaData.copyrightText(),
80 homepage: pluginMetaData.website(),
81 licenses: {pluginLicense},
82 parent: q);
83
84 tabWidget->addTab(widget: aboutWidget, i18nc("@title:tab", "About"));
85
86 // And here we go, authors page...
87 const int authorCount = pluginMetaData.authors().count();
88 if (authorCount) {
89 // TODO: add bug report address to plugin metadata
90 QWidget *authorWidget = createAuthorsWidget(authors: pluginMetaData.authors(), customAuthorTextEnabled: false, customAuthorRichText: QString(), bugAddress: QString(), parent: q);
91
92 const QString authorPageTitle = i18ncp("@title:tab", "Author", "Authors", authorCount);
93 tabWidget->addTab(widget: authorWidget, authorPageTitle);
94 }
95
96 // And credits page...
97 if (!pluginMetaData.otherContributors().isEmpty()) {
98 QWidget *creditWidget = createCreditWidget(credits: pluginMetaData.otherContributors(), parent: q);
99 tabWidget->addTab(widget: creditWidget, i18nc("@title:tab", "Thanks To"));
100 }
101
102 // Finally, the optional translators page...
103 if (!(opt & KAboutPluginDialog::HideTranslators) && !pluginMetaData.translators().isEmpty()) {
104 QWidget *translatorWidget = createTranslatorsWidget(translators: pluginMetaData.translators(), parent: q);
105 tabWidget->addTab(widget: translatorWidget, i18nc("@title:tab", "Translation"));
106 }
107
108 createForm(titleWidget, tabWidget, dialog: q);
109}
110
111#include "moc_kaboutplugindialog.cpp"
112

source code of kxmlgui/src/kaboutplugindialog.cpp