From af38a105df7d7b9186b34037fd14a4318d069141 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 4 Feb 2015 10:22:07 -0800 Subject: [PATCH] Re-implemented Setup View --- files/Setup/cogwheels.png | Bin 0 -> 10484 bytes qgroundcontrol.pro | 10 +- qgroundcontrol.qrc | 13 +- qml/QGroundControl/Controls/SetupButton.qml | 88 ++++++++++++ qml/QGroundControl/Controls/qmldir | 2 + src/VehicleSetup/SetupView.cc | 125 +++++++++--------- src/VehicleSetup/SetupView.h | 20 ++- src/VehicleSetup/SetupView.ui | 90 +++++++++++++ src/VehicleSetup/SetupViewButtons.qml | 88 ++++++++++++ src/VehicleSetup/SetupWidgetHolder.ui | 40 ------ ...upViewConnected.qml => VehicleSummary.qml} | 33 +---- src/test.qml | 14 +- 12 files changed, 370 insertions(+), 153 deletions(-) create mode 100644 files/Setup/cogwheels.png create mode 100644 qml/QGroundControl/Controls/SetupButton.qml create mode 100644 qml/QGroundControl/Controls/qmldir create mode 100644 src/VehicleSetup/SetupView.ui create mode 100644 src/VehicleSetup/SetupViewButtons.qml delete mode 100644 src/VehicleSetup/SetupWidgetHolder.ui rename src/VehicleSetup/{SetupViewConnected.qml => VehicleSummary.qml} (71%) diff --git a/files/Setup/cogwheels.png b/files/Setup/cogwheels.png new file mode 100644 index 0000000000000000000000000000000000000000..7ef3297fed5815fe15293da65e7cddf17ab25aab GIT binary patch literal 10484 zcmXwf2Rs~K)b_H<>bv^t7E6$*(Ic#0gAgSNvQ`NaEo$@@B}DICwAG3BkFto~qxTjy z5+uglRckTQ{iKp+YYb!7t(2oDULe}NDIKQpzI z-GE<2Xe~8m(9P{9udO5zXd!V{HwFGfMsxec17&0}0*%CPG;~ymSMkC0FqjP)_a6|5 z1Eis>Xy~=@!|#n+{c^YbSMqZOVuXL4VYe>Akoy6vp&$nPwpq*W?rT*AdLj8;%7)n zV@y3BXegugX~UAi$7cLI_`JCSR+m(_0cxx%rIMw#R`P26PIG6 z-pIt52!=PU`ZJg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J;C=66@tQItbs{FLv!%wQcwf%PH8%^W{qp;VaG6M@F(=U--x&DB|x0TKj| zP<3#{_i>R>()QTkj=b{&3H?{|{N>!Jd8d77?nS(4=XgftAM_sIc0A^-DdWgDi*7g38q9A%wFNG|y1D|=w5pr%km&e` z+3Qch^aK1Zzp$|T&s$vxAfe^Jf{Umy2rx=1K4`arVN72=;hWT10YiBm9iSF817#o- zMz<~s$aDXM3`lauWL=IgmP zKtXbHV`_Yh4ICM^);dEDcpqM9DAGLcmR|l*Gv79D=MZm}w?Vd)5F|wcs4bQYR(r3@r6X>1EykzDy2VA4+gYMEG*pC+l-FtE|LgoP@`+pUM57E{{|CN zGQ!jNrTVIWX&`^{4|}4YWaH31kQZBn$;G*g3kyeAHVn?SVx^L5KJKgq{@_WgdPsy$M<3F%+Q@Pxm z7Nu+D4&B>(39u$5m~d~6!|c5S9}I(JG3)r`a% zR10V_fYMF_6eY<5QV}U>)$LA=vD&`RB9{hj7oj_#4W@uGzTEzIt{q7ZsUmKd?-!Ah zieQ!X05TrLz;@?$^>(;$>@23ta#E;ZFmCCIT*e2o64jBRKyC^ZtW+Usr0kzDK><)C zuWCA1Vf;pC!+@fXKM?2*hf4Br?Xh_!r>|V0M!cPfbnC zrZJTSxO(pSJc%%^2y#d$Ha>U~FPq*-p^yeIog~ypxy+8MQvV9?BRPa1*h(+!|BC$B cH*Ua3V5Uz$zxO8r^@$)26src/test.qml qml/QGroundControl/FactControls/qmldir - - - qml/QGroundControl/FactControls/SetupButton.qml qml/QGroundControl/FactControls/FactLabel.qml qml/QGroundControl/FactControls/FactTextField.qml qml/QGroundControl/FactControls/FactCheckBox.qml + qml/QGroundControl/Controls/qmldir + qml/QGroundControl/Controls/SetupButton.qml + files/images/px4/airframes/octo_x.png files/images/px4/boards/px4fmu_2.x.png - src/VehicleSetup/SetupViewConnected.qml - src/VehicleSetup/SetupViewDisconnected.qml - src/VehicleSetup/SetupPane.qml + src/VehicleSetup/SetupViewButtons.qml + src/VehicleSetup/VehicleSummary.qml src/AutoPilotPlugins/PX4/SafetyComponent.qml @@ -263,6 +262,8 @@ src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml + files/Setup/cogwheels.png + diff --git a/qml/QGroundControl/Controls/SetupButton.qml b/qml/QGroundControl/Controls/SetupButton.qml new file mode 100644 index 000000000..64b720663 --- /dev/null +++ b/qml/QGroundControl/Controls/SetupButton.qml @@ -0,0 +1,88 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import QtGraphicalEffects 1.0 +import QGroundControl.FactSystem 1.0 + +Button { + checkable: true + height: 80 + + text: "Button" + property bool setupComplete: true + property bool setupIndicator: true + + style: ButtonStyle { + id: buttonStyle + + property var __qgcpal: QGCPalette { + colorGroup: control.enabled ? QGCPalette.Active : QGCPalette.Disabled + } + + background: Rectangle { + id: innerRect + readonly property real titleHeight: 30 + + border.color: control.checked ? "#eee333" : "#676767" + radius: 10 + + color: control.checked ? "#eee333" : "#343434" + + Text { + id: titleBar + + width: parent.width + height: parent.titleHeight + + verticalAlignment: TextEdit.AlignVCenter + horizontalAlignment: TextEdit.AlignHCenter + + text: control.text + font.pixelSize: 12 + color: control.checked ? "black" : "white" + + Rectangle { + id: setupIndicator + + readonly property real indicatorRadius: 6 + + x: parent.width - (indicatorRadius * 2) - 5 + y: (parent.height - (indicatorRadius * 2)) / 2 + width: indicatorRadius * 2 + height: indicatorRadius * 2 + + radius: indicatorRadius + color: control.setupIndicator ? (control.setupComplete ? "green" : "red") : innerRect.color + } + } + + Rectangle { + width: parent.width + height: parent.height - parent.titleHeight + + y: parent.titleHeight + + color: __qgcpal.window + border.color: control.checked ? "#eee333" : "#676767" + + Image { + id: buttonImage + source: "setupButtonImage.png" + sourceSize: Qt.size(parent.width - 20, parent.height - 20) + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + smooth: true + visible: false + } + + ColorOverlay { + anchors.fill: buttonImage + source: buttonImage + color: control.checked ? "#eee333" : "#58585a" + } + } + } + + label: Item {} + } +} diff --git a/qml/QGroundControl/Controls/qmldir b/qml/QGroundControl/Controls/qmldir new file mode 100644 index 000000000..48c30e1a2 --- /dev/null +++ b/qml/QGroundControl/Controls/qmldir @@ -0,0 +1,2 @@ +Module QGroundControl.Controls +SetupButton 1.0 SetupButton.qml \ No newline at end of file diff --git a/src/VehicleSetup/SetupView.cc b/src/VehicleSetup/SetupView.cc index d48af88e4..fd13f54e7 100644 --- a/src/VehicleSetup/SetupView.cc +++ b/src/VehicleSetup/SetupView.cc @@ -25,13 +25,14 @@ /// @author Don Gagne #include "SetupView.h" +#include "ui_SetupView.h" #include "UASManager.h" #include "AutoPilotPluginManager.h" #include "VehicleComponent.h" #include "PX4FirmwareUpgrade.h" #include "ParameterEditor.h" -#include "SetupWidgetHolder.h" +#include "QGCQmlWidgetHolder.h" #include "MainWindow.h" #include "QGCMessageBox.h" @@ -40,16 +41,38 @@ #include SetupView::SetupView(QWidget* parent) : - QGCQuickWidget(parent), + QWidget(parent), _uasCurrent(NULL), _initComplete(false), - _autoPilotPlugin(NULL) + _autoPilotPlugin(NULL), + _currentSetupWidget(NULL), + _ui(new Ui::SetupView) { + _ui->setupUi(this); + bool fSucceeded = connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(_setActiveUAS(UASInterface*))); Q_UNUSED(fSucceeded); Q_ASSERT(fSucceeded); - setResizeMode(SizeRootObjectToView); + //setResizeMode(SizeRootObjectToView); + + _ui->buttonHolder->setAutoPilot(NULL); + _ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtons.qml")); + + QObject* rootObject = (QObject*)_ui->buttonHolder->rootObject(); + Q_ASSERT(rootObject); + + fSucceeded = connect(rootObject, SIGNAL(setupButtonClicked(QVariant)), this, SLOT(_setupButtonClicked(QVariant))); + Q_ASSERT(fSucceeded); + + fSucceeded = connect(rootObject, SIGNAL(firmwareButtonClicked()), this, SLOT(_firmwareButtonClicked())); + Q_ASSERT(fSucceeded); + + fSucceeded = connect(rootObject, SIGNAL(parametersButtonClicked()), this, SLOT(_parametersButtonClicked())); + Q_ASSERT(fSucceeded); + + fSucceeded = connect(rootObject, SIGNAL(summaryButtonClicked()), this, SLOT(_summaryButtonClicked())); + Q_ASSERT(fSucceeded); _setActiveUAS(UASManager::instance()->getActiveUAS()); } @@ -63,10 +86,16 @@ void SetupView::_setActiveUAS(UASInterface* uas) { if (_uasCurrent) { Q_ASSERT(_autoPilotPlugin); - disconnect(_autoPilotPlugin); - _autoPilotPlugin = NULL; + disconnect(_autoPilotPlugin, &AutoPilotPlugin::pluginReady, this, &SetupView::_pluginReady); } + _autoPilotPlugin = NULL; + _ui->buttonHolder->setAutoPilot(NULL); + _firmwareButtonClicked(); + QObject* button = _ui->buttonHolder->rootObject()->findChild("firmwareButton"); + Q_ASSERT(button); + button->setProperty("checked", true); + _uasCurrent = uas; if (_uasCurrent) { @@ -74,48 +103,27 @@ void SetupView::_setActiveUAS(UASInterface* uas) connect(_autoPilotPlugin, &AutoPilotPlugin::pluginReady, this, &SetupView::_pluginReady); if (_autoPilotPlugin->pluginIsReady()) { - _setConnectedView(); + _pluginReady(); } - } else { - _setDisconnectedView(); } } void SetupView::_pluginReady(void) { - _setConnectedView(); -} - -void SetupView::_setViewConnections(void) -{ - QObject*button = rootObject()->findChild("firmwareButton"); + _ui->buttonHolder->setAutoPilot(_autoPilotPlugin); + _summaryButtonClicked(); + QObject* button = _ui->buttonHolder->rootObject()->findChild("summaryButton"); Q_ASSERT(button); - connect(button, SIGNAL(clicked()), this, SLOT(_firmwareButtonClicked())); - - button = rootObject()->findChild("parametersButton"); - if (button) { - connect(button, SIGNAL(clicked()), this, SLOT(_parametersButtonClicked())); - } + button->setProperty("checked", true); } -void SetupView::_setDisconnectedView(void) +void SetupView::_changeSetupWidget(QWidget* newWidget) { - setSource(QUrl::fromUserInput("qrc:qml/SetupViewDisconnected.qml")); - _setViewConnections(); -} - -void SetupView::_setConnectedView(void) -{ - Q_ASSERT(_uasCurrent); - Q_ASSERT(_autoPilotPlugin); - - setAutoPilot(_autoPilotPlugin); - - setSource(QUrl::fromUserInput("qrc:qml/SetupViewConnected.qml")); - disconnect(_autoPilotPlugin); - _setViewConnections(); - - connect((QObject*)rootObject(), SIGNAL(buttonClicked(QVariant)), this, SLOT(_setupButtonClicked(QVariant))); + if (_currentSetupWidget) { + delete _currentSetupWidget; + } + _currentSetupWidget = newWidget; + _ui->setupWidgetLayout->addWidget(newWidget); } void SetupView::_firmwareButtonClicked(void) @@ -125,24 +133,27 @@ void SetupView::_firmwareButtonClicked(void) return; } - SetupWidgetHolder* dialog = new SetupWidgetHolder(MainWindow::instance()); - dialog->setModal(true); - dialog->setWindowTitle("Firmware Upgrade"); - - PX4FirmwareUpgrade* setup = new PX4FirmwareUpgrade(dialog); - dialog->setInnerWidget(setup); - dialog->exec(); + PX4FirmwareUpgrade* setup = new PX4FirmwareUpgrade(this); + _changeSetupWidget(setup); } void SetupView::_parametersButtonClicked(void) { - SetupWidgetHolder* dialog = new SetupWidgetHolder(MainWindow::instance()); - dialog->setModal(true); - dialog->setWindowTitle("Parameter Editor"); + ParameterEditor* setup = new ParameterEditor(_uasCurrent, QStringList(), this); + _changeSetupWidget(setup); +} + +void SetupView::_summaryButtonClicked(void) +{ + Q_ASSERT(_autoPilotPlugin); - ParameterEditor* setup = new ParameterEditor(_uasCurrent, QStringList(), dialog); - dialog->setInnerWidget(setup); - dialog->exec(); + QGCQmlWidgetHolder* summary = new QGCQmlWidgetHolder; + Q_CHECK_PTR(summary); + + summary->setAutoPilot(_autoPilotPlugin); + summary->setSource(QUrl::fromUserInput("qrc:/qml/VehicleSummary.qml")); + + _changeSetupWidget(summary); } void SetupView::_setupButtonClicked(const QVariant& component) @@ -161,15 +172,5 @@ void SetupView::_setupButtonClicked(const QVariant& component) return; } - SetupWidgetHolder dialog(MainWindow::instance()); - dialog.setModal(true); - dialog.setWindowTitle(vehicle->name()); - - QWidget* setupWidget = vehicle->setupWidget(); - - dialog.resize(setupWidget->minimumSize()); - dialog.setInnerWidget(setupWidget); - dialog.exec(); - - delete setupWidget; + _changeSetupWidget(vehicle->setupWidget()); } diff --git a/src/VehicleSetup/SetupView.h b/src/VehicleSetup/SetupView.h index 24f974eba..8c4a6bc8e 100644 --- a/src/VehicleSetup/SetupView.h +++ b/src/VehicleSetup/SetupView.h @@ -24,18 +24,22 @@ #ifndef SETUPVIEW_H #define SETUPVIEW_H - #include "UASInterface.h" #include "ParameterEditor.h" #include "VehicleComponent.h" -#include "QGCQuickWidget.h" #include "AutoPilotPlugin.h" +#include + /// @file /// @brief This class is used to display the UI for the VehicleComponent objects. /// @author Don Gagne -class SetupView : public QGCQuickWidget +namespace Ui { + class SetupView; +} + +class SetupView : public QWidget { Q_OBJECT @@ -48,16 +52,18 @@ private slots: void _pluginReady(void); void _firmwareButtonClicked(void); void _parametersButtonClicked(void); + void _summaryButtonClicked(void); void _setupButtonClicked(const QVariant& component); private: - void _setConnectedView(void); - void _setDisconnectedView(void); - void _setViewConnections(void); - + void _changeSetupWidget(QWidget* newWidget); + UASInterface* _uasCurrent; ///< Currently active UAS bool _initComplete; ///< true: parameters are ready and ui has been setup AutoPilotPlugin* _autoPilotPlugin; + QWidget* _currentSetupWidget; + + Ui::SetupView* _ui; }; #endif diff --git a/src/VehicleSetup/SetupView.ui b/src/VehicleSetup/SetupView.ui new file mode 100644 index 000000000..d5bc228c6 --- /dev/null +++ b/src/VehicleSetup/SetupView.ui @@ -0,0 +1,90 @@ + + + SetupView + + + + 0 + 0 + 946 + 821 + + + + Form + + + + + + + 0 + 0 + + + + + 160 + 0 + + + + + 160 + 16777215 + + + + QGCQuickWidget::SizeRootObjectToView + + + + + + + + 0 + 0 + 400 + 300 + + + + Form + + + true + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + QGCQuickWidget + QQuickWidget +
QGCQuickWidget.h
+ 1 +
+
+ + +
diff --git a/src/VehicleSetup/SetupViewButtons.qml b/src/VehicleSetup/SetupViewButtons.qml new file mode 100644 index 000000000..8d8aa34a7 --- /dev/null +++ b/src/VehicleSetup/SetupViewButtons.qml @@ -0,0 +1,88 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import QGroundControl.FactSystem 1.0 +import QGroundControl.Controls 1.0 + +Rectangle { + id: topLevel + + QGCPalette { id: palette; colorGroup: QGCPalette.Active } + color: palette.window + + signal firmwareButtonClicked; + signal summaryButtonClicked; + signal parametersButtonClicked; + signal setupButtonClicked(variant component); + + ExclusiveGroup { id: setupButtonGroup } + + Component { + id: disconnectedButtons + + Column { + spacing: 10 + + SetupButton { + id: firmwareButton; objectName: "firmwareButton" + width: parent.width + text: "FIRMWARE" + setupIndicator: false + exclusiveGroup: setupButtonGroup + onClicked: topLevel.firmwareButtonClicked() + } + } + } + + Component { + id: connectedButtons + + Column { + spacing: 10 + + SetupButton { + id: summaryButton; objectName: "summaryButton" + width: parent.width + text: "VEHICLE SUMMARY" + setupIndicator: false + exclusiveGroup: setupButtonGroup + onClicked: topLevel.summaryButtonClicked() + } + + SetupButton { + id: firmwareButton; objectName: "firmwareButton" + width: parent.width + text: "FIRMWARE" + setupIndicator: false + exclusiveGroup: setupButtonGroup + onClicked: topLevel.firmwareButtonClicked() + } + + Repeater { + model: autopilot.components + + SetupButton { + width: parent.width + text: modelData.name.toUpperCase() + setupComplete: modelData.setupComplete + exclusiveGroup: setupButtonGroup + onClicked: topLevel.setupButtonClicked(modelData) + } + } + + SetupButton { + width: parent.width + text: "PARAMETERS" + setupIndicator: false + exclusiveGroup: setupButtonGroup + onClicked: topLevel.parametersButtonClicked() + } + } + } + + + Loader { + anchors.fill: parent + sourceComponent: autopilot ? connectedButtons : disconnectedButtons + } +} diff --git a/src/VehicleSetup/SetupWidgetHolder.ui b/src/VehicleSetup/SetupWidgetHolder.ui deleted file mode 100644 index 05e3a0b9b..000000000 --- a/src/VehicleSetup/SetupWidgetHolder.ui +++ /dev/null @@ -1,40 +0,0 @@ - - - SetupWidgetHolder - - - - 0 - 0 - 400 - 300 - - - - Form - - - true - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - diff --git a/src/VehicleSetup/SetupViewConnected.qml b/src/VehicleSetup/VehicleSummary.qml similarity index 71% rename from src/VehicleSetup/SetupViewConnected.qml rename to src/VehicleSetup/VehicleSummary.qml index cd2956d62..8569e290c 100644 --- a/src/VehicleSetup/SetupViewConnected.qml +++ b/src/VehicleSetup/VehicleSummary.qml @@ -4,34 +4,29 @@ import QtQuick.Controls.Styles 1.2 import QGroundControl.FactSystem 1.0 Rectangle { + width: 600 + height: 400 + QGCPalette { id: palette; colorGroup: QGCPalette.Active } id: topLevel objectName: "topLevel" color: palette.window - - signal buttonClicked(variant component); - Image { anchors.fill: parent fillMode: Image.PreserveAspectFit smooth: true source: autopilot.setupBackgroundImage; } - Column { anchors.margins: 20 anchors.fill: parent spacing: 5 - Rectangle { id: header; color: "lightblue"; radius: 10.0; width: parent.width; height: titleText.height + 20; opacity: 0.8; - Text { id: titleText; anchors.centerIn: parent; font.pointSize: 24; text: "Vehicle Setup" } - } - Flow { width: parent.width; - height: parent.height - header.height - footer.height + height: parent.height spacing: 5 Repeater { @@ -54,9 +49,8 @@ Rectangle { border.color: "#888" radius: 10 - color: control.activeFocus ? "#47b" : "white" - opacity: control.hovered || control.activeFocus ? 1 : 0.8 - Behavior on opacity {NumberAnimation{ duration: 100 }} + color: "white" + opacity: 0.8 Text { id: titleBar @@ -108,23 +102,8 @@ Rectangle { label: Item {} } - - onClicked: topLevel.buttonClicked(modelData) } } } - - Rectangle { id: footer; color: "lightblue"; radius: 10.0; width: parent.width; height: titleText.height + 20; opacity: 0.8; - - property real spacing: (width - firmwareButton.width - parametersButton.width) / 3 - - Button { id: firmwareButton; objectName: "firmwareButton"; - x: parent.spacing; anchors.verticalCenter: parent.verticalCenter; - text: "Firmware Upgrade" } - Button { id: parametersButton; objectName: "parametersButton" - x: firmwareButton.width + (parent.spacing*2); anchors.verticalCenter: parent.verticalCenter; - text: "Parameters" } - } - } } diff --git a/src/test.qml b/src/test.qml index e623f499a..fa45fe272 100644 --- a/src/test.qml +++ b/src/test.qml @@ -1,10 +1,14 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 -//import QGroundControl.FactControls 1.0 +import QGroundControl.FactControls 1.0 -Row { -width: 200 -Text { id: firstCol; text: "Col 1" } -Text { horizontalAlignment: Text.AlignRight; width: parent.width - firstCol.contentWidth; text: "Col 2" } + +Rectangle { + QGCPalette { id: palette; colorGroup: enabled ? QGCPalette.Active : QGCPalette.Disabled } + + width: 100 + height: 100 + color: "#e43f3f" + // palette.windowText } -- 2.22.0