00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "qgsabout.h"
00020 #include "qgsapplication.h"
00021 #include "qgsproviderregistry.h"
00022 #include "qgslogger.h"
00023 #include <QDesktopServices>
00024 #include <QFile>
00025 #include <QTextStream>
00026 #include <QImageReader>
00027 #include <QSqlDatabase>
00028
00029
00030
00031
00032
00033
00034
00035 QgsAbout::QgsAbout()
00036 : QDialog( NULL, Qt::WindowSystemMenuHint )
00037 {
00038 setupUi( this );
00039 init();
00040 }
00041
00042 QgsAbout::~QgsAbout()
00043 {
00044 }
00045
00046 void QgsAbout::init()
00047 {
00048 setPluginInfo();
00049
00050
00051 QPixmap icon( QgsApplication::iconsPath() + "qgis-icon-60x60.png" );
00052 qgisIcon->setPixmap( icon );
00053
00054
00055 QStringList lines;
00056
00057 QFile file( QgsApplication::authorsFilePath() );
00058 #ifdef QGISDEBUG
00059 printf(( "Reading authors file " + file.fileName() +
00060 ".............................................\n" ).toLocal8Bit().constData() );
00061 #endif
00062 if ( file.open( QIODevice::ReadOnly ) )
00063 {
00064 QTextStream stream( &file );
00065
00066 stream.setCodec( "UTF-8" );
00067 QString line;
00068 #ifdef QGISDEBUG
00069 int i = 1;
00070 #endif
00071
00072 while ( !stream.atEnd() )
00073 {
00074 line = stream.readLine();
00075
00076 if ( line.left( 1 ) == "#" ) continue;
00077 #ifdef QGISDEBUG
00078 printf( "Contributor: %3d: %s\n", i++, line.toLocal8Bit().constData() );
00079 #endif
00080 QStringList myTokens = line.split( "\t", QString::SkipEmptyParts );
00081
00082 lines += myTokens[0];
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 }
00094 file.close();
00095 listBox1->clear();
00096 listBox1->insertItems( 0, lines );
00097
00098
00099 if ( listBox1->count() > 0 )
00100 listBox1->setCurrentRow( 0 );
00101 }
00102
00103
00104 QFile sponsorFile( QgsApplication::sponsorsFilePath() );
00105 #ifdef QGISDEBUG
00106 printf(( "Reading sponsors file " + sponsorFile.fileName() +
00107 ".............................................\n" ).toLocal8Bit().constData() );
00108 #endif
00109 if ( sponsorFile.open( QIODevice::ReadOnly ) )
00110 {
00111 QString sponsorHTML = ""
00112 + tr( "<p>The following have sponsored QGIS by contributing "
00113 "money to fund development and other project costs</p>" )
00114 + "<hr>"
00115 "<table width='100%'>"
00116 "<tr><th>" + tr( "Name" ) + "</th>"
00117 "<th>" + tr( "Website" ) + "</th></tr>";
00118 QString website;
00119 QTextStream sponsorStream( &sponsorFile );
00120
00121 sponsorStream.setCodec( "UTF-8" );
00122 QString sline;
00123 while ( !sponsorStream.atEnd() )
00124 {
00125 sline = sponsorStream.readLine();
00126
00127 if ( sline.left( 1 ) == "#" ) continue;
00128 QStringList myTokens = sline.split( "|", QString::SkipEmptyParts );
00129 if ( myTokens.size() > 1 )
00130 {
00131 website = myTokens[1];
00132 }
00133 else
00134 {
00135 website = " ";
00136 }
00137 sponsorHTML += "<tr>";
00138 sponsorHTML += "<td>" + myTokens[0] + "</td><td>" + website + "</td>";
00139
00140 sponsorHTML += "</tr>";
00141 }
00142 sponsorHTML += "</table>";
00143
00144 QString myStyle = QgsApplication::reportStyleSheet();
00145 txtSponsors->clear();
00146 txtSponsors->document()->setDefaultStyleSheet( myStyle );
00147 txtSponsors->setHtml( sponsorHTML );
00148 QgsDebugMsg( QString( "sponsorHTML:%1" ).arg( sponsorHTML.toAscii().constData() ) );
00149 QgsDebugMsg( QString( "txtSponsors:%1" ).arg( txtSponsors->toHtml().toAscii().constData() ) );
00150 }
00151 }
00152
00153 void QgsAbout::setVersion( QString v )
00154 {
00155 lblVersion->setText( v );
00156 }
00157
00158 void QgsAbout::setWhatsNew( QString txt )
00159 {
00160 QString myStyle = QgsApplication::reportStyleSheet();
00161 txtWhatsNew->clear();
00162 txtWhatsNew->document()->setDefaultStyleSheet( myStyle );
00163 txtWhatsNew->setHtml( txt );
00164 }
00165
00166 void QgsAbout::setPluginInfo()
00167 {
00168 QString myString;
00169
00170 myString += "<b>" + tr( "Available QGIS Data Provider Plugins" ) + "</b><br>";
00171 myString += QgsProviderRegistry::instance()->pluginList( true );
00172
00173 myString += "<b>" + tr( "Available Qt Database Plugins" ) + "</b><br>";
00174 myString += "<ol>\n<li>\n";
00175 QStringList myDbDriverList = QSqlDatabase::drivers();
00176 myString += myDbDriverList.join( "</li>\n<li>" );
00177 myString += "</li>\n</ol>\n";
00178
00179 myString += "<b>" + tr( "Available Qt Image Plugins" ) + "</b><br>";
00180 myString += "<ol>\n<li>\n";
00181 QList<QByteArray> myImageFormats = QImageReader::supportedImageFormats();
00182 QList<QByteArray>::const_iterator myIterator = myImageFormats.begin();
00183 while ( myIterator != myImageFormats.end() )
00184 {
00185 QString myFormat = ( *myIterator ).data();
00186 myString += myFormat + "</li>\n<li>";
00187 ++myIterator;
00188 }
00189 myString += "</li>\n</ol>\n";
00190
00191 QString myStyle = QgsApplication::reportStyleSheet();
00192 txtBrowserPlugins->clear();
00193 txtBrowserPlugins->document()->setDefaultStyleSheet( myStyle );
00194 txtBrowserPlugins->setText( myString );
00195 }
00196
00197 void QgsAbout::on_buttonCancel_clicked()
00198 {
00199 reject();
00200 }
00201
00202 void QgsAbout::on_listBox1_currentItemChanged( QListWidgetItem *theItem )
00203 {
00204
00205 #ifdef QGISDEBUG
00206 printf( "Loading mug: " );
00207 #endif
00208 QString myString = listBox1->currentItem()->text();
00209 myString = myString.replace( " ", "_" );
00210 myString = QgsAbout::fileSystemSafe( myString );
00211 #ifdef QGISDEBUG
00212 printf( "Loading mug: %s", myString.toLocal8Bit().constData() );
00213 #endif
00214 myString = QgsApplication::developerPath() + myString + QString( ".jpg" );
00215 #ifdef QGISDEBUG
00216 printf( "Loading mug: %s\n", myString.toLocal8Bit().constData() );
00217 #endif
00218
00219
00220
00221
00222 }
00223
00224 void QgsAbout::on_btnQgisUser_clicked()
00225 {
00226
00227 QString url = "http://lists.osgeo.org/mailman/listinfo/qgis-user";
00228 openUrl( url );
00229 }
00230
00231 void QgsAbout::on_btnQgisHome_clicked()
00232 {
00233 openUrl( "http://qgis.org" );
00234 }
00235
00236 void QgsAbout::openUrl( QString url )
00237 {
00238
00239 QDesktopServices::openUrl( url );
00240 }
00241
00242
00243
00244
00245
00246
00247
00248 QString QgsAbout::fileSystemSafe( QString fileName )
00249 {
00250 QString result;
00251 QByteArray utf8 = fileName.toUtf8();
00252
00253 for ( int i = 0; i < utf8.size(); i++ )
00254 {
00255 uchar c = utf8[i];
00256
00257 if ( c > 0x7f )
00258 {
00259 result = result + QString( "%1" ).arg( c, 2, 16, QChar( '0' ) );
00260 }
00261 else
00262 {
00263 result = result + QString( c );
00264 }
00265 }
00266 result.replace( QRegExp( "[^a-z0-9A-Z]" ), "_" );
00267 QgsDebugMsg( result );
00268
00269 return result;
00270 }