diff --git a/.gitignore b/.gitignore index cf34ac8..3184e1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,55 +1,52 @@ -*.swp -*.nfs -CMakeFiles -*Makefile* -tags -build*/ -Info.plist -obj -.DS_Store -*.log -*~ -*~.skp -bin/*.exe -bin/*.txt -bin/mac -*pro.user* -qrc_*.cpp -*.Debug -*.Release -tmp -debug -release -qgroundcontrol -mavlinkgen-build-desktop -qgroundcontrol.xcodeproj/** -doc/html -doc/doxy.log -deploy/mac -deploy/linux -deploy/qgroundcontrol* -controller_log* -user_config.pri -*.app -*.ncb -*.vcproj -*.vcxproj* -*.sdf -*.ipch -*.pdb -*.sln -*.sln -*.vcproj -*.user -*.ncb -*.idb -*.project -*.cproject -*.sln -*.suo -*.uhf.txt -*.opensdf - -thirdParty/qserialport-build-desktop/ -thirdParty/qserialport/bin/ -thirdParty/qserialport/lib/ +*.swp +*.nfs +CMakeFiles +*Makefile* +tags +build*/ +Info.plist +obj +.DS_Store +*.log +*~ +*~.skp +bin/*.exe +bin/*.txt +bin/mac +*pro.user* +qrc_*.cpp +*.Debug +*.Release +tmp +debug +release +qgroundcontrol +mavlinkgen-build-desktop +qgroundcontrol.xcodeproj/** +doc/html +doc/doxy.log +deploy/mac +deploy/linux +deploy/qgroundcontrol* +controller_log* +user_config.pri +*.app +*.ncb +*.vcproj +*.vcxproj* +*.sdf +*.ipch +*.pdb +*.sln +*.sln +*.vcproj +*.user +*.ncb +*.idb +*.project +*.cproject +*.sln +*.suo +*.uhf.txt +*.opensdf +apmplanner2.xcodeproj/ diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index d8ec276..02ca75f 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -65,6 +65,19 @@ macx|macx-g++42|macx-g++|macx-llvm: { QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/apmplanner2.app/Contents/Frameworks QMAKE_POST_LINK += && cp -rf $$BASEDIR/libs/lib/Frameworks/* $$TARGETDIR/apmplanner2.app/Contents/Frameworks +# # Copy QML stuff +message(BASEDIR $$BASEDIR) + QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/apmplanner2.app/Contents/MacOS/qml + QMAKE_POST_LINK += && cp -rf $$BASEDIR/qml/*.qml $$TARGETDIR/apmplanner2.app/Contents/MacOS/qml + + QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/apmplanner2.app/Contents/MacOS/qml/components/ + QMAKE_POST_LINK += && cp -rf $$BASEDIR/qml/components/*.qml $$TARGETDIR/apmplanner2.app/Contents/MacOS/qml/components + + QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/apmplanner2.app/Contents/MacOS/qml/resources + QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/apmplanner2.app/Contents/MacOS/qml/resources/apmplanner + QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/apmplanner2.app/Contents/MacOS/qml/resources/apmplanner/toolbar + QMAKE_POST_LINK += && cp -rf $$BASEDIR/qml/resources/apmplanner/toolbar/*.png $$TARGETDIR/apmplanner2.app/Contents/MacOS/qml/resources/apmplanner/toolbar + # Fix library paths inside executable QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/apmplanner2.app/Contents/MacOS/apmplanner2 diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 9d1ca11..01475e1 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -29,7 +29,8 @@ QT += network \ xml \ phonon \ webkit \ - sql + sql \ + declarative TEMPLATE = app TARGET = apmplanner2 @@ -47,6 +48,9 @@ linux-g++|linux-g++-64{ TARGETDIR = $${OUT_PWD} BUILDDIR = $${OUT_PWD}/build } + +DESTDIR = $${TARGETDIR} + LANGUAGE = C++ OBJECTS_DIR = $${BUILDDIR}/obj MOC_DIR = $${BUILDDIR}/moc @@ -153,6 +157,7 @@ include(libs/serialport/apmserial.pri) #linux-g++::SOURCES += libs/qextserialport/qextserialenumerator_unix.cpp #linux-g++-64::SOURCES += libs/qextserialport/qextserialenumerator_unix.cpp #win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += libs/qextserialport/qextserialenumerator_win.cpp + # Input FORMS += src/ui/MainWindow.ui \ src/ui/CommSettings.ui \ @@ -431,7 +436,8 @@ HEADERS += src/MG.h \ src/ui/configuration/GeoFenceConfig.h \ src/ui/configuration/FailSafeConfig.h \ src/ui/configuration/AdvancedParamConfig.h \ - src/ui/configuration/ArduCopterPidConfig.h + src/ui/configuration/ArduCopterPidConfig.h \ + src/ui/apmtoolbar.h # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h @@ -630,7 +636,8 @@ SOURCES += src/main.cc \ src/ui/configuration/GeoFenceConfig.cc \ src/ui/configuration/FailSafeConfig.cc \ src/ui/configuration/AdvancedParamConfig.cc \ - src/ui/configuration/ArduCopterPidConfig.cc + src/ui/configuration/ArduCopterPidConfig.cc \ + src/ui/apmtoolbar.cpp # Enable Google Earth only on Mac OS and Windows with Visual Studio compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc @@ -767,3 +774,28 @@ unix:!macx:!symbian: LIBS += -losg OTHER_FILES += \ dongfang_notes.txt \ src/ui/dongfang-scrapyard.txt + +OTHER_FILES += \ + qml/ApmToolBar.qml \ + qml/components/Button.qml \ + qml/resources/apmplanner/toolbar/connect.png \ + qml/resources/apmplanner/toolbar/flightplanner.png \ + qml/resources/apmplanner/toolbar/helpwizard.png \ + qml/resources/apmplanner/toolbar/softwareconfig.png \ + qml/resources/apmplanner/toolbar/terminal.png \ + qml/resources/apmplanner/toolbar/simulation.png \ + qml/resources/apmplanner/toolbar/hardwareconfig.png \ + qml/resources/apmplanner/toolbar/flightdata.png \ + qml/resources/apmplanner/toolbar/disconnect.png \ + qml/resources/apmplanner/toolbar/donate.png \ + + +#qmlcomponents.path += $${DESTDIR}$${TARGET}/components +#qmlcomponents.files += ./components/Button.qml + +#sources.files += ApmToolBar.qml +#sources.path += $$DESTDIR/qml +#target.path += apmplanner2 +#INSTALLS += sources target + +message( BASEDIR $$BASEDIR DESTDIR $$DESTDIR TARGET $$TARGET TARGETDIR $$TARGETDIR) diff --git a/qml/ApmToolBar.qml b/qml/ApmToolBar.qml new file mode 100644 index 0000000..6748a65 --- /dev/null +++ b/qml/ApmToolBar.qml @@ -0,0 +1,75 @@ +import QtQuick 1.1 +import "./components" + + +Rectangle { + id: toolbar + width: parent.width + height: 72 + color: "black" + border.color: "black" + + Row { + anchors.left: parent.left + spacing: 2 + + Button { + id: flightDataView + label: "FLIGHT DATA" + image: "./resources/apmplanner/toolbar/flightdata.png" + onClicked: { + globalObj.selectFlightView() + } + } + + Button { + id: flightPlanView + label: "FLIGHT PLAN" + image: "./resources/apmplanner/toolbar/flightplanner.png" + onClicked: globalObj.selectFlightPlanView() + } + + Button { + id: hardwareConfigView + label: "HARDWARE" + image: "./resources/apmplanner/toolbar/hardwareconfig.png" + margins: 8 + onClicked: globalObj.selectHardwareView() + } + + Button { + id: softwareConfigView + label: "SOFTWARE" + image: "./resources/apmplanner/toolbar/softwareconfig.png" + margins: 8 + onClicked: globalObj.selectSoftwareView() + } + + Button { + id: simualtionView + label: "SIMULATION" + image: "./resources/apmplanner/toolbar/simulation.png" + onClicked: globalObj.selectSimulationView() + } + + Button { + id: terminalView + label: "TERMINAL" + image: "./resources/apmplanner/toolbar/terminal.png" + onClicked: globalObj.selectTerminalView() + } + } + + Row { + anchors.left: parent.right + spacing: 2 + + Button { + id: connectButton + label: "CONNECT" + image: "./resources/apmplanner/toolbar/connect.png" + onClicked: globalObj.connect() + } + } +} + diff --git a/qml/components/Button.qml b/qml/components/Button.qml new file mode 100644 index 0000000..567eca2 --- /dev/null +++ b/qml/components/Button.qml @@ -0,0 +1,70 @@ +import QtQuick 1.1 + +Rectangle { + signal clicked + + property string label: "button label" + property alias image: buttonImage.source + property int margins: 2 + + id: button + width: 72 + height: 72 + radius: 3 + smooth: true + border.width: 2 + + Text { + id: buttonLabel + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + anchors.margins: 2 + text: label + color: "white" + font.pointSize: 10 + } + + Image { + id: buttonImage + anchors.horizontalCenter: button.horizontalCenter + anchors.top: buttonLabel.bottom + anchors.margins: margins + source: image + fillMode: Image.PreserveAspectFit + width: image.width + height: image.height + } + + signal buttonClick() + + onButtonClick: { + console.log(buttonLabel.text + " clicked.") + clicked() + } + + // Highlighting and ativation section + property color buttonColor: "black" + property color onHoverbuttonColor: "lightblue" + property color onHoverColor: "darkblue" + property color borderColor: "black" + + MouseArea { + id: buttonMouseArea + anchors.fill: parent + onClicked: buttonClick() + hoverEnabled: true + onEntered: { + parent.border.color = onHoverColor + parent.color = onHoverbuttonColor + } + onExited: { + parent.border.color = borderColor + parent.color = buttonColor + } + onPressed: parent.color = Qt.darker(onHoverbuttonColor, 1.5) + onReleased: parent.color = buttonColor + } + color: buttonColor + border.color: borderColor +} + diff --git a/qml/resources/apmplanner/toolbar/connect.png b/qml/resources/apmplanner/toolbar/connect.png new file mode 100644 index 0000000..8572674 Binary files /dev/null and b/qml/resources/apmplanner/toolbar/connect.png differ diff --git a/qml/resources/apmplanner/toolbar/disconnect.png b/qml/resources/apmplanner/toolbar/disconnect.png new file mode 100644 index 0000000..57f2f50 Binary files /dev/null and b/qml/resources/apmplanner/toolbar/disconnect.png differ diff --git a/qml/resources/apmplanner/toolbar/donate.png b/qml/resources/apmplanner/toolbar/donate.png new file mode 100644 index 0000000..80b1a14 Binary files /dev/null and b/qml/resources/apmplanner/toolbar/donate.png differ diff --git a/qml/resources/apmplanner/toolbar/flightdata.png b/qml/resources/apmplanner/toolbar/flightdata.png new file mode 100644 index 0000000..aa8fb36 Binary files /dev/null and b/qml/resources/apmplanner/toolbar/flightdata.png differ diff --git a/qml/resources/apmplanner/toolbar/flightplanner.png b/qml/resources/apmplanner/toolbar/flightplanner.png new file mode 100644 index 0000000..72e1b40 Binary files /dev/null and b/qml/resources/apmplanner/toolbar/flightplanner.png differ diff --git a/qml/resources/apmplanner/toolbar/hardwareconfig.png b/qml/resources/apmplanner/toolbar/hardwareconfig.png new file mode 100644 index 0000000..56fb561 Binary files /dev/null and b/qml/resources/apmplanner/toolbar/hardwareconfig.png differ diff --git a/qml/resources/apmplanner/toolbar/helpwizard.png b/qml/resources/apmplanner/toolbar/helpwizard.png new file mode 100644 index 0000000..ac5c20a Binary files /dev/null and b/qml/resources/apmplanner/toolbar/helpwizard.png differ diff --git a/qml/resources/apmplanner/toolbar/simulation.png b/qml/resources/apmplanner/toolbar/simulation.png new file mode 100644 index 0000000..e8a1c31 Binary files /dev/null and b/qml/resources/apmplanner/toolbar/simulation.png differ diff --git a/qml/resources/apmplanner/toolbar/softwareconfig.png b/qml/resources/apmplanner/toolbar/softwareconfig.png new file mode 100644 index 0000000..e2516db Binary files /dev/null and b/qml/resources/apmplanner/toolbar/softwareconfig.png differ diff --git a/qml/resources/apmplanner/toolbar/terminal.png b/qml/resources/apmplanner/toolbar/terminal.png new file mode 100644 index 0000000..bb639d3 Binary files /dev/null and b/qml/resources/apmplanner/toolbar/terminal.png differ diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index aaa076b..870d805 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -38,6 +38,7 @@ This file is part of the QGROUNDCONTROL project #include #include #include +#include #include "dockwidgettitlebareventfilter.h" #include "QGC.h" #include "MAVLinkSimulationLink.h" @@ -63,6 +64,7 @@ This file is part of the QGROUNDCONTROL project #include "QGCTabbedInfoView.h" #include "UASRawStatusView.h" #include "PrimaryFlightDisplay.h" +#include "apmtoolbar.h" #ifdef QGC_OSG_ENABLED #include "Q3DWidgetFactory.h" @@ -179,6 +181,15 @@ MainWindow::MainWindow(QWidget *parent): actions << ui.actionSoftwareConfig; toolBar->setPerspectiveChangeActions(actions); + // We only want one of these. + apmToolBar = new APMToolBar(this); + apmToolBar->setFlightViewAction(ui.actionFlightView); + apmToolBar->setFlightPlanViewAction(ui.actionMissionView); + apmToolBar->setHardwareViewAction(ui.actionHardwareConfig); + apmToolBar->setSoftwareViewAction(ui.actionSoftwareConfig); + apmToolBar->setSimulationViewAction(ui.actionSimulation_View); + apmToolBar->setTerminalViewAction(ui.actionSimulation_View); + // Add actions for advanced users (displayed in dropdown under "advanced") QList advancedActions; advancedActions << ui.actionSimulation_View; @@ -598,10 +609,16 @@ void MainWindow::buildCommonWidgets() } createDockWidget(engineeringView,new HUD(320,240,this),tr("Video Downlink"),"HEAD_UP_DISPLAY_DOCKWIDGET",VIEW_ENGINEER,Qt::RightDockWidgetArea,this->width()/1.5); - createDockWidget(simView,new PrimaryFlightDisplay(320,240,this),tr("Primary Flight Display"),"PRIMARY_FLIGHT_DISPLAY_DOCKWIDGET",VIEW_SIMULATION,Qt::RightDockWidgetArea,this->width()/1.5); + createDockWidget(engineeringView,new HUD(320,240,this),tr("Video Downlink"),"HEAD_UP_DISPLAY_DOCKWIDGET",VIEW_ENGINEER,Qt::RightDockWidgetArea,this->width()/1.5); + + createDockWidget(simView,new PrimaryFlightDisplay(320,240,this),tr("Primary Flight Display"),"PRIMARY_FLIGHT_DISPLAY_DOCKWIDGET",VIEW_SIMULATION,Qt::RightDockWidgetArea,this->width()/1.5); createDockWidget(pilotView,new PrimaryFlightDisplay(320,240,this),tr("Primary Flight Display"),"PRIMARY_FLIGHT_DISPLAY_DOCKWIDGET",VIEW_FLIGHT,Qt::LeftDockWidgetArea,this->width()/1.8); + // Add Our new 'toolbar' + qDebug() << "width" << this->width(); + createDockWidget(pilotView,apmToolBar,tr("APM Tool Bar"),"APM_TOOLBAR_DOCKWIDGET",VIEW_FLIGHT,Qt::TopDockWidgetArea,this->width(), 70); + QGCTabbedInfoView *infoview = new QGCTabbedInfoView(this); infoview->addSource(mavlinkDecoder); createDockWidget(pilotView,infoview,tr("Info View"),"UAS_INFO_INFOVIEW_DOCKWIDGET",VIEW_FLIGHT,Qt::LeftDockWidgetArea); @@ -844,6 +861,11 @@ void MainWindow::loadDockWidget(QString name) { createDockWidget(centerStack->currentWidget(),new UASQuickView(this),tr("Quick View"),"UAS_INFO_QUICKVIEW_DOCKWIDGET",currentView,Qt::LeftDockWidgetArea); } + else if (name == "APM_TOOLBAR_DOCKWIDGET") + { + // Add Our new 'toolbar' + createDockWidget(centerStack->currentWidget(),apmToolBar,tr("APM Tool Bar"),"APM_TOOLBAR_DOCKWIDGET",VIEW_FLIGHT,Qt::TopDockWidgetArea,this->width(), 70); + } else { if (customWidgetNameToFilenameMap.contains(name)) diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 4435268..5d765de 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -84,6 +84,7 @@ This file is part of the QGROUNDCONTROL project #include "MAVLinkDecoder.h" #include "ApmHardwareConfig.h" #include "ApmSoftwareConfig.h" +#include "apmtoolbar.h" class QGCMapTool; class QGCMAVLinkMessageSender; @@ -403,6 +404,7 @@ protected: QPointer toolBar; QPointer customStatusBar; + QPointer apmToolBar; QPointer debugConsole; diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui index f51da40..99a69c4 100644 --- a/src/ui/MainWindow.ui +++ b/src/ui/MainWindow.ui @@ -6,14 +6,14 @@ 0 0 - 800 - 500 + 1024 + 600 - 800 - 500 + 1024 + 600 @@ -50,8 +50,8 @@ 0 0 - 800 - 21 + 1024 + 22 diff --git a/src/ui/QGCToolBar.cc b/src/ui/QGCToolBar.cc index 6490726..1a7414b 100644 --- a/src/ui/QGCToolBar.cc +++ b/src/ui/QGCToolBar.cc @@ -229,8 +229,10 @@ void QGCToolBar::setPerspectiveChangeActions(const QList &actions) first->setToolTip(actions.first()->toolTip()); first->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); first->setCheckable(true); + connect(first, SIGNAL(clicked(bool)), actions.first(), SIGNAL(triggered(bool))); connect(actions.first(),SIGNAL(triggered(bool)),first,SLOT(setChecked(bool))); + first->setStyleSheet("QToolButton { min-height: 24px; max-height: 24px; min-width: 60px; color: #222222; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #A2A3A4, stop: 1 #B6B7B8); margin-left: 8px; margin-right: 0px; padding-left: 4px; padding-right: 8px; border-radius: 0px; border : 0px solid blue; border-bottom-left-radius: 6px; border-top-left-radius: 6px; border-left: 1px solid #484848; border-top: 1px solid #484848; border-bottom: 1px solid #484848; } QToolButton:checked { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #555555, stop: 1 #787878); color: #DDDDDD; }"); addWidget(first); group->addButton(first); diff --git a/src/ui/apmtoolbar.cpp b/src/ui/apmtoolbar.cpp new file mode 100644 index 0000000..71e3e9a --- /dev/null +++ b/src/ui/apmtoolbar.cpp @@ -0,0 +1,81 @@ +#include +#include +#include + +#include "apmtoolbar.h" + +APMToolBar::APMToolBar(QWidget *parent) : + QDeclarativeView(parent) +{ + // Configure our QML object + this->rootContext()->setContextProperty("globalObj", this); + setSource(QUrl::fromLocalFile("qml/ApmToolBar.qml")); + setResizeMode(QDeclarativeView::SizeRootObjectToView); +} + +void APMToolBar::setFlightViewAction(QAction *action) +{ + connect(this, SIGNAL(selectFlightView()), action, SIGNAL(triggered())); +} + +void APMToolBar::setFlightPlanViewAction(QAction *action) +{ + connect(this, SIGNAL(selectFlightPlanView()), action, SIGNAL(triggered())); +} + +void APMToolBar::setHardwareViewAction(QAction *action) +{ + connect(this, SIGNAL(selectHardwareView()), action, SIGNAL(triggered())); +} + +void APMToolBar::setSoftwareViewAction(QAction *action) +{ + connect(this, SIGNAL(selectSoftwareView()), action, SIGNAL(triggered())); +} + +void APMToolBar::setSimulationViewAction(QAction *action) +{ + connect(this, SIGNAL(selectSimualtionView()), action, SIGNAL(triggered())); +} + +void APMToolBar::setTerminalViewAction(QAction *action) +{ + connect(this, SIGNAL(selectTerminalView()), action, SIGNAL(triggered())); +} + +void APMToolBar::selectFlightView() +{ + qDebug() << "APMToolBar: SelectFlightView"; +// emit triggerFlightView(); +} + +void APMToolBar::selectFlightPlanView() +{ + qDebug() << "APMToolBar: SelectFlightPlanView"; +} + +void APMToolBar::selectHardwareView() +{ + qDebug() << "APMToolBar: selectHardwareView"; +} + +void APMToolBar::selectSoftwareView() +{ + qDebug() << "APMToolBar: selectSoftwareView"; +} + +void APMToolBar::selectSimulationView() +{ + qDebug() << "APMToolBar: selectSimulationView"; +} + +void APMToolBar::selectTerminalView() +{ + qDebug() << "APMToolBar: selectTerminalView"; +} + +void APMToolBar::connectMAV() +{ + qDebug() << "APMToolBar: connect"; +} + diff --git a/src/ui/apmtoolbar.h b/src/ui/apmtoolbar.h new file mode 100644 index 0000000..e7d0386 --- /dev/null +++ b/src/ui/apmtoolbar.h @@ -0,0 +1,41 @@ +#ifndef APMTOOLBAR_H +#define APMTOOLBAR_H + +#include +#include + +class APMToolBar : public QDeclarativeView +{ + Q_OBJECT +public: + explicit APMToolBar(QWidget *parent = 0); + + void setFlightViewAction(QAction *action); + void setFlightPlanViewAction(QAction *action); + void setHardwareViewAction(QAction *action); + void setSoftwareViewAction(QAction *action); + void setSimulationViewAction(QAction *action); + void setTerminalViewAction(QAction *action); + +signals: + void triggerFlightView(); + void triggerFlightPlanView(); + void triggerHardwareView(); + void triggerSoftwareView(); + void triggerSimulationView(); + void triggerTerminalView(); + +public slots: +//signals: + void selectFlightView(); + void selectFlightPlanView(); + void selectHardwareView(); + void selectSoftwareView(); + void selectSimulationView(); + void selectTerminalView(); + +public slots: + void connectMAV(); +}; + +#endif // APMTOOLBAR_H