Skip to content

Commit 9952fc8

Browse files
committed
Add Developers Map in About dialog
1 parent 1d9eb8f commit 9952fc8

File tree

8 files changed

+96
-8
lines changed

8 files changed

+96
-8
lines changed

doc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ELSE(TXT2TAGS_EXECUTABLE)
2020
)
2121
ENDIF(TXT2TAGS_EXECUTABLE)
2222

23-
SET(QGIS_DOC_FILES ${QGIS_DOC_FILES} index.html news.html favicon.ico style.css AUTHORS CONTRIBUTORS SPONSORS DONORS TRANSLATORS LICENSE)
23+
SET(QGIS_DOC_FILES ${QGIS_DOC_FILES} index.html news.html developersmap.html contributors.json favicon.ico style.css AUTHORS CONTRIBUTORS SPONSORS DONORS TRANSLATORS LICENSE)
2424

2525
INSTALL(FILES ${QGIS_DOC_FILES} DESTINATION ${QGIS_DATA_DIR}/doc)
2626
INSTALL(FILES ../images/icons/qgis-icon-60x60.png DESTINATION ${QGIS_DATA_DIR}/doc/images)

doc/developersmap.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<html>
2+
<head>
3+
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
4+
<style type="text/css">
5+
body { padding: 0; margin: 0; }
6+
html, body, #developers-map { height: 100%; }
7+
</style>
8+
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
9+
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
10+
<link rel="points" type="application/json" href="contributors.json">
11+
</head>
12+
<body>
13+
<div id="developers-map"></div>
14+
<script>
15+
var developersMapTiles = L.tileLayer('http://a.tiles.mapbox.com/v3/lyzidiamond.map-ietb6srb/{z}/{x}/{y}.png', {
16+
maxZooom: 18
17+
});
18+
19+
$.getJSON($('link[rel="points"]').attr("href"), function(data) {
20+
var geojson = L.geoJson(data, {
21+
onEachFeature: function (feature, layer) {
22+
layer.bindPopup(feature.properties.Name);
23+
}
24+
});
25+
var map = L.map('developers-map').fitBounds(geojson.getBounds());
26+
developersMapTiles.addTo(map);
27+
geojson.addTo(map);
28+
});
29+
</script>
30+
</body>
31+
</html>

python/core/qgsapplication.sip

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
110110
* but don't have commit access. */
111111
static const QString contributorsFilePath();
112112

113-
/**Returns the path to the sponsors file.*/
113+
/** Returns the path to the developers map file.
114+
* The developers map was created by using leaflet framework,
115+
* it shows the doc/contributors.json file.
116+
* @note this function was added in version 2.7 */
117+
static const QString developersMapFilePath();
118+
119+
/**Returns the path to the sponsors file. */
114120
static const QString sponsorsFilePath();
115121

116122
/** Returns the path to the donors file. */

src/app/qgsabout.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <QTextStream>
2525
#include <QImageReader>
2626
#include <QSqlDatabase>
27+
#include <QTcpSocket>
2728

