From 27737cde80cff5dfb59ce4823dc8e96fcf3f204e Mon Sep 17 00:00:00 2001 From: pixhawk Date: Sun, 12 Dec 2010 13:08:58 +0100 Subject: [PATCH] Added widget menu --- qgroundcontrol.pri | 2 + qgroundcontrol.pro | 6 ++- src/comm/MAVLinkSimulationLink.cc | 15 ++++---- src/uas/PxQuadMAV.cc | 2 +- src/ui/MainWindow.cc | 55 +++++++++++++++++++++++++++ src/ui/MainWindow.h | 7 ++++ src/ui/QGCMainWindowAPConfigurator.cc | 6 +++ src/ui/QGCMainWindowAPConfigurator.h | 18 +++++++++ src/ui/map3D/QGCGoogleEarthView.cc | 40 ++++++++++++++----- src/ui/map3D/QGCGoogleEarthView.h | 6 +++ 10 files changed, 138 insertions(+), 19 deletions(-) create mode 100644 src/ui/QGCMainWindowAPConfigurator.cc create mode 100644 src/ui/QGCMainWindowAPConfigurator.h diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index 49cdbf323..08e2358f8 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -80,6 +80,8 @@ macx { QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$TARGETDIR/qgroundcontrol.app/Contents/MacOs # Copy google earth starter file QMAKE_POST_LINK += && cp -f $$BASEDIR/images/earth.html $$TARGETDIR/qgroundcontrol.app/Contents/MacOs + # Copy CSS stylesheet + QMAKE_POST_LINK += && cp -f $$BASEDIR/images/style-mission.css $$TARGETDIR/qgroundcontrol.app/Contents/MacOs/qgroundcontrol.css # Copy model files #QMAKE_POST_LINK += && cp -f $$BASEDIR/models/*.dae $$TARGETDIR/qgroundcontrol.app/Contents/MacOs diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index f7cbd8f43..d526a2607 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -249,7 +249,8 @@ HEADERS += src/MG.h \ src/ui/SlugsHilSim.h \ src/ui/SlugsPIDControl.h \ src/ui/SlugsVideoCamControl.h \ - src/ui/SlugsPadCameraControl.h + src/ui/SlugsPadCameraControl.h \ + src/ui/QGCMainWindowAPConfigurator.h contains(DEPENDENCIES_PRESENT, osg) { message("Including headers for OpenSceneGraph") @@ -359,7 +360,8 @@ SOURCES += src/main.cc \ src/ui/SlugsHilSim.cc \ src/ui/SlugsPIDControl.cpp \ src/ui/SlugsVideoCamControl.cpp \ - src/ui/SlugsPadCameraControl.cpp + src/ui/SlugsPadCameraControl.cpp \ + src/ui/QGCMainWindowAPConfigurator.cc contains(DEPENDENCIES_PRESENT, osg) { message("Including sources for OpenSceneGraph") diff --git a/src/comm/MAVLinkSimulationLink.cc b/src/comm/MAVLinkSimulationLink.cc index 4d8966621..eec64a2bb 100644 --- a/src/comm/MAVLinkSimulationLink.cc +++ b/src/comm/MAVLinkSimulationLink.cc @@ -559,16 +559,17 @@ void MAVLinkSimulationLink::mainloop() // Send controller states -// uint8_t attControl = 1; -// uint8_t posXYControl = 1; -// uint8_t posZControl = 0; -// uint8_t posYawControl = 1; -// uint8_t gpsLock = 2; -// uint8_t visLock = 3; - //uint8_t posLock = qMax(gpsLock, visLock); #ifdef MAVLINK_ENABLED_PIXHAWK + uint8_t attControl = 1; + uint8_t posXYControl = 1; + uint8_t posZControl = 0; + uint8_t posYawControl = 1; + + uint8_t gpsLock = 2; + uint8_t visLock = 3; + uint8_t posLock = qMax(gpsLock, visLock); messageSize = mavlink_msg_control_status_pack(systemId, componentId, &msg, posLock, visLock, gpsLock, attControl, posXYControl, posZControl, posYawControl); #endif diff --git a/src/uas/PxQuadMAV.cc b/src/uas/PxQuadMAV.cc index ba79d860e..2b9739ee4 100644 --- a/src/uas/PxQuadMAV.cc +++ b/src/uas/PxQuadMAV.cc @@ -41,12 +41,12 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) { // Let UAS handle the default message set UAS::receiveMessage(link, message); -// mavlink_message_t* msg = &message; //qDebug() << "PX RECEIVED" << msg->sysid << msg->compid << msg->msgid; // Only compile this portion if matching MAVLink packets have been compiled #ifdef MAVLINK_ENABLED_PIXHAWK + mavlink_message_t* msg = &message; if (message.sysid == uasId) { diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index df135436a..b655244bd 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -81,6 +81,11 @@ MainWindow::MainWindow(QWidget *parent) : // Adjust the size adjustSize(); + + // Set menu + QMenu* widgetMenu = createPopupMenu(); + widgetMenu->setTitle("Widgets"); + ui.menuBar->addMenu(widgetMenu); } MainWindow::~MainWindow() @@ -89,6 +94,46 @@ MainWindow::~MainWindow() statusBar = NULL; } +//QList* MainWindow::getMainWidgets() +//{ + +//} + +//QMenu* QMainWindow::getDockWidgetMenu() +//{ +// Q_D(QMainWindow); +// QMenu *menu = 0; +//#ifndef QT_NO_DOCKWIDGET +// QList dockwidgets = qFindChildren(this); +// if (dockwidgets.size()) { +// menu = new QMenu(this); +// for (int i = 0; i < dockwidgets.size(); ++i) { +// QDockWidget *dockWidget = dockwidgets.at(i); +// if (dockWidget->parentWidget() == this +// && d->layout->contains(dockWidget)) { +// menu->addAction(dockwidgets.at(i)->toggleViewAction()); +// } +// } +// menu->addSeparator(); +// } +//#endif // QT_NO_DOCKWIDGET +//#ifndef QT_NO_TOOLBAR +// QList toolbars = qFindChildren(this); +// if (toolbars.size()) { +// if (!menu) +// menu = new QMenu(this); +// for (int i = 0; i < toolbars.size(); ++i) { +// QToolBar *toolBar = toolbars.at(i); +// if (toolBar->parentWidget() == this +// && d->layout->contains(toolBar)) { +// menu->addAction(toolbars.at(i)->toggleViewAction()); +// } +// } +// } +//#endif +// Q_UNUSED(d); +// return menu; +//} void MainWindow::buildWidgets() { @@ -287,6 +332,16 @@ void MainWindow::configureWindowName() #endif } +void MainWindow::createCenterWidgetMenu() +{ + +} + +void MainWindow::createDockWidgetMenu() +{ + +} + QStatusBar* MainWindow::createStatusBar() { QStatusBar* bar = new QStatusBar(); diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 646dc0a21..475da821d 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -160,6 +160,9 @@ protected: void arrangeCenterStack(); void configureWindowName(); + void createCenterWidgetMenu(); + void createDockWidgetMenu(); + // TODO Should be moved elsewhere, as the protocol does not belong to the UI MAVLinkProtocol* mavlink; AS4Protocol* as4link; @@ -168,6 +171,10 @@ protected: LinkInterface* udpLink; QSettings settings; + // Widget lists + QList > centerWidgets; + QList > dockWidgets; + // Center widgets QPointer linechartWidget; QPointer hudWidget; diff --git a/src/ui/QGCMainWindowAPConfigurator.cc b/src/ui/QGCMainWindowAPConfigurator.cc new file mode 100644 index 000000000..69da8c599 --- /dev/null +++ b/src/ui/QGCMainWindowAPConfigurator.cc @@ -0,0 +1,6 @@ +#include "QGCMainWindowAPConfigurator.h" + +QGCMainWindowAPConfigurator::QGCMainWindowAPConfigurator(QObject *parent) : + QObject(parent) +{ +} diff --git a/src/ui/QGCMainWindowAPConfigurator.h b/src/ui/QGCMainWindowAPConfigurator.h new file mode 100644 index 000000000..f4806f820 --- /dev/null +++ b/src/ui/QGCMainWindowAPConfigurator.h @@ -0,0 +1,18 @@ +#ifndef QGCMAINWINDOWAPCONFIGURATOR_H +#define QGCMAINWINDOWAPCONFIGURATOR_H + +#include + +class QGCMainWindowAPConfigurator : public QObject +{ + Q_OBJECT +public: + explicit QGCMainWindowAPConfigurator(QObject *parent = 0); + +signals: + +public slots: + +}; + +#endif // QGCMAINWINDOWAPCONFIGURATOR_H diff --git a/src/ui/map3D/QGCGoogleEarthView.cc b/src/ui/map3D/QGCGoogleEarthView.cc index 2754dc6aa..ecd7e52e2 100644 --- a/src/ui/map3D/QGCGoogleEarthView.cc +++ b/src/ui/map3D/QGCGoogleEarthView.cc @@ -16,9 +16,11 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : QWidget(parent), updateTimer(new QTimer(this)), + refreshRateMs(200), mav(NULL), followCamera(true), trailEnabled(true), + webViewInitialized(false), #if (defined Q_OS_MAC) webViewMac(new QWebView(this)), #endif @@ -34,22 +36,14 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : #endif ui->setupUi(this); - #if (defined Q_OS_MAC) ui->webViewLayout->addWidget(webViewMac); - webViewMac->setPage(new QGCWebPage(webViewMac)); - webViewMac->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - webViewMac->load(QUrl("earth.html")); -#endif - -#if (defined Q_OS_WIN) & !(defined __MINGW32__) - webViewWin->load(QUrl("earth.html")); #endif #if ((defined Q_OS_MAC) | ((defined Q_OS_WIN) & !(defined __MINGW32__))) connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateState())); - updateTimer->start(200); + updateTimer->start(refreshRateMs); #endif // Follow checkbox @@ -94,9 +88,36 @@ void QGCGoogleEarthView::follow(bool follow) followCamera = follow; } +void QGCGoogleEarthView::hide() +{ + updateTimer->stop(); + QWidget::hide(); +} + +void QGCGoogleEarthView::show() +{ + if (!webViewInitialized) + { +#if (defined Q_OS_MAC) + webViewMac->setPage(new QGCWebPage(webViewMac)); + webViewMac->settings()->setAttribute(QWebSettings::PluginsEnabled, true); + webViewMac->load(QUrl("earth.html")); +#endif + +#if (defined Q_OS_WIN) & !(defined __MINGW32__) + webViewWin->load(QUrl("earth.html")); +#endif + webViewInitialized = true; + } + updateTimer->start(); + QWidget::show(); +} + void QGCGoogleEarthView::updateState() { #ifdef Q_OS_MAC + if (isVisible()) + { if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool()) { static bool initialized = false; @@ -140,6 +161,7 @@ void QGCGoogleEarthView::updateState() } #endif } +} void QGCGoogleEarthView::changeEvent(QEvent *e) { diff --git a/src/ui/map3D/QGCGoogleEarthView.h b/src/ui/map3D/QGCGoogleEarthView.h index f0f4aed07..8ecf5d8f4 100644 --- a/src/ui/map3D/QGCGoogleEarthView.h +++ b/src/ui/map3D/QGCGoogleEarthView.h @@ -62,13 +62,19 @@ public slots: void showWaypoints(bool state); /** @brief Follow the aircraft during flight */ void follow(bool follow); + /** @brief Hide and deactivate */ + void hide(); + /** @brief Show and activate */ + void show(); protected: void changeEvent(QEvent *e); QTimer* updateTimer; + int refreshRateMs; UASInterface* mav; bool followCamera; bool trailEnabled; + bool webViewInitialized; #if (defined Q_OS_WIN) && !(defined __MINGW32__) WebAxWidget* webViewWin; #endif -- 2.22.0