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{
24 public:
25 PluginAboutDialogPrivate()
26 {
27 }
28 ~PluginAboutDialogPrivate()
29 {
30 }
31
32 Ui::MarbleAboutDialog u_dialog;
33};
34
35PluginAboutDialog::PluginAboutDialog( QWidget *parent )
36 : QDialog( parent ),
37 d( new PluginAboutDialogPrivate() )
38{
39 d->u_dialog.setupUi( this );
40
41 setAboutText( QString() );
42 setAuthorsText( QString() );
43 setDataText( QString() );
44 setLicenseAgreementText( QString() );
45}
46
47PluginAboutDialog::~PluginAboutDialog()
48{
49 delete d;
50}
51
52void PluginAboutDialog::setName( const QString& name )
53{
54 d->u_dialog.m_pMarbleTitleLabel->setText( name );
55 setWindowTitle( tr( "About %1" ).arg( name ) );
56}
57
58void PluginAboutDialog::setVersion( const QString& version )
59{
60 d->u_dialog.m_pMarbleVersionLabel->setText( tr( "Version %1" ).arg( version ) );
61}
62
63void PluginAboutDialog::setIcon( const QIcon& icon )
64{
65 d->u_dialog.m_pMarbleLogoLabel->setPixmap( icon.pixmap( 64, 64 ) );
66}
67
68void PluginAboutDialog::setAboutText( const QString& about )
69{
70 d->u_dialog.m_pMarbleAboutBrowser->setText( about );
71}
72
73void PluginAboutDialog::setAuthors(const QVector<PluginAuthor>& authors)
74{
75 QString string;
76 for ( const PluginAuthor& author: authors ) {
77 string += author.name + QLatin1String("\n ") +
78 author.email + QLatin1String("\n ") +
79 author.task + QLatin1String("\n\n");
80 }
81
82 setAuthorsText( string );
83}
84
85void PluginAboutDialog::setAuthorsText( const QString& authors )
86{
87 d->u_dialog.m_pMarbleAuthorsBrowser->setText( authors );
88}
89
90void PluginAboutDialog::setDataText( const QString& data )
91{
92 if ( data.isNull() ) {
93 d->u_dialog.tabWidget->removeTab( d->u_dialog.tabWidget->indexOf( d->u_dialog.m_dataTab ) );
94 }
95 else {
96 d->u_dialog.tabWidget->insertTab( dataTabIndex, d->u_dialog.m_dataTab, tr( "Data" ) );
97 d->u_dialog.m_pMarbleDataBrowser->setText( data );
98 }
99}
100
101void PluginAboutDialog::setLicense( PluginAboutDialog::LicenseKey license )
102{
103 QString filename;
104 switch ( license ) {
105 case PluginAboutDialog::License_LGPL_V2:
106 filename = "lgpl2.txt";
107 break;
108 default:
109 filename = "lgpl2.txt";
110 }
111
112 const QString path = MarbleDirs::path(QLatin1String("licenses/") + filename );
113 QTextBrowser *browser = d->u_dialog.m_pMarbleLicenseBrowser;
114 browser->setText( QString() );
115 if( !path.isEmpty() )
116 {
117 QFile f( path );
118 if( f.open( QIODevice::ReadOnly ) )
119 {
120 QTextStream ts( &f );
121 browser->setText( ts.readAll() );
122 }
123 f.close();
124 }
125}
126
127void PluginAboutDialog::setLicenseAgreementText( const QString& license )
128{
129 if ( license.isNull() ) {
130 setLicense( PluginAboutDialog::License_LGPL_V2 );
131 }
132 else {
133 d->u_dialog.m_pMarbleLicenseBrowser->setText( license );
134 }
135}
136
137} // namespace Marble
138
139#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 Fri Jul 26 2024 11:57:57 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.