File indexing completed on 2024-04-14 03:48:00
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de> 0004 // 0005 0006 // Self 0007 #include "PluginAboutDialog.h" 0008 0009 // Marble 0010 #include "MarbleDirs.h" 0011 #include "ui_MarbleAboutDialog.h" 0012 0013 // Qt 0014 #include <QTextStream> 0015 0016 namespace Marble 0017 { 0018 0019 // The index of the "Data" tab. 0020 int dataTabIndex = 2; 0021 0022 class PluginAboutDialogPrivate 0023 { 0024 public: 0025 PluginAboutDialogPrivate() 0026 { 0027 } 0028 ~PluginAboutDialogPrivate() 0029 { 0030 } 0031 0032 Ui::MarbleAboutDialog u_dialog; 0033 }; 0034 0035 PluginAboutDialog::PluginAboutDialog( QWidget *parent ) 0036 : QDialog( parent ), 0037 d( new PluginAboutDialogPrivate() ) 0038 { 0039 d->u_dialog.setupUi( this ); 0040 0041 setAboutText( QString() ); 0042 setAuthorsText( QString() ); 0043 setDataText( QString() ); 0044 setLicenseAgreementText( QString() ); 0045 } 0046 0047 PluginAboutDialog::~PluginAboutDialog() 0048 { 0049 delete d; 0050 } 0051 0052 void PluginAboutDialog::setName( const QString& name ) 0053 { 0054 d->u_dialog.m_pMarbleTitleLabel->setText( name ); 0055 setWindowTitle( tr( "About %1" ).arg( name ) ); 0056 } 0057 0058 void PluginAboutDialog::setVersion( const QString& version ) 0059 { 0060 d->u_dialog.m_pMarbleVersionLabel->setText( tr( "Version %1" ).arg( version ) ); 0061 } 0062 0063 void PluginAboutDialog::setIcon( const QIcon& icon ) 0064 { 0065 d->u_dialog.m_pMarbleLogoLabel->setPixmap( icon.pixmap( 64, 64 ) ); 0066 } 0067 0068 void PluginAboutDialog::setAboutText( const QString& about ) 0069 { 0070 d->u_dialog.m_pMarbleAboutBrowser->setText( about ); 0071 } 0072 0073 void PluginAboutDialog::setAuthors(const QVector<PluginAuthor>& authors) 0074 { 0075 QString string; 0076 for ( const PluginAuthor& author: authors ) { 0077 string += author.name + QLatin1String("\n ") + 0078 author.email + QLatin1String("\n ") + 0079 author.task + QLatin1String("\n\n"); 0080 } 0081 0082 setAuthorsText( string ); 0083 } 0084 0085 void PluginAboutDialog::setAuthorsText( const QString& authors ) 0086 { 0087 d->u_dialog.m_pMarbleAuthorsBrowser->setText( authors ); 0088 } 0089 0090 void PluginAboutDialog::setDataText( const QString& data ) 0091 { 0092 if ( data.isNull() ) { 0093 d->u_dialog.tabWidget->removeTab( d->u_dialog.tabWidget->indexOf( d->u_dialog.m_dataTab ) ); 0094 } 0095 else { 0096 d->u_dialog.tabWidget->insertTab( dataTabIndex, d->u_dialog.m_dataTab, tr( "Data" ) ); 0097 d->u_dialog.m_pMarbleDataBrowser->setText( data ); 0098 } 0099 } 0100 0101 void PluginAboutDialog::setLicense( PluginAboutDialog::LicenseKey license ) 0102 { 0103 QString filename; 0104 switch ( license ) { 0105 case PluginAboutDialog::License_LGPL_V2: 0106 filename = "lgpl2.txt"; 0107 break; 0108 default: 0109 filename = "lgpl2.txt"; 0110 } 0111 0112 const QString path = MarbleDirs::path(QLatin1String("licenses/") + filename ); 0113 QTextBrowser *browser = d->u_dialog.m_pMarbleLicenseBrowser; 0114 browser->setText( QString() ); 0115 if( !path.isEmpty() ) 0116 { 0117 QFile f( path ); 0118 if( f.open( QIODevice::ReadOnly ) ) 0119 { 0120 QTextStream ts( &f ); 0121 browser->setText( ts.readAll() ); 0122 } 0123 f.close(); 0124 } 0125 } 0126 0127 void PluginAboutDialog::setLicenseAgreementText( const QString& license ) 0128 { 0129 if ( license.isNull() ) { 0130 setLicense( PluginAboutDialog::License_LGPL_V2 ); 0131 } 0132 else { 0133 d->u_dialog.m_pMarbleLicenseBrowser->setText( license ); 0134 } 0135 } 0136 0137 } // namespace Marble 0138 0139 #include "moc_PluginAboutDialog.cpp"