Marble

PluginAboutDialog.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de>
4//
5
6// Self
7#include "PluginAboutDialog.h"
8
9// Marble
10#include "MarbleDirs.h"
11#include "ui_MarbleAboutDialog.h"
12
13// Qt
14#include <QTextStream>
15
16namespace Marble
17{
18
19// The index of the "Data" tab.
20int dataTabIndex = 2;
21
22class PluginAboutDialogPrivate
23{
24public:
25 PluginAboutDialogPrivate() = default;
26 ~PluginAboutDialogPrivate() = default;
27
28 Ui::MarbleAboutDialog u_dialog;
29};
30
31PluginAboutDialog::PluginAboutDialog(QWidget *parent)
32 : QDialog(parent)
33 , d(new PluginAboutDialogPrivate())
34{
35 d->u_dialog.setupUi(this);
36
37 setAboutText(QString());
38 setAuthorsText(QString());
39 setDataText(QString());
40 setLicenseAgreementText(QString());
41}
42
43PluginAboutDialog::~PluginAboutDialog()
44{
45 delete d;
46}
47
48void PluginAboutDialog::setName(const QString &name)
49{
50 d->u_dialog.m_pMarbleTitleLabel->setText(name);
51 setWindowTitle(tr("About %1").arg(name));
52}
53
54void PluginAboutDialog::setVersion(const QString &version)
55{
56 d->u_dialog.m_pMarbleVersionLabel->setText(tr("Version %1").arg(version));
57}
58
59void PluginAboutDialog::setIcon(const QIcon &icon)
60{
61 d->u_dialog.m_pMarbleLogoLabel->setPixmap(icon.pixmap(64, 64));
62}
63
64void PluginAboutDialog::setAboutText(const QString &about)
65{
66 d->u_dialog.m_pMarbleAboutBrowser->setText(about);
67}
68
69void PluginAboutDialog::setAuthors(const QList<PluginAuthor> &authors)
70{
71 QString string;
72 for (const PluginAuthor &author : authors) {
73 string += author.name + QLatin1StringView("\n ") + author.email + QLatin1StringView("\n ") + author.task + QLatin1StringView("\n\n");
74 }
75
76 setAuthorsText(string);
77}
78
79void PluginAboutDialog::setAuthorsText(const QString &authors)
80{
81 d->u_dialog.m_pMarbleAuthorsBrowser->setText(authors);
82}
83
84void PluginAboutDialog::setDataText(const QString &data)
85{
86 if (data.isNull()) {
87 d->u_dialog.tabWidget->removeTab(d->u_dialog.tabWidget->indexOf(d->u_dialog.m_dataTab));
88 } else {
89 d->u_dialog.tabWidget->insertTab(dataTabIndex, d->u_dialog.m_dataTab, tr("Data"));
90 d->u_dialog.m_pMarbleDataBrowser->setText(data);
91 }
92}
93
94void PluginAboutDialog::setLicense(PluginAboutDialog::LicenseKey license)
95{
96 QString filename;
97 switch (license) {
98 case PluginAboutDialog::License_LGPL_V2:
99 filename = QStringLiteral("lgpl2.txt");
100 break;
101 default:
102 filename = QStringLiteral("lgpl2.txt");
103 }
104
105 const QString path = MarbleDirs::path(QLatin1StringView("licenses/") + filename);
106 QTextBrowser *browser = d->u_dialog.m_pMarbleLicenseBrowser;
107 browser->setText(QString());
108 if (!path.isEmpty()) {
109 QFile f(path);
110 if (f.open(QIODevice::ReadOnly)) {
111 QTextStream ts(&f);
112 browser->setText(ts.readAll());
113 }
114 f.close();
115 }
116}
117
118void PluginAboutDialog::setLicenseAgreementText(const QString &license)
119{
120 if (license.isNull()) {
121 setLicense(PluginAboutDialog::License_LGPL_V2);
122 } else {
123 d->u_dialog.m_pMarbleLicenseBrowser->setText(license);
124 }
125}
126
127} // namespace Marble
128
129#include "moc_PluginAboutDialog.cpp"
QString path(const QString &relativePath)
Binds a QML item to a specific geodetic location in screen coordinates.
QPixmap pixmap(QWindow *window, const QSize &size, Mode mode, State state) const const
bool isEmpty() const const
bool isNull() const const
void setText(const QString &text)
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.