From b1d7f8976cc451b5e6d647e739e4cda0a7736f22 Mon Sep 17 00:00:00 2001 From: pixhawk Date: Sat, 1 Jan 2011 17:29:41 +0100 Subject: [PATCH] Minor improvements and bugfixes --- src/ui/MapWidget.cc | 22 ++++++++++++++++------ src/ui/MapWidget.h | 4 ++++ src/ui/map3D/QGCGoogleEarthView.cc | 14 +++++++++----- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index 07e4904bb..385f66f9f 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -12,7 +12,7 @@ #include #include - +#include #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) { diff --git a/src/ui/MapWidget.h b/src/ui/MapWidget.h index 66125a4ae..f3dde1ed4 100644 --- a/src/ui/MapWidget.h +++ b/src/ui/MapWidget.h @@ -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; diff --git a/src/ui/map3D/QGCGoogleEarthView.cc b/src/ui/map3D/QGCGoogleEarthView.cc index 63eb87c48..5d63bab4a 100644 --- a/src/ui/map3D/QGCGoogleEarthView.cc +++ b/src/ui/map3D/QGCGoogleEarthView.cc @@ -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; } } -- 2.22.0