Commit b1d7f897 authored by pixhawk's avatar pixhawk

Minor improvements and bugfixes

parent 32e1c529
......@@ -12,7 +12,7 @@
#include <QComboBox>
#include <QGridLayout>
#include <QDir>
#include "MapWidget.h"
#include "ui_MapWidget.h"
......@@ -43,7 +43,7 @@ MapWidget::MapWidget(QWidget *parent) :
mc = new qmapcontrol::MapControl(QSize(320, 240));
mc->showScale(true);
mc->showCoord(true);
mc->enablePersistentCache(qApp->applicationDirPath());
mc->enablePersistentCache();
mc->setMouseTracking(true); // required to update the mouse position for diplay and capture
// create MapAdapter to get maps from
......@@ -76,10 +76,10 @@ MapWidget::MapWidget(QWidget *parent) :
// Set default zoom level
mc->setZoom(16);
// Zurich, ETH
//mc->setView(QPointF(8.548056,47.376389));
mc->setView(QPointF(8.548056,47.376389));
// Veracruz Mexico, ETH
mc->setView(QPointF(-96.105208,19.138955));
// Veracruz Mexico
//mc->setView(QPointF(-96.105208,19.138955));
// Add controls to select map provider
/////////////////////////////////////////////////
......@@ -600,7 +600,7 @@ void MapWidget::updatePosition(float time, double lat, double lon)
{
Q_UNUSED(time);
//gpsposition->setText(QString::number(time) + " / " + QString::number(lat) + " / " + QString::number(lon));
if (followgps->isChecked())
if (followgps->isChecked() && isVisible())
{
mc->setView(QPointF(lat, lon));
}
......@@ -655,6 +655,16 @@ void MapWidget::resizeEvent(QResizeEvent* event )
mc->resize(this->size());
}
void MapWidget::showEvent(QShowEvent* event)
{
Q_UNUSED(event);
}
void MapWidget::hideEvent(QHideEvent* event)
{
Q_UNUSED(event);
}
void MapWidget::changeEvent(QEvent *e)
{
......
......@@ -81,6 +81,10 @@ protected:
void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event);
void resizeEvent(QResizeEvent* event);
/** @brief Start widget updating */
void showEvent(QShowEvent* event);
/** @brief Stop widget updating */
void hideEvent(QHideEvent* event);
QAction* osmAction;
QAction* yahooActionMap;
......
......@@ -203,7 +203,8 @@ void QGCGoogleEarthView::setHome(double lat, double lon, double alt)
void QGCGoogleEarthView::hideEvent(QHideEvent* event)
{
Q_UNUSED(event) updateTimer->stop();
Q_UNUSED(event);
updateTimer->stop();
}
void QGCGoogleEarthView::showEvent(QShowEvent* event)
......@@ -211,11 +212,9 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
// React only to internal (pre-display)
// events
Q_UNUSED(event)
{
// Enable widget, initialize on first run
// FIXME Re-inits now on every visibility change
//if (!webViewInitialized)
if (!webViewInitialized)
{
#if (defined Q_OS_MAC)
webViewMac->setPage(new QGCWebPage(webViewMac));
......@@ -233,9 +232,11 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
gEarthInitialized = false;
QTimer::singleShot(3000, this, SLOT(initializeGoogleEarth()));
}
else
{
updateTimer->start(refreshRateMs);
}
}
}
void QGCGoogleEarthView::printWinException(int no, QString str1, QString str2, QString str3)
......@@ -349,6 +350,9 @@ void QGCGoogleEarthView::initializeGoogleEarth()
connect(ui->camDistanceSlider, SIGNAL(valueChanged(int)), this, SLOT(setViewRangeScaledInt(int)));
setViewRangeScaledInt(ui->camDistanceSlider->value());
// Start update timer
updateTimer->start(refreshRateMs);
gEarthInitialized = true;
}
}
......
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