Commit 126ad85e authored by pixhawk's avatar pixhawk

Merge branch 'dev-lin' of https://github.com/pixhawk/qgroundcontrol into dev

parents dee19d0c df70c98b
...@@ -204,7 +204,7 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) ...@@ -204,7 +204,7 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv)
QGCCore::~QGCCore() QGCCore::~QGCCore()
{ {
//mainWindow->storeSettings(); //mainWindow->storeSettings();
mainWindow->hide(); mainWindow->close();
mainWindow->deleteLater(); mainWindow->deleteLater();
// Delete singletons // Delete singletons
delete LinkManager::instance(); delete LinkManager::instance();
......
...@@ -66,6 +66,22 @@ protected: ...@@ -66,6 +66,22 @@ protected:
DomModel* model; DomModel* model;
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
signals:
void visibilityChanged(bool visible);
protected:
void showEvent(QShowEvent* event)
{
QWidget::showEvent(event);
emit visibilityChanged(true);
}
void hideEvent(QHideEvent* event)
{
QWidget::hideEvent(event);
emit visibilityChanged(false);
}
private: private:
Ui::XMLCommProtocolWidget *m_ui; Ui::XMLCommProtocolWidget *m_ui;
}; };
......
...@@ -176,14 +176,64 @@ public: ...@@ -176,14 +176,64 @@ public:
/** @brief Get the type of the system (airplane, quadrotor, helicopter,..)*/ /** @brief Get the type of the system (airplane, quadrotor, helicopter,..)*/
virtual int getSystemType() = 0; virtual int getSystemType() = 0;
/** @brief Get the type of the autopilot (PIXHAWK, APM, UDB, PPZ,..) */
virtual int getAutopilotType() = 0;
virtual void setAutopilotType(int apType)= 0;
QString getSystemTypeString(int type)
{
switch (type)
{
default:
case 0:
return "MAV_TYPE_GENERIC";
case 1:
return "MAV_TYPE_FIXED_WING";
case 2:
return "MAV_TYPE_QUADROTOR";
case 3:
return "MAV_TYPE_COAXIAL";
case 4:
return "MAV_TYPE_HELICOPTER";
case 5:
return "MAV_TYPE_GROUND";
case 6:
return "MAV_TYPE_GCS";
case 7:
return "MAV_TYPE_AIRSHIP";
case 8:
return "MAV_TYPE_FREE_BALLOON";
case 9:
return "MAV_TYPE_ROCKET";
case 10:
return "MAV_TYPE_UGV_GROUND_ROVER";
case 11:
return "MAV_TYPE_UGV_SURFACE_SHIP";
}
}
QString getAutopilotTypeString(int type)
{
switch (type)
{
default:
case 0:
return "MAV_AUTOPILOT_GENERIC";
case 1:
return "MAV_AUTOPILOT_PIXHAWK";
case 2:
return "MAV_AUTOPILOT_SLUGS";
case 3:
return "MAV_AUTOPILOT_ARDUPILOTMEGA";
case 4:
return "MAV_AUTOPILOT_OPENPILOT";
}
}
QColor getColor() { QColor getColor() {
return color; return color;
} }
virtual int getAutopilotType() = 0;
virtual void setAutopilotType(int apType)= 0;
public slots: public slots:
/** @brief Set a new name for the system */ /** @brief Set a new name for the system */
......
...@@ -200,14 +200,16 @@ void HUD::showEvent(QShowEvent* event) ...@@ -200,14 +200,16 @@ void HUD::showEvent(QShowEvent* event)
// events // events
QGLWidget::showEvent(event); QGLWidget::showEvent(event);
refreshTimer->start(updateInterval); refreshTimer->start(updateInterval);
emit visibilityChanged(true);
} }
void HUD::hideEvent(QHideEvent* event) void HUD::hideEvent(QHideEvent* event)
{ {
// React only to internal (pre-display) // React only to internal (pre-display)
// events // events
QGLWidget::hideEvent(event);
refreshTimer->stop(); refreshTimer->stop();
QGLWidget::hideEvent(event);
emit visibilityChanged(false);
} }
void HUD::contextMenuEvent (QContextMenuEvent* event) void HUD::contextMenuEvent (QContextMenuEvent* event)
......
...@@ -113,6 +113,9 @@ protected slots: ...@@ -113,6 +113,9 @@ protected slots:
void drawPolygon(QPolygonF refPolygon, QPainter* painter); void drawPolygon(QPolygonF refPolygon, QPainter* painter);
signals:
void visibilityChanged(bool visible);
protected: protected:
void commitRawDataToGL(); void commitRawDataToGL();
/** @brief Convert reference coordinates to screen coordinates */ /** @brief Convert reference coordinates to screen coordinates */
......
...@@ -128,11 +128,8 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -128,11 +128,8 @@ MainWindow::MainWindow(QWidget *parent):
setCentralWidget(centerStack); setCentralWidget(centerStack);
buildCommonWidgets(); buildCommonWidgets();
connectCommonWidgets(); connectCommonWidgets();
arrangeCommonCenterStack();
configureWindowName(); configureWindowName();
loadStyle(currentStyle); loadStyle(currentStyle);
...@@ -235,7 +232,13 @@ MainWindow::~MainWindow() ...@@ -235,7 +232,13 @@ MainWindow::~MainWindow()
delete dockWidget->widget(); delete dockWidget->widget();
delete dockWidget; delete dockWidget;
} }
else
{
delete dynamic_cast<QObject*>(*i);
}
} }
// Delete all UAS objects
} }
/** /**
...@@ -243,11 +246,9 @@ MainWindow::~MainWindow() ...@@ -243,11 +246,9 @@ MainWindow::~MainWindow()
*/ */
void MainWindow::setDefaultSettingsForAp() void MainWindow::setDefaultSettingsForAp()
{ {
// Check if the settings exist, instantiate defaults if necessary
// // Check if the settings exist, instantiate defaults if necessary
// // UNCONNECTED VIEW DEFAULT // // UNCONNECTED VIEW DEFAULT
//// QString centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_MAP, VIEW_UNCONNECTED); //// QString centralKey = buildMenuKey(SUB_SECTION_CHECKED, CENTRAL_MAP, VIEW_UNCONNECTED);
// if (!settings.contains(centralKey)) { // if (!settings.contains(centralKey)) {
...@@ -574,6 +575,9 @@ void MainWindow::buildCommonWidgets() ...@@ -574,6 +575,9 @@ void MainWindow::buildCommonWidgets()
addTool(video2DockWidget, tr("Video Stream 2"), Qt::LeftDockWidgetArea); addTool(video2DockWidget, tr("Video Stream 2"), Qt::LeftDockWidgetArea);
} }
// Custom widgets, added last to all menus and layouts
buildCustomWidget();
// Dialogue widgets // Dialogue widgets
//FIXME: free memory in destructor //FIXME: free memory in destructor
...@@ -588,6 +592,8 @@ void MainWindow::addTool(QDockWidget* widget, const QString& title, Qt::DockWidg ...@@ -588,6 +592,8 @@ void MainWindow::addTool(QDockWidget* widget, const QString& title, Qt::DockWidg
var.setValue((QWidget*)widget); var.setValue((QWidget*)widget);
tempAction->setData(var); tempAction->setData(var);
connect(tempAction,SIGNAL(triggered(bool)),this, SLOT(showTool(bool))); connect(tempAction,SIGNAL(triggered(bool)),this, SLOT(showTool(bool)));
connect(widget, SIGNAL(visibilityChanged(bool)), tempAction, SLOT(setChecked(bool)));
tempAction->setChecked(widget->isVisible());
addDockWidget(area, widget); addDockWidget(area, widget);
} }
...@@ -614,6 +620,8 @@ void MainWindow::addCentralWidget(QWidget* widget, const QString& title) ...@@ -614,6 +620,8 @@ void MainWindow::addCentralWidget(QWidget* widget, const QString& title)
tempAction->setData(var); tempAction->setData(var);
centerStackActionGroup.addAction(tempAction); centerStackActionGroup.addAction(tempAction);
connect(tempAction,SIGNAL(triggered()),this, SLOT(showCentralWidget())); connect(tempAction,SIGNAL(triggered()),this, SLOT(showCentralWidget()));
connect(widget, SIGNAL(visibilityChanged(bool)), tempAction, SLOT(setChecked(bool)));
tempAction->setChecked(widget->isVisible());
} }
} }
...@@ -677,34 +685,58 @@ void MainWindow::loadCustomWidget() ...@@ -677,34 +685,58 @@ void MainWindow::loadCustomWidget()
{ {
QString widgetFileExtension(".qgw"); QString widgetFileExtension(".qgw");
QString fileName = QFileDialog::getOpenFileName(this, tr("Specify Widget File Name"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("QGroundControl Widget (*%1);;").arg(widgetFileExtension)); QString fileName = QFileDialog::getOpenFileName(this, tr("Specify Widget File Name"), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), tr("QGroundControl Widget (*%1);;").arg(widgetFileExtension));
QGCToolWidget* tool = new QGCToolWidget("", this); loadCustomWidget(fileName);
tool->loadSettings(fileName); }
if (QGCToolWidget::instances()->size() < 2) void MainWindow::loadCustomWidget(const QString& fileName, bool singleinstance)
{
QGCToolWidget* tool = new QGCToolWidget("", this);
if (tool->loadSettings(fileName, true) || !singleinstance)
{ {
// This is the first widget // Add widget to UI
ui.menuTools->addSeparator(); QDockWidget* dock = new QDockWidget(tool->getTitle(), this);
connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
dock->setWidget(tool);
tool->setParent(dock);
QAction* showAction = new QAction("Show Unnamed Tool", this);
showAction->setCheckable(true);
connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
tool->setMainMenuAction(showAction);
ui.menuTools->addAction(showAction);
this->addDockWidget(Qt::BottomDockWidgetArea, dock);
dock->setVisible(true);
}
else
{
return;
} }
// Add widget to UI
QDockWidget* dock = new QDockWidget(tool->getTitle(), this);
connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
dock->setWidget(tool);
tool->setParent(dock);
QAction* showAction = new QAction("Show Unnamed Tool", this);
showAction->setCheckable(true);
connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
tool->setMainMenuAction(showAction);
ui.menuTools->addAction(showAction);
this->addDockWidget(Qt::BottomDockWidgetArea, dock);
dock->setVisible(true);
} }
void MainWindow::arrangeCommonCenterStack() void MainWindow::loadCustomWidgetsFromDefaults(const QString& systemType, const QString& autopilotType)
{ {
QString defaultsDir = qApp->applicationDirPath() + "/files/" + systemType.toLower() + "/" + autopilotType.toLower() + "/widgets/";
QDir widgets(defaultsDir);
QStringList files = widgets.entryList();
if (files.count() == 0)
{
qDebug() << "No default custom widgets for system " << systemType << "autopilot" << autopilotType << " found";
qDebug() << "Tried with path: " << defaultsDir;
}
// Load all custom widgets found in the AP folder
for(int i = 0; i < files.count(); ++i)
{
QString file = files[i];
if (file.endsWith(".qgw"))
{
// Will only be loaded if not already a custom widget with
// the same name is present
loadCustomWidget(file, true);
}
}
} }
void MainWindow::loadSettings() void MainWindow::loadSettings()
...@@ -1155,10 +1187,8 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1155,10 +1187,8 @@ void MainWindow::UASCreated(UASInterface* uas)
// Connect the UAS to the full user interface // Connect the UAS to the full user interface
if (uas != NULL) { if (uas != NULL)
// Set default settings {
setDefaultSettingsForAp();
// The pilot, operator and engineer views were not available on startup, enable them now // The pilot, operator and engineer views were not available on startup, enable them now
ui.actionPilotsView->setEnabled(true); ui.actionPilotsView->setEnabled(true);
ui.actionOperatorsView->setEnabled(true); ui.actionOperatorsView->setEnabled(true);
...@@ -1236,6 +1266,11 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1236,6 +1266,11 @@ void MainWindow::UASCreated(UASInterface* uas)
addCentralWidget(linechartWidget, tr("Realtime Plot")); addCentralWidget(linechartWidget, tr("Realtime Plot"));
} }
// Load default custom widgets for this autopilot type
loadCustomWidgetsFromDefaults(uas->getSystemTypeString(uas->getSystemType()), uas->getAutopilotTypeString(uas->getAutopilotType()));
// Change the view only if this is the first UAS // Change the view only if this is the first UAS
// If this is the first connected UAS, it is both created as well as // If this is the first connected UAS, it is both created as well as
...@@ -1275,10 +1310,9 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1275,10 +1310,9 @@ void MainWindow::UASCreated(UASInterface* uas)
if (!ui.menuConnected_Systems->isEnabled()) ui.menuConnected_Systems->setEnabled(true); if (!ui.menuConnected_Systems->isEnabled()) ui.menuConnected_Systems->setEnabled(true);
// Custom widgets, added last to all menus and layouts
buildCustomWidget();
// Restore the mainwindow size // Restore the mainwindow size
if (settings.contains(getWindowGeometryKey())) { if (settings.contains(getWindowGeometryKey()))
{
restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray()); restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray());
} }
} }
...@@ -1302,7 +1336,13 @@ void MainWindow::loadViewState() ...@@ -1302,7 +1336,13 @@ void MainWindow::loadViewState()
{ {
// Restore center stack state // Restore center stack state
int index = settings.value(getWindowStateKey()+"CENTER_WIDGET", centerStack->currentIndex()).toInt(); int index = settings.value(getWindowStateKey()+"CENTER_WIDGET", centerStack->currentIndex()).toInt();
centerStack->setCurrentIndex(index); // The offline plot view is usually the consequence of a logging run, always show the realtime view first
if (centerStack->indexOf(dataplotWidget) == index)
{
// Rewrite to realtime plot
index = centerStack->indexOf(linechartWidget);
}
if (index != -1) centerStack->setCurrentIndex(index);
// Restore the widget positions and size // Restore the widget positions and size
if (settings.contains(getWindowStateKey())) if (settings.contains(getWindowStateKey()))
......
...@@ -178,9 +178,15 @@ public slots: ...@@ -178,9 +178,15 @@ public slots:
/** @brief Add a custom tool widget */ /** @brief Add a custom tool widget */
void createCustomWidget(); void createCustomWidget();
/** @brief Load a custom tool widget from a file */ /** @brief Load a custom tool widget from a file chosen by user (QFileDialog) */
void loadCustomWidget(); void loadCustomWidget();
/** @brief Load a custom tool widget from a file */
void loadCustomWidget(const QString& fileName, bool singleinstance=false);
/** @brief Load custom widgets from default file */
void loadCustomWidgetsFromDefaults(const QString& systemType, const QString& autopilotType);
void closeEvent(QCloseEvent* event); void closeEvent(QCloseEvent* event);
/** @brief Load data view, allowing to plot flight data */ /** @brief Load data view, allowing to plot flight data */
...@@ -275,21 +281,8 @@ protected: ...@@ -275,21 +281,8 @@ protected:
void buildCustomWidget(); void buildCustomWidget();
void buildCommonWidgets(); void buildCommonWidgets();
// void buildPxWidgets();
// void buildSlugsWidgets();
void connectCommonWidgets(); void connectCommonWidgets();
// void connectPxWidgets();
// void connectSlugsWidgets();
void arrangeCommonCenterStack();
// void arrangePxCenterStack();
// void arrangeSlugsCenterStack();
void connectCommonActions(); void connectCommonActions();
// void connectPxActions();
// void connectSlugsActions();
void configureWindowName(); void configureWindowName();
void loadSettings(); void loadSettings();
...@@ -307,9 +300,7 @@ protected: ...@@ -307,9 +300,7 @@ protected:
// Center widgets // Center widgets
QPointer<Linecharts> linechartWidget; QPointer<Linecharts> linechartWidget;
QPointer<HUD> hudWidget; QPointer<HUD> hudWidget;
QPointer<QGCMapTool> mapWidget; QPointer<QGCMapTool> mapWidget;
QPointer<XMLCommProtocolWidget> protocolWidget; QPointer<XMLCommProtocolWidget> protocolWidget;
QPointer<QGCDataPlot2D> dataplotWidget; QPointer<QGCDataPlot2D> dataplotWidget;
...@@ -322,6 +313,7 @@ protected: ...@@ -322,6 +313,7 @@ protected:
#if (defined _MSC_VER) || (defined Q_OS_MAC) #if (defined _MSC_VER) || (defined Q_OS_MAC)
QPointer<QGCGoogleEarthView> gEarthWidget; QPointer<QGCGoogleEarthView> gEarthWidget;
#endif #endif
// Dock widgets // Dock widgets
QPointer<QDockWidget> controlDockWidget; QPointer<QDockWidget> controlDockWidget;
QPointer<QDockWidget> controlParameterWidget; QPointer<QDockWidget> controlParameterWidget;
......
...@@ -46,7 +46,22 @@ public slots: ...@@ -46,7 +46,22 @@ public slots:
/** @brief Calculate and display regression function*/ /** @brief Calculate and display regression function*/
bool calculateRegression(); bool calculateRegression();
signals:
void visibilityChanged(bool visible);
protected: protected:
void showEvent(QShowEvent* event)
{
QWidget::showEvent(event);
emit visibilityChanged(true);
}
void hideEvent(QHideEvent* event)
{
QWidget::hideEvent(event);
emit visibilityChanged(false);
}
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
IncrementalPlot* plot; IncrementalPlot* plot;
LogCompressor* compressor; LogCompressor* compressor;
......
...@@ -109,14 +109,19 @@ QList<QGCToolWidget*> QGCToolWidget::createWidgetsFromSettings(QWidget* parent, ...@@ -109,14 +109,19 @@ QList<QGCToolWidget*> QGCToolWidget::createWidgetsFromSettings(QWidget* parent,
return instances()->values(); return instances()->values();
} }
void QGCToolWidget::loadSettings(const QString& settings) /**
* @param singleinstance If this is set to true, the widget settings will only be loaded if not another widget with the same title exists
*/
bool QGCToolWidget::loadSettings(const QString& settings, bool singleinstance)
{ {
QSettings set(settings, QSettings::IniFormat); QSettings set(settings, QSettings::IniFormat);
QStringList groups = set.childGroups(); QStringList groups = set.childGroups();
QString widgetName = groups.first(); QString widgetName = groups.first();
if (singleinstance && QGCToolWidget::instances()->keys().contains(widgetName)) return false;
setTitle(widgetName); setTitle(widgetName);
qDebug() << "WIDGET TITLE LOADED: " << widgetName; qDebug() << "WIDGET TITLE LOADED: " << widgetName;
loadSettings(set); loadSettings(set);
return true;
} }
void QGCToolWidget::loadSettings(QSettings& settings) void QGCToolWidget::loadSettings(QSettings& settings)
......
...@@ -47,7 +47,7 @@ public slots: ...@@ -47,7 +47,7 @@ public slots:
/** @brief Load this widget from a QSettings object */ /** @brief Load this widget from a QSettings object */
void loadSettings(QSettings& settings); void loadSettings(QSettings& settings);
/** @brief Load this widget from a settings file */ /** @brief Load this widget from a settings file */
void loadSettings(const QString& settings); bool loadSettings(const QString& settings, bool singleinstance=false);
/** @brief Store this widget to a QSettings object */ /** @brief Store this widget to a QSettings object */
void storeSettings(QSettings& settings); void storeSettings(QSettings& settings);
/** @brief Store this widget to a settings file */ /** @brief Store this widget to a settings file */
......
...@@ -30,32 +30,35 @@ void Linecharts::showEvent(QShowEvent* event) ...@@ -30,32 +30,35 @@ void Linecharts::showEvent(QShowEvent* event)
{ {
// React only to internal (pre-display) // React only to internal (pre-display)
// events // events
Q_UNUSED(event) { Q_UNUSED(event)
QWidget* prevWidget = currentWidget(); QWidget* prevWidget = currentWidget();
if (prevWidget) { if (prevWidget)
LinechartWidget* chart = dynamic_cast<LinechartWidget*>(prevWidget); {
if (chart) { LinechartWidget* chart = dynamic_cast<LinechartWidget*>(prevWidget);
this->active = true; if (chart) {
chart->setActive(true); this->active = true;
} chart->setActive(true);
} }
} }
QWidget::showEvent(event);
emit visibilityChanged(true);
} }
void Linecharts::hideEvent(QHideEvent* event) void Linecharts::hideEvent(QHideEvent* event)
{ {
// React only to internal (pre-display) // React only to internal (pre-display)
// events // events
Q_UNUSED(event) { Q_UNUSED(event)
QWidget* prevWidget = currentWidget(); QWidget* prevWidget = currentWidget();
if (prevWidget) { if (prevWidget) {
LinechartWidget* chart = dynamic_cast<LinechartWidget*>(prevWidget); LinechartWidget* chart = dynamic_cast<LinechartWidget*>(prevWidget);
if (chart) { if (chart) {
this->active = false; this->active = false;
chart->setActive(false); chart->setActive(false);
}
} }
} }
QWidget::hideEvent(event);
emit visibilityChanged(false);
} }
void Linecharts::selectSystem(int systemid) void Linecharts::selectSystem(int systemid)
......
...@@ -16,6 +16,7 @@ public: ...@@ -16,6 +16,7 @@ public:
signals: signals:
/** @brief This signal is emitted once a logfile has been finished writing */ /** @brief This signal is emitted once a logfile has been finished writing */
void logfileWritten(QString fileName); void logfileWritten(QString fileName);
void visibilityChanged(bool visible);
public slots: public slots:
/** @brief Select plot for one system */ /** @brief Select plot for one system */
...@@ -24,6 +25,7 @@ public slots: ...@@ -24,6 +25,7 @@ public slots:
void addSystem(UASInterface* uas); void addSystem(UASInterface* uas);
protected: protected:
QMap<int, LinechartWidget*> plots; QMap<int, LinechartWidget*> plots;
bool active; bool active;
/** @brief Start updating widget */ /** @brief Start updating widget */
......
...@@ -20,6 +20,22 @@ public slots: ...@@ -20,6 +20,22 @@ public slots:
/** @brief Update slider zoom from map change */ /** @brief Update slider zoom from map change */
void setZoom(int zoom); void setZoom(int zoom);
signals:
void visibilityChanged(bool visible);
protected:
void showEvent(QShowEvent* event)
{
QWidget::showEvent(event);
emit visibilityChanged(true);
}
void hideEvent(QHideEvent* event)
{
QWidget::hideEvent(event);
emit visibilityChanged(false);
}
private: private:
Ui::QGCMapTool *ui; Ui::QGCMapTool *ui;
}; };
......
...@@ -376,18 +376,20 @@ void QGCGoogleEarthView::moveToPosition() ...@@ -376,18 +376,20 @@ void QGCGoogleEarthView::moveToPosition()
void QGCGoogleEarthView::hideEvent(QHideEvent* event) void QGCGoogleEarthView::hideEvent(QHideEvent* event)
{ {
Q_UNUSED(event);
updateTimer->stop(); updateTimer->stop();
QWidget::hideEvent(event);
emit visibilityChanged(false);
} }
void QGCGoogleEarthView::showEvent(QShowEvent* event) void QGCGoogleEarthView::showEvent(QShowEvent* event)
{ {
// React only to internal (pre-display) // React only to internal (pre-display)
// events // events
Q_UNUSED(event) QWidget::showEvent(event);
// Enable widget, initialize on first run // Enable widget, initialize on first run
if (!webViewInitialized) { if (!webViewInitialized)
{
#if (defined Q_OS_MAC) #if (defined Q_OS_MAC)
webViewMac->setPage(new QGCWebPage(webViewMac)); webViewMac->setPage(new QGCWebPage(webViewMac));
webViewMac->settings()->setAttribute(QWebSettings::PluginsEnabled, true); webViewMac->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
...@@ -404,9 +406,12 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event) ...@@ -404,9 +406,12 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
gEarthInitialized = false; gEarthInitialized = false;
QTimer::singleShot(3000, this, SLOT(initializeGoogleEarth())); QTimer::singleShot(3000, this, SLOT(initializeGoogleEarth()));
} else { }
else
{
updateTimer->start(refreshRateMs); updateTimer->start(refreshRateMs);
} }
emit visibilityChanged(true);
} }
void QGCGoogleEarthView::printWinException(int no, QString str1, QString str2, QString str3) void QGCGoogleEarthView::printWinException(int no, QString str1, QString str2, QString str3)
......
...@@ -137,6 +137,9 @@ public: ...@@ -137,6 +137,9 @@ public:
/** @brief Get a document element */ /** @brief Get a document element */
QVariant documentElement(QString name); QVariant documentElement(QString name);
signals:
void visibilityChanged(bool visible);
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
QTimer* updateTimer; QTimer* updateTimer;
......
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