File indexing completed on 2024-09-15 12:04:23
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2007 Urs Wolfer <uwolfer at kde.org> 0004 SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org> 0005 SPDX-FileCopyrightText: 2010 Teo Mrnjavac <teo@kde.org> 0006 SPDX-FileCopyrightText: 2021 Julius Künzel <jk.kdedev@smartlab.uber.space> 0007 0008 Parts of this class have been take from the KAboutApplication class, which was: 0009 SPDX-FileCopyrightText: 2000 Waldo Bastian <bastian@kde.org> 0010 SPDX-FileCopyrightText: 2000 Espen Sand <espen@kde.org> 0011 0012 SPDX-License-Identifier: LGPL-2.0-only 0013 */ 0014 0015 #include "kaboutapplicationdialog.h" 0016 0017 #include "kabstractaboutdialog_p.h" 0018 #include "klicensedialog_p.h" 0019 // KF 0020 #include <KAboutData> 0021 #include <KLocalizedString> 0022 #include <KWidgetItemDelegate> 0023 // Qt 0024 #include <QApplication> 0025 #include <QLabel> 0026 #include <QTabWidget> 0027 #include <QVBoxLayout> 0028 0029 class KAboutApplicationDialogPrivate : public KAbstractAboutDialogPrivate 0030 { 0031 public: 0032 KAboutApplicationDialogPrivate(const KAboutData &aboutData, KAboutApplicationDialog *parent) 0033 : q(parent) 0034 , aboutData(aboutData) 0035 { 0036 } 0037 0038 void init(KAboutApplicationDialog::Options opt); 0039 0040 private: 0041 KAboutApplicationDialog *const q; 0042 0043 const KAboutData aboutData; 0044 }; 0045 0046 KAboutApplicationDialog::KAboutApplicationDialog(const KAboutData &aboutData, QWidget *parent) 0047 : KAboutApplicationDialog(aboutData, NoOptions, parent) 0048 { 0049 } 0050 0051 KAboutApplicationDialog::KAboutApplicationDialog(const KAboutData &aboutData, Options opt, QWidget *parent) 0052 : QDialog(parent) 0053 , d(new KAboutApplicationDialogPrivate(aboutData, this)) 0054 { 0055 d->init(opt); 0056 } 0057 0058 void KAboutApplicationDialogPrivate::init(KAboutApplicationDialog::Options opt) 0059 { 0060 q->setWindowTitle(i18nc("@title:window", "About %1", aboutData.displayName())); 0061 0062 // Set up the title widget... 0063 QIcon titleIcon; 0064 if (aboutData.programLogo().canConvert<QPixmap>()) { 0065 titleIcon = QIcon(aboutData.programLogo().value<QPixmap>()); 0066 } else if (aboutData.programLogo().canConvert<QImage>()) { 0067 titleIcon = QIcon(QPixmap::fromImage(aboutData.programLogo().value<QImage>())); 0068 } else if (aboutData.programLogo().canConvert<QIcon>()) { 0069 titleIcon = aboutData.programLogo().value<QIcon>(); 0070 } else { 0071 titleIcon = qApp->windowIcon(); 0072 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2) 0073 // Legacy support for deprecated KAboutData::programIconName() 0074 QT_WARNING_PUSH 0075 QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") 0076 QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") 0077 if (titleIcon.isNull() && !aboutData.programIconName().isEmpty()) { 0078 titleIcon = QIcon::fromTheme(aboutData.programIconName()); 0079 } 0080 QT_WARNING_POP 0081 #endif 0082 } 0083 0084 QWidget *titleWidget = createTitleWidget(titleIcon, aboutData.displayName(), aboutData.version(), q); 0085 0086 // Then the tab bar... 0087 QTabWidget *tabWidget = new QTabWidget; 0088 tabWidget->setUsesScrollButtons(false); 0089 0090 // Set up the first page... 0091 QWidget *aboutWidget = createAboutWidget(aboutData.shortDescription(), // 0092 aboutData.otherText(), 0093 aboutData.copyrightStatement(), 0094 aboutData.homepage(), 0095 aboutData.licenses(), 0096 q); 0097 0098 tabWidget->addTab(aboutWidget, i18nc("@title:tab", "About")); 0099 0100 // Components page 0101 if (!(opt & KAboutApplicationDialog::HideLibraries)) { 0102 QWidget *componentWidget = createComponentWidget(aboutData.components(), q); 0103 0104 const QString componentPageTitle = i18nc("@title:tab", "Components"); 0105 tabWidget->addTab(componentWidget, componentPageTitle); 0106 } 0107 0108 // And here we go, authors page... 0109 const int authorCount = aboutData.authors().count(); 0110 if (authorCount) { 0111 QWidget *authorWidget = 0112 createAuthorsWidget(aboutData.authors(), aboutData.customAuthorTextEnabled(), aboutData.customAuthorRichText(), aboutData.bugAddress(), q); 0113 0114 const QString authorPageTitle = i18ncp("@title:tab", "Author", "Authors", authorCount); 0115 tabWidget->addTab(authorWidget, authorPageTitle); 0116 } 0117 0118 // And credits page... 0119 if (!aboutData.credits().isEmpty()) { 0120 QWidget *creditWidget = createCreditWidget(aboutData.credits(), q); 0121 tabWidget->addTab(creditWidget, i18nc("@title:tab", "Thanks To")); 0122 } 0123 0124 // Finally, the optional translators page... 0125 if (!(opt & KAboutApplicationDialog::HideTranslators) && !aboutData.translators().isEmpty()) { 0126 QWidget *translatorWidget = createTranslatorsWidget(aboutData.translators(), q); 0127 0128 tabWidget->addTab(translatorWidget, i18nc("@title:tab", "Translation")); 0129 } 0130 0131 createForm(titleWidget, tabWidget, q); 0132 } 0133 0134 KAboutApplicationDialog::~KAboutApplicationDialog() 0135 { 0136 // The delegate wants to be deleted before the items it created, otherwise 0137 // complains bitterly about it 0138 qDeleteAll(findChildren<KWidgetItemDelegate *>()); 0139 } 0140 0141 #include "moc_kaboutapplicationdialog.cpp"