From fa793fe43d0e1457bfcc94c18421a25693fa1694 Mon Sep 17 00:00:00 2001 From: Stefan Dunca Date: Tue, 23 Apr 2019 11:25:25 +0200 Subject: [PATCH] New toolstrip based on QGCHoverButton --- src/FlightDisplay/FlightDisplayView.qml | 8 +- src/PlanView/PlanView.qml | 115 ++++++------ src/QmlControls/DropPanel.qml | 2 +- src/QmlControls/ToolStrip.qml | 240 ++++++------------------ 4 files changed, 121 insertions(+), 244 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 3a0b8aed3..3c0ada586 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -561,16 +561,16 @@ Item { ToolStrip { visible: (activeVehicle ? activeVehicle.guidedModeSupported : true) && !QGroundControl.videoManager.fullScreen id: toolStrip - anchors.leftMargin: isInstrumentRight() ? ScreenTools.defaultFontPixelWidth : undefined + + anchors.leftMargin: isInstrumentRight() ? ScreenTools.defaultFontPixelWidth * 2 : undefined anchors.left: isInstrumentRight() ? _mapAndVideo.left : undefined anchors.rightMargin:isInstrumentRight() ? undefined : ScreenTools.defaultFontPixelWidth anchors.right: isInstrumentRight() ? undefined : _mapAndVideo.right - anchors.topMargin: ScreenTools.toolbarHeight + (_margins * 2) + anchors.topMargin: ScreenTools.toolbarHeight + anchors.leftMargin anchors.top: _mapAndVideo.top z: _mapAndVideo.z + 4 - title: qsTr("Fly") maxHeight: (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y - buttonVisible: [_useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, true, true ] + buttonVisible: [_useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, _guidedController.showPause, !_guidedController.showPause ] buttonEnabled: [_useChecklist && activeVehicle, _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable ] property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort diff --git a/src/PlanView/PlanView.qml b/src/PlanView/PlanView.qml index bf59906c4..bee5fd752 100644 --- a/src/PlanView/PlanView.qml +++ b/src/PlanView/PlanView.qml @@ -286,7 +286,7 @@ Item { var sequenceNumber = _missionController.insertROIMissionItem(coordinate, index) _missionController.setCurrentPlanViewIndex(sequenceNumber, true) _addROIOnClick = false - toolStrip.uncheckAll() + toolStrip.lastClickedButton.checked = false } property int _moveDialogMissionItemIndex @@ -533,64 +533,64 @@ Item { border.width: object.lineWidth } } + } - ToolStrip { - id: toolStrip - anchors.leftMargin: ScreenTools.defaultFontPixelWidth - anchors.left: parent.left - anchors.topMargin: _toolButtonTopMargin - anchors.top: parent.top - color: qgcPal.window - title: qsTr("Plan") - z: QGroundControl.zOrderWidgets - showAlternateIcon: [ _planMasterController.dirty, false, false, false, false, false, false ] - rotateImage: [ _planMasterController.syncInProgress, false, false, false, false, false, false ] - animateImage: [ _planMasterController.dirty, false, false, false, false, false, false ] - buttonEnabled: [ !_planMasterController.syncInProgress, true, true, true, true, true, true ] - buttonVisible: [ true, true, _waypointsOnlyMode, true, true, _showZoom, _showZoom ] - maxHeight: mapScale.y - toolStrip.y - - property bool _showZoom: !ScreenTools.isMobile - - model: [ - { - name: qsTr("File"), - iconSource: "/qmlimages/MapSync.svg", - alternateIconSource: "/qmlimages/MapSyncChanged.svg", - dropPanelComponent: syncDropPanel - }, - { - name: qsTr("Waypoint"), - iconSource: "/qmlimages/MapAddMission.svg", - toggle: true - }, - { - name: qsTr("ROI"), - iconSource: "/qmlimages/MapAddMission.svg", - toggle: true - }, - { - name: _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"), - iconSource: "/qmlimages/MapDrawShape.svg", - dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel - }, - { - name: qsTr("Center"), - iconSource: "/qmlimages/MapCenter.svg", - dropPanelComponent: centerMapDropPanel - }, - { - name: qsTr("In"), - iconSource: "/qmlimages/ZoomPlus.svg" - }, - { - name: qsTr("Out"), - iconSource: "/qmlimages/ZoomMinus.svg" - } - ] + //----------------------------------------------------------- + // Left tool strip + ToolStrip { + id: toolStrip + anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 + anchors.left: parent.left + anchors.topMargin: _toolButtonTopMargin + anchors.leftMargin + anchors.top: parent.top + z: QGroundControl.zOrderWidgets + showAlternateIcon: [ _planMasterController.dirty, false, false, false, false, false, false ] + rotateImage: [ _planMasterController.syncInProgress, false, false, false, false, false, false ] + animateImage: [ _planMasterController.dirty, false, false, false, false, false, false ] + buttonEnabled: [ !_planMasterController.syncInProgress, true, true, true, true, true, true ] + buttonVisible: [ true, true, _waypointsOnlyMode, true, true, _showZoom, _showZoom ] + maxHeight: mapScale.y - toolStrip.y + property bool _showZoom: !ScreenTools.isMobile + + model: [ + { + name: qsTr("File"), + iconSource: "/qmlimages/MapSync.svg", + alternateIconSource: "/qmlimages/MapSyncChanged.svg", + dropPanelComponent: syncDropPanel + }, + { + name: qsTr("Waypoint"), + iconSource: "/qmlimages/MapAddMission.svg", + toggle: true + }, + { + name: qsTr("ROI"), + iconSource: "/qmlimages/MapAddMission.svg", + toggle: true + }, + { + name: _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"), + iconSource: "/qmlimages/MapDrawShape.svg", + dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel + }, + { + name: qsTr("Center"), + iconSource: "/qmlimages/MapCenter.svg", + dropPanelComponent: centerMapDropPanel + }, + { + name: qsTr("In"), + iconSource: "/qmlimages/ZoomPlus.svg" + }, + { + name: qsTr("Out"), + iconSource: "/qmlimages/ZoomMinus.svg" + } + ] - onClicked: { - switch (index) { + onClicked: { + switch (index) { case 1: _addWaypointOnClick = checked _addROIOnClick = false @@ -610,7 +610,6 @@ Item { case 6: editorMap.zoomLevel -= 0.5 break - } } } } diff --git a/src/QmlControls/DropPanel.qml b/src/QmlControls/DropPanel.qml index 7e1ef2a14..c9f3d7144 100644 --- a/src/QmlControls/DropPanel.qml +++ b/src/QmlControls/DropPanel.qml @@ -63,7 +63,7 @@ Item { if (visible) { visible = false _dropDownComponent = undefined - toolStrip.uncheckAll() + toolStrip.lastClickedButton.checked = false } } diff --git a/src/QmlControls/ToolStrip.qml b/src/QmlControls/ToolStrip.qml index 8e1335c50..a9417099e 100644 --- a/src/QmlControls/ToolStrip.qml +++ b/src/QmlControls/ToolStrip.qml @@ -8,215 +8,93 @@ ****************************************************************************/ import QtQuick 2.11 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.2 import QGroundControl.ScreenTools 1.0 import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 Rectangle { id: _root - color: qgcPal.window - width: ScreenTools.isMobile ? ScreenTools.minTouchPixels : ScreenTools.defaultFontPixelWidth * 7 + color: qgcPal.windowShade + width: _idealWidth < repeater.contentWidth ? repeater.contentWidth : _idealWidth height: toolStripColumn.height + (toolStripColumn.anchors.margins * 2) - radius: _radius - border.width: 1 - border.color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.35) : Qt.rgba(1,1,1,0.35) + radius: ScreenTools.defaultFontPixelWidth / 2 - property string title: "Title" property alias model: repeater.model - property var showAlternateIcon ///< List of bool values, one for each button in strip - true: show alternate icon, false: show normal icon - property var rotateImage ///< List of bool values, one for each button in strip - true: animation rotation, false: static image - property var animateImage ///< List of bool values, one for each button in strip - true: animate image, false: static image - property var buttonEnabled ///< List of bool values, one for each button in strip - true: button enabled, false: button disabled - property var buttonVisible ///< List of bool values, one for each button in strip - true: button visible, false: button invisible - property real maxHeight ///< Maximum height for control, determines whether text is hidden to make control shorter + property var rotateImage ///< List of bool values, one for each button in strip - true: animation rotation, false: static image + property var animateImage ///< List of bool values, one for each button in strip - true: animate image, false: static image + property var buttonEnabled ///< List of bool values, one for each button in strip - true: button enabled, false: button disabled + property var buttonVisible ///< List of bool values, one for each button in strip - true: button visible, false: button invisible + property real maxHeight ///< Maximum height for control, determines whether text is hidden to make control shorter + property var showAlternateIcon ///< List of bool values, one for each button in strip - true: show alternate icon, false: show normal icon - signal clicked(int index, bool checked) + property AbstractButton lastClickedButton: null - readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2 - readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2 - readonly property real _buttonSpacing: ScreenTools.defaultFontPixelHeight / 4 + // Ensure we don't get lower than + property real _idealWidth: (ScreenTools.isMobile ? ScreenTools.minTouchPixels : ScreenTools.defaultFontPixelWidth * 10) + toolStripColumn.anchors.margins * 2 - QGCPalette { id: qgcPal } - ExclusiveGroup { id: dropButtonsExclusiveGroup } - - function uncheckAll() { - dropButtonsExclusiveGroup.current = null - // Signal all toggles as off - for (var i=0; i