Skip to content

Commit

Permalink
Add Developers Map in About dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa committed Dec 21, 2014
1 parent 1d9eb8f commit 9952fc8
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 8 deletions.
2 changes: 1 addition & 1 deletion doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ELSE(TXT2TAGS_EXECUTABLE)
)
ENDIF(TXT2TAGS_EXECUTABLE)

SET(QGIS_DOC_FILES ${QGIS_DOC_FILES} index.html news.html favicon.ico style.css AUTHORS CONTRIBUTORS SPONSORS DONORS TRANSLATORS LICENSE)
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)

INSTALL(FILES ${QGIS_DOC_FILES} DESTINATION ${QGIS_DATA_DIR}/doc)
INSTALL(FILES ../images/icons/qgis-icon-60x60.png DESTINATION ${QGIS_DATA_DIR}/doc/images)
Expand Down
31 changes: 31 additions & 0 deletions doc/developersmap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
<style type="text/css">
body { padding: 0; margin: 0; }
html, body, #developers-map { height: 100%; }
</style>
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<link rel="points" type="application/json" href="contributors.json">
</head>
<body>
<div id="developers-map"></div>
<script>
var developersMapTiles = L.tileLayer('http://a.tiles.mapbox.com/v3/lyzidiamond.map-ietb6srb/{z}/{x}/{y}.png', {
maxZooom: 18
});

$.getJSON($('link[rel="points"]').attr("href"), function(data) {
var geojson = L.geoJson(data, {
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.Name);
}
});
var map = L.map('developers-map').fitBounds(geojson.getBounds());
developersMapTiles.addTo(map);
geojson.addTo(map);
});
</script>
</body>
</html>
8 changes: 7 additions & 1 deletion python/core/qgsapplication.sip
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
* but don't have commit access. */
static const QString contributorsFilePath();

/**Returns the path to the sponsors file.*/
/** Returns the path to the developers map file.
* The developers map was created by using leaflet framework,
* it shows the doc/contributors.json file.
* @note this function was added in version 2.7 */
static const QString developersMapFilePath();

/**Returns the path to the sponsors file. */
static const QString sponsorsFilePath();

/** Returns the path to the donors file. */
Expand Down
19 changes: 19 additions & 0 deletions src/app/qgsabout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QTextStream>
#include <QImageReader>
#include <QSqlDatabase>
#include <QTcpSocket>

/* Uncomment this block to use preloaded images
#include <map>
Expand Down Expand Up @@ -51,6 +52,17 @@ void QgsAbout::init()
{
setPluginInfo();

// check internet connection in order to hide/show the developers map widget
int DEVELOPERS_MAP_INDEX = 5;
QTcpSocket socket;
QString host = "qgis.org";
int port = 80;
socket.connectToHost( host, port );
if ( socket.waitForConnected( 1000 ) )
setDevelopersMap();
else
mOptionsListWidget->item( DEVELOPERS_MAP_INDEX )->setHidden( true );

// set the 60x60 icon pixmap
QPixmap icon( QgsApplication::iconsPath() + "qgis-icon-60x60.png" );
qgisIcon->setPixmap( icon );
Expand Down Expand Up @@ -303,3 +315,10 @@ QString QgsAbout::fileSystemSafe( QString fileName )

return result;
}

void QgsAbout::setDevelopersMap()
{
developersMapView->settings()->setAttribute( QWebSettings::JavascriptEnabled, true );
QUrl url = QUrl::fromLocalFile( QgsApplication::developersMapFilePath() );
developersMapView->load( url );
}
1 change: 1 addition & 0 deletions src/app/qgsabout.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class APP_EXPORT QgsAbout : public QgsOptionsDialogBase, private Ui::QgsAbout
void setWhatsNew();
void setLicence();
void setPluginInfo();
void setDevelopersMap();
void init();
void openUrl( QString url );

Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,10 @@ const QString QgsApplication::contributorsFilePath()
{
return ABISYM( mPkgDataPath ) + QString( "/doc/CONTRIBUTORS" );
}
const QString QgsApplication::developersMapFilePath()
{
return ABISYM( mPkgDataPath ) + QString( "/doc/developersmap.html" );
}
/*!
Returns the path to the sponsors file.
*/
Expand Down
8 changes: 7 additions & 1 deletion src/core/qgsapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ class CORE_EXPORT QgsApplication : public QApplication
* but don't have commit access. */
static const QString contributorsFilePath();

/**Returns the path to the sponsors file.*/
/** Returns the path to the developers map file.
* The developers map was created by using leaflet framework,
* it shows the doc/contributors.json file.
* @note this function was added in version 2.7 */
static const QString developersMapFilePath();

/** Returns the path to the sponsors file. */
static const QString sponsorsFilePath();

/** Returns the path to the donors file. */
Expand Down
31 changes: 26 additions & 5 deletions src/ui/qgsabout.ui
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
<string>Contributors</string>
</property>
</item>
<item>
<property name="text">
<string>Developers Map</string>
</property>
</item>
<item>
<property name="text">
<string>Translators</string>
Expand Down Expand Up @@ -150,7 +155,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>5</number>
</property>
<widget class="QWidget" name="mOptsPage_01">
<layout class="QVBoxLayout" name="verticalLayout_4">
Expand Down Expand Up @@ -191,8 +196,8 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item>
<widget class="QWebView" name="txtVersion" native="true">
<property name="url" stdset="0">
<widget class="QWebView" name="txtVersion">
<property name="url">
<url>
<string>about:blank</string>
</url>
Expand Down Expand Up @@ -359,14 +364,30 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="developersMap">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWebView" name="developersMapView">
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_5">
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QWebView" name="txtTranslators" native="true">
<property name="url" stdset="0">
<widget class="QWebView" name="txtTranslators">
<property name="url">
<url>
<string>about:blank</string>
</url>
Expand Down

0 comments on commit 9952fc8

Please sign in to comment.