Commit 415baa2c authored by lm's avatar lm

Finishing refactoring for today, added persistence to map position and zoom level

parent a7ae20ed
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#define WITH_TEXT_TO_SPEECH 1 #define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl" #define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 0.8.3 (Alpha RC6)" #define QGC_APPLICATION_VERSION "v. 0.8.3 (Alpha RC7)"
namespace QGC namespace QGC
......
...@@ -44,7 +44,7 @@ warnVoltage(9.5f), ...@@ -44,7 +44,7 @@ warnVoltage(9.5f),
warnLevelPercent(20.0f), warnLevelPercent(20.0f),
currentVoltage(12.0f), currentVoltage(12.0f),
lpVoltage(12.0f), lpVoltage(12.0f),
batteryRemainingEstimateEnabled(true), batteryRemainingEstimateEnabled(false),
mode(MAV_MODE_UNINIT), mode(MAV_MODE_UNINIT),
status(MAV_STATE_UNINIT), status(MAV_STATE_UNINIT),
onboardTimeOffset(0), onboardTimeOffset(0),
......
...@@ -92,11 +92,24 @@ MapWidget::MapWidget(QWidget *parent) : ...@@ -92,11 +92,24 @@ MapWidget::MapWidget(QWidget *parent) :
// Layer* gsatLayer = new Layer("Google Satellite", gsat, Layer::MapLayer); // Layer* gsatLayer = new Layer("Google Satellite", gsat, Layer::MapLayer);
// mc->addLayer(gsatLayer); // mc->addLayer(gsatLayer);
// Zurich, ETH
int lastZoom = 16;
double lastLat = 47.376889;
double lastLon = 8.548056;
QSettings settings;
settings.beginGroup("QGC_MAPWIDGET");
lastLat = settings.value("LAST_LATITUDE", lastLat).toDouble();
lastLon = settings.value("LAST_LONGITUDE", lastLon).toDouble();
lastZoom = settings.value("LAST_ZOOM", lastZoom).toInt();
settings.endGroup();
// SET INITIAL POSITION AND ZOOM // SET INITIAL POSITION AND ZOOM
// Set default zoom level // Set default zoom level
mc->setZoom(16); mc->setZoom(lastZoom);
// Zurich, ETH mc->setView(QPointF(lastLon, lastLat));
mc->setView(QPointF(8.548056,47.376889));
// Veracruz Mexico // Veracruz Mexico
//mc->setView(QPointF(-96.105208,19.138955)); //mc->setView(QPointF(-96.105208,19.138955));
...@@ -262,7 +275,7 @@ void MapWidget::goTo() ...@@ -262,7 +275,7 @@ void MapWidget::goTo()
bool ok; bool ok;
QString text = QInputDialog::getText(this, tr("Please enter coordinates"), QString text = QInputDialog::getText(this, tr("Please enter coordinates"),
tr("Coordinates (Lat,Lon):"), QLineEdit::Normal, tr("Coordinates (Lat,Lon):"), QLineEdit::Normal,
QString("%1,%2").arg(mc->currentCoordinate().x()).arg(mc->currentCoordinate().y()), &ok); QString("%1,%2").arg(mc->currentCoordinate().y()).arg(mc->currentCoordinate().x()), &ok);
if (ok && !text.isEmpty()) if (ok && !text.isEmpty())
{ {
QStringList split = text.split(","); QStringList split = text.split(",");
...@@ -276,7 +289,7 @@ void MapWidget::goTo() ...@@ -276,7 +289,7 @@ void MapWidget::goTo()
if (ok) if (ok)
{ {
mc->setView(QPointF(latitude, longitude)); mc->setView(QPointF(longitude, latitude));
} }
} }
} }
...@@ -990,6 +1003,14 @@ void MapWidget::showEvent(QShowEvent* event) ...@@ -990,6 +1003,14 @@ void MapWidget::showEvent(QShowEvent* event)
void MapWidget::hideEvent(QHideEvent* event) void MapWidget::hideEvent(QHideEvent* event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
QSettings settings;
settings.beginGroup("QGC_MAPWIDGET");
QPointF currentPos = mc->currentCoordinate();
settings.setValue("LAST_LATITUDE", currentPos.y());
settings.setValue("LAST_LONGITUDE", currentPos.x());
settings.setValue("LAST_ZOOM", mc->currentZoom());
settings.endGroup();
settings.sync();
} }
......
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