Commit 7e431b30 authored by Dennis Nienhüser's avatar Dennis Nienhüser

Basic saving and restoring of settings (e.g. last position)

parent f6c75012
......@@ -13,6 +13,8 @@ import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Layouts 1.1
import org.kde.edu.marble 0.20
Item {
id: root
height: column.height + Screen.pixelDensity * 4
......@@ -22,6 +24,17 @@ Item {
colorGroup: SystemPalette.Active
}
Settings {
id: settings
Component.onDestruction: {
settings.setValue("Developer", "positionProvider", marbleMaps.currentPositionProvider)
settings.setValue("Developer", "textureTiles", marbleMaps.isPropertyEnabled("mapnik") ? "true" : "false")
settings.setValue("Developer", "runtimeTrace", runtimeTrace.checked ? "true" : "false")
settings.setValue("Developer", "debugPolygons", debugPolygons.checked ? "true" : "false")
}
}
Rectangle {
anchors.fill: parent
color: palette.base
......@@ -45,22 +58,27 @@ Item {
CheckBox {
text: "Simulate GPS Position near Route"
checked: settings.value("Developer", "positionProvider") === "RouteSimulationPositionProviderPlugin"
onCheckedChanged: marbleMaps.currentPositionProvider = checked ? "RouteSimulationPositionProviderPlugin" : "QtPositioning"
}
CheckBox {
text: "Show OSM Bitmap Tiles"
checked: marbleMaps.isPropertyEnabled("mapnik")
checked: settings.value("Developer", "textureTiles") === "true"
onCheckedChanged: marbleMaps.setPropertyEnabled("mapnik", checked)
}
CheckBox {
id: runtimeTrace
text: "Show Render Performance"
checked: settings.value("Developer", "runtimeTrace") === "true"
onCheckedChanged: marbleMaps.setShowRuntimeTrace(checked)
}
CheckBox {
id: debugPolygons
text: "Render in Debug Mode"
checked: settings.value("Developer", "debugPolygons") === "true"
onCheckedChanged: marbleMaps.setShowDebugPolygons(checked)
}
......
......@@ -120,6 +120,9 @@ ApplicationWindow {
updateIndicator();
}
Component.onCompleted: marbleMaps.loadSettings()
Component.onDestruction: marbleMaps.writeSettings()
function updateIndicator() {
if ( !positionVisible && positionAvailable ) {
zoomToPositionButton.updateIndicator();
......
......@@ -22,6 +22,9 @@ using namespace Marble;
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
app.setApplicationName( "Marble Maps" );
app.setOrganizationName( "KDE" );
app.setOrganizationDomain( "kde.org" );
#ifdef Q_OS_ANDROID
MarbleGlobal::Profiles profiles = MarbleGlobal::SmallScreen | MarbleGlobal::HighResolution;
......
......@@ -14,6 +14,7 @@
#include <QPaintDevice>
#include <QtMath>
#include <QQmlContext>
#include <QSettings>
#include <MarbleModel.h>
#include <MarbleMap.h>
......@@ -856,6 +857,30 @@ namespace Marble
emit placemarkDelegateChanged(placemarkDelegate);
}
void MarbleQuickItem::loadSettings()
{
QSettings settings;
settings.beginGroup("MarbleQuickItem");
double lon = settings.value("centerLon", QVariant(0.0)).toDouble();
double lat = settings.value("centerLat", QVariant(0.0)).toDouble();
centerOn(lon, lat);
int const zoom = settings.value("zoom", QVariant(0)).toInt();
if (zoom > 0) {
setZoom(zoom);
}
settings.endGroup();
}
void MarbleQuickItem::writeSettings()
{
QSettings settings;
settings.beginGroup("MarbleQuickItem");
settings.setValue("centerLon", QVariant(d->m_map.centerLongitude()));
settings.setValue("centerLat", QVariant(d->m_map.centerLatitude()));
settings.setValue("zoom", QVariant(zoom()));
settings.endGroup();
}
QObject *MarbleQuickItem::getEventFilter() const
{ //We would want to install the same event filter for abstract layer QuickItems such as PinchArea
return &d->m_inputHandler;
......
......@@ -125,6 +125,9 @@ namespace Marble
void setPlacemarkDelegate(QQmlComponent* placemarkDelegate);
Q_INVOKABLE void loadSettings();
Q_INVOKABLE void writeSettings();
public:
void paint(QPainter *painter);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment