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 <[email protected]>
5  SPDX-FileCopyrightText: 2010 Teo Mrnjavac <[email protected]>
6 
7  Parts of this class have been take from the KAboutApplication class, which was:
8  SPDX-FileCopyrightText: 2000 Waldo Bastian <[email protected]>
9  SPDX-FileCopyrightText: 2000 Espen Sand <[email protected]>
10 
11  SPDX-License-Identifier: LGPL-2.0-only
12 */
13 
14 #include "kaboutapplicationdialog.h"
15 
16 #include "kabstractaboutdialog_p.h"
17 #include "../kxmlgui_version.h"
18 // KF
19 #include <KAboutData>
20 #include <KLocalizedString>
21 #include <KWidgetItemDelegate>
22 // Qt
23 #include <QApplication>
24 #include <QLabel>
25 #include <QTabWidget>
26 #include <QVBoxLayout>
27 
28 
29 class Q_DECL_HIDDEN KAboutApplicationDialog::Private : public KAbstractAboutDialogPrivate
30 {
31 public:
32  Private(const KAboutData &aboutData, KAboutApplicationDialog *parent)
33  : q(parent)
34  , aboutData(aboutData)
35  {}
36 
37  void init(Options opt);
38 
39 private:
40  KAboutApplicationDialog * const q;
41 
42  const KAboutData aboutData;
43 };
44 
45 
47  : KAboutApplicationDialog(aboutData, NoOptions, parent)
48 {
49 }
50 
52  : QDialog(parent)
53  , d(new Private(aboutData, this))
54 {
55  d->init(opt);
56 }
57 
58 void KAboutApplicationDialog::Private::init(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 #if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2)
73  // Legacy support for deprecated KAboutData::programIconName()
74 QT_WARNING_PUSH
75 QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
76 QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
77  if (titleIcon.isNull() && !aboutData.programIconName().isEmpty()) {
78  titleIcon = QIcon::fromTheme(aboutData.programIconName());
79  }
80 QT_WARNING_POP
81 #endif
82  }
83 
84  QWidget *titleWidget = createTitleWidget(titleIcon, aboutData.displayName(), aboutData.version(), q);
85 
86  //Then the tab bar...
87  QTabWidget *tabWidget = new QTabWidget;
88  tabWidget->setUsesScrollButtons(false);
89 
90  //Set up the first page...
91  QWidget *aboutWidget = createAboutWidget(aboutData.shortDescription(), aboutData.otherText(),
92  aboutData.copyrightStatement(), aboutData.homepage(),
93  aboutData.licenses(), q);
94 
95  tabWidget->addTab(aboutWidget, i18nc("@title:tab", "About"));
96 
97  // Version
98  QWidget *versionWidget = new QWidget(q);
99  QVBoxLayout *versionLayout = new QVBoxLayout;
100  if (!(opt & HideKdeVersion)) {
101  QLabel *versionLabel = new QLabel(
102  i18n("<ul><li>KDE Frameworks %1</li><li>Qt %2 (built against %3)</li><li>The <em>%4</em> windowing system</li></ul>",
103  QStringLiteral(KXMLGUI_VERSION_STRING),
104  QString::fromLocal8Bit(qVersion()),
105  QStringLiteral(QT_VERSION_STR),
108  versionLayout->addWidget(versionLabel);
109  }
110  versionLayout->addStretch();
111  versionWidget->setLayout(versionLayout);
112  tabWidget->addTab(versionWidget, i18nc("@title:tab", "Libraries"));
113 
114  //And here we go, authors page...
115  const int authorCount = aboutData.authors().count();
116  if (authorCount) {
117  QWidget *authorWidget = createAuthorsWidget(aboutData.authors(), aboutData.ocsProviderUrl(),
118  aboutData.customAuthorTextEnabled(),
119  aboutData.customAuthorRichText(),
120  aboutData.bugAddress(), q);
121 
122  const QString authorPageTitle = i18ncp("@title:tab", "Author", "Authors", authorCount);
123  tabWidget->addTab(authorWidget, authorPageTitle);
124  }
125 
126  //And credits page...
127  if (!aboutData.credits().isEmpty()) {
128  QWidget *creditWidget = createCreditWidget(aboutData.credits(), aboutData.ocsProviderUrl(), q);
129  tabWidget->addTab(creditWidget, i18nc("@title:tab", "Thanks To"));
130  }
131 
132  //Finally, the optional translators page...
133  if (!(opt & HideTranslators) && !aboutData.translators().isEmpty()) {
134  QWidget *translatorWidget = createTranslatorsWidget(aboutData.translators(), aboutData.ocsProviderUrl(), q);
135 
136  tabWidget->addTab(translatorWidget, i18nc("@title:tab", "Translation"));
137  }
138 
139  createForm(titleWidget, tabWidget, q);
140 }
141 
142 KAboutApplicationDialog::~KAboutApplicationDialog()
143 {
144  delete d;
145  // The delegate wants to be deleted before the items it created, otherwise
146  // complains bitterly about it
147  qDeleteAll(findChildren<KWidgetItemDelegate *>());
148 }
KAboutApplicationDialog(const KAboutData &aboutData, Options opts, QWidget *parent=nullptr)
Constructor.
Standard "About Application" dialog box.
QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
QString fromLocal8Bit(const char *str, int size)
void setLayout(QLayout *layout)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
TextSelectableByMouse
Don&#39;t show the KDE version next to the application name and version.
QString i18ncp(const char *context, const char *singular, const char *plural, const TYPE &arg...)
QCA_EXPORT void init()
QString i18n(const char *text, const TYPE &arg...)
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
void setUsesScrollButtons(bool useButtons)
void addStretch(int stretch)
bool isNull() const const
Don&#39;t show the translators tab.
QWidget(QWidget *parent, Qt::WindowFlags f)
QIcon fromTheme(const QString &name)
QObject * parent() const const
QString platformName()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 12 2020 22:50:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.