/
qgsabout.cpp
363 lines (335 loc) · 11.8 KB
/
qgsabout.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
/***************************************************************************
qgsabout.cpp - description
-------------------
begin : Sat Aug 10 2002
copyright : (C) 2002 by Gary E.Sherman
email : sherman at mrcc.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#include "qgsabout.h"
#include "qgsapplication.h"
#include "qgsproviderregistry.h"
#include "qgslogger.h"
#include <QDesktopServices>
#include <QFile>
#include <QTextStream>
#include <QImageReader>
#include <QSqlDatabase>
/* Uncomment this block to use preloaded images
#include <map>
#include "qgslogger.h"
std::map<QString, QPixmap> mugs;
*/
#ifdef Q_OS_MACX
QgsAbout::QgsAbout()
: QDialog( NULL, Qt::WindowSystemMenuHint ) // Modeless dialog with close button only
#else
QgsAbout::QgsAbout()
: QDialog( NULL ) // Normal dialog in non Mac-OS
#endif
{
setupUi( this );
init();
}
QgsAbout::~QgsAbout()
{
}
void QgsAbout::init()
{
setPluginInfo();
// set the 60x60 icon pixmap
QPixmap icon( QgsApplication::iconsPath() + "qgis-icon-60x60.png" );
qgisIcon->setPixmap( icon );
//read the authors file to populate the svn committers list
QStringList lines;
//
// Load the authors (svn committers) list
//
QFile file( QgsApplication::authorsFilePath() );
if ( file.open( QIODevice::ReadOnly ) )
{
QTextStream stream( &file );
// Always use UTF-8
stream.setCodec( "UTF-8" );
QString line;
while ( !stream.atEnd() )
{
line = stream.readLine(); // line of text excluding '\n'
//ignore the line if it starts with a hash....
if ( line.left( 1 ) == "#" ) continue;
QStringList myTokens = line.split( "\t", QString::SkipEmptyParts );
lines << myTokens[0];
}
file.close();
lstDevelopers->clear();
lstDevelopers->insertItems( 0, lines );
if ( lstDevelopers->count() > 0 )
{
lstDevelopers->setCurrentRow( 0 );
}
}
lines.clear();
//
// Now load up the contributors list
//
QFile file2( QgsApplication::contributorsFilePath() );
printf( "Reading contributors file %s.............................................\n",
file2.fileName().toLocal8Bit().constData() );
if ( file2.open( QIODevice::ReadOnly ) )
{
QTextStream stream( &file2 );
// Always use UTF-8
stream.setCodec( "UTF-8" );
QString line;
while ( !stream.atEnd() )
{
line = stream.readLine(); // line of text excluding '\n'
//ignore the line if it starts with a hash....
if ( line.left( 1 ) == "#" ) continue;
lines += line;
}
file2.close();
lstContributors->clear();
lstContributors->insertItems( 0, lines );
if ( lstContributors->count() > 0 )
{
lstContributors->setCurrentRow( 0 );
}
}
// read the SPONSORS file and populate the text widget
QFile sponsorFile( QgsApplication::sponsorsFilePath() );
#ifdef QGISDEBUG
printf( "Reading sponsors file %s.............................................\n",
sponsorFile.fileName().toLocal8Bit().constData() );
#endif
if ( sponsorFile.open( QIODevice::ReadOnly ) )
{
QString sponsorHTML = ""
+ tr( "<p>QGIS sponsorship programme:"
"contribute to QGIS development</p>" )
+ "<hr>"
"<table width='100%'>"
"<tr><th>" + tr( "Name" ) + "</th>"
"<th>" + tr( "Website" ) + "</th></tr>";
QString website;
QTextStream sponsorStream( &sponsorFile );
// Always use UTF-8
sponsorStream.setCodec( "UTF-8" );
QString sline;
while ( !sponsorStream.atEnd() )
{
sline = sponsorStream.readLine(); // line of text excluding '\n'
//ignore the line if it starts with a hash....
if ( sline.left( 1 ) == "#" ) continue;
QStringList myTokens = sline.split( "|", QString::SkipEmptyParts );
if ( myTokens.size() == 0 )
{
continue;
}
else if ( myTokens.size() > 1 )
{
website = "<a href=\"" + myTokens[1].remove( ' ' ) + "\">" + myTokens[1] + "</a>";
}
else
{
website = " ";
}
sponsorHTML += "<tr>";
sponsorHTML += "<td>" + myTokens[0] + "</td><td>" + website + "</td>";
// close the row
sponsorHTML += "</tr>";
}
sponsorHTML += "</table>";
QString myStyle = QgsApplication::reportStyleSheet();
txtSponsors->clear();
txtSponsors->document()->setDefaultStyleSheet( myStyle );
txtSponsors->setHtml( sponsorHTML );
QgsDebugMsg( QString( "sponsorHTML:%1" ).arg( sponsorHTML.toAscii().constData() ) );
QgsDebugMsg( QString( "txtSponsors:%1" ).arg( txtSponsors->toHtml().toAscii().constData() ) );
}
// read the DONORS file and populate the text widget
QFile donorsFile( QgsApplication::donorsFilePath() );
#ifdef QGISDEBUG
printf( "Reading donors file %s.............................................\n",
donorsFile.fileName().toLocal8Bit().constData() );
#endif
if ( donorsFile.open( QIODevice::ReadOnly ) )
{
QString donorsHTML = ""
+ tr( "<p>The following individuals and institutions have contributed "
"money to fund QGIS development and other project costs</p>" )
+ "<hr>"
"<table width='100%'>"
"<tr><th>" + tr( "Name" ) + "</th>"
"<th>" + tr( "Website" ) + "</th></tr>";
QString website;
QTextStream donorsStream( &donorsFile );
// Always use UTF-8
donorsStream.setCodec( "UTF-8" );
QString sline;
while ( !donorsStream.atEnd() )
{
sline = donorsStream.readLine(); // line of text excluding '\n'
//ignore the line if it starts with a hash....
if ( sline.left( 1 ) == "#" ) continue;
QStringList myTokens = sline.split( "|", QString::SkipEmptyParts );
if ( myTokens.size() > 1 )
{
website = "<a href=\"" + myTokens[1].remove( ' ' ) + "\">" + myTokens[1] + "</a>";
}
else
{
website = " ";
}
donorsHTML += "<tr>";
donorsHTML += "<td>" + myTokens[0] + "</td><td>" + website + "</td>";
// close the row
donorsHTML += "</tr>";
}
donorsHTML += "</table>";
QString myStyle = QgsApplication::reportStyleSheet();
txtDonors->clear();
txtDonors->document()->setDefaultStyleSheet( myStyle );
txtDonors->setHtml( donorsHTML );
QgsDebugMsg( QString( "donorsHTML:%1" ).arg( donorsHTML.toAscii().constData() ) );
QgsDebugMsg( QString( "txtDonors:%1" ).arg( txtDonors->toHtml().toAscii().constData() ) );
}
// read the TRANSLATORS file and populate the text widget
QFile translatorFile( QgsApplication::translatorsFilePath() );
#ifdef QGISDEBUG
printf( "Reading translators file %s.............................................\n",
translatorFile.fileName().toLocal8Bit().constData() );
#endif
if ( translatorFile.open( QIODevice::ReadOnly ) )
{
QString translatorHTML = ""
+ tr( "<p>The following have contributed to QGIS"
" by translating the user interface or documentation</p>" )
+ "<hr>"
"<table width='100%'>"
"<tr><th>" + tr( "Language" ) + "</th>"
"<th>" + tr( "Names" ) + "</th></tr>";
QString website;
QTextStream translatorStream( &translatorFile );
// Always use UTF-8
translatorStream.setCodec( "UTF-8" );
QString sline;
while ( !translatorStream.atEnd() )
{
sline = translatorStream.readLine(); // line of text excluding '\n'
//ignore the line if it starts with a hash....
if ( sline.left( 1 ) == "#" ) continue;
QStringList myTokens = sline.split( "|", QString::SkipEmptyParts );
if ( myTokens.size() > 1 )
{
website = myTokens[1];
}
else
{
website = " ";
}
translatorHTML += "<tr>";
translatorHTML += "<td>" + myTokens[0] + "</td><td>" + website + "</td>";
// close the row
translatorHTML += "</tr>";
}
translatorHTML += "</table>";
QString myStyle = QgsApplication::reportStyleSheet();
txtTranslators->clear();
txtTranslators->document()->setDefaultStyleSheet( myStyle );
txtTranslators->setHtml( translatorHTML );
QgsDebugMsg( QString( "translatorHTML:%1" ).arg( translatorHTML.toAscii().constData() ) );
QgsDebugMsg( QString( "txtTranslators:%1" ).arg( txtTranslators->toHtml().toAscii().constData() ) );
}
}
void QgsAbout::setVersion( QString v )
{
lblVersion->setText( v );
}
void QgsAbout::setWhatsNew( QString txt )
{
QString myStyle = QgsApplication::reportStyleSheet();
txtWhatsNew->clear();
txtWhatsNew->document()->setDefaultStyleSheet( myStyle );
txtWhatsNew->setHtml( txt );
}
void QgsAbout::setPluginInfo()
{
QString myString;
//provide info about the plugins available
myString += "<b>" + tr( "Available QGIS Data Provider Plugins" ) + "</b><br>";
myString += QgsProviderRegistry::instance()->pluginList( true );
//qt database plugins
myString += "<b>" + tr( "Available Qt Database Plugins" ) + "</b><br>";
myString += "<ol>\n<li>\n";
QStringList myDbDriverList = QSqlDatabase::drivers();
myString += myDbDriverList.join( "</li>\n<li>" );
myString += "</li>\n</ol>\n";
//qt image plugins
myString += "<b>" + tr( "Available Qt Image Plugins" ) + "</b><br>";
myString += tr( "Qt Image Plugin Search Paths <br>" );
myString += QApplication::libraryPaths().join( "<br>" );
myString += "<ol>\n<li>\n";
QList<QByteArray> myImageFormats = QImageReader::supportedImageFormats();
QList<QByteArray>::const_iterator myIterator = myImageFormats.begin();
while ( myIterator != myImageFormats.end() )
{
QString myFormat = ( *myIterator ).data();
myString += myFormat + "</li>\n<li>";
++myIterator;
}
myString += "</li>\n</ol>\n";
QString myStyle = QgsApplication::reportStyleSheet();
txtProviders->clear();
txtProviders->document()->setDefaultStyleSheet( myStyle );
txtProviders->setText( myString );
}
void QgsAbout::on_btnQgisUser_clicked()
{
// find a browser
QString url = "http://lists.osgeo.org/mailman/listinfo/qgis-user";
openUrl( url );
}
void QgsAbout::on_btnQgisHome_clicked()
{
openUrl( "http://qgis.org" );
}
void QgsAbout::openUrl( QString url )
{
//use the users default browser
QDesktopServices::openUrl( url );
}
/*
* The function below makes a name safe for using in most file system
* Step 1: Code QString as UTF-8
* Step 2: Replace all bytes of the UTF-8 above 0x7f with the hexcode in lower case.
* Step 2: Replace all non [a-z][a-Z][0-9] with underscore (backward compatibility)
*/
QString QgsAbout::fileSystemSafe( QString fileName )
{
QString result;
QByteArray utf8 = fileName.toUtf8();
for ( int i = 0; i < utf8.size(); i++ )
{
uchar c = utf8[i];
if ( c > 0x7f )
{
result = result + QString( "%1" ).arg( c, 2, 16, QChar( '0' ) );
}
else
{
result = result + QString( c );
}
}
result.replace( QRegExp( "[^a-z0-9A-Z]" ), "_" );
QgsDebugMsg( result );
return result;
}