2829
/* Uncomment this block to use preloaded images
2930
#include <map>
@@ -51,6 +52,17 @@ void QgsAbout::init()
5152
{
5253
setPluginInfo();
5354

55+
// check internet connection in order to hide/show the developers map widget
56+
int DEVELOPERS_MAP_INDEX = 5;
57+
QTcpSocket socket;
58+
QString host = "qgis.org";
59+
int port = 80;
60+
socket.connectToHost( host, port );
61+
if ( socket.waitForConnected( 1000 ) )
62+
setDevelopersMap();
63+
else
64+
mOptionsListWidget->item( DEVELOPERS_MAP_INDEX )->setHidden( true );
65+
5466
// set the 60x60 icon pixmap
5567
QPixmap icon( QgsApplication::iconsPath() + "qgis-icon-60x60.png" );
5668
qgisIcon->setPixmap( icon );
@@ -303,3 +315,10 @@ QString QgsAbout::fileSystemSafe( QString fileName )
303315

304316
return result;
305317
}
318+
319+
void QgsAbout::setDevelopersMap()
320+
{
321+
developersMapView->settings()->setAttribute( QWebSettings::JavascriptEnabled, true );
322+
QUrl url = QUrl::fromLocalFile( QgsApplication::developersMapFilePath() );
323+
developersMapView->load( url );
324+
}

src/app/qgsabout.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class APP_EXPORT QgsAbout : public QgsOptionsDialogBase, private Ui::QgsAbout
3333
void setWhatsNew();
3434
void setLicence();
3535
void setPluginInfo();
36+
void setDevelopersMap();
3637
void init();
3738
void openUrl( QString url );
3839

src/core/qgsapplication.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,10 @@ const QString QgsApplication::contributorsFilePath()
439439
{
440440
return ABISYM( mPkgDataPath ) + QString( "/doc/CONTRIBUTORS" );
441441
}
442+
const QString QgsApplication::developersMapFilePath()
443+
{
444+
return ABISYM( mPkgDataPath ) + QString( "/doc/developersmap.html" );
445+
}
442446
/*!
443447
Returns the path to the sponsors file.
444448
*/

src/core/qgsapplication.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ class CORE_EXPORT QgsApplication : public QApplication
8484
* but don't have commit access. */
8585
static const QString contributorsFilePath();
8686

87-
/**Returns the path to the sponsors file.*/
87+
/** Returns the path to the developers map file.
88+
* The developers map was created by using leaflet framework,
89+
* it shows the doc/contributors.json file.
90+
* @note this function was added in version 2.7 */
91+
static const QString developersMapFilePath();
92+
93+
/** Returns the path to the sponsors file. */
8894
static const QString sponsorsFilePath();
8995

9096
/** Returns the path to the donors file. */

src/ui/qgsabout.ui

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@
105105
<string>Contributors</string>
106106
</property>
107107
</item>
108+
<item>
109+
<property name="text">
110+
<string>Developers Map</string>
111+
</property>
112+
</item>
108113
<item>
109114
<property name="text">
110115
<string>Translators</string>
@@ -150,7 +155,7 @@
150155
</sizepolicy>
151156
</property>
152157
<property name="currentIndex">
153-
<number>0</number>
158+
<number>5</number>
154159
</property>
155160
<widget class="QWidget" name="mOptsPage_01">
156161
<layout class="QVBoxLayout" name="verticalLayout_4">
@@ -191,8 +196,8 @@ p, li { white-space: pre-wrap; }
191196
</layout>
192197
</item>
193198
<item>
194-
<widget class="QWebView" name="txtVersion" native="true">
195-
<property name="url" stdset="0">
199+
<widget class="QWebView" name="txtVersion">
200+
<property name="url">
196201
<url>
197202
<string>about:blank</string>
198203
</url>
@@ -359,14 +364,30 @@ p, li { white-space: pre-wrap; }
359364
</item>
360365
</layout>
361366
</widget>
367+
<widget class="QWidget" name="developersMap">
368+
<layout class="QGridLayout" name="gridLayout_2">
369+
<property name="margin">
370+
<number>0</number>
371+
</property>
372+
<item row="0" column="0">
373+
<widget class="QWebView" name="developersMapView">
374+
<property name="url">
375+
<url>
376+
<string>about:blank</string>
377+
</url>
378+
</property>
379+
</widget>
380+
</item>
381+
</layout>
382+
</widget>
362383
<widget class="QWidget" name="page_5">
363384
<layout class="QVBoxLayout" name="verticalLayout_8">
364385
<property name="margin">
365386
<number>0</number>
366387
</property>
367388
<item>
368-
<widget class="QWebView" name="txtTranslators" native="true">
369-
<property name="url" stdset="0">
389+
<widget class="QWebView" name="txtTranslators">
390+
<property name="url">
370391
<url>
371392
<string>about:blank</string>
372393
</url>

0 commit comments

Comments
 (0)