KXmlGui

kaboutapplicationdialog.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 Friedrich W. H. Kossebau <kossebau@kde.org>
5 SPDX-FileCopyrightText: 2010 Teo Mrnjavac <teo@kde.org>
6 SPDX-FileCopyrightText: 2021 Julius Künzel <jk.kdedev@smartlab.uber.space>
7
8 Parts of this class have been take from the KAboutApplication class, which was:
9 SPDX-FileCopyrightText: 2000 Waldo Bastian <bastian@kde.org>
10 SPDX-FileCopyrightText: 2000 Espen Sand <espen@kde.org>
11
12 SPDX-License-Identifier: LGPL-2.0-only
13*/
14
15#include "kaboutapplicationdialog.h"
16
17#include "kabstractaboutdialog_p.h"
18#include "klicensedialog_p.h"
19// KF
20#include <KAboutData>
21#include <KLocalizedString>
22#include <KWidgetItemDelegate>
23// Qt
24#include <QApplication>
25#include <QLabel>
26#include <QTabWidget>
27#include <QVBoxLayout>
28
29class KAboutApplicationDialogPrivate : public KAbstractAboutDialogPrivate
30{
31public:
32 KAboutApplicationDialogPrivate(const KAboutData &aboutData, KAboutApplicationDialog *parent)
33 : q(parent)
34 , aboutData(aboutData)
35 {
36 }
37
39
40private:
42
43 const KAboutData aboutData;
44};
45
47 : KAboutApplicationDialog(aboutData, NoOptions, parent)
48{
49}
50
52 : QDialog(parent)
53 , d(new KAboutApplicationDialogPrivate(aboutData, this))
54{
55 d->init(opt);
56}
57
58void KAboutApplicationDialogPrivate::init(KAboutApplicationDialog::Options opt)
59{
60 q->setWindowTitle(i18nc("@title:window", "About %1", aboutData.displayName()));
61
62 // Set up the title widget...
63 QIcon titleIcon;
64 if (aboutData.programLogo().canConvert<QPixmap>()) {
65 titleIcon = QIcon(aboutData.programLogo().value<QPixmap>());
66 } else if (aboutData.programLogo().canConvert<QImage>()) {
67 titleIcon = QIcon(QPixmap::fromImage(aboutData.programLogo().value<QImage>()));
68 } else if (aboutData.programLogo().canConvert<QIcon>()) {
69 titleIcon = aboutData.programLogo().value<QIcon>();
70 } else {
71 titleIcon = qApp->windowIcon();
72 }
73
74 QWidget *titleWidget = createTitleWidget(titleIcon, aboutData.displayName(), aboutData.version(), q);
75
76 // Then the tab bar...
77 QTabWidget *tabWidget = new QTabWidget;
78 tabWidget->setUsesScrollButtons(false);
79
80 // Set up the first page...
81 QWidget *aboutWidget = createAboutWidget(aboutData.shortDescription(), //
82 aboutData.otherText(),
83 aboutData.copyrightStatement(),
84 aboutData.homepage(),
85 aboutData.licenses(),
86 q);
87
88 tabWidget->addTab(aboutWidget, i18nc("@title:tab", "About"));
89
90 // Components page
92 QWidget *componentWidget = createComponentWidget(aboutData.components(), q);
93
94 const QString componentPageTitle = i18nc("@title:tab", "Components");
95 tabWidget->addTab(componentWidget, componentPageTitle);
96 }
97
98 // And here we go, authors page...
99 const int authorCount = aboutData.authors().count();
100 if (authorCount) {
101 QWidget *authorWidget =
102 createAuthorsWidget(aboutData.authors(), aboutData.customAuthorTextEnabled(), aboutData.customAuthorRichText(), aboutData.bugAddress(), q);
103
104 const QString authorPageTitle = i18ncp("@title:tab", "Author", "Authors", authorCount);
105 tabWidget->addTab(authorWidget, authorPageTitle);
106 }
107
108 // And credits page...
109 if (!aboutData.credits().isEmpty()) {
110 QWidget *creditWidget = createCreditWidget(aboutData.credits(), q);
111 tabWidget->addTab(creditWidget, i18nc("@title:tab", "Thanks To"));
112 }
113
114 // Finally, the optional translators page...
115 if (!(opt & KAboutApplicationDialog::HideTranslators) && !aboutData.translators().isEmpty()) {
116 QWidget *translatorWidget = createTranslatorsWidget(aboutData.translators(), q);
117
118 tabWidget->addTab(translatorWidget, i18nc("@title:tab", "Translation"));
119 }
120
121 createForm(titleWidget, tabWidget, q);
122}
123
124KAboutApplicationDialog::~KAboutApplicationDialog()
125{
126 // The delegate wants to be deleted before the items it created, otherwise
127 // complains bitterly about it
129}
130
131#include "moc_kaboutapplicationdialog.cpp"
Standard "About Application" dialog box.
@ HideTranslators
Don't show the translators tab.
@ HideLibraries
Don't show the libraries tab.
KAboutApplicationDialog(const KAboutData &aboutData, Options opts, QWidget *parent=nullptr)
Constructor.
QVariant programLogo() const
QString customAuthorRichText() const
QList< KAboutPerson > credits() const
bool customAuthorTextEnabled() const
QList< KAboutPerson > authors() const
QString shortDescription() const
QString copyrightStatement() const
QString homepage() const
QString version() const
QList< KAboutPerson > translators() const
QString bugAddress() const
QString displayName() const
QString otherText() const
QList< KAboutComponent > components() const
QList< KAboutLicense > licenses() 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...)
QList< T > findChildren(Qt::FindChildOptions options) const const
QPixmap fromImage(QImage &&image, Qt::ImageConversionFlags flags)
int addTab(QWidget *page, const QIcon &icon, const QString &label)
void setUsesScrollButtons(bool useButtons)
bool canConvert() const const
T value() const const
void setWindowTitle(const QString &)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.