Commit 27737cde authored by pixhawk's avatar pixhawk

Added widget menu

parent 07b5f77e
...@@ -80,6 +80,8 @@ macx { ...@@ -80,6 +80,8 @@ macx {
QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$TARGETDIR/qgroundcontrol.app/Contents/MacOs QMAKE_POST_LINK += && cp -rf $$BASEDIR/audio $$TARGETDIR/qgroundcontrol.app/Contents/MacOs
# Copy google earth starter file # Copy google earth starter file
QMAKE_POST_LINK += && cp -f $$BASEDIR/images/earth.html $$TARGETDIR/qgroundcontrol.app/Contents/MacOs 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 # Copy model files
#QMAKE_POST_LINK += && cp -f $$BASEDIR/models/*.dae $$TARGETDIR/qgroundcontrol.app/Contents/MacOs #QMAKE_POST_LINK += && cp -f $$BASEDIR/models/*.dae $$TARGETDIR/qgroundcontrol.app/Contents/MacOs
......
...@@ -249,7 +249,8 @@ HEADERS += src/MG.h \ ...@@ -249,7 +249,8 @@ HEADERS += src/MG.h \
src/ui/SlugsHilSim.h \ src/ui/SlugsHilSim.h \
src/ui/SlugsPIDControl.h \ src/ui/SlugsPIDControl.h \
src/ui/SlugsVideoCamControl.h \ src/ui/SlugsVideoCamControl.h \
src/ui/SlugsPadCameraControl.h src/ui/SlugsPadCameraControl.h \
src/ui/QGCMainWindowAPConfigurator.h
contains(DEPENDENCIES_PRESENT, osg) { contains(DEPENDENCIES_PRESENT, osg) {
message("Including headers for OpenSceneGraph") message("Including headers for OpenSceneGraph")
...@@ -359,7 +360,8 @@ SOURCES += src/main.cc \ ...@@ -359,7 +360,8 @@ SOURCES += src/main.cc \
src/ui/SlugsHilSim.cc \ src/ui/SlugsHilSim.cc \
src/ui/SlugsPIDControl.cpp \ src/ui/SlugsPIDControl.cpp \
src/ui/SlugsVideoCamControl.cpp \ src/ui/SlugsVideoCamControl.cpp \
src/ui/SlugsPadCameraControl.cpp src/ui/SlugsPadCameraControl.cpp \
src/ui/QGCMainWindowAPConfigurator.cc
contains(DEPENDENCIES_PRESENT, osg) { contains(DEPENDENCIES_PRESENT, osg) {
message("Including sources for OpenSceneGraph") message("Including sources for OpenSceneGraph")
......
...@@ -559,16 +559,17 @@ void MAVLinkSimulationLink::mainloop() ...@@ -559,16 +559,17 @@ void MAVLinkSimulationLink::mainloop()
// Send controller states // 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 #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); messageSize = mavlink_msg_control_status_pack(systemId, componentId, &msg, posLock, visLock, gpsLock, attControl, posXYControl, posZControl, posYawControl);
#endif #endif
......
...@@ -41,12 +41,12 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -41,12 +41,12 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message)
{ {
// Let UAS handle the default message set // Let UAS handle the default message set
UAS::receiveMessage(link, message); UAS::receiveMessage(link, message);
// mavlink_message_t* msg = &message;
//qDebug() << "PX RECEIVED" << msg->sysid << msg->compid << msg->msgid; //qDebug() << "PX RECEIVED" << msg->sysid << msg->compid << msg->msgid;
// Only compile this portion if matching MAVLink packets have been compiled // Only compile this portion if matching MAVLink packets have been compiled
#ifdef MAVLINK_ENABLED_PIXHAWK #ifdef MAVLINK_ENABLED_PIXHAWK
mavlink_message_t* msg = &message;
if (message.sysid == uasId) if (message.sysid == uasId)
{ {
......
...@@ -81,6 +81,11 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -81,6 +81,11 @@ MainWindow::MainWindow(QWidget *parent) :
// Adjust the size // Adjust the size
adjustSize(); adjustSize();
// Set menu
QMenu* widgetMenu = createPopupMenu();
widgetMenu->setTitle("Widgets");
ui.menuBar->addMenu(widgetMenu);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
...@@ -89,6 +94,46 @@ MainWindow::~MainWindow() ...@@ -89,6 +94,46 @@ MainWindow::~MainWindow()
statusBar = NULL; statusBar = NULL;
} }
//QList<QWidget* >* MainWindow::getMainWidgets()
//{
//}
//QMenu* QMainWindow::getDockWidgetMenu()
//{
// Q_D(QMainWindow);
// QMenu *menu = 0;
//#ifndef QT_NO_DOCKWIDGET
// QList<QDockWidget *> dockwidgets = qFindChildren<QDockWidget *>(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<QToolBar *> toolbars = qFindChildren<QToolBar *>(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() void MainWindow::buildWidgets()
{ {
...@@ -287,6 +332,16 @@ void MainWindow::configureWindowName() ...@@ -287,6 +332,16 @@ void MainWindow::configureWindowName()
#endif #endif
} }
void MainWindow::createCenterWidgetMenu()
{
}
void MainWindow::createDockWidgetMenu()
{
}
QStatusBar* MainWindow::createStatusBar() QStatusBar* MainWindow::createStatusBar()
{ {
QStatusBar* bar = new QStatusBar(); QStatusBar* bar = new QStatusBar();
......
...@@ -160,6 +160,9 @@ protected: ...@@ -160,6 +160,9 @@ protected:
void arrangeCenterStack(); void arrangeCenterStack();
void configureWindowName(); void configureWindowName();
void createCenterWidgetMenu();
void createDockWidgetMenu();
// TODO Should be moved elsewhere, as the protocol does not belong to the UI // TODO Should be moved elsewhere, as the protocol does not belong to the UI
MAVLinkProtocol* mavlink; MAVLinkProtocol* mavlink;
AS4Protocol* as4link; AS4Protocol* as4link;
...@@ -168,6 +171,10 @@ protected: ...@@ -168,6 +171,10 @@ protected:
LinkInterface* udpLink; LinkInterface* udpLink;
QSettings settings; QSettings settings;
// Widget lists
QList<QPointer<QWidget> > centerWidgets;
QList<QPointer<QDockWidget> > dockWidgets;
// Center widgets // Center widgets
QPointer<Linecharts> linechartWidget; QPointer<Linecharts> linechartWidget;
QPointer<HUD> hudWidget; QPointer<HUD> hudWidget;
......
#include "QGCMainWindowAPConfigurator.h"
QGCMainWindowAPConfigurator::QGCMainWindowAPConfigurator(QObject *parent) :
QObject(parent)
{
}
#ifndef QGCMAINWINDOWAPCONFIGURATOR_H
#define QGCMAINWINDOWAPCONFIGURATOR_H
#include <QObject>
class QGCMainWindowAPConfigurator : public QObject
{
Q_OBJECT
public:
explicit QGCMainWindowAPConfigurator(QObject *parent = 0);
signals:
public slots:
};
#endif // QGCMAINWINDOWAPCONFIGURATOR_H
...@@ -16,9 +16,11 @@ ...@@ -16,9 +16,11 @@
QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
QWidget(parent), QWidget(parent),
updateTimer(new QTimer(this)), updateTimer(new QTimer(this)),
refreshRateMs(200),
mav(NULL), mav(NULL),
followCamera(true), followCamera(true),
trailEnabled(true), trailEnabled(true),
webViewInitialized(false),
#if (defined Q_OS_MAC) #if (defined Q_OS_MAC)
webViewMac(new QWebView(this)), webViewMac(new QWebView(this)),
#endif #endif
...@@ -34,22 +36,14 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : ...@@ -34,22 +36,14 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
#endif #endif
ui->setupUi(this); ui->setupUi(this);
#if (defined Q_OS_MAC) #if (defined Q_OS_MAC)
ui->webViewLayout->addWidget(webViewMac); 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 #endif
#if ((defined Q_OS_MAC) | ((defined Q_OS_WIN) & !(defined __MINGW32__))) #if ((defined Q_OS_MAC) | ((defined Q_OS_WIN) & !(defined __MINGW32__)))
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateState())); connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateState()));
updateTimer->start(200); updateTimer->start(refreshRateMs);
#endif #endif
// Follow checkbox // Follow checkbox
...@@ -94,9 +88,36 @@ void QGCGoogleEarthView::follow(bool follow) ...@@ -94,9 +88,36 @@ void QGCGoogleEarthView::follow(bool follow)
followCamera = 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() void QGCGoogleEarthView::updateState()
{ {
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
if (isVisible())
{
if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool()) if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
{ {
static bool initialized = false; static bool initialized = false;
...@@ -140,6 +161,7 @@ void QGCGoogleEarthView::updateState() ...@@ -140,6 +161,7 @@ void QGCGoogleEarthView::updateState()
} }
#endif #endif
} }
}
void QGCGoogleEarthView::changeEvent(QEvent *e) void QGCGoogleEarthView::changeEvent(QEvent *e)
{ {
......
...@@ -62,13 +62,19 @@ public slots: ...@@ -62,13 +62,19 @@ public slots:
void showWaypoints(bool state); void showWaypoints(bool state);
/** @brief Follow the aircraft during flight */ /** @brief Follow the aircraft during flight */
void follow(bool follow); void follow(bool follow);
/** @brief Hide and deactivate */
void hide();
/** @brief Show and activate */
void show();
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
QTimer* updateTimer; QTimer* updateTimer;
int refreshRateMs;
UASInterface* mav; UASInterface* mav;
bool followCamera; bool followCamera;
bool trailEnabled; bool trailEnabled;
bool webViewInitialized;
#if (defined Q_OS_WIN) && !(defined __MINGW32__) #if (defined Q_OS_WIN) && !(defined __MINGW32__)
WebAxWidget* webViewWin; WebAxWidget* webViewWin;
#endif #endif
......
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