Add Developers Map in About dialog

This commit is contained in:
Salvatore Larosa 2014-10-18 14:12:59 +02:00
parent 1d9eb8f66d
commit 9952fc8aa6
8 changed files with 96 additions and 8 deletions

View File

@ -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)

31
doc/developersmap.html Normal file
View File

@ -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>

View File

@ -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. */

View File

@ -24,6 +24,7 @@
#include <QTextStream>
#include <QImageReader>
#include <QSqlDatabase>
#include <QTcpSocket>
/* Uncomment this block to use preloaded images
#include <map>
@ -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 );
@ -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 );
}

View File

@ -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 );

View File

@ -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.
*/

View File

@ -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. */

View File

@ -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>
@ -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">
@ -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>
@ -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>