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 <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(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
46 : KAboutPluginDialog(pluginMetaData, NoOptions, parent)
47{
48}
49
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
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(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 // Set up the first page...
77 QWidget *aboutWidget = createAboutWidget(pluginMetaData.description(), //
78 extraInformation,
79 pluginMetaData.copyrightText(),
80 pluginMetaData.website(),
81 {pluginLicense},
82 q);
83
84 tabWidget->addTab(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(pluginMetaData.authors(), false, QString(), QString(), q);
91
92 const QString authorPageTitle = i18ncp("@title:tab", "Author", "Authors", authorCount);
93 tabWidget->addTab(authorWidget, authorPageTitle);
94 }
95
96 // And credits page...
97 if (!pluginMetaData.otherContributors().isEmpty()) {
98 QWidget *creditWidget = createCreditWidget(pluginMetaData.otherContributors(), q);
99 tabWidget->addTab(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(pluginMetaData.translators(), q);
105 tabWidget->addTab(translatorWidget, i18nc("@title:tab", "Translation"));
106 }
107
108 createForm(titleWidget, tabWidget, q);
109}
110
111#include "moc_kaboutplugindialog.cpp"
Standard "About Plugin" dialog box.
KAboutPluginDialog(const KPluginMetaData &pluginMetaData, Options options, QWidget *parent=nullptr)
Constructor.
@ HideTranslators
Don't show the translators tab.
QString copyrightText() const
QString website() const
QList< KAboutPerson > authors() const
QString iconName() const
QString name() const
QList< KAboutPerson > otherContributors() const
QString version() const
QString description() const
QList< KAboutPerson > translators() const
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...)
QIcon fromTheme(const QString &name)
QList< T > findChildren(Qt::FindChildOptions options) const const
bool isEmpty() const const
int addTab(QWidget *page, const QIcon &icon, const QString &label)
void setUsesScrollButtons(bool useButtons)
void setWindowTitle(const QString &)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:32 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.