From 61a41ef0c1e9d5a2042776e9e49a235c52fb9843 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Sun, 15 Dec 2019 15:14:10 -0500 Subject: [PATCH] Allow analyze pages to float (desktop versions only) --- qgcimages.qrc | 1 + src/AnalyzeView/AnalyzePage.qml | 77 +++++-- src/AnalyzeView/AnalyzeView.qml | 47 +++- src/AnalyzeView/FloatingWindow.svg | 10 + src/AnalyzeView/MAVLinkInspectorPage.qml | 275 ++++++++++++----------- 5 files changed, 252 insertions(+), 158 deletions(-) create mode 100644 src/AnalyzeView/FloatingWindow.svg diff --git a/qgcimages.qrc b/qgcimages.qrc index e0e6be148..4c0d059bb 100644 --- a/qgcimages.qrc +++ b/qgcimages.qrc @@ -80,6 +80,7 @@ src/VehicleSetup/FirmwareUpgradeIcon.png src/AutoPilotPlugins/Common/Images/FlightModesComponentIcon.png src/AutoPilotPlugins/Common/Images/FlightModesComponentIcon.png + src/AnalyzeView/FloatingWindow.svg src/AutoPilotPlugins/APM/Images/bluerov-frame.png src/AutoPilotPlugins/APM/Images/simple3-frame.png src/AutoPilotPlugins/APM/Images/simple4-frame.png diff --git a/src/AnalyzeView/AnalyzePage.qml b/src/AnalyzeView/AnalyzePage.qml index ffee7ed67..a8aeb1af6 100644 --- a/src/AnalyzeView/AnalyzePage.qml +++ b/src/AnalyzeView/AnalyzePage.qml @@ -23,36 +23,73 @@ Item { property alias pageComponent: pageLoader.sourceComponent property alias pageName: pageNameLabel.text property alias pageDescription: pageDescriptionLabel.text + property alias headerComponent: headerLoader.sourceComponent property real availableWidth: width - pageLoader.x property real availableHeight: height - pageLoader.y + property bool poped: false property real _margins: ScreenTools.defaultFontPixelHeight * 0.5 + signal popout() + + Loader { + id: headerLoader + anchors.topMargin: _margins + anchors.top: parent.top + anchors.left: parent.left + anchors.right: floatIcon.left + } + + Column { + id: headingColumn + anchors.topMargin: _margins + anchors.top: parent.top + anchors.left: parent.left + anchors.right: floatIcon.left + spacing: _margins + visible: !ScreenTools.isShortScreen && headerLoader.sourceComponent === null + QGCLabel { + id: pageNameLabel + font.pointSize: ScreenTools.largeFontPointSize + } + QGCLabel { + id: pageDescriptionLabel + anchors.left: parent.left + anchors.right: parent.right + wrapMode: Text.WordWrap + } + } + QGCFlickable { - anchors.fill: parent + anchors.topMargin: ScreenTools.defaultFontPixelHeight + anchors.top: headerLoader.sourceComponent === null ? (headingColumn.visible ? headingColumn.bottom : parent.top) : headerLoader.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right contentWidth: pageLoader.x + pageLoader.item.width contentHeight: pageLoader.y + pageLoader.item.height clip: true - Column { - id: headingColumn - width: parent.width - spacing: _margins - QGCLabel { - id: pageNameLabel - font.pointSize: ScreenTools.largeFontPointSize - visible: !ScreenTools.isShortScreen - } - QGCLabel { - id: pageDescriptionLabel - anchors.left: parent.left - anchors.right: parent.right - wrapMode: Text.WordWrap - visible: !ScreenTools.isShortScreen - } - } Loader { id: pageLoader - anchors.topMargin: _margins - anchors.top: headingColumn.bottom } } + + QGCColoredImage { + id: floatIcon + anchors.top: parent.top + anchors.right: parent.right + width: ScreenTools.defaultFontPixelHeight * 2 + height: width + sourceSize.width: width + source: "/qmlimages/FloatingWindow.svg" + fillMode: Image.PreserveAspectFit + color: qgcPal.text + visible: !poped && !ScreenTools.isMobile + MouseArea { + anchors.fill: parent + onClicked: { + popout() + } + } + } + } diff --git a/src/AnalyzeView/AnalyzeView.qml b/src/AnalyzeView/AnalyzeView.qml index e8c775557..cf5009efc 100644 --- a/src/AnalyzeView/AnalyzeView.qml +++ b/src/AnalyzeView/AnalyzeView.qml @@ -13,6 +13,7 @@ /// @author Don Gagne import QtQuick 2.3 +import QtQuick.Window 2.2 import QtQuick.Controls 1.2 import QGroundControl 1.0 @@ -34,6 +35,8 @@ Rectangle { readonly property real _verticalMargin: _defaultTextHeight / 2 readonly property real _buttonWidth: _defaultTextWidth * 18 + property int _curIndex: 0 + GeoTagController { id: geoController } @@ -136,11 +139,41 @@ Rectangle { model: ScreenTools.isMobile ? mobileModel : desktopModel Component.onCompleted: itemAt(0).checked = true SubMenuButton { + id: subMenu imageResource: buttonImage setupIndicator: false exclusiveGroup: setupButtonGroup text: buttonText - onClicked: { panelLoader.source = pageSource; checked = true; } + property var window: analyzeWidgetWindow + property var loader: analyzeWidgetLoader + onClicked: { + _curIndex = index + panelLoader.source = pageSource + checked = true + } + Window { + id: analyzeWidgetWindow + width: mainWindow.width * 0.5 + height: mainWindow.height * 0.5 + visible: false + title: buttonText + Rectangle { + color: qgcPal.window + anchors.fill: parent + Loader { + id: analyzeWidgetLoader + anchors.fill: parent + } + } + onClosing: { + analyzeWidgetWindow.visible = false + analyzeWidgetLoader.source = "" + _curIndex = index + panelLoader.source = pageSource + subMenu.visible = true + subMenu.checked = true + } + } } } } @@ -158,6 +191,18 @@ Rectangle { color: qgcPal.windowShade } + Connections { + target: panelLoader.item + onPopout: { + buttonRepeater.itemAt(_curIndex).window.visible = true + var source = panelLoader.source + panelLoader.source = "" + buttonRepeater.itemAt(_curIndex).loader.source = source + buttonRepeater.itemAt(_curIndex).visible = false + buttonRepeater.itemAt(_curIndex).loader.item.poped = true + } + } + Loader { id: panelLoader anchors.topMargin: _verticalMargin diff --git a/src/AnalyzeView/FloatingWindow.svg b/src/AnalyzeView/FloatingWindow.svg new file mode 100644 index 000000000..1ac61247c --- /dev/null +++ b/src/AnalyzeView/FloatingWindow.svg @@ -0,0 +1,10 @@ + + + + + diff --git a/src/AnalyzeView/MAVLinkInspectorPage.qml b/src/AnalyzeView/MAVLinkInspectorPage.qml index e1c4b25bf..55bdbabcc 100644 --- a/src/AnalyzeView/MAVLinkInspectorPage.qml +++ b/src/AnalyzeView/MAVLinkInspectorPage.qml @@ -18,9 +18,9 @@ import QGroundControl.Controls 1.0 import QGroundControl.Controllers 1.0 import QGroundControl.ScreenTools 1.0 -Item { - anchors.fill: parent - anchors.margins: ScreenTools.defaultFontPixelWidth +AnalyzePage { + headerComponent: headerComponent + pageComponent: pageComponent property var curVehicle: controller ? controller.activeVehicle : null property int curMessageIndex: 0 @@ -33,154 +33,155 @@ Item { id: controller } - DeadMouseArea { - anchors.fill: parent - } - - //-- Header - RowLayout { - id: header - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - QGCLabel { - text: qsTr("Inspect real time MAVLink messages.") - } + Component { + id: headerComponent + //-- Header RowLayout { - Layout.alignment: Qt.AlignRight - visible: curVehicle ? curVehicle.compIDsStr.length > 2 : false + id: header + anchors.left: parent.left + anchors.right: parent.right QGCLabel { - text: qsTr("Component ID:") + text: qsTr("Inspect real time MAVLink messages.") } - QGCComboBox { - id: cidCombo - model: curVehicle ? curVehicle.compIDsStr : [] - Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 10 - currentIndex: 0 - onActivated: { - if(curVehicle && curVehicle.compIDsStr.length > 1) { - selectionValid = false - if(index < 1) - curCompID = 0 - else - curCompID = curVehicle.compIDs[index - 1] + RowLayout { + Layout.alignment: Qt.AlignRight + visible: curVehicle ? curVehicle.compIDsStr.length > 2 : false + QGCLabel { + text: qsTr("Component ID:") + } + QGCComboBox { + id: cidCombo + model: curVehicle ? curVehicle.compIDsStr : [] + Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 10 + currentIndex: 0 + onActivated: { + if(curVehicle && curVehicle.compIDsStr.length > 1) { + selectionValid = false + if(index < 1) + curCompID = 0 + else + curCompID = curVehicle.compIDs[index - 1] + } } } } } } - //-- Messages (Buttons) - QGCFlickable { - id: buttonGrid - anchors.top: header.bottom - anchors.topMargin: ScreenTools.defaultFontPixelHeight - anchors.bottom: parent.bottom - anchors.left: parent.left - width: maxButtonWidth - contentWidth: width - contentHeight: buttonCol.height - ColumnLayout { - id: buttonCol - anchors.left: parent.left - anchors.right: parent.right - spacing: ScreenTools.defaultFontPixelHeight * 0.25 - Repeater { - model: curVehicle ? curVehicle.messages : [] - delegate: MAVLinkMessageButton { - text: object.name - compID: object.cid - checked: curMessageIndex === index - messageHz: object.messageHz - visible: curCompID === 0 || curCompID === compID - onClicked: { - selectionValid = true - curMessageIndex = index + Component { + id: pageComponent + RowLayout { + width: availableWidth + height: availableHeight + //-- Messages (Buttons) + QGCFlickable { + id: buttonGrid + width: maxButtonWidth + Layout.maximumWidth:maxButtonWidth + Layout.fillHeight: true + Layout.fillWidth: true + contentWidth: width + contentHeight: buttonCol.height + ColumnLayout { + id: buttonCol + anchors.left: parent.left + anchors.right: parent.right + spacing: ScreenTools.defaultFontPixelHeight * 0.25 + Repeater { + model: curVehicle ? curVehicle.messages : [] + delegate: MAVLinkMessageButton { + text: object.name + compID: object.cid + checked: curMessageIndex === index + messageHz: object.messageHz + visible: curCompID === 0 || curCompID === compID + onClicked: { + selectionValid = true + curMessageIndex = index + } + Layout.fillWidth: true + } } - Layout.fillWidth: true } } - } - } - //-- Message Data - QGCFlickable { - id: messageGrid - visible: curMessage !== null && selectionValid - anchors.top: buttonGrid.top - anchors.bottom: parent.bottom - anchors.left: buttonGrid.right - anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 - anchors.right: parent.right - contentWidth: messageCol.width - contentHeight: messageCol.height - ColumnLayout { - id: messageCol - spacing: ScreenTools.defaultFontPixelHeight * 0.25 - GridLayout { - columns: 2 - columnSpacing: ScreenTools.defaultFontPixelWidth - rowSpacing: ScreenTools.defaultFontPixelHeight * 0.25 - QGCLabel { - text: qsTr("Message:") - Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 20 - } - QGCLabel { - color: qgcPal.buttonHighlight - text: curMessage ? curMessage.name + ' (' + curMessage.id + ') ' + curMessage.messageHz.toFixed(1) + 'Hz' : "" - } - QGCLabel { - text: qsTr("Component:") - } - QGCLabel { - text: curMessage ? curMessage.cid : "" - } - QGCLabel { - text: qsTr("Count:") - } - QGCLabel { - text: curMessage ? curMessage.count : "" - } - } - Item { height: ScreenTools.defaultFontPixelHeight; width: 1 } - QGCLabel { - text: qsTr("Message Fields:") - } - Rectangle { - Layout.fillWidth: true - height: 1 - color: qgcPal.text - } - Item { height: ScreenTools.defaultFontPixelHeight * 0.25; width: 1 } - GridLayout { - columns: 3 - columnSpacing: ScreenTools.defaultFontPixelWidth - rowSpacing: ScreenTools.defaultFontPixelHeight * 0.25 - Repeater { - model: curMessage ? curMessage.fields : [] - delegate: QGCLabel { - Layout.row: index - Layout.column: 0 - Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 20 - text: object.name + //-- Message Data + QGCFlickable { + id: messageGrid + visible: curMessage !== null && selectionValid + Layout.fillHeight: true + Layout.fillWidth: true + contentWidth: messageCol.width + contentHeight: messageCol.height + ColumnLayout { + id: messageCol + spacing: ScreenTools.defaultFontPixelHeight * 0.25 + GridLayout { + columns: 2 + columnSpacing: ScreenTools.defaultFontPixelWidth + rowSpacing: ScreenTools.defaultFontPixelHeight * 0.25 + QGCLabel { + text: qsTr("Message:") + Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 20 + } + QGCLabel { + color: qgcPal.buttonHighlight + text: curMessage ? curMessage.name + ' (' + curMessage.id + ') ' + curMessage.messageHz.toFixed(1) + 'Hz' : "" + } + QGCLabel { + text: qsTr("Component:") + } + QGCLabel { + text: curMessage ? curMessage.cid : "" + } + QGCLabel { + text: qsTr("Count:") + } + QGCLabel { + text: curMessage ? curMessage.count : "" + } } - } - Repeater { - model: curMessage ? curMessage.fields : [] - delegate: QGCLabel { - Layout.row: index - Layout.column: 1 - Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 30 - Layout.maximumWidth: ScreenTools.defaultFontPixelWidth * 30 - wrapMode: Text.WordWrap - text: object.value + Item { height: ScreenTools.defaultFontPixelHeight; width: 1 } + QGCLabel { + text: qsTr("Message Fields:") } - } - Repeater { - model: curMessage ? curMessage.fields : [] - delegate: QGCLabel { - Layout.row: index - Layout.column: 2 - text: object.type + Rectangle { + Layout.fillWidth: true + height: 1 + color: qgcPal.text + } + Item { height: ScreenTools.defaultFontPixelHeight * 0.25; width: 1 } + GridLayout { + columns: 3 + columnSpacing: ScreenTools.defaultFontPixelWidth + rowSpacing: ScreenTools.defaultFontPixelHeight * 0.25 + Repeater { + model: curMessage ? curMessage.fields : [] + delegate: QGCLabel { + Layout.row: index + Layout.column: 0 + Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 20 + text: object.name + } + } + Repeater { + model: curMessage ? curMessage.fields : [] + delegate: QGCLabel { + Layout.row: index + Layout.column: 1 + Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 30 + Layout.maximumWidth: ScreenTools.defaultFontPixelWidth * 30 + wrapMode: Text.WordWrap + text: object.value + } + } + Repeater { + model: curMessage ? curMessage.fields : [] + delegate: QGCLabel { + Layout.row: index + Layout.column: 2 + text: object.type + } + } } } } -- 2.22.0