Commit 27737cde authored by pixhawk's avatar pixhawk

Added widget menu

parent 07b5f77e
......@@ -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
......
......@@ -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")
......
......@@ -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
......
......@@ -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)
{
......
......@@ -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<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()
{
......@@ -287,6 +332,16 @@ void MainWindow::configureWindowName()
#endif
}
void MainWindow::createCenterWidgetMenu()
{
}
void MainWindow::createDockWidgetMenu()
{
}
QStatusBar* MainWindow::createStatusBar()
{
QStatusBar* bar = new QStatusBar();
......
......@@ -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<QPointer<QWidget> > centerWidgets;
QList<QPointer<QDockWidget> > dockWidgets;
// Center widgets
QPointer<Linecharts> linechartWidget;
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 @@
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)
{
......
......@@ -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
......
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