File indexing completed on 2024-09-08 12:23:19
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2007 Urs Wolfer <uwolfer at kde.org> 0004 SPDX-FileCopyrightText: 2008, 2019 Friedrich W. H. Kossebau <kossebau@kde.org> 0005 SPDX-FileCopyrightText: 2010 Teo Mrnjavac <teo@kde.org> 0006 0007 Parts of this class have been take from the KAboutApplication class, which was 0008 SPDX-FileCopyrightText: 2000 Waldo Bastian <bastian@kde.org> 0009 SPDX-FileCopyrightText: 2000 Espen Sand <espen@kde.org> 0010 0011 SPDX-License-Identifier: LGPL-2.0-only 0012 */ 0013 0014 #include "kaboutplugindialog.h" 0015 0016 #include "kabstractaboutdialog_p.h" 0017 // KF 0018 #include <KAboutData> 0019 #include <KLocalizedString> 0020 #include <KPluginMetaData> 0021 #include <KWidgetItemDelegate> 0022 // Qt 0023 #include <QGuiApplication> 0024 #include <QTabWidget> 0025 0026 class KAboutPluginDialogPrivate : public KAbstractAboutDialogPrivate 0027 { 0028 public: 0029 KAboutPluginDialogPrivate(const KPluginMetaData &pluginMetaData, KAboutPluginDialog *parent) 0030 : q(parent) 0031 , pluginMetaData(pluginMetaData) 0032 , pluginLicense(KAboutLicense::byKeyword(pluginMetaData.license())) 0033 { 0034 } 0035 0036 void init(KAboutPluginDialog::Options opt); 0037 0038 public: 0039 KAboutPluginDialog *const q; 0040 0041 const KPluginMetaData pluginMetaData; 0042 const KAboutLicense pluginLicense; 0043 }; 0044 0045 KAboutPluginDialog::KAboutPluginDialog(const KPluginMetaData &pluginMetaData, QWidget *parent) 0046 : KAboutPluginDialog(pluginMetaData, NoOptions, parent) 0047 { 0048 } 0049 0050 KAboutPluginDialog::KAboutPluginDialog(const KPluginMetaData &pluginMetaData, Options opt, QWidget *parent) 0051 : QDialog(parent) 0052 , d(new KAboutPluginDialogPrivate(pluginMetaData, this)) 0053 { 0054 d->init(opt); 0055 } 0056 0057 KAboutPluginDialog::~KAboutPluginDialog() 0058 { 0059 // The delegates want to be deleted before the items it created 0060 qDeleteAll(findChildren<KWidgetItemDelegate *>()); 0061 } 0062 0063 void KAboutPluginDialogPrivate::init(KAboutPluginDialog::Options opt) 0064 { 0065 q->setWindowTitle(i18nc("@title:window", "About %1", pluginMetaData.name())); 0066 0067 // Set up the title widget... 0068 const QIcon pluginIcon = !pluginMetaData.iconName().isEmpty() ? QIcon::fromTheme(pluginMetaData.iconName()) : qApp->windowIcon(); 0069 QWidget *titleWidget = createTitleWidget(pluginIcon, pluginMetaData.name(), pluginMetaData.version(), q); 0070 0071 // Then the tab bar... 0072 QTabWidget *tabWidget = new QTabWidget; 0073 tabWidget->setUsesScrollButtons(false); 0074 0075 QString extraInformation; 0076 #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 87) 0077 QT_WARNING_PUSH 0078 QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") 0079 QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") 0080 extraInformation = pluginMetaData.extraInformation(); 0081 QT_WARNING_POP 0082 #endif 0083 // Set up the first page... 0084 QWidget *aboutWidget = createAboutWidget(pluginMetaData.description(), // 0085 extraInformation, 0086 pluginMetaData.copyrightText(), 0087 pluginMetaData.website(), 0088 {pluginLicense}, 0089 q); 0090 0091 tabWidget->addTab(aboutWidget, i18nc("@title:tab", "About")); 0092 0093 // And here we go, authors page... 0094 const int authorCount = pluginMetaData.authors().count(); 0095 if (authorCount) { 0096 // TODO: add bug report address to plugin metadata 0097 QWidget *authorWidget = createAuthorsWidget(pluginMetaData.authors(), false, QString(), QString(), q); 0098 0099 const QString authorPageTitle = i18ncp("@title:tab", "Author", "Authors", authorCount); 0100 tabWidget->addTab(authorWidget, authorPageTitle); 0101 } 0102 0103 // And credits page... 0104 if (!pluginMetaData.otherContributors().isEmpty()) { 0105 QWidget *creditWidget = createCreditWidget(pluginMetaData.otherContributors(), q); 0106 tabWidget->addTab(creditWidget, i18nc("@title:tab", "Thanks To")); 0107 } 0108 0109 // Finally, the optional translators page... 0110 if (!(opt & KAboutPluginDialog::HideTranslators) && !pluginMetaData.translators().isEmpty()) { 0111 QWidget *translatorWidget = createTranslatorsWidget(pluginMetaData.translators(), q); 0112 tabWidget->addTab(translatorWidget, i18nc("@title:tab", "Translation")); 0113 } 0114 0115 createForm(titleWidget, tabWidget, q); 0116 } 0117 0118 #include "moc_kaboutplugindialog.cpp"