From 7ec0e37829d57ba08bb083cca22103d228cb9a64 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Mon, 13 May 2024 16:35:44 +0330 Subject: [PATCH 01/17] Add Navigating drawer. --- src/qml/NavigatingDrawer.qml | 123 ++++++++++++++++++++++++++ src/qml/NavigationInformationView.qml | 10 ++- src/qml/qgismobileapp.qml | 61 ++++--------- src/qml/qml.qrc | 1 + 4 files changed, 146 insertions(+), 49 deletions(-) create mode 100644 src/qml/NavigatingDrawer.qml diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/NavigatingDrawer.qml new file mode 100644 index 0000000000..1d3642b34d --- /dev/null +++ b/src/qml/NavigatingDrawer.qml @@ -0,0 +1,123 @@ +import QtQuick 2.14 +import QtQuick.Controls 2.14 + +import org.qfield 1.0 +import Theme 1.0 + +Drawer { + id: controller + height: defaultHeight + Overlay.modal: null + modal: false + width: parent.width + edge: Qt.BottomEdge + dragMargin: 0 + closePolicy: Popup.NoAutoClose + + property Navigation navigation + property PositioningSettings positioningSettings + property real defaultHeight: positioningPreciseView.height + details.height + 32 + property real positioningPreciseViewHeight + property alias positioningPreciseView: positioningPv + property bool closeRequested: false + property bool shouldBeOpen: false + property bool positioningPreciseEnabled: false + + onShouldBeOpenChanged: { + if(shouldBeOpen){ + closeRequested = false; + open() + }else{ + closeRequested = true; + close() + } + } + + onClosed: { + if (!closeRequested) { + // view dragged down but we should bring it back + controller.height = details.height + 24 + controller.open() + } + } + + background: Rectangle { + anchors.fill: parent + color: "transparent" + } + + Column { + spacing: 8 + width: parent.width + + Rectangle { + id: details + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - 16 + height: navigationInformationView.height + radius: 8 + color: "black" + + NavigationInformationView { + id: navigationInformationView + navigation: controller.navigation + width: parent.width + anchors.centerIn: parent + radius: parent.radius + clip: true + } + + Rectangle { + width: 50 + height: 2 + radius: 4 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: 2 + } + + MouseArea { + anchors.fill: details + + property int dragStartY: 0 + + onPressed: mouse => { + dragStartY = mouse.y + } + onPositionChanged: mouse => { + var deltaY = mouse.y - dragStartY + if (deltaY < -details.height / 4){ // && positioningPv.canShow) { + controller.height = controller.defaultHeight + } + } + } + } + + Rectangle { + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - 16 + height: positioningPv.height + radius: 8 + color: "black" + + PositioningPreciseView { + id: positioningPv + precision: positioningSettings.preciseViewPrecision + width: parent.width + height: positioningPreciseViewHeight + } + + Rectangle{ + visible: !positioningPreciseEnabled + anchors.fill: positioningPv + color: "#cc2e2e2e" + + Text{ + anchors.centerIn: parent + text: "Enable Gps to show!" + color: "white" + } + } + } + } +} diff --git a/src/qml/NavigationInformationView.qml b/src/qml/NavigationInformationView.qml index da5a88d0ad..0eb59aa8a9 100644 --- a/src/qml/NavigationInformationView.qml +++ b/src/qml/NavigationInformationView.qml @@ -21,11 +21,8 @@ Rectangle { property color alternateBackgroundColor: Theme.navigationBackgroundColor property color textColor: Theme.mainTextColor - height: childrenRect.height - width: parent.width - anchors.margins: 20 - color: Theme.mainBackgroundColor + height: content.height Timer { id: featureVertexTimer @@ -46,6 +43,7 @@ Rectangle { } ColumnLayout { + id: content width: parent.width spacing: 0 @@ -132,6 +130,7 @@ Rectangle { Rectangle { height: rowHeight width: grid.cellWidth + radius: 4 color: alternateBackgroundColor Text { @@ -151,6 +150,7 @@ Rectangle { Rectangle { height: rowHeight width: grid.cellWidth + radius: 4 color: backgroundColor Text { @@ -170,6 +170,7 @@ Rectangle { Rectangle { height: rowHeight width: grid.cellWidth + radius: 4 color: grid.rows == 2 ? backgroundColor : alternateBackgroundColor Text { @@ -188,6 +189,7 @@ Rectangle { Rectangle { height: rowHeight width: grid.cellWidth + radius: 4 color: grid.rows == 2 ? alternateBackgroundColor : backgroundColor Text { diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 38992755ab..38ad009354 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -711,9 +711,9 @@ ApplicationWindow { location: positionSource.active ? positionSource.projectedPosition : GeometryUtils.emptyPoint() proximityAlarm: positioningSettings.preciseViewProximityAlarm - && positioningPreciseView.visible - && positioningPreciseView.hasAcceptableAccuracy - && !positioningPreciseView.hasAlarmSnoozed + && navigatingDrawer.positioningPreciseView.visible + && navigatingDrawer.positioningPreciseView.hasAcceptableAccuracy + && !navigatingDrawer.positioningPreciseView.hasAlarmSnoozed proximityAlarmThreshold: positioningSettings.preciseViewPrecision } @@ -931,6 +931,18 @@ ApplicationWindow { } } + NavigatingDrawer{ + id: navigatingDrawer + navigation: navigation + positioningSettings: positioningSettings + positioningPreciseViewHeight: Math.min(mainWindow.height / 2.5, 400) + shouldBeOpen: navigation.isActive && !elevationProfile.visible && mapCanvasMap.isEnabled + positioningPreciseEnabled: !isNaN(navigation.distance) + && (positioningSettings.alwaysShowPreciseView + || (hasAcceptableAccuracy && projectDistance < precision)) + && !elevationProfile.visible + } + Column { id: informationView anchors.bottom: parent.bottom @@ -939,7 +951,7 @@ ApplicationWindow { anchors.bottomMargin: mainWindow.sceneBottomMargin visible: navigation.isActive || positioningSettings.showPositionInformation || - positioningPreciseView.visible || + navigatingDrawer.positioningPreciseView.visible || sensorInformationView.activeSensors > 0 || (stateMachine.state === 'measure' && elevationProfileButton.elevationProfileActive) @@ -957,40 +969,6 @@ ApplicationWindow { crs: mapCanvas.mapSettings.destinationCrs } - NavigationInformationView { - id: navigationInformationView - visible: navigation.isActive && !elevationProfile.visible - navigation: navigation - } - - Rectangle { - visible: navigationInformationView.visible && positioningPreciseView.visible - width: parent.width - height: 1 - color: Theme.navigationBackgroundColor - } - - PositioningPreciseView { - id: positioningPreciseView - - precision: positioningSettings.preciseViewPrecision - - visible: !isNaN(navigation.distance) - && (positioningSettings.alwaysShowPreciseView - || (hasAcceptableAccuracy && projectDistance < precision)) - && !elevationProfile.visible - width: parent.width - height: Math.min(mainWindow.height / 2.5, 400) - } - - Rectangle { - visible: positioningInformationView.visible - && (positioningPreciseView.visible || navigationInformationView.visible) - width: parent.width - height: 1 - color: Theme.navigationBackgroundColor - } - PositioningInformationView { id: positioningInformationView visible: positioningSettings.showPositionInformation && !elevationProfile.visible @@ -998,13 +976,6 @@ ApplicationWindow { antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : NaN } - Rectangle { - visible: positioningInformationView.visible && sensorInformationView.visible - width: parent.width - height: 1 - color: Theme.sensorBackgroundColor - } - SensorInformationView { id: sensorInformationView } diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc index 11e14d5b09..ca9a34e614 100644 --- a/src/qml/qml.qrc +++ b/src/qml/qml.qrc @@ -102,5 +102,6 @@ QFieldLocalDataPickerScreen.qml QFieldSketcher.qml PluginManagerSettings.qml + NavigatingDrawer.qml From 5583fa4fbe7d98f84cfbfebc7b6bf95b8343a52e Mon Sep 17 00:00:00 2001 From: Mohsen Date: Mon, 13 May 2024 18:54:53 +0330 Subject: [PATCH 02/17] Sync with Digitizing panel. --- src/qml/NavigatingDrawer.qml | 3 ++- src/qml/qgismobileapp.qml | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/NavigatingDrawer.qml index 1d3642b34d..1de4c2436a 100644 --- a/src/qml/NavigatingDrawer.qml +++ b/src/qml/NavigatingDrawer.qml @@ -56,7 +56,7 @@ Drawer { width: parent.width - 16 height: navigationInformationView.height radius: 8 - color: "black" + color: Theme.mainBackgroundColor NavigationInformationView { id: navigationInformationView @@ -74,6 +74,7 @@ Drawer { anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 2 + color: Theme.mainTextColor } MouseArea { diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 38ad009354..9949593e16 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -1707,8 +1707,9 @@ ApplicationWindow { id: locationToolbar anchors.right: mapCanvas.right anchors.rightMargin: 4 - anchors.bottom: digitizingToolbarContainer.top - anchors.bottomMargin: 4 + y: navigatingDrawer.shouldBeOpen ? ( parent.height - height ) - (navigatingDrawer.height * navigatingDrawer.position) - (digitizingToolbar.stateVisible? 50: 0) : + digitizingToolbarContainerAnchor.y - height - 4 + spacing: 4 QfToolButton { @@ -2006,7 +2007,14 @@ ApplicationWindow { } } } + } + // this is a dummy item to get digitizingToolbarContainer y and bind to + Item{ + id: digitizingToolbarContainerAnchor + width: parent.width + height: 1 + anchors.bottom: digitizingToolbarContainer.top } Column { @@ -2015,7 +2023,7 @@ ApplicationWindow { anchors.rightMargin: 4 anchors.bottom: mapCanvas.bottom anchors.bottomMargin: informationView.visible - ? 4 + ? navigatingDrawer.height * navigatingDrawer.position : mainWindow.sceneBottomMargin + 4 spacing: 4 From 274233230ea4f25ac35a1f6c8de3f0be066ae342 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Mon, 13 May 2024 21:43:24 +0330 Subject: [PATCH 03/17] Responsive compassArrow and ScaleBar. when we drag navigatingDrawer it should change position of both compassArrow and ScaleBar too. --- src/qml/NavigatingDrawer.qml | 5 +++-- src/qml/qgismobileapp.qml | 28 ++++++++++------------------ 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/NavigatingDrawer.qml index 1de4c2436a..c5b86a3b06 100644 --- a/src/qml/NavigatingDrawer.qml +++ b/src/qml/NavigatingDrawer.qml @@ -22,6 +22,7 @@ Drawer { property bool closeRequested: false property bool shouldBeOpen: false property bool positioningPreciseEnabled: false + property real realtimeHeight: controller.height * controller.position onShouldBeOpenChanged: { if(shouldBeOpen){ @@ -53,7 +54,7 @@ Drawer { Rectangle { id: details anchors.horizontalCenter: parent.horizontalCenter - width: parent.width - 16 + width: parent.width - 8 height: navigationInformationView.height radius: 8 color: Theme.mainBackgroundColor @@ -96,7 +97,7 @@ Drawer { Rectangle { anchors.horizontalCenter: parent.horizontalCenter - width: parent.width - 16 + width: parent.width - 8 height: positioningPv.height radius: 8 color: "black" diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 9949593e16..1a3d95e713 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -1095,33 +1095,26 @@ ApplicationWindow { QfToolButton { id: compassArrow + y: navigatingDrawer.shouldBeOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - 44 : + digitizingToolbarContainerAnchor.y - height - 4 rotation: mapCanvas.mapSettings.rotation visible: rotation != 0 - anchors.left: mapCanvas.left - anchors.bottom: mapCanvas.bottom anchors.leftMargin: 4 - anchors.bottomMargin: informationView.visible - ? 54 - : mainWindow.sceneBottomMargin + 54 - round: true bgcolor: Theme.darkGraySemiOpaque iconSource: Theme.getThemeVectorIcon('ic_compass_arrow_24dp') - onClicked: mapCanvas.mapSettings.rotation = 0 } ScaleBar { + y: navigatingDrawer.shouldBeOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) : + digitizingToolbarContainerAnchor.y - height - 4 + visible: qfieldSettings.showScaleBar mapSettings: mapCanvas.mapSettings - anchors.left: mapCanvas.left - anchors.bottom: mapCanvas.bottom anchors.leftMargin: 4 - anchors.bottomMargin: informationView.visible - ? 10 - : mainWindow.sceneBottomMargin + 10 } QfDropShadow { @@ -1162,10 +1155,9 @@ ApplicationWindow { id: zoomToolbar anchors.right: mapCanvas.right anchors.rightMargin: 10 - anchors.bottom: mapCanvas.bottom - anchors.bottomMargin: ( mapCanvas.height - zoomToolbar.height / 2 ) / 2 + anchors.bottom: locationToolbar.top + anchors.bottomMargin: 8 spacing: 8 - visible: !screenLocker.enabled && (locationToolbar.height + digitizingToolbarContainer.height) / mapCanvas.height < 0.41 QfToolButton { @@ -1707,7 +1699,7 @@ ApplicationWindow { id: locationToolbar anchors.right: mapCanvas.right anchors.rightMargin: 4 - y: navigatingDrawer.shouldBeOpen ? ( parent.height - height ) - (navigatingDrawer.height * navigatingDrawer.position) - (digitizingToolbar.stateVisible? 50: 0) : + y: navigatingDrawer.shouldBeOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - (digitizingToolbar.stateVisible? 50: 0) : digitizingToolbarContainerAnchor.y - height - 4 spacing: 4 @@ -2009,8 +2001,8 @@ ApplicationWindow { } } - // this is a dummy item to get digitizingToolbarContainer y and bind to Item{ + // this is a dummy item to get digitizingToolbarContainer y and bind to id: digitizingToolbarContainerAnchor width: parent.width height: 1 @@ -2023,7 +2015,7 @@ ApplicationWindow { anchors.rightMargin: 4 anchors.bottom: mapCanvas.bottom anchors.bottomMargin: informationView.visible - ? navigatingDrawer.height * navigatingDrawer.position + ? navigatingDrawer.realtimeHeight : mainWindow.sceneBottomMargin + 4 spacing: 4 From 77aaa1f0800569ad869df0967b7e912214d46f9a Mon Sep 17 00:00:00 2001 From: Mohsen Date: Mon, 13 May 2024 23:12:23 +0330 Subject: [PATCH 04/17] Don't show PositioningPrecise whenever it's disabled! --- src/qml/NavigatingDrawer.qml | 49 +++++++++++++++++++++--------------- src/qml/qgismobileapp.qml | 14 +++++------ 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/NavigatingDrawer.qml index c5b86a3b06..7008ebf174 100644 --- a/src/qml/NavigatingDrawer.qml +++ b/src/qml/NavigatingDrawer.qml @@ -20,12 +20,33 @@ Drawer { property real positioningPreciseViewHeight property alias positioningPreciseView: positioningPv property bool closeRequested: false - property bool shouldBeOpen: false + property bool shouldOpen: false property bool positioningPreciseEnabled: false property real realtimeHeight: controller.height * controller.position - onShouldBeOpenChanged: { - if(shouldBeOpen){ + property bool isMinimal: controller.height < 2 * details.height + property bool isExpanded: positioningPreciseEnabled && !isMinimal + + function showExpanded(){ + controller.height = positioningPreciseViewHeight + details.height + 32 + controller.open() + } + + function showMinimized(){ + controller.height = details.height + 24 + controller.open() + } + + onPositioningPreciseEnabledChanged: { + if(positioningPreciseEnabled){ + showExpanded() + }else{ + showMinimized() + } + } + + onShouldOpenChanged: { + if(shouldOpen){ closeRequested = false; open() }else{ @@ -37,8 +58,7 @@ Drawer { onClosed: { if (!closeRequested) { // view dragged down but we should bring it back - controller.height = details.height + 24 - controller.open() + showMinimized() } } @@ -88,8 +108,8 @@ Drawer { } onPositionChanged: mouse => { var deltaY = mouse.y - dragStartY - if (deltaY < -details.height / 4){ // && positioningPv.canShow) { - controller.height = controller.defaultHeight + if (deltaY < -details.height / 6 && positioningPreciseEnabled) { + showExpanded() } } } @@ -101,24 +121,13 @@ Drawer { height: positioningPv.height radius: 8 color: "black" + clip: true PositioningPreciseView { id: positioningPv precision: positioningSettings.preciseViewPrecision width: parent.width - height: positioningPreciseViewHeight - } - - Rectangle{ - visible: !positioningPreciseEnabled - anchors.fill: positioningPv - color: "#cc2e2e2e" - - Text{ - anchors.centerIn: parent - text: "Enable Gps to show!" - color: "white" - } + height: positioningPreciseEnabled? positioningPreciseViewHeight: 0 } } } diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 1a3d95e713..1bc7924dd9 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -936,7 +936,7 @@ ApplicationWindow { navigation: navigation positioningSettings: positioningSettings positioningPreciseViewHeight: Math.min(mainWindow.height / 2.5, 400) - shouldBeOpen: navigation.isActive && !elevationProfile.visible && mapCanvasMap.isEnabled + shouldOpen: navigation.isActive && !elevationProfile.visible && mapCanvasMap.isEnabled positioningPreciseEnabled: !isNaN(navigation.distance) && (positioningSettings.alwaysShowPreciseView || (hasAcceptableAccuracy && projectDistance < precision)) @@ -1095,7 +1095,7 @@ ApplicationWindow { QfToolButton { id: compassArrow - y: navigatingDrawer.shouldBeOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - 44 : + y: navigatingDrawer.shouldOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - 44 : digitizingToolbarContainerAnchor.y - height - 4 rotation: mapCanvas.mapSettings.rotation visible: rotation != 0 @@ -1108,8 +1108,8 @@ ApplicationWindow { } ScaleBar { - y: navigatingDrawer.shouldBeOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) : - digitizingToolbarContainerAnchor.y - height - 4 + y: navigatingDrawer.shouldOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) : + digitizingToolbarContainerAnchor.y visible: qfieldSettings.showScaleBar mapSettings: mapCanvas.mapSettings @@ -1155,8 +1155,8 @@ ApplicationWindow { id: zoomToolbar anchors.right: mapCanvas.right anchors.rightMargin: 10 - anchors.bottom: locationToolbar.top - anchors.bottomMargin: 8 + anchors.verticalCenter: mapCanvas.verticalCenter + anchors.verticalCenterOffset: navigatingDrawer.isMinimal? 0: (digitizingToolbar.stateVisible? -270: -200) * navigatingDrawer.position spacing: 8 visible: !screenLocker.enabled && (locationToolbar.height + digitizingToolbarContainer.height) / mapCanvas.height < 0.41 @@ -1699,7 +1699,7 @@ ApplicationWindow { id: locationToolbar anchors.right: mapCanvas.right anchors.rightMargin: 4 - y: navigatingDrawer.shouldBeOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - (digitizingToolbar.stateVisible? 50: 0) : + y: navigatingDrawer.shouldOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - (digitizingToolbar.stateVisible? 50: 0) : digitizingToolbarContainerAnchor.y - height - 4 spacing: 4 From 9ab3227d96d3882f33b50cf8409093fb038781d0 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Tue, 14 May 2024 19:15:18 +0330 Subject: [PATCH 05/17] Invisible positioningPrecise if it is disabled. --- src/qml/NavigatingDrawer.qml | 11 +++++++---- src/qml/qgismobileapp.qml | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/NavigatingDrawer.qml index 7008ebf174..abef242965 100644 --- a/src/qml/NavigatingDrawer.qml +++ b/src/qml/NavigatingDrawer.qml @@ -24,8 +24,8 @@ Drawer { property bool positioningPreciseEnabled: false property real realtimeHeight: controller.height * controller.position - property bool isMinimal: controller.height < 2 * details.height - property bool isExpanded: positioningPreciseEnabled && !isMinimal + property bool isMinimal: shouldOpen && controller.height < 2 * details.height + property bool isExpanded: shouldOpen && positioningPreciseEnabled && !isMinimal function showExpanded(){ controller.height = positioningPreciseViewHeight + details.height + 32 @@ -40,8 +40,10 @@ Drawer { onPositioningPreciseEnabledChanged: { if(positioningPreciseEnabled){ showExpanded() - }else{ + }else if(shouldOpen){ showMinimized() + }else{ + } } @@ -58,7 +60,7 @@ Drawer { onClosed: { if (!closeRequested) { // view dragged down but we should bring it back - showMinimized() + showMinimized() } } @@ -96,6 +98,7 @@ Drawer { anchors.top: parent.top anchors.topMargin: 2 color: Theme.mainTextColor + visible: positioningPreciseEnabled } MouseArea { diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 1bc7924dd9..fb2722da05 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -1138,15 +1138,18 @@ ApplicationWindow { QfToolButton { id: alertIcon + y: navigatingDrawer.isExpanded && digitizingToolbar.stateVisible ? 34: locatorItem.height + 4 iconSource: Theme.getThemeVectorIcon( "ic_alert_black_24dp" ) round: true bgcolor: "transparent" - visible: !screenLocker.enabled && messageLog.unreadMessages - anchors.right: pluginsToolbar.right - anchors.top: pluginsToolbar.bottom - anchors.topMargin: 4 + + Behavior on y{ + NumberAnimation{ + duration: 100 + } + } onClicked: messageLog.visible = true } From 485240ba20fe67bf406a799b68d865fdfc50562e Mon Sep 17 00:00:00 2001 From: Mohsen Date: Tue, 14 May 2024 22:13:38 +0330 Subject: [PATCH 06/17] Add PositioningInformationView to NavigatingDrawer. --- src/qml/NavigatingDrawer.qml | 114 ++++++++++++++++++++++------------- src/qml/qgismobileapp.qml | 29 ++++----- 2 files changed, 82 insertions(+), 61 deletions(-) diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/NavigatingDrawer.qml index abef242965..1af95e1fdf 100644 --- a/src/qml/NavigatingDrawer.qml +++ b/src/qml/NavigatingDrawer.qml @@ -6,50 +6,61 @@ import Theme 1.0 Drawer { id: controller + width: parent.width height: defaultHeight Overlay.modal: null modal: false - width: parent.width edge: Qt.BottomEdge dragMargin: 0 closePolicy: Popup.NoAutoClose property Navigation navigation property PositioningSettings positioningSettings - property real defaultHeight: positioningPreciseView.height + details.height + 32 + property Positioning positionSource + property double antennaHeight property real positioningPreciseViewHeight property alias positioningPreciseView: positioningPv - property bool closeRequested: false + property bool closeRequested: true + property bool positioningInformationViewEnabled: false property bool shouldOpen: false property bool positioningPreciseEnabled: false property real realtimeHeight: controller.height * controller.position - property bool isMinimal: shouldOpen && controller.height < 2 * details.height - property bool isExpanded: shouldOpen && positioningPreciseEnabled && !isMinimal - - function showExpanded(){ - controller.height = positioningPreciseViewHeight + details.height + 32 - controller.open() - } - - function showMinimized(){ - controller.height = details.height + 24 - controller.open() + property real defaultHeight: details.height + positioningIfo.height + positioningPreciseViewRect.height + 24 + + function resetHeight(){ + let newHeight = 0 + newHeight += (details.height + 8) + newHeight += (positioningIfo.height + 8) + newHeight += (positioningPreciseViewRect.height + 8) + newHeight += 16 + controller.height = newHeight } onPositioningPreciseEnabledChanged: { - if(positioningPreciseEnabled){ - showExpanded() + if(!positioningPreciseEnabled ){ + controller.height -= positioningPreciseViewHeight + controller.open() }else if(shouldOpen){ - showMinimized() - }else{ + controller.height += positioningPreciseViewHeight + controller.open() + } + } + onPositioningInformationViewEnabledChanged: { + if(!positioningInformationViewEnabled ){ + controller.height -= positioningInformationView.height + controller.open() + }else if(shouldOpen){ + controller.height += positioningInformationView.height + controller.open() } } onShouldOpenChanged: { if(shouldOpen){ closeRequested = false; + resetHeight() open() }else{ closeRequested = true; @@ -57,10 +68,17 @@ Drawer { } } + onOpened: { + if(closeRequested){ + controller.close() + } + } + onClosed: { if (!closeRequested) { // view dragged down but we should bring it back - showMinimized() + resetHeight() + controller.open() } } @@ -70,6 +88,7 @@ Drawer { } Column { + id: mainContent spacing: 8 width: parent.width @@ -89,36 +108,28 @@ Drawer { radius: parent.radius clip: true } + } - Rectangle { - width: 50 - height: 2 - radius: 4 - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - anchors.topMargin: 2 - color: Theme.mainTextColor - visible: positioningPreciseEnabled - } - - MouseArea { - anchors.fill: details - - property int dragStartY: 0 + Rectangle { + id: positioningIfo + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - 8 + height: positioningInformationViewEnabled? positioningInformationView.height: 0 + radius: 8 + color: Theme.mainBackgroundColor + clip: true - onPressed: mouse => { - dragStartY = mouse.y - } - onPositionChanged: mouse => { - var deltaY = mouse.y - dragStartY - if (deltaY < -details.height / 6 && positioningPreciseEnabled) { - showExpanded() - } - } + PositioningInformationView { + id: positioningInformationView + visible: positioningInformationViewEnabled + positionSource: controller.positionSource + antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : NaN + radius: parent.radius } } Rectangle { + id: positioningPreciseViewRect anchors.horizontalCenter: parent.horizontalCenter width: parent.width - 8 height: positioningPv.height @@ -134,4 +145,21 @@ Drawer { } } } + + MouseArea { + anchors.fill: parent + property int dragStartY: 0 + + onPressed: mouse => { + dragStartY = mouse.y + } + + onPositionChanged: mouse => { + var deltaY = mouse.y - dragStartY + if (deltaY < -details.height / 6 && positioningPreciseEnabled) { + resetHeight() + controller.open() + } + } + } } diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index fb2722da05..50acef36bf 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -933,14 +933,21 @@ ApplicationWindow { NavigatingDrawer{ id: navigatingDrawer + shouldOpen: navigation.isActive && + !elevationProfile.visible && + mapCanvasMap.isEnabled && + !messageLog.visible + navigation: navigation positioningSettings: positioningSettings positioningPreciseViewHeight: Math.min(mainWindow.height / 2.5, 400) - shouldOpen: navigation.isActive && !elevationProfile.visible && mapCanvasMap.isEnabled positioningPreciseEnabled: !isNaN(navigation.distance) && (positioningSettings.alwaysShowPreciseView || (hasAcceptableAccuracy && projectDistance < precision)) && !elevationProfile.visible + positioningInformationViewEnabled: positioningSettings.showPositionInformation && !elevationProfile.visible + positionSource: positionSource + antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : NaN } Column { @@ -969,13 +976,6 @@ ApplicationWindow { crs: mapCanvas.mapSettings.destinationCrs } - PositioningInformationView { - id: positioningInformationView - visible: positioningSettings.showPositionInformation && !elevationProfile.visible - positionSource: positionSource - antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : NaN - } - SensorInformationView { id: sensorInformationView } @@ -1138,18 +1138,12 @@ ApplicationWindow { QfToolButton { id: alertIcon - y: navigatingDrawer.isExpanded && digitizingToolbar.stateVisible ? 34: locatorItem.height + 4 iconSource: Theme.getThemeVectorIcon( "ic_alert_black_24dp" ) round: true bgcolor: "transparent" - visible: !screenLocker.enabled && messageLog.unreadMessages + visible: !screenLocker.enabled && messageLog.unreadMessages anchors.right: pluginsToolbar.right - - Behavior on y{ - NumberAnimation{ - duration: 100 - } - } + y: parent.height / 4 - (navigatingDrawer.position * navigatingDrawer.height / 3.7 + (digitizingToolbar.stateVisible ? 70: 0)) onClicked: messageLog.visible = true } @@ -1158,8 +1152,7 @@ ApplicationWindow { id: zoomToolbar anchors.right: mapCanvas.right anchors.rightMargin: 10 - anchors.verticalCenter: mapCanvas.verticalCenter - anchors.verticalCenterOffset: navigatingDrawer.isMinimal? 0: (digitizingToolbar.stateVisible? -270: -200) * navigatingDrawer.position + y: parent.height / 2 - (navigatingDrawer.position * navigatingDrawer.height / 1.75 + (digitizingToolbar.stateVisible ? 70: 0)) spacing: 8 visible: !screenLocker.enabled && (locationToolbar.height + digitizingToolbarContainer.height) / mapCanvas.height < 0.41 From 974a682ec294ed5fde7a6ac8e1a93609d85b81bc Mon Sep 17 00:00:00 2001 From: Mohsen Date: Wed, 15 May 2024 17:05:24 +0330 Subject: [PATCH 07/17] Modify alertIcon and zoomToolbar visibility based on their "y" property. --- src/qml/qgismobileapp.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 50acef36bf..21dfdb1599 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -1143,7 +1143,7 @@ ApplicationWindow { bgcolor: "transparent" visible: !screenLocker.enabled && messageLog.unreadMessages anchors.right: pluginsToolbar.right - y: parent.height / 4 - (navigatingDrawer.position * navigatingDrawer.height / 3.7 + (digitizingToolbar.stateVisible ? 70: 0)) + y: Math.max(16, parent.height / 4 - (navigatingDrawer.realtimeHeight / 3.7 + (digitizingToolbar.stateVisible ? 70: 0))) onClicked: messageLog.visible = true } @@ -1152,9 +1152,9 @@ ApplicationWindow { id: zoomToolbar anchors.right: mapCanvas.right anchors.rightMargin: 10 - y: parent.height / 2 - (navigatingDrawer.position * navigatingDrawer.height / 1.75 + (digitizingToolbar.stateVisible ? 70: 0)) + y: parent.height / 2 - (navigatingDrawer.realtimeHeight / 1.75 + (digitizingToolbar.stateVisible ? 70: 0) + (elevationProfile.visible ? 70: 0)) spacing: 8 - visible: !screenLocker.enabled && (locationToolbar.height + digitizingToolbarContainer.height) / mapCanvas.height < 0.41 + visible: !screenLocker.enabled && (locationToolbar.height + digitizingToolbarContainer.height) / (digitizingToolbarContainerAnchor.y) < 0.41 QfToolButton { id: zoomInButton From 138c408a443cf15fbd9ff3b80a2bb57b392cc60b Mon Sep 17 00:00:00 2001 From: Mohsen Date: Wed, 15 May 2024 19:55:50 +0330 Subject: [PATCH 08/17] Show NavigatingDrawer if positioningInformationView is visible. --- src/qml/NavigatingDrawer.qml | 23 ++++++++++++++++++----- src/qml/qgismobileapp.qml | 13 ++++++------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/NavigatingDrawer.qml index 1af95e1fdf..44dcb777c6 100644 --- a/src/qml/NavigatingDrawer.qml +++ b/src/qml/NavigatingDrawer.qml @@ -21,6 +21,7 @@ Drawer { property real positioningPreciseViewHeight property alias positioningPreciseView: positioningPv property bool closeRequested: true + property bool navigationInformationViewEnabled: navigation.isActive property bool positioningInformationViewEnabled: false property bool shouldOpen: false property bool positioningPreciseEnabled: false @@ -37,16 +38,17 @@ Drawer { controller.height = newHeight } - onPositioningPreciseEnabledChanged: { - if(!positioningPreciseEnabled ){ - controller.height -= positioningPreciseViewHeight + onNavigationInformationViewEnabledChanged: { + if(!navigationInformationViewEnabled ){ + controller.height -= navigationInformationView.height controller.open() }else if(shouldOpen){ - controller.height += positioningPreciseViewHeight + controller.height += navigationInformationView.height controller.open() } } + onPositioningInformationViewEnabledChanged: { if(!positioningInformationViewEnabled ){ controller.height -= positioningInformationView.height @@ -57,6 +59,16 @@ Drawer { } } + onPositioningPreciseEnabledChanged: { + if(!positioningPreciseEnabled ){ + controller.height -= positioningPreciseViewHeight + controller.open() + }else if(shouldOpen){ + controller.height += positioningPreciseViewHeight + controller.open() + } + } + onShouldOpenChanged: { if(shouldOpen){ closeRequested = false; @@ -96,9 +108,10 @@ Drawer { id: details anchors.horizontalCenter: parent.horizontalCenter width: parent.width - 8 - height: navigationInformationView.height + height: navigationInformationViewEnabled? navigationInformationView.height: 0 radius: 8 color: Theme.mainBackgroundColor + clip: true NavigationInformationView { id: navigationInformationView diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 21dfdb1599..5b80a3beca 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -933,7 +933,7 @@ ApplicationWindow { NavigatingDrawer{ id: navigatingDrawer - shouldOpen: navigation.isActive && + shouldOpen: (navigation.isActive || positioningSettings.showPositionInformation ) && !elevationProfile.visible && mapCanvasMap.isEnabled && !messageLog.visible @@ -941,10 +941,12 @@ ApplicationWindow { navigation: navigation positioningSettings: positioningSettings positioningPreciseViewHeight: Math.min(mainWindow.height / 2.5, 400) - positioningPreciseEnabled: !isNaN(navigation.distance) + positioningPreciseEnabled: !elevationProfile.visible + && !isNaN(navigation.distance) + && navigation.isActive && (positioningSettings.alwaysShowPreciseView || (hasAcceptableAccuracy && projectDistance < precision)) - && !elevationProfile.visible + positioningInformationViewEnabled: positioningSettings.showPositionInformation && !elevationProfile.visible positionSource: positionSource antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : NaN @@ -956,10 +958,7 @@ ApplicationWindow { anchors.left: parent.left anchors.right: parent.right anchors.bottomMargin: mainWindow.sceneBottomMargin - visible: navigation.isActive || - positioningSettings.showPositionInformation || - navigatingDrawer.positioningPreciseView.visible || - sensorInformationView.activeSensors > 0 || + visible: sensorInformationView.activeSensors > 0 || (stateMachine.state === 'measure' && elevationProfileButton.elevationProfileActive) width: parent.width From fc726486d580f8fe393a42943af6e0b33a7af977 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Wed, 15 May 2024 20:55:06 +0330 Subject: [PATCH 09/17] Fix positioningPrecise visibility. based on showing always or not in settings + formatting NavigatingDrawer. --- src/qml/NavigatingDrawer.qml | 44 +++++++++++++++++------------------- src/qml/qgismobileapp.qml | 21 ++++++----------- 2 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/NavigatingDrawer.qml index 44dcb777c6..a3df914148 100644 --- a/src/qml/NavigatingDrawer.qml +++ b/src/qml/NavigatingDrawer.qml @@ -14,22 +14,21 @@ Drawer { dragMargin: 0 closePolicy: Popup.NoAutoClose + property alias positioningPreciseView: positioningPv property Navigation navigation property PositioningSettings positioningSettings property Positioning positionSource property double antennaHeight + property real realtimeHeight: controller.height * controller.position property real positioningPreciseViewHeight - property alias positioningPreciseView: positioningPv + property real defaultHeight: details.height + positioningIfo.height + positioningPreciseViewRect.height + 24 property bool closeRequested: true property bool navigationInformationViewEnabled: navigation.isActive property bool positioningInformationViewEnabled: false property bool shouldOpen: false property bool positioningPreciseEnabled: false - property real realtimeHeight: controller.height * controller.position - property bool isMinimal: shouldOpen && controller.height < 2 * details.height - property real defaultHeight: details.height + positioningIfo.height + positioningPreciseViewRect.height + 24 - function resetHeight(){ + function resetHeight() { let newHeight = 0 newHeight += (details.height + 8) newHeight += (positioningIfo.height + 8) @@ -39,56 +38,55 @@ Drawer { } onNavigationInformationViewEnabledChanged: { - if(!navigationInformationViewEnabled ){ + if (!navigationInformationViewEnabled) { controller.height -= navigationInformationView.height controller.open() - }else if(shouldOpen){ + } else if (shouldOpen) { controller.height += navigationInformationView.height controller.open() } } - onPositioningInformationViewEnabledChanged: { - if(!positioningInformationViewEnabled ){ + if (!positioningInformationViewEnabled) { controller.height -= positioningInformationView.height controller.open() - }else if(shouldOpen){ + } else if (shouldOpen) { controller.height += positioningInformationView.height controller.open() } } onPositioningPreciseEnabledChanged: { - if(!positioningPreciseEnabled ){ + if (!positioningPreciseEnabled) { controller.height -= positioningPreciseViewHeight controller.open() - }else if(shouldOpen){ + } else if (shouldOpen) { controller.height += positioningPreciseViewHeight controller.open() } } onShouldOpenChanged: { - if(shouldOpen){ - closeRequested = false; + if (shouldOpen) { + closeRequested = false resetHeight() open() - }else{ - closeRequested = true; + } else { + closeRequested = true close() } } onOpened: { - if(closeRequested){ + if (closeRequested) { controller.close() } } onClosed: { if (!closeRequested) { - // view dragged down but we should bring it back + // view is dragged down but we must bring it back resetHeight() controller.open() } @@ -108,7 +106,7 @@ Drawer { id: details anchors.horizontalCenter: parent.horizontalCenter width: parent.width - 8 - height: navigationInformationViewEnabled? navigationInformationView.height: 0 + height: navigationInformationViewEnabled ? navigationInformationView.height : 0 radius: 8 color: Theme.mainBackgroundColor clip: true @@ -127,7 +125,7 @@ Drawer { id: positioningIfo anchors.horizontalCenter: parent.horizontalCenter width: parent.width - 8 - height: positioningInformationViewEnabled? positioningInformationView.height: 0 + height: positioningInformationViewEnabled ? positioningInformationView.height : 0 radius: 8 color: Theme.mainBackgroundColor clip: true @@ -154,7 +152,7 @@ Drawer { id: positioningPv precision: positioningSettings.preciseViewPrecision width: parent.width - height: positioningPreciseEnabled? positioningPreciseViewHeight: 0 + height: positioningPreciseEnabled ? positioningPreciseViewHeight : 0 } } } @@ -168,8 +166,8 @@ Drawer { } onPositionChanged: mouse => { - var deltaY = mouse.y - dragStartY - if (deltaY < -details.height / 6 && positioningPreciseEnabled) { + var deltaY = mouse.y - dragStartY + if (deltaY < -details.height / 6 && positioningPreciseEnabled) { resetHeight() controller.open() } diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 5b80a3beca..488c07e054 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -945,7 +945,8 @@ ApplicationWindow { && !isNaN(navigation.distance) && navigation.isActive && (positioningSettings.alwaysShowPreciseView - || (hasAcceptableAccuracy && projectDistance < precision)) + || ( positioningPreciseView.hasAcceptableAccuracy + && positioningPreciseView.projectDistance < positioningPreciseView.precision )) positioningInformationViewEnabled: positioningSettings.showPositionInformation && !elevationProfile.visible positionSource: positionSource @@ -1095,7 +1096,7 @@ ApplicationWindow { QfToolButton { id: compassArrow y: navigatingDrawer.shouldOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - 44 : - digitizingToolbarContainerAnchor.y - height - 4 + digitizingToolbarContainer.y - height - 4 rotation: mapCanvas.mapSettings.rotation visible: rotation != 0 anchors.left: mapCanvas.left @@ -1108,7 +1109,7 @@ ApplicationWindow { ScaleBar { y: navigatingDrawer.shouldOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) : - digitizingToolbarContainerAnchor.y + digitizingToolbarContainer.y visible: qfieldSettings.showScaleBar mapSettings: mapCanvas.mapSettings @@ -1153,7 +1154,7 @@ ApplicationWindow { anchors.rightMargin: 10 y: parent.height / 2 - (navigatingDrawer.realtimeHeight / 1.75 + (digitizingToolbar.stateVisible ? 70: 0) + (elevationProfile.visible ? 70: 0)) spacing: 8 - visible: !screenLocker.enabled && (locationToolbar.height + digitizingToolbarContainer.height) / (digitizingToolbarContainerAnchor.y) < 0.41 + visible: !screenLocker.enabled && (locationToolbar.height + digitizingToolbarContainer.height) / (digitizingToolbarContainer.y) < 0.41 QfToolButton { id: zoomInButton @@ -1695,7 +1696,7 @@ ApplicationWindow { anchors.right: mapCanvas.right anchors.rightMargin: 4 y: navigatingDrawer.shouldOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - (digitizingToolbar.stateVisible? 50: 0) : - digitizingToolbarContainerAnchor.y - height - 4 + digitizingToolbarContainer.y - height - 4 spacing: 4 @@ -1996,20 +1997,12 @@ ApplicationWindow { } } - Item{ - // this is a dummy item to get digitizingToolbarContainer y and bind to - id: digitizingToolbarContainerAnchor - width: parent.width - height: 1 - anchors.bottom: digitizingToolbarContainer.top - } - Column { id: digitizingToolbarContainer anchors.right: mapCanvas.right anchors.rightMargin: 4 anchors.bottom: mapCanvas.bottom - anchors.bottomMargin: informationView.visible + anchors.bottomMargin: navigatingDrawer.shouldOpen ? navigatingDrawer.realtimeHeight : mainWindow.sceneBottomMargin + 4 spacing: 4 From 16e30a3c6c23fa26374e7046efb21c84bbde9795 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Thu, 16 May 2024 19:34:24 +0330 Subject: [PATCH 10/17] Fix inconsistent bottom margin. --- src/qml/NavigatingDrawer.qml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/NavigatingDrawer.qml index a3df914148..292fc1a103 100644 --- a/src/qml/NavigatingDrawer.qml +++ b/src/qml/NavigatingDrawer.qml @@ -39,30 +39,30 @@ Drawer { onNavigationInformationViewEnabledChanged: { if (!navigationInformationViewEnabled) { - controller.height -= navigationInformationView.height + controller.height -= (navigationInformationView.height + 8) controller.open() } else if (shouldOpen) { - controller.height += navigationInformationView.height + controller.height += (navigationInformationView.height + 8) controller.open() } } onPositioningInformationViewEnabledChanged: { if (!positioningInformationViewEnabled) { - controller.height -= positioningInformationView.height + controller.height -= (positioningInformationView.height + 8) controller.open() } else if (shouldOpen) { - controller.height += positioningInformationView.height + controller.height += (positioningInformationView.height + 8) controller.open() } } onPositioningPreciseEnabledChanged: { if (!positioningPreciseEnabled) { - controller.height -= positioningPreciseViewHeight + controller.height -= (positioningPreciseViewHeight + 8) controller.open() } else if (shouldOpen) { - controller.height += positioningPreciseViewHeight + controller.height += (positioningPreciseViewHeight + 8) controller.open() } } From f016e81a7675ef9794bba6b9f6060dc3ca64e649 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Fri, 17 May 2024 00:50:42 +0330 Subject: [PATCH 11/17] Cleanup codes and transparent background. --- src/qml/NavigatingDrawer.qml | 147 ++++++++----------------- src/qml/NavigationInformationView.qml | 15 +-- src/qml/PositioningInformationView.qml | 6 +- src/qml/PositioningPreciseView.qml | 3 +- src/qml/qgismobileapp.qml | 10 +- 5 files changed, 64 insertions(+), 117 deletions(-) diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/NavigatingDrawer.qml index 292fc1a103..e8f102f063 100644 --- a/src/qml/NavigatingDrawer.qml +++ b/src/qml/NavigatingDrawer.qml @@ -7,68 +7,59 @@ import Theme 1.0 Drawer { id: controller width: parent.width - height: defaultHeight + height: mainContent.height Overlay.modal: null modal: false edge: Qt.BottomEdge dragMargin: 0 closePolicy: Popup.NoAutoClose - property alias positioningPreciseView: positioningPv - property Navigation navigation - property PositioningSettings positioningSettings - property Positioning positionSource - property double antennaHeight property real realtimeHeight: controller.height * controller.position - property real positioningPreciseViewHeight - property real defaultHeight: details.height + positioningIfo.height + positioningPreciseViewRect.height + 24 property bool closeRequested: true + property bool openRequested: false + + // NavigationInformationView property bool navigationInformationViewEnabled: navigation.isActive + + // PositioningInformationView + property Navigation navigation + property double antennaHeight property bool positioningInformationViewEnabled: false - property bool shouldOpen: false + + // PositioningPreciseView + property alias positioningPreciseView: positioningPv + property PositioningSettings positioningSettings + property Positioning positionSource property bool positioningPreciseEnabled: false + property real positioningPreciseViewHeight function resetHeight() { let newHeight = 0 - newHeight += (details.height + 8) - newHeight += (positioningIfo.height + 8) - newHeight += (positioningPreciseViewRect.height + 8) + newHeight += (navigationInformationView.height + 8) + newHeight += (positioningInformationView.height + 8) + newHeight += (positioningPv.height + 8) newHeight += 16 controller.height = newHeight } - onNavigationInformationViewEnabledChanged: { - if (!navigationInformationViewEnabled) { - controller.height -= (navigationInformationView.height + 8) + function updateDrawerHeight(visibleView, viewHeight){ + if (!visibleView) { + controller.height -= (viewHeight + 8) controller.open() - } else if (shouldOpen) { - controller.height += (navigationInformationView.height + 8) + } else if (openRequested) { + controller.height += (viewHeight + 8) controller.open() } } - onPositioningInformationViewEnabledChanged: { - if (!positioningInformationViewEnabled) { - controller.height -= (positioningInformationView.height + 8) - controller.open() - } else if (shouldOpen) { - controller.height += (positioningInformationView.height + 8) - controller.open() - } - } + onNavigationInformationViewEnabledChanged: updateDrawerHeight (navigationInformationViewEnabled, navigationInformationView.contentHeight) - onPositioningPreciseEnabledChanged: { - if (!positioningPreciseEnabled) { - controller.height -= (positioningPreciseViewHeight + 8) - controller.open() - } else if (shouldOpen) { - controller.height += (positioningPreciseViewHeight + 8) - controller.open() - } - } + onPositioningInformationViewEnabledChanged: updateDrawerHeight (positioningInformationViewEnabled, positioningInformationView.contentHeight) - onShouldOpenChanged: { - if (shouldOpen) { + onPositioningPreciseEnabledChanged: updateDrawerHeight (positioningPreciseEnabled, positioningPreciseViewHeight) + + onOpenRequestedChanged: { + if (openRequested) { closeRequested = false resetHeight() open() @@ -87,14 +78,12 @@ Drawer { onClosed: { if (!closeRequested) { // view is dragged down but we must bring it back - resetHeight() controller.open() } } - background: Rectangle { + background: Item { anchors.fill: parent - color: "transparent" } Column { @@ -102,75 +91,35 @@ Drawer { spacing: 8 width: parent.width - Rectangle { - id: details - anchors.horizontalCenter: parent.horizontalCenter + NavigationInformationView { + id: navigationInformationView width: parent.width - 8 - height: navigationInformationViewEnabled ? navigationInformationView.height : 0 - radius: 8 - color: Theme.mainBackgroundColor + height: navigationInformationViewEnabled ? contentHeight : 0 + anchors.horizontalCenter: parent.horizontalCenter clip: true - - NavigationInformationView { - id: navigationInformationView - navigation: controller.navigation - width: parent.width - anchors.centerIn: parent - radius: parent.radius - clip: true - } + navigation: controller.navigation + radius: 8 } - Rectangle { - id: positioningIfo - anchors.horizontalCenter: parent.horizontalCenter + PositioningInformationView { + id: positioningInformationView width: parent.width - 8 - height: positioningInformationViewEnabled ? positioningInformationView.height : 0 - radius: 8 - color: Theme.mainBackgroundColor + height: positioningInformationViewEnabled ? contentHeight : 0 + anchors.horizontalCenter: parent.horizontalCenter clip: true - - PositioningInformationView { - id: positioningInformationView - visible: positioningInformationViewEnabled - positionSource: controller.positionSource - antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : NaN - radius: parent.radius - } + visible: positioningInformationViewEnabled + positionSource: controller.positionSource + antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : NaN + radius: 8 } - Rectangle { - id: positioningPreciseViewRect - anchors.horizontalCenter: parent.horizontalCenter + PositioningPreciseView { + id: positioningPv width: parent.width - 8 - height: positioningPv.height - radius: 8 - color: "black" + height: positioningPreciseEnabled ? positioningPreciseViewHeight : 0 + anchors.horizontalCenter: parent.horizontalCenter clip: true - - PositioningPreciseView { - id: positioningPv - precision: positioningSettings.preciseViewPrecision - width: parent.width - height: positioningPreciseEnabled ? positioningPreciseViewHeight : 0 - } - } - } - - MouseArea { - anchors.fill: parent - property int dragStartY: 0 - - onPressed: mouse => { - dragStartY = mouse.y - } - - onPositionChanged: mouse => { - var deltaY = mouse.y - dragStartY - if (deltaY < -details.height / 6 && positioningPreciseEnabled) { - resetHeight() - controller.open() - } + precision: positioningSettings.preciseViewPrecision } } } diff --git a/src/qml/NavigationInformationView.qml b/src/qml/NavigationInformationView.qml index 0eb59aa8a9..14ad7ed33c 100644 --- a/src/qml/NavigationInformationView.qml +++ b/src/qml/NavigationInformationView.qml @@ -17,12 +17,14 @@ Rectangle { property int ceilsCount: 4 property double rowHeight: 30 - property color backgroundColor: Theme.mainBackgroundColor + property color backgroundColor: "transparent" property color alternateBackgroundColor: Theme.navigationBackgroundColor property color textColor: Theme.mainTextColor + property real contentHeight: content.height - color: Theme.mainBackgroundColor - height: content.height + color: "#dd" + Theme.mainBackgroundColor.toString().slice(1) + border.color: alternateBackgroundColor + border.width: 2 Timer { id: featureVertexTimer @@ -47,10 +49,9 @@ Rectangle { width: parent.width spacing: 0 - Rectangle { + Item { Layout.fillWidth: true Layout.preferredHeight: childrenRect.height - color: Theme.navigationColor RowLayout { width: parent.width @@ -130,7 +131,6 @@ Rectangle { Rectangle { height: rowHeight width: grid.cellWidth - radius: 4 color: alternateBackgroundColor Text { @@ -150,7 +150,6 @@ Rectangle { Rectangle { height: rowHeight width: grid.cellWidth - radius: 4 color: backgroundColor Text { @@ -170,7 +169,6 @@ Rectangle { Rectangle { height: rowHeight width: grid.cellWidth - radius: 4 color: grid.rows == 2 ? backgroundColor : alternateBackgroundColor Text { @@ -189,7 +187,6 @@ Rectangle { Rectangle { height: rowHeight width: grid.cellWidth - radius: 4 color: grid.rows == 2 ? alternateBackgroundColor : backgroundColor Text { diff --git a/src/qml/PositioningInformationView.qml b/src/qml/PositioningInformationView.qml index 1897362fd3..299036d256 100644 --- a/src/qml/PositioningInformationView.qml +++ b/src/qml/PositioningInformationView.qml @@ -19,15 +19,15 @@ Rectangle { property double antennaHeight: NaN property double rowHeight: 30 - property color backgroundColor: Theme.mainBackgroundColor + property color backgroundColor: "transparent" property color alternateBackgroundColor: Theme.positionBackgroundColor property color textColor: positionSource.currentness ? Theme.mainTextColor : Theme.secondaryTextColor - height: grid.rows * positioningInformationView.rowHeight + property real contentHeight: grid.rows * positioningInformationView.rowHeight width: parent.width anchors.margins: 20 - color: Theme.mainBackgroundColor + color: "#dd" + Theme.mainBackgroundColor.toString().slice(1) Grid { id: grid diff --git a/src/qml/PositioningPreciseView.qml b/src/qml/PositioningPreciseView.qml index 7c3f049011..8cf4274e3b 100644 --- a/src/qml/PositioningPreciseView.qml +++ b/src/qml/PositioningPreciseView.qml @@ -31,7 +31,8 @@ Item { Rectangle { anchors.fill: parent - color: Theme.mainBackgroundColor + color: "#ee" + Theme.mainBackgroundColor.toString().slice(1) + radius: 8 } Row { diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 488c07e054..79c34d8996 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -933,7 +933,7 @@ ApplicationWindow { NavigatingDrawer{ id: navigatingDrawer - shouldOpen: (navigation.isActive || positioningSettings.showPositionInformation ) && + openRequested: (navigation.isActive || positioningSettings.showPositionInformation ) && !elevationProfile.visible && mapCanvasMap.isEnabled && !messageLog.visible @@ -1095,7 +1095,7 @@ ApplicationWindow { QfToolButton { id: compassArrow - y: navigatingDrawer.shouldOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - 44 : + y: navigatingDrawer.openRequested ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - 44 : digitizingToolbarContainer.y - height - 4 rotation: mapCanvas.mapSettings.rotation visible: rotation != 0 @@ -1108,7 +1108,7 @@ ApplicationWindow { } ScaleBar { - y: navigatingDrawer.shouldOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) : + y: navigatingDrawer.openRequested ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) : digitizingToolbarContainer.y visible: qfieldSettings.showScaleBar @@ -1695,7 +1695,7 @@ ApplicationWindow { id: locationToolbar anchors.right: mapCanvas.right anchors.rightMargin: 4 - y: navigatingDrawer.shouldOpen ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - (digitizingToolbar.stateVisible? 50: 0) : + y: navigatingDrawer.openRequested ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - (digitizingToolbar.stateVisible? 50: 0) : digitizingToolbarContainer.y - height - 4 spacing: 4 @@ -2002,7 +2002,7 @@ ApplicationWindow { anchors.right: mapCanvas.right anchors.rightMargin: 4 anchors.bottom: mapCanvas.bottom - anchors.bottomMargin: navigatingDrawer.shouldOpen + anchors.bottomMargin: navigatingDrawer.openRequested ? navigatingDrawer.realtimeHeight : mainWindow.sceneBottomMargin + 4 spacing: 4 From cad99c6f1d9ebc3262b1f4dd353192c1834a85e6 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Sat, 18 May 2024 18:57:07 +0330 Subject: [PATCH 12/17] Resolves PR issues - 1: naming, formatting inconsistencies, move logic. Add mainBackgroundTransparentColor. Rename navigatingDrawer to informationDrawer. Move some input logic into the InformationDrawer. --- ...gatingDrawer.qml => InformationDrawer.qml} | 29 +++++++++------ src/qml/NavigationInformationView.qml | 2 +- src/qml/PositioningInformationView.qml | 2 +- src/qml/imports/Theme/Theme.qml | 2 + src/qml/qgismobileapp.qml | 37 +++++++------------ src/qml/qml.qrc | 2 +- 6 files changed, 37 insertions(+), 37 deletions(-) rename src/qml/{NavigatingDrawer.qml => InformationDrawer.qml} (69%) diff --git a/src/qml/NavigatingDrawer.qml b/src/qml/InformationDrawer.qml similarity index 69% rename from src/qml/NavigatingDrawer.qml rename to src/qml/InformationDrawer.qml index e8f102f063..8d6367aa8d 100644 --- a/src/qml/NavigatingDrawer.qml +++ b/src/qml/InformationDrawer.qml @@ -17,27 +17,34 @@ Drawer { property real realtimeHeight: controller.height * controller.position property bool closeRequested: true property bool openRequested: false + property real itemRadius: 8 + property bool uiConflictFree: false // NavigationInformationView property bool navigationInformationViewEnabled: navigation.isActive // PositioningInformationView property Navigation navigation - property double antennaHeight - property bool positioningInformationViewEnabled: false + property bool positioningInformationViewEnabled: positioningSettings.showPositionInformation && uiConflictFree // PositioningPreciseView - property alias positioningPreciseView: positioningPv + property alias positioningPreciseView: positioningPreciseView property PositioningSettings positioningSettings property Positioning positionSource - property bool positioningPreciseEnabled: false property real positioningPreciseViewHeight + property bool positioningPreciseEnabled: uiConflictFree + && !isNaN(navigation.distance) + && navigation.isActive + && (positioningSettings.alwaysShowPreciseView + || ( positioningPreciseView.hasAcceptableAccuracy + && positioningPreciseView.projectDistance < positioningPreciseView.precision )) + function resetHeight() { let newHeight = 0 newHeight += (navigationInformationView.height + 8) newHeight += (positioningInformationView.height + 8) - newHeight += (positioningPv.height + 8) + newHeight += (positioningPreciseView.height + 8) newHeight += 16 controller.height = newHeight } @@ -52,11 +59,11 @@ Drawer { } } - onNavigationInformationViewEnabledChanged: updateDrawerHeight (navigationInformationViewEnabled, navigationInformationView.contentHeight) + onNavigationInformationViewEnabledChanged: updateDrawerHeight(navigationInformationViewEnabled, navigationInformationView.contentHeight) - onPositioningInformationViewEnabledChanged: updateDrawerHeight (positioningInformationViewEnabled, positioningInformationView.contentHeight) + onPositioningInformationViewEnabledChanged: updateDrawerHeight(positioningInformationViewEnabled, positioningInformationView.contentHeight) - onPositioningPreciseEnabledChanged: updateDrawerHeight (positioningPreciseEnabled, positioningPreciseViewHeight) + onPositioningPreciseEnabledChanged: updateDrawerHeight(positioningPreciseEnabled, positioningPreciseViewHeight) onOpenRequestedChanged: { if (openRequested) { @@ -98,7 +105,7 @@ Drawer { anchors.horizontalCenter: parent.horizontalCenter clip: true navigation: controller.navigation - radius: 8 + radius: itemRadius } PositioningInformationView { @@ -110,11 +117,11 @@ Drawer { visible: positioningInformationViewEnabled positionSource: controller.positionSource antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : NaN - radius: 8 + radius: itemRadius } PositioningPreciseView { - id: positioningPv + id: positioningPreciseView width: parent.width - 8 height: positioningPreciseEnabled ? positioningPreciseViewHeight : 0 anchors.horizontalCenter: parent.horizontalCenter diff --git a/src/qml/NavigationInformationView.qml b/src/qml/NavigationInformationView.qml index 14ad7ed33c..1377075d8f 100644 --- a/src/qml/NavigationInformationView.qml +++ b/src/qml/NavigationInformationView.qml @@ -22,7 +22,7 @@ Rectangle { property color textColor: Theme.mainTextColor property real contentHeight: content.height - color: "#dd" + Theme.mainBackgroundColor.toString().slice(1) + color: Theme.mainBackgroundColorSemiOpaque border.color: alternateBackgroundColor border.width: 2 diff --git a/src/qml/PositioningInformationView.qml b/src/qml/PositioningInformationView.qml index 299036d256..bc9aaeb910 100644 --- a/src/qml/PositioningInformationView.qml +++ b/src/qml/PositioningInformationView.qml @@ -27,7 +27,7 @@ Rectangle { width: parent.width anchors.margins: 20 - color: "#dd" + Theme.mainBackgroundColor.toString().slice(1) + color: Theme.mainBackgroundColorSemiOpaque Grid { id: grid diff --git a/src/qml/imports/Theme/Theme.qml b/src/qml/imports/Theme/Theme.qml index 326a0de2c3..fd85318f01 100644 --- a/src/qml/imports/Theme/Theme.qml +++ b/src/qml/imports/Theme/Theme.qml @@ -7,6 +7,8 @@ QtObject { property bool darkTheme: false property color mainBackgroundColor: darkTheme ? "#303030" : "#fafafa" + property color mainBackgroundColorSemiOpaque: darkTheme ? "#dd303030" : "#ddfafafa" + property color mainTextColor: darkTheme ? "#EEEEEE" : "#000000" readonly property color mainTextDisabledColor: darkTheme ? "#73EEEEEE" : "#73000000" readonly property color mainColor: "#80cc28" diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 79c34d8996..fdf57b5028 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -711,9 +711,9 @@ ApplicationWindow { location: positionSource.active ? positionSource.projectedPosition : GeometryUtils.emptyPoint() proximityAlarm: positioningSettings.preciseViewProximityAlarm - && navigatingDrawer.positioningPreciseView.visible - && navigatingDrawer.positioningPreciseView.hasAcceptableAccuracy - && !navigatingDrawer.positioningPreciseView.hasAlarmSnoozed + && informationDrawer.positioningPreciseView.visible + && informationDrawer.positioningPreciseView.hasAcceptableAccuracy + && !informationDrawer.positioningPreciseView.hasAlarmSnoozed proximityAlarmThreshold: positioningSettings.preciseViewPrecision } @@ -931,26 +931,17 @@ ApplicationWindow { } } - NavigatingDrawer{ - id: navigatingDrawer + InformationDrawer { + id: informationDrawer openRequested: (navigation.isActive || positioningSettings.showPositionInformation ) && !elevationProfile.visible && mapCanvasMap.isEnabled && !messageLog.visible - navigation: navigation + positionSource: positionSource positioningSettings: positioningSettings positioningPreciseViewHeight: Math.min(mainWindow.height / 2.5, 400) - positioningPreciseEnabled: !elevationProfile.visible - && !isNaN(navigation.distance) - && navigation.isActive - && (positioningSettings.alwaysShowPreciseView - || ( positioningPreciseView.hasAcceptableAccuracy - && positioningPreciseView.projectDistance < positioningPreciseView.precision )) - - positioningInformationViewEnabled: positioningSettings.showPositionInformation && !elevationProfile.visible - positionSource: positionSource - antennaHeight: positioningSettings.antennaHeightActivated ? positioningSettings.antennaHeight : NaN + uiConflictFree: !elevationProfile.visible } Column { @@ -1095,7 +1086,7 @@ ApplicationWindow { QfToolButton { id: compassArrow - y: navigatingDrawer.openRequested ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - 44 : + y: informationDrawer.openRequested ? ( parent.height - height ) - (informationDrawer.realtimeHeight) - 44 : digitizingToolbarContainer.y - height - 4 rotation: mapCanvas.mapSettings.rotation visible: rotation != 0 @@ -1108,7 +1099,7 @@ ApplicationWindow { } ScaleBar { - y: navigatingDrawer.openRequested ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) : + y: informationDrawer.openRequested ? ( parent.height - height ) - (informationDrawer.realtimeHeight) : digitizingToolbarContainer.y visible: qfieldSettings.showScaleBar @@ -1143,7 +1134,7 @@ ApplicationWindow { bgcolor: "transparent" visible: !screenLocker.enabled && messageLog.unreadMessages anchors.right: pluginsToolbar.right - y: Math.max(16, parent.height / 4 - (navigatingDrawer.realtimeHeight / 3.7 + (digitizingToolbar.stateVisible ? 70: 0))) + y: Math.max(16, parent.height / 4 - (informationDrawer.realtimeHeight / 3.7 + (digitizingToolbar.stateVisible ? 70: 0))) onClicked: messageLog.visible = true } @@ -1152,7 +1143,7 @@ ApplicationWindow { id: zoomToolbar anchors.right: mapCanvas.right anchors.rightMargin: 10 - y: parent.height / 2 - (navigatingDrawer.realtimeHeight / 1.75 + (digitizingToolbar.stateVisible ? 70: 0) + (elevationProfile.visible ? 70: 0)) + y: parent.height / 2 - (informationDrawer.realtimeHeight / 1.75 + (digitizingToolbar.stateVisible ? 70: 0) + (elevationProfile.visible ? 70: 0)) spacing: 8 visible: !screenLocker.enabled && (locationToolbar.height + digitizingToolbarContainer.height) / (digitizingToolbarContainer.y) < 0.41 @@ -1695,7 +1686,7 @@ ApplicationWindow { id: locationToolbar anchors.right: mapCanvas.right anchors.rightMargin: 4 - y: navigatingDrawer.openRequested ? ( parent.height - height ) - (navigatingDrawer.realtimeHeight) - (digitizingToolbar.stateVisible? 50: 0) : + y: informationDrawer.openRequested ? ( parent.height - height ) - (informationDrawer.realtimeHeight) - (digitizingToolbar.stateVisible? 50: 0) : digitizingToolbarContainer.y - height - 4 spacing: 4 @@ -2002,8 +1993,8 @@ ApplicationWindow { anchors.right: mapCanvas.right anchors.rightMargin: 4 anchors.bottom: mapCanvas.bottom - anchors.bottomMargin: navigatingDrawer.openRequested - ? navigatingDrawer.realtimeHeight + anchors.bottomMargin: informationDrawer.openRequested + ? informationDrawer.realtimeHeight : mainWindow.sceneBottomMargin + 4 spacing: 4 diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc index ca9a34e614..580ee931bd 100644 --- a/src/qml/qml.qrc +++ b/src/qml/qml.qrc @@ -102,6 +102,6 @@ QFieldLocalDataPickerScreen.qml QFieldSketcher.qml PluginManagerSettings.qml - NavigatingDrawer.qml + InformationDrawer.qml From 50a9fe7ccca848330336e1d846b43cd3e43dc7fb Mon Sep 17 00:00:00 2001 From: Mohsen Date: Sat, 18 May 2024 20:15:48 +0330 Subject: [PATCH 13/17] Resolves PR issues - 2: Add SensorInformationView to InformationDrawer. Move SensorInformationView from qgisMobileApp.qml to InformationDrawer. --- src/qml/InformationDrawer.qml | 23 ++++++++++++++++------- src/qml/SensorInformationView.qml | 6 +++--- src/qml/qgismobileapp.qml | 19 ++++++++----------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/qml/InformationDrawer.qml b/src/qml/InformationDrawer.qml index 8d6367aa8d..4e86a89698 100644 --- a/src/qml/InformationDrawer.qml +++ b/src/qml/InformationDrawer.qml @@ -20,6 +20,9 @@ Drawer { property real itemRadius: 8 property bool uiConflictFree: false + // SensorInformationView + property bool sensorInformationViewEnabled: sensorInformationView.activeSensors > 0 + // NavigationInformationView property bool navigationInformationViewEnabled: navigation.isActive @@ -45,6 +48,7 @@ Drawer { newHeight += (navigationInformationView.height + 8) newHeight += (positioningInformationView.height + 8) newHeight += (positioningPreciseView.height + 8) + newHeight += (sensorInformationView.height + 8) newHeight += 16 controller.height = newHeight } @@ -65,6 +69,8 @@ Drawer { onPositioningPreciseEnabledChanged: updateDrawerHeight(positioningPreciseEnabled, positioningPreciseViewHeight) + onSensorInformationViewEnabledChanged: updateDrawerHeight(sensorInformationViewEnabled, sensorInformationView.contentHeight) + onOpenRequestedChanged: { if (openRequested) { closeRequested = false @@ -95,14 +101,14 @@ Drawer { Column { id: mainContent + width: parent.width - 8 + anchors.horizontalCenter: parent.horizontalCenter spacing: 8 - width: parent.width NavigationInformationView { id: navigationInformationView - width: parent.width - 8 + width: parent.width height: navigationInformationViewEnabled ? contentHeight : 0 - anchors.horizontalCenter: parent.horizontalCenter clip: true navigation: controller.navigation radius: itemRadius @@ -110,9 +116,8 @@ Drawer { PositioningInformationView { id: positioningInformationView - width: parent.width - 8 + width: parent.width height: positioningInformationViewEnabled ? contentHeight : 0 - anchors.horizontalCenter: parent.horizontalCenter clip: true visible: positioningInformationViewEnabled positionSource: controller.positionSource @@ -122,11 +127,15 @@ Drawer { PositioningPreciseView { id: positioningPreciseView - width: parent.width - 8 + width: parent.width height: positioningPreciseEnabled ? positioningPreciseViewHeight : 0 - anchors.horizontalCenter: parent.horizontalCenter clip: true precision: positioningSettings.preciseViewPrecision } + + SensorInformationView { + id: sensorInformationView + height: sensorInformationViewEnabled ? contentHeight : 0 + } } } diff --git a/src/qml/SensorInformationView.qml b/src/qml/SensorInformationView.qml index 787f7a9fad..e2f34f8ea9 100644 --- a/src/qml/SensorInformationView.qml +++ b/src/qml/SensorInformationView.qml @@ -16,11 +16,11 @@ Rectangle { property color backgroundColor: Theme.mainBackgroundColor property color alternateBackgroundColor: Theme.sensorBackgroundColor property color textColor: Theme.mainTextColor - - width: parent.width - height: parent.width > 620 + property real contentHeight: parent.width > 620 ? rowHeight * Math.ceil(grid.count / 3) : rowHeight * Math.ceil(grid.count / 2) + + width: parent.width anchors.margins: 20 color: Theme.mainBackgroundColor diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index fdf57b5028..7035238044 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -933,15 +933,17 @@ ApplicationWindow { InformationDrawer { id: informationDrawer - openRequested: (navigation.isActive || positioningSettings.showPositionInformation ) && - !elevationProfile.visible && - mapCanvasMap.isEnabled && - !messageLog.visible + openRequested: (navigation.isActive || + positioningSettings.showPositionInformation || + sensorInformationViewEnabled) && + uiConflictFree && + mapCanvasMap.isEnabled + navigation: navigation positionSource: positionSource positioningSettings: positioningSettings positioningPreciseViewHeight: Math.min(mainWindow.height / 2.5, 400) - uiConflictFree: !elevationProfile.visible + uiConflictFree: !elevationProfile.visible && !messageLog.visible } Column { @@ -950,8 +952,7 @@ ApplicationWindow { anchors.left: parent.left anchors.right: parent.right anchors.bottomMargin: mainWindow.sceneBottomMargin - visible: sensorInformationView.activeSensors > 0 || - (stateMachine.state === 'measure' && elevationProfileButton.elevationProfileActive) + visible: stateMachine.state === 'measure' && elevationProfileButton.elevationProfileActive width: parent.width @@ -966,10 +967,6 @@ ApplicationWindow { project: qgisProject crs: mapCanvas.mapSettings.destinationCrs } - - SensorInformationView { - id: sensorInformationView - } } QfDropShadow { From dc5281e49dd83e77d6f71eaa414752c90cdbfc00 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Sun, 19 May 2024 10:06:23 +0700 Subject: [PATCH 14/17] Simplify handling of items overlayed on top of map canvas, get rid of y property --- src/qml/qgismobileapp.qml | 1967 ++++++++++++++++++------------------- 1 file changed, 982 insertions(+), 985 deletions(-) diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 7035238044..b67dc5d138 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -235,6 +235,19 @@ ApplicationWindow { } } + PositioningSettings { + id: positioningSettings + + onPositioningActivatedChanged: { + if (positioningActivated) { + displayToast( qsTr( "Activating positioning service" ) ) + positionSource.active = true + } else { + positionSource.active = false + } + } + } + Connections { target: positionSource.device @@ -969,574 +982,592 @@ ApplicationWindow { } } - QfDropShadow { - anchors.fill: informationView - visible: informationView.visible - verticalOffset: -2 - radius: 6.0 - color: "#30000000" - source: informationView - } - /************************************************** - * Map Canvas Decorations like + * Map Canvas Overlays * - Position Information View * - Scale Bar **************************************************/ - Text { - id: coordinateLocatorInformationOverlay + Item { + id: mapCanvasOverlays + anchors.fill: mapCanvas + anchors.bottomMargin: informationDrawer.openRequested ? informationDrawer.realtimeHeight : 0 - property bool coordinatesIsXY: CoordinateReferenceSystemUtils.defaultCoordinateOrderForCrsIsXY(projectInfo.coordinateDisplayCrs) - property bool coordinatesIsGeographic: projectInfo.coordinateDisplayCrs.isGeographic + Text { + id: coordinateLocatorInformationOverlay - DistanceArea { - id: digitizingGeometryMeasure + property bool coordinatesIsXY: CoordinateReferenceSystemUtils.defaultCoordinateOrderForCrsIsXY(projectInfo.coordinateDisplayCrs) + property bool coordinatesIsGeographic: projectInfo.coordinateDisplayCrs.isGeographic - property VectorLayer currentLayer: dashBoard.activeLayer + DistanceArea { + id: digitizingGeometryMeasure - rubberbandModel: currentRubberband ? currentRubberband.model : null - project: qgisProject - crs: qgisProject ? qgisProject.crs : CoordinateReferenceSystemUtils.invalidCrs() - } + property VectorLayer currentLayer: dashBoard.activeLayer - // The position is dynamically calculated to follow the coordinate locator - x: { + rubberbandModel: currentRubberband ? currentRubberband.model : null + project: qgisProject + crs: qgisProject ? qgisProject.crs : CoordinateReferenceSystemUtils.invalidCrs() + } + + // The position is dynamically calculated to follow the coordinate locator + x: { var newX = coordinateLocator.displayPosition.x + 20; if (newX + width > mapCanvas.x + mapCanvas.width) - newX -= width + 40; + newX -= width + 40; return newX; - } - y: { + } + y: { var newY = coordinateLocator.displayPosition.y + 14 if (newY + height > mapCanvas.y + mapCanvas.height) - newY -= height - 28; + newY -= height - 28; return newY; - } - - textFormat: Text.PlainText - text: { - if ((qfieldSettings.numericalDigitizingInformation && stateMachine.state === "digitize" ) || stateMachine.state === 'measure') { - var point = GeometryUtils.reprojectPoint(coordinateLocator.currentCoordinate, coordinateLocator.mapSettings.destinationCrs, projectInfo.coordinateDisplayCrs) - var coordinates; - if (coordinatesIsXY) { - coordinates = '%1: %2\n%3: %4\n' - .arg(coordinatesIsGeographic ? qsTr( 'Lon' ) : 'X') - .arg(point.x.toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 5 : 2 )) - .arg(coordinatesIsGeographic ? qsTr( 'Lat' ) : 'Y') - .arg(point.y.toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 5 : 2 )); - } else { - coordinates = '%1: %2\n%3: %4\n' - .arg(coordinatesIsGeographic ? qsTr( 'Lat' ) : 'Y') - .arg(point.y.toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 5 : 2 )) - .arg(coordinatesIsGeographic ? qsTr( 'Lon' ) : 'X') - .arg(point.x.toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 5 : 2 )); - } - - return '%1%2%3%4%5%6' - .arg(stateMachine.state === 'digitize' || !digitizingToolbar.isDigitizing - ? coordinates - : '') - - .arg(digitizingGeometryMeasure.lengthValid && digitizingGeometryMeasure.segmentLength != 0.0 - ? '%1: %2\n' - .arg( digitizingGeometryMeasure.segmentLength != digitizingGeometryMeasure.length ? qsTr( 'Segment') : qsTr( 'Length' ) ) - .arg(UnitTypes.formatDistance( digitizingGeometryMeasure.convertLengthMeansurement( digitizingGeometryMeasure.segmentLength, projectInfo.distanceUnits ) , 3, projectInfo.distanceUnits ) ) - : '') - - .arg(digitizingGeometryMeasure.lengthValid && digitizingGeometryMeasure.segmentLength != 0.0 - ? '%1: %2\n' - .arg( qsTr( 'Azimuth') ) - .arg( UnitTypes.formatAngle( digitizingGeometryMeasure.azimuth < 0 ? digitizingGeometryMeasure.azimuth + 360 : digitizingGeometryMeasure.azimuth, 2, Qgis.AngleUnit.Degrees ) ) - : '') - - .arg(currentRubberband && currentRubberband.model && currentRubberband.model.geometryType === Qgis.GeometryType.Polygon - ? digitizingGeometryMeasure.perimeterValid - ? '%1: %2\n' - .arg( qsTr( 'Perimeter') ) - .arg(UnitTypes.formatDistance( digitizingGeometryMeasure.convertLengthMeansurement( digitizingGeometryMeasure.perimeter, projectInfo.distanceUnits ), 3, projectInfo.distanceUnits ) ) - : '' - : digitizingGeometryMeasure.lengthValid && digitizingGeometryMeasure.segmentLength != digitizingGeometryMeasure.length - ? '%1: %2\n' - .arg( qsTr( 'Length') ) - .arg(UnitTypes.formatDistance( digitizingGeometryMeasure.convertLengthMeansurement( digitizingGeometryMeasure.length, projectInfo.distanceUnits ),3, projectInfo.distanceUnits ) ) - : '') - - .arg(digitizingGeometryMeasure.areaValid - ? '%1: %2\n' - .arg( qsTr( 'Area') ) - .arg(UnitTypes.formatArea( digitizingGeometryMeasure.convertAreaMeansurement( digitizingGeometryMeasure.area, projectInfo.areaUnits ), 3, projectInfo.areaUnits ) ) - : '') - - .arg(stateMachine.state === 'measure' && digitizingToolbar.isDigitizing - ? coordinates - : '') - } else { - return ''; } - } - - font: Theme.strongTipFont - style: Text.Outline - styleColor: Theme.light - } - - QfToolButton { - id: compassArrow - y: informationDrawer.openRequested ? ( parent.height - height ) - (informationDrawer.realtimeHeight) - 44 : - digitizingToolbarContainer.y - height - 4 - rotation: mapCanvas.mapSettings.rotation - visible: rotation != 0 - anchors.left: mapCanvas.left - anchors.leftMargin: 4 - round: true - bgcolor: Theme.darkGraySemiOpaque - iconSource: Theme.getThemeVectorIcon('ic_compass_arrow_24dp') - onClicked: mapCanvas.mapSettings.rotation = 0 - } - ScaleBar { - y: informationDrawer.openRequested ? ( parent.height - height ) - (informationDrawer.realtimeHeight) : - digitizingToolbarContainer.y - - visible: qfieldSettings.showScaleBar - mapSettings: mapCanvas.mapSettings - anchors.left: mapCanvas.left - anchors.leftMargin: 4 - } + textFormat: Text.PlainText + text: { + if ((qfieldSettings.numericalDigitizingInformation && stateMachine.state === "digitize" ) || stateMachine.state === 'measure') { + var point = GeometryUtils.reprojectPoint(coordinateLocator.currentCoordinate, coordinateLocator.mapSettings.destinationCrs, projectInfo.coordinateDisplayCrs) + var coordinates; + if (coordinatesIsXY) { + coordinates = '%1: %2\n%3: %4\n' + .arg(coordinatesIsGeographic ? qsTr( 'Lon' ) : 'X') + .arg(point.x.toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 5 : 2 )) + .arg(coordinatesIsGeographic ? qsTr( 'Lat' ) : 'Y') + .arg(point.y.toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 5 : 2 )); + } else { + coordinates = '%1: %2\n%3: %4\n' + .arg(coordinatesIsGeographic ? qsTr( 'Lat' ) : 'Y') + .arg(point.y.toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 5 : 2 )) + .arg(coordinatesIsGeographic ? qsTr( 'Lon' ) : 'X') + .arg(point.x.toLocaleString( Qt.locale(), 'f', coordinatesIsGeographic ? 5 : 2 )); + } - QfDropShadow { - anchors.fill: featureForm - horizontalOffset: mainWindow.width >= mainWindow.height ? -2: 0 - verticalOffset: mainWindow.width < mainWindow.height ? -2: 0 - radius: 6.0 - color: "#80000000" - source: featureForm - } + return '%1%2%3%4%5%6' + .arg(stateMachine.state === 'digitize' || !digitizingToolbar.isDigitizing + ? coordinates + : '') + + .arg(digitizingGeometryMeasure.lengthValid && digitizingGeometryMeasure.segmentLength != 0.0 + ? '%1: %2\n' + .arg( digitizingGeometryMeasure.segmentLength != digitizingGeometryMeasure.length ? qsTr( 'Segment') : qsTr( 'Length' ) ) + .arg(UnitTypes.formatDistance( digitizingGeometryMeasure.convertLengthMeansurement( digitizingGeometryMeasure.segmentLength, projectInfo.distanceUnits ) , 3, projectInfo.distanceUnits ) ) + : '') + + .arg(digitizingGeometryMeasure.lengthValid && digitizingGeometryMeasure.segmentLength != 0.0 + ? '%1: %2\n' + .arg( qsTr( 'Azimuth') ) + .arg( UnitTypes.formatAngle( digitizingGeometryMeasure.azimuth < 0 ? digitizingGeometryMeasure.azimuth + 360 : digitizingGeometryMeasure.azimuth, 2, Qgis.AngleUnit.Degrees ) ) + : '') + + .arg(currentRubberband && currentRubberband.model && currentRubberband.model.geometryType === Qgis.GeometryType.Polygon + ? digitizingGeometryMeasure.perimeterValid + ? '%1: %2\n' + .arg( qsTr( 'Perimeter') ) + .arg(UnitTypes.formatDistance( digitizingGeometryMeasure.convertLengthMeansurement( digitizingGeometryMeasure.perimeter, projectInfo.distanceUnits ), 3, projectInfo.distanceUnits ) ) + : '' + : digitizingGeometryMeasure.lengthValid && digitizingGeometryMeasure.segmentLength != digitizingGeometryMeasure.length + ? '%1: %2\n' + .arg( qsTr( 'Length') ) + .arg(UnitTypes.formatDistance( digitizingGeometryMeasure.convertLengthMeansurement( digitizingGeometryMeasure.length, projectInfo.distanceUnits ),3, projectInfo.distanceUnits ) ) + : '') + + .arg(digitizingGeometryMeasure.areaValid + ? '%1: %2\n' + .arg( qsTr( 'Area') ) + .arg(UnitTypes.formatArea( digitizingGeometryMeasure.convertAreaMeansurement( digitizingGeometryMeasure.area, projectInfo.areaUnits ), 3, projectInfo.areaUnits ) ) + : '') + + .arg(stateMachine.state === 'measure' && digitizingToolbar.isDigitizing + ? coordinates + : '') + } else { + return ''; + } + } - Column { - id: pluginsToolbar - objectName: "pluginsToolbar" + font: Theme.strongTipFont + style: Text.Outline + styleColor: Theme.light + } - anchors.right: locatorItem.right - anchors.top: locatorItem.bottom - anchors.topMargin: 4 - spacing: 4 - } + QfToolButton { + id: compassArrow + rotation: mapCanvas.mapSettings.rotation + visible: rotation != 0 + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.leftMargin: 4 + anchors.bottomMargin: 54 + round: true + bgcolor: Theme.darkGraySemiOpaque + iconSource: Theme.getThemeVectorIcon('ic_compass_arrow_24dp') + onClicked: mapCanvas.mapSettings.rotation = 0 + } - QfToolButton { - id: alertIcon - iconSource: Theme.getThemeVectorIcon( "ic_alert_black_24dp" ) - round: true - bgcolor: "transparent" - visible: !screenLocker.enabled && messageLog.unreadMessages - anchors.right: pluginsToolbar.right - y: Math.max(16, parent.height / 4 - (informationDrawer.realtimeHeight / 3.7 + (digitizingToolbar.stateVisible ? 70: 0))) + ScaleBar { + visible: qfieldSettings.showScaleBar + mapSettings: mapCanvas.mapSettings + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.leftMargin: 4 + anchors.bottomMargin: 10 + } - onClicked: messageLog.visible = true - } + Column { + id: pluginsToolbar + objectName: "pluginsToolbar" - Column { - id: zoomToolbar - anchors.right: mapCanvas.right - anchors.rightMargin: 10 - y: parent.height / 2 - (informationDrawer.realtimeHeight / 1.75 + (digitizingToolbar.stateVisible ? 70: 0) + (elevationProfile.visible ? 70: 0)) - spacing: 8 - visible: !screenLocker.enabled && (locationToolbar.height + digitizingToolbarContainer.height) / (digitizingToolbarContainer.y) < 0.41 + anchors.right: locatorItem.right + anchors.top: locatorItem.bottom + anchors.topMargin: 4 + spacing: 4 + } QfToolButton { - id: zoomInButton + id: alertIcon + iconSource: Theme.getThemeVectorIcon( "ic_alert_black_24dp" ) round: true + bgcolor: "transparent" + visible: !screenLocker.enabled && messageLog.unreadMessages + anchors.right: pluginsToolbar.right + anchors.top: pluginsToolbar.bottom + anchors.topMargin: 4 + + onClicked: messageLog.visible = true + } + + Column { + id: zoomToolbar anchors.right: parent.right + anchors.rightMargin: 10 + anchors.bottom: parent.bottom + anchors.bottomMargin: (parent.height - zoomToolbar.height / 2 ) / 2 + spacing: 8 + visible: !screenLocker.enabled && (locationToolbar.height + digitizingToolbarContainer.height) / (digitizingToolbarContainer.y) < 0.41 - bgcolor: Theme.darkGray - iconSource: Theme.getThemeIcon( "ic_add_white_24dp" ) + QfToolButton { + id: zoomInButton + round: true + anchors.right: parent.right + + bgcolor: Theme.darkGray + iconSource: Theme.getThemeIcon( "ic_add_white_24dp" ) - width: 36 - height: 36 + width: 36 + height: 36 - onClicked: { + onClicked: { if ( gnssButton.followActive ) gnssButton.followActiveSkipExtentChanged = true; mapCanvasMap.zoomIn(Qt.point(mapCanvas.x + mapCanvas.width / 2,mapCanvas.y + mapCanvas.height / 2)); + } } - } - QfToolButton { - id: zoomOutButton - round: true - anchors.right: parent.right + QfToolButton { + id: zoomOutButton + round: true + anchors.right: parent.right - bgcolor: Theme.darkGray - iconSource: Theme.getThemeIcon( "ic_remove_white_24dp" ) + bgcolor: Theme.darkGray + iconSource: Theme.getThemeIcon( "ic_remove_white_24dp" ) - width: 36 - height: 36 + width: 36 + height: 36 - onClicked: { + onClicked: { if ( gnssButton.followActive ) gnssButton.followActiveSkipExtentChanged = true; mapCanvasMap.zoomOut(Qt.point(mapCanvas.x + mapCanvas.width / 2,mapCanvas.y + mapCanvas.height / 2)); - } - } - } - - LocatorItem { - id: locatorItem - - locatorModelSuperBridge.navigation: navigation - locatorModelSuperBridge.bookmarks: bookmarkModel - locatorModelSuperBridge.activeLayer: dashBoard.activeLayer - - anchors.right: parent.right - anchors.top: parent.top - anchors.topMargin: mainWindow.sceneTopMargin + 4 - anchors.rightMargin: 4 - - visible: !screenLocker.enabled && stateMachine.state !== 'measure' - - Keys.onReleased: (event) => { - if (event.key === Qt.Key_Back || event.key === Qt.Key_Escape) { - event.accepted = true - state = "off" - } - } - - onStateChanged: { - if ( state == "off" ) { - focus = false - if ( featureForm.visible ) { - featureForm.focus = true - } else { - keyHandler.focus = true } } } - } - LocatorSettings { - id: locatorSettings - locatorFiltersModel: locatorItem.locatorFiltersModel + LocatorItem { + id: locatorItem - modal: true - closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside - parent: Overlay.overlay - } + locatorModelSuperBridge.navigation: navigation + locatorModelSuperBridge.bookmarks: bookmarkModel + locatorModelSuperBridge.activeLayer: dashBoard.activeLayer - PluginManagerSettings { - id: pluginManagerSettings + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: mainWindow.sceneTopMargin + 4 + anchors.rightMargin: 4 - modal: true - closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside - parent: Overlay.overlay - } + visible: !screenLocker.enabled && stateMachine.state !== 'measure' - QfDropShadow { - anchors.fill: locatorItem - visible: locatorItem.searchFieldVisible - verticalOffset: 2 - radius: 10 - color: "#66212121" - source: locatorItem - } + Keys.onReleased: (event) => { + if (event.key === Qt.Key_Back || event.key === Qt.Key_Escape) { + event.accepted = true + state = "off" + } + } - DashBoard { - id: dashBoard - allowLayerChange: !digitizingToolbar.isDigitizing - mapSettings: mapCanvas.mapSettings - interactive: !welcomeScreen.visible - && !qfieldSettings.visible - && !qfieldCloudScreen.visible - && !qfieldLocalDataPickerScreen.visible - && !codeReader.visible - && !screenLocker.enabled - - onOpenedChanged: { - if ( !opened ) { - if ( featureForm.visible ) { - featureForm.focus = true; + onStateChanged: { + if ( state == "off" ) { + focus = false + if ( featureForm.visible ) { + featureForm.focus = true + } else { + keyHandler.focus = true + } } } } - function ensureEditableLayerSelected() { - var firstEditableLayer = null; - var activeLayerLocked = false; - for (var i = 0; i < layerTree.rowCount(); i++) - { - var index = layerTree.index(i, 0) - if (firstEditableLayer === null) - { - if ( - layerTree.data(index,FlatLayerTreeModel.Type) === 'layer' - && layerTree.data(index, FlatLayerTreeModel.ReadOnly) === false - && layerTree.data(index, FlatLayerTreeModel.GeometryLocked) === false) - { - firstEditableLayer = layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer); - } - } - if (activeLayer != null && activeLayer === layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer)) - { - if ( - layerTree.data(index, FlatLayerTreeModel.ReadOnly) === true - || layerTree.data(index, FlatLayerTreeModel.GeometryLocked) === true - ) - { - activeLayerLocked = true; - } - else - { - break; - } - } - if ( - firstEditableLayer !== null - && (activeLayer == null || activeLayerLocked === true) - ) - { - activeLayer = firstEditableLayer; - break; - } - } + QfDropShadow { + anchors.fill: locatorItem + visible: locatorItem.searchFieldVisible + verticalOffset: 2 + radius: 10 + color: "#66212121" + source: locatorItem } - } - /* The main menu */ - Row { - id: mainMenuBar - visible: !screenLocker.enabled - width: childrenRect.width - height: childrenRect.height - topPadding: mainWindow.sceneTopMargin + 4 - leftPadding: 4 - spacing: 4 + /* The main menu */ + Row { + id: mainMenuBar + visible: !screenLocker.enabled + width: childrenRect.width + height: childrenRect.height + topPadding: mainWindow.sceneTopMargin + 4 + leftPadding: 4 + spacing: 4 - QfToolButton { - id: menuButton - round: true - iconSource: Theme.getThemeIcon( "ic_menu_white_24dp" ) - bgcolor: dashBoard.opened ? Theme.mainColor : Theme.darkGray + QfToolButton { + id: menuButton + round: true + iconSource: Theme.getThemeIcon( "ic_menu_white_24dp" ) + bgcolor: dashBoard.opened ? Theme.mainColor : Theme.darkGray - onClicked: dashBoard.opened ? dashBoard.close() : dashBoard.open() + onClicked: dashBoard.opened ? dashBoard.close() : dashBoard.open() - onPressAndHold: { - mainMenu.popup(menuButton.x, menuButton.y) + onPressAndHold: { + mainMenu.popup(menuButton.x, menuButton.y) + } } - } - QfCloseButton { - id: closeMeasureTool - visible: stateMachine.state === 'measure' - toolImage: Theme.getThemeVectorIcon( "ic_measurement_black_24dp" ) - toolText: qsTr( 'Close measure tool' ) + QfCloseButton { + id: closeMeasureTool + visible: stateMachine.state === 'measure' + toolImage: Theme.getThemeVectorIcon( "ic_measurement_black_24dp" ) + toolText: qsTr( 'Close measure tool' ) - onClose: mainWindow.closeMeasureTool() - } + onClose: mainWindow.closeMeasureTool() + } - QfCloseButton { - id: closeGeometryEditorsTool - visible: ( stateMachine.state === "digitize" && geometryEditingVertexModel.vertexCount > 0 ) - toolImage: geometryEditorsToolbar.image - toolText: qsTr( 'Stop editing' ) + QfCloseButton { + id: closeGeometryEditorsTool + visible: ( stateMachine.state === "digitize" && geometryEditingVertexModel.vertexCount > 0 ) + toolImage: geometryEditorsToolbar.image + toolText: qsTr( 'Stop editing' ) - onClose: geometryEditorsToolbar.cancelEditors() - } + onClose: geometryEditorsToolbar.cancelEditors() + } - QfCloseButton { - id: abortRequestGeometry - visible: digitizingToolbar.geometryRequested - toolImage: Theme.getThemeIcon( "ic_edit_geometry_white" ) - toolText: qsTr( 'Cancel addition' ) + QfCloseButton { + id: abortRequestGeometry + visible: digitizingToolbar.geometryRequested + toolImage: Theme.getThemeIcon( "ic_edit_geometry_white" ) + toolText: qsTr( 'Cancel addition' ) - onClose: digitizingToolbar.cancel() + onClose: digitizingToolbar.cancel() + } } - } - Column { - id: mainToolbar - visible: !screenLocker.enabled - anchors.left: mainMenuBar.left - anchors.top: mainMenuBar.bottom - anchors.leftMargin: 4 - anchors.topMargin: 4 - spacing: 4 - - QfToolButtonDrawer { - name: "digitizingDrawer" - size: 48 - round: true - bgcolor: Theme.darkGray - iconSource: Theme.getThemeVectorIcon('ic_digitizing_settings_black_24dp') - iconColor: "white" + Column { + id: mainToolbar + visible: !screenLocker.enabled + anchors.left: mainMenuBar.left + anchors.top: mainMenuBar.bottom + anchors.leftMargin: 4 + anchors.topMargin: 4 spacing: 4 - visible: stateMachine.state === "digitize" - && dashBoard.activeLayer - && dashBoard.activeLayer.isValid - && ( - dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Polygon - || dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Line - || dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Point - ) - QfToolButton { - id: snappingButton - width: 40 - height: 40 - padding: 2 + QfToolButtonDrawer { + name: "digitizingDrawer" + size: 48 round: true - state: qgisProject && qgisProject.snappingConfig.enabled ? "On" : "Off" - iconSource: Theme.getThemeVectorIcon( "ic_snapping_white_24dp" ) - iconColor: "white" bgcolor: Theme.darkGray + iconSource: Theme.getThemeVectorIcon('ic_digitizing_settings_black_24dp') + iconColor: "white" + spacing: 4 + visible: stateMachine.state === "digitize" + && dashBoard.activeLayer + && dashBoard.activeLayer.isValid + && ( + dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Polygon + || dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Line + || dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Point + ) + + QfToolButton { + id: snappingButton + width: 40 + height: 40 + padding: 2 + round: true + state: qgisProject && qgisProject.snappingConfig.enabled ? "On" : "Off" + iconSource: Theme.getThemeVectorIcon( "ic_snapping_white_24dp" ) + iconColor: "white" + bgcolor: Theme.darkGray + + states: [ + State { + + name: "Off" + PropertyChanges { + target: snappingButton + iconColor: "white" + bgcolor: Theme.darkGraySemiOpaque + } + }, + + State { + name: "On" + PropertyChanges { + target: snappingButton + iconColor: Theme.mainColor + bgcolor: Theme.darkGray + } + } + ] + + onClicked: { + var snappingConfig = qgisProject.snappingConfig + snappingConfig.enabled = !snappingConfig.enabled + qgisProject.snappingConfig = snappingConfig + projectInfo.snappingEnabled = snappingConfig.enabled + displayToast( snappingConfig.enabled ? qsTr( "Snapping turned on" ) : qsTr( "Snapping turned off" ) ) + } + } - states: [ - State { + QfToolButton { + id: topologyButton + width: 40 + height: 40 + padding: 2 + round: true + state: qgisProject && qgisProject.topologicalEditing ? "On" : "Off" + iconSource: Theme.getThemeVectorIcon( "ic_topology_white_24dp" ) + iconColor: "white" + bgcolor: Theme.darkGray + + states: [ + State { + + name: "Off" + PropertyChanges { + target: topologyButton + iconColor: "white" + bgcolor: Theme.darkGraySemiOpaque + } + }, + + State { + name: "On" + PropertyChanges { + target: topologyButton + iconColor: Theme.mainColor + bgcolor: Theme.darkGray + } + } + ] - name: "Off" - PropertyChanges { - target: snappingButton - iconColor: "white" - bgcolor: Theme.darkGraySemiOpaque + onClicked: { + qgisProject.topologicalEditing = !qgisProject.topologicalEditing; + displayToast( qgisProject.topologicalEditing ? qsTr( "Topological editing turned on" ) : qsTr( "Topological editing turned off" ) ); + } + } + + QfToolButton { + id: freehandButton + width: visible ? 40 : 0 + height: visible ? 40 : 0 + padding: 2 + round: true + visible: hoverHandler.hasBeenHovered && !(positionSource.active && positioningSettings.positioningCoordinateLock) && stateMachine.state === "digitize" + && ((digitizingToolbar.geometryRequested && digitizingToolbar.geometryRequestedLayer && digitizingToolbar.geometryRequestedLayer.isValid && + (digitizingToolbar.geometryRequestedLayer.geometryType() === Qgis.GeometryType.Polygon + || digitizingToolbar.geometryRequestedLayer.geometryType() === Qgis.GeometryType.Line)) + || (!digitizingToolbar.geometryRequested && dashBoard.activeLayer && dashBoard.activeLayer.isValid && + (dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Polygon + || dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Line))) + iconSource: Theme.getThemeVectorIcon( "ic_freehand_white_24dp" ) + iconColor: "white" + bgcolor: Theme.darkGray + + property bool freehandDigitizing: false + state: freehandDigitizing ? "On" : "Off" + + states: [ + State { + name: "Off" + PropertyChanges { + target: freehandButton + iconColor: "white" + bgcolor: Theme.darkGraySemiOpaque + } + }, + + State { + name: "On" + PropertyChanges { + target: freehandButton + iconColor: Theme.mainColor + bgcolor: Theme.darkGray + } } - }, + ] - State { - name: "On" - PropertyChanges { - target: snappingButton - iconColor: Theme.mainColor - bgcolor: Theme.darkGray + onClicked: { + freehandDigitizing = !freehandDigitizing + + if (freehandDigitizing && positioningSettings.positioningCoordinateLock) { + positioningSettings.positioningCoordinateLock = false; } + + displayToast( freehandDigitizing ? qsTr( "Freehand digitizing turned on" ) : qsTr( "Freehand digitizing turned off" ) ); + settings.setValue( "/QField/Digitizing/FreehandActive", freehandDigitizing ); } - ] - onClicked: { - var snappingConfig = qgisProject.snappingConfig - snappingConfig.enabled = !snappingConfig.enabled - qgisProject.snappingConfig = snappingConfig - projectInfo.snappingEnabled = snappingConfig.enabled - displayToast( snappingConfig.enabled ? qsTr( "Snapping turned on" ) : qsTr( "Snapping turned off" ) ) + Component.onCompleted: { + freehandDigitizing = settings.valueBool( "/QField/Digitizing/FreehandActive", false ) + } } - } - QfToolButton { - id: topologyButton - width: 40 - height: 40 - padding: 2 - round: true - state: qgisProject && qgisProject.topologicalEditing ? "On" : "Off" - iconSource: Theme.getThemeVectorIcon( "ic_topology_white_24dp" ) - iconColor: "white" - bgcolor: Theme.darkGray + QfToolButton { + id: snapToCommonAngleButton + + width: visible ? 40 : 0 + height: visible ? 40 : 0 + round: true + visible: dashBoard.activeLayer + && ( + dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Polygon + || dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Line + ) + iconSource: Theme.getThemeVectorIcon( "ic_common_angle_white_24dp" ) + iconColor: "white" + bgcolor: Theme.darkGray + + property bool isSnapToCommonAngleEnabled: false + property bool isSnapToCommonAngleRelative: true + property int snapToCommonAngleDegrees: 45 + + state: isSnapToCommonAngleEnabled ? "On" : "Off" + + states: [ + State { + name: "Off" + PropertyChanges { + target: snapToCommonAngleButton + iconColor: "white" + bgcolor: Theme.darkGraySemiOpaque + } + }, + + State { + name: "On" + PropertyChanges { + target: snapToCommonAngleButton + iconColor: Theme.mainColor + bgcolor: Theme.darkGray + } + } + ] - states: [ - State { + onClicked: { + isSnapToCommonAngleEnabled = !isSnapToCommonAngleEnabled; + settings.setValue( "/QField/Digitizing/SnapToCommonAngleIsEnabled", isSnapToCommonAngleEnabled ); - name: "Off" - PropertyChanges { - target: topologyButton - iconColor: "white" - bgcolor: Theme.darkGraySemiOpaque - } - }, + displayToast( + isSnapToCommonAngleEnabled + ? qsTr( "Snap to %1° angle turned on" ).arg( snapToCommonAngleDegrees ) + : qsTr( "Snap to common angle turned off" ) + ); + } - State { - name: "On" - PropertyChanges { - target: topologyButton - iconColor: Theme.mainColor - bgcolor: Theme.darkGray - } + onPressAndHold: { + snapToCommonAngleMenu.popup( parent.x, parent.y ); } - ] - onClicked: { - qgisProject.topologicalEditing = !qgisProject.topologicalEditing; - displayToast( qgisProject.topologicalEditing ? qsTr( "Topological editing turned on" ) : qsTr( "Topological editing turned off" ) ); - } - } + Component.onCompleted: { + isSnapToCommonAngleEnabled = settings.valueBool( "/QField/Digitizing/SnapToCommonAngleIsEnabled", false ); + isSnapToCommonAngleRelative = settings.valueBool( "/QField/Digitizing/SnapToCommonAngleIsRelative", true ); + snapToCommonAngleDegrees = settings.valueInt( "/QField/Digitizing/SnapToCommonAngleDegrees", snapToCommonAngleDegrees ); + } - QfToolButton { - id: freehandButton - width: visible ? 40 : 0 - height: visible ? 40 : 0 - padding: 2 - round: true - visible: hoverHandler.hasBeenHovered && !(positionSource.active && positioningSettings.positioningCoordinateLock) && stateMachine.state === "digitize" - && ((digitizingToolbar.geometryRequested && digitizingToolbar.geometryRequestedLayer && digitizingToolbar.geometryRequestedLayer.isValid && - (digitizingToolbar.geometryRequestedLayer.geometryType() === Qgis.GeometryType.Polygon - || digitizingToolbar.geometryRequestedLayer.geometryType() === Qgis.GeometryType.Line)) - || (!digitizingToolbar.geometryRequested && dashBoard.activeLayer && dashBoard.activeLayer.isValid && - (dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Polygon - || dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Line))) - iconSource: Theme.getThemeVectorIcon( "ic_freehand_white_24dp" ) - iconColor: "white" - bgcolor: Theme.darkGray - property bool freehandDigitizing: false - state: freehandDigitizing ? "On" : "Off" + Menu { + id: snapToCommonAngleMenu - states: [ - State { - name: "Off" - PropertyChanges { - target: freehandButton - iconColor: "white" - bgcolor: Theme.darkGraySemiOpaque - } - }, + MenuItem { + text: qsTr( "Relative angle" ) + font: Theme.defaultFont + height: 48 + leftPadding: Theme.menuItemCheckLeftPadding - State { - name: "On" - PropertyChanges { - target: freehandButton - iconColor: Theme.mainColor - bgcolor: Theme.darkGray + checkable: true + checked: snapToCommonAngleButton.isSnapToCommonAngleRelative + + onTriggered: { + snapToCommonAngleButton.isSnapToCommonAngleRelative = checked; + settings.setValue( "/QField/Digitizing/SnapToCommonAngleIsRelative", snapToCommonAngleButton.isSnapToCommonAngleRelative ); + } } - } - ] - onClicked: { - freehandDigitizing = !freehandDigitizing + MenuSeparator { width: parent.width } - if (freehandDigitizing && positioningSettings.positioningCoordinateLock) { - positioningSettings.positioningCoordinateLock = false; - } + Repeater { + // list of common angles to snap to + model: [10, 15, 30, 45, 90] + delegate: MenuItem { + required property int modelData - displayToast( freehandDigitizing ? qsTr( "Freehand digitizing turned on" ) : qsTr( "Freehand digitizing turned off" ) ); - settings.setValue( "/QField/Digitizing/FreehandActive", freehandDigitizing ); - } + text: qsTr( "Snap every %1°" ).arg( modelData ) - Component.onCompleted: { - freehandDigitizing = settings.valueBool( "/QField/Digitizing/FreehandActive", false ) + font: Theme.defaultFont + height: 48 + leftPadding: Theme.menuItemCheckLeftPadding + + checkable: true + checked: modelData === snapToCommonAngleButton.snapToCommonAngleDegrees + enabled: modelData !== snapToCommonAngleButton.snapToCommonAngleDegrees + + onTriggered: { + if ( !checked ) { + return; + } + + snapToCommonAngleButton.isSnapToCommonAngleEnabled = true; + snapToCommonAngleButton.snapToCommonAngleDegrees = modelData; + settings.setValue( "/QField/Digitizing/SnapToCommonAngleDegrees", snapToCommonAngleButton.snapToCommonAngleDegrees ); + + displayToast( qsTr( "Snap to %1° angle turned on" ).arg( modelData ) ); + + snapToCommonAngleMenu.close(); + } + } + } + } } } QfToolButton { - id: snapToCommonAngleButton - - width: visible ? 40 : 0 - height: visible ? 40 : 0 + id: elevationProfileButton round: true - visible: dashBoard.activeLayer - && ( - dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Polygon - || dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Line - ) - iconSource: Theme.getThemeVectorIcon( "ic_common_angle_white_24dp" ) - iconColor: "white" - bgcolor: Theme.darkGray + visible: stateMachine.state === 'measure' + iconSource: Theme.getThemeVectorIcon( "ic_elevation_white_24dp" ) - property bool isSnapToCommonAngleEnabled: false - property bool isSnapToCommonAngleRelative: true - property int snapToCommonAngleDegrees: 45 + bgcolor: Theme.darkGray - state: isSnapToCommonAngleEnabled ? "On" : "Off" + property bool elevationProfileActive: false + state: elevationProfileActive ? "On" : "Off" states: [ State { name: "Off" PropertyChanges { - target: snapToCommonAngleButton - iconColor: "white" + target: elevationProfileButton + iconSource: Theme.getThemeVectorIcon( "ic_elevation_white_24dp" ) bgcolor: Theme.darkGraySemiOpaque } }, @@ -1544,400 +1575,301 @@ ApplicationWindow { State { name: "On" PropertyChanges { - target: snapToCommonAngleButton - iconColor: Theme.mainColor + target: elevationProfileButton + iconSource: Theme.getThemeVectorIcon( "ic_elevation_green_24dp" ) bgcolor: Theme.darkGray } } ] onClicked: { - isSnapToCommonAngleEnabled = !isSnapToCommonAngleEnabled; - settings.setValue( "/QField/Digitizing/SnapToCommonAngleIsEnabled", isSnapToCommonAngleEnabled ); + elevationProfileActive = !elevationProfileActive - displayToast( - isSnapToCommonAngleEnabled - ? qsTr( "Snap to %1° angle turned on" ).arg( snapToCommonAngleDegrees ) - : qsTr( "Snap to common angle turned off" ) - ); - } + // Draw an elevation profile if we have enough points to do so + if ( digitizingToolbar.rubberbandModel.vertexCount > 2 ) { + // Clear the pre-existing profile to trigger a zoom to full updated profile curve + elevationProfile.clear(); + elevationProfile.profileCurve = GeometryUtils.lineFromRubberband(digitizingToolbar.rubberbandModel, elevationProfile.crs) + elevationProfile.refresh(); + } - onPressAndHold: { - snapToCommonAngleMenu.popup( parent.x, parent.y ); + settings.setValue( "/QField/Measuring/ElevationProfile", elevationProfileActive ); } Component.onCompleted: { - isSnapToCommonAngleEnabled = settings.valueBool( "/QField/Digitizing/SnapToCommonAngleIsEnabled", false ); - isSnapToCommonAngleRelative = settings.valueBool( "/QField/Digitizing/SnapToCommonAngleIsRelative", true ); - snapToCommonAngleDegrees = settings.valueInt( "/QField/Digitizing/SnapToCommonAngleDegrees", snapToCommonAngleDegrees ); - } - - - Menu { - id: snapToCommonAngleMenu - - MenuItem { - text: qsTr( "Relative angle" ) - font: Theme.defaultFont - height: 48 - leftPadding: Theme.menuItemCheckLeftPadding - - checkable: true - checked: snapToCommonAngleButton.isSnapToCommonAngleRelative - - onTriggered: { - snapToCommonAngleButton.isSnapToCommonAngleRelative = checked; - settings.setValue( "/QField/Digitizing/SnapToCommonAngleIsRelative", snapToCommonAngleButton.isSnapToCommonAngleRelative ); - } - } - - MenuSeparator { width: parent.width } - - Repeater { - // list of common angles to snap to - model: [10, 15, 30, 45, 90] - delegate: MenuItem { - required property int modelData - - text: qsTr( "Snap every %1°" ).arg( modelData ) - - font: Theme.defaultFont - height: 48 - leftPadding: Theme.menuItemCheckLeftPadding - - checkable: true - checked: modelData === snapToCommonAngleButton.snapToCommonAngleDegrees - enabled: modelData !== snapToCommonAngleButton.snapToCommonAngleDegrees - - onTriggered: { - if ( !checked ) { - return; - } - - snapToCommonAngleButton.isSnapToCommonAngleEnabled = true; - snapToCommonAngleButton.snapToCommonAngleDegrees = modelData; - settings.setValue( "/QField/Digitizing/SnapToCommonAngleDegrees", snapToCommonAngleButton.snapToCommonAngleDegrees ); - - displayToast( qsTr( "Snap to %1° angle turned on" ).arg( modelData ) ); - - snapToCommonAngleMenu.close(); - } - } - } + elevationProfileActive = settings.valueBool( "/QField/Measuring/ElevationProfile", false ) } } } - QfToolButton { - id: elevationProfileButton - round: true - visible: stateMachine.state === 'measure' - iconSource: Theme.getThemeVectorIcon( "ic_elevation_white_24dp" ) + BusyIndicator { + id: busyIndicator + anchors.left: mainMenuBar.left + anchors.top: mainToolbar.bottom + width: menuButton.width + 10 + height: width + running: mapCanvasMap.isRendering + } - bgcolor: Theme.darkGray + Column { + id: locationToolbar + anchors.right: parent.right + anchors.rightMargin: 4 + anchors.bottom: digitizingToolbarContainer.top + anchors.bottomMargin: 4 - property bool elevationProfileActive: false - state: elevationProfileActive ? "On" : "Off" + spacing: 4 - states: [ - State { - name: "Off" - PropertyChanges { - target: elevationProfileButton - iconSource: Theme.getThemeVectorIcon( "ic_elevation_white_24dp" ) - bgcolor: Theme.darkGraySemiOpaque - } - }, - - State { - name: "On" - PropertyChanges { - target: elevationProfileButton - iconSource: Theme.getThemeVectorIcon( "ic_elevation_green_24dp" ) - bgcolor: Theme.darkGray - } - } - ] + QfToolButton { + id: navigationButton + visible: navigation.isActive + round: true + anchors.right: parent.right + + property bool isFollowLocationActive: positionSource.active && gnssButton.followActive && followIncludeDestination + iconSource: isFollowLocationActive + ? Theme.getThemeIcon( "ic_navigation_flag_white_24dp" ) + : Theme.getThemeIcon( "ic_navigation_flag_purple_24dp" ) + bgcolor: isFollowLocationActive + ? Theme.navigationColor + : Theme.darkGray + + /* + / When set to true, when the map follows the device's current position, the extent + / will always include the destination marker. + */ + property bool followIncludeDestination: true - onClicked: { - elevationProfileActive = !elevationProfileActive + onClicked: { + if (positionSource.active && gnssButton.followActive) { + followIncludeDestination = !followIncludeDestination + settings.setValue("/QField/Navigation/FollowIncludeDestination", followIncludeDestination); - // Draw an elevation profile if we have enough points to do so - if ( digitizingToolbar.rubberbandModel.vertexCount > 2 ) { - // Clear the pre-existing profile to trigger a zoom to full updated profile curve - elevationProfile.clear(); - elevationProfile.profileCurve = GeometryUtils.lineFromRubberband(digitizingToolbar.rubberbandModel, elevationProfile.crs) - elevationProfile.refresh(); + gnssButton.followLocation(true) + } else { + mapCanvas.mapSettings.setCenter(navigation.destination) + } } - settings.setValue( "/QField/Measuring/ElevationProfile", elevationProfileActive ); - } - - Component.onCompleted: { - elevationProfileActive = settings.valueBool( "/QField/Measuring/ElevationProfile", false ) - } - } - } - - Column { - id: locationToolbar - anchors.right: mapCanvas.right - anchors.rightMargin: 4 - y: informationDrawer.openRequested ? ( parent.height - height ) - (informationDrawer.realtimeHeight) - (digitizingToolbar.stateVisible? 50: 0) : - digitizingToolbarContainer.y - height - 4 - - spacing: 4 - - QfToolButton { - id: navigationButton - visible: navigation.isActive - round: true - anchors.right: parent.right + onPressAndHold: { + navigationMenu.popup( + locationToolbar.x + locationToolbar.width - navigationMenu.width, + locationToolbar.y + locationToolbar.height - navigationMenu.height + ) + } - property bool isFollowLocationActive: positionSource.active && gnssButton.followActive && followIncludeDestination - iconSource: isFollowLocationActive - ? Theme.getThemeIcon( "ic_navigation_flag_white_24dp" ) - : Theme.getThemeIcon( "ic_navigation_flag_purple_24dp" ) - bgcolor: isFollowLocationActive - ? Theme.navigationColor - : Theme.darkGray - - /* - / When set to true, when the map follows the device's current position, the extent - / will always include the destination marker. - */ - property bool followIncludeDestination: true - - onClicked: { - if (positionSource.active && gnssButton.followActive) { - followIncludeDestination = !followIncludeDestination - settings.setValue("/QField/Navigation/FollowIncludeDestination", followIncludeDestination); - - gnssButton.followLocation(true) - } else { - mapCanvas.mapSettings.setCenter(navigation.destination) + Component.onCompleted: { + followIncludeDestination = settings.valueBool("/QField/Navigation/FollowIncludeDestination", true) } } - onPressAndHold: { - navigationMenu.popup( - locationToolbar.x + locationToolbar.width - navigationMenu.width, - locationToolbar.y + locationToolbar.height - navigationMenu.height - ) - } + QfToolButton { + id: gnssLockButton + anchors.right: parent.right + state: positionSource.active && positioningSettings.positioningCoordinateLock ? "On" : "Off" + visible: gnssButton.state === "On" && ( stateMachine.state === "digitize" || stateMachine.state === 'measure' ) + round: true + checkable: true + checked: positioningSettings.positioningCoordinateLock - Component.onCompleted: { - followIncludeDestination = settings.valueBool("/QField/Navigation/FollowIncludeDestination", true) - } - } + states: [ + State { + name: "Off" + PropertyChanges { + target: gnssLockButton + iconSource: Theme.getThemeIcon( "ic_gps_link_white_24dp" ) + bgcolor: Theme.darkGraySemiOpaque + } + }, - QfToolButton { - id: gnssLockButton - anchors.right: parent.right - state: positionSource.active && positioningSettings.positioningCoordinateLock ? "On" : "Off" - visible: gnssButton.state === "On" && ( stateMachine.state === "digitize" || stateMachine.state === 'measure' ) - round: true - checkable: true - checked: positioningSettings.positioningCoordinateLock - - states: [ - State { - name: "Off" - PropertyChanges { - target: gnssLockButton - iconSource: Theme.getThemeIcon( "ic_gps_link_white_24dp" ) - bgcolor: Theme.darkGraySemiOpaque - } - }, - - State { - name: "On" - PropertyChanges { - target: gnssLockButton - iconSource: Theme.getThemeIcon( "ic_gps_link_activated_white_24dp" ) - bgcolor: Theme.darkGray + State { + name: "On" + PropertyChanges { + target: gnssLockButton + iconSource: Theme.getThemeIcon( "ic_gps_link_activated_white_24dp" ) + bgcolor: Theme.darkGray + } } - } - ] + ] - onCheckedChanged: { - if (gnssButton.state === "On") { - if (checked) { + onCheckedChanged: { + if (gnssButton.state === "On") { + if (checked) { if (freehandButton.freehandDigitizing) { - // deactivate freehand digitizing when cursor locked is on - freehandButton.clicked(); + // deactivate freehand digitizing when cursor locked is on + freehandButton.clicked(); } displayToast( qsTr( "Coordinate cursor now locked to position" ) ) if (positionSource.positionInformation.latitudeValid) { var screenLocation = mapCanvas.mapSettings.coordinateToScreen(locationMarker.location); if ( screenLocation.x < 0 || screenLocation.x > mainWindow.width || - screenLocation.y < 0 || screenLocation.y > mainWindow.height ) { + screenLocation.y < 0 || screenLocation.y > mainWindow.height ) { mapCanvas.mapSettings.setCenter(positionSource.projectedPosition); } } positioningSettings.positioningCoordinateLock = true; - } else { - displayToast( qsTr( "Coordinate cursor unlocked" ) ) - positioningSettings.positioningCoordinateLock = false; - // deactivate any active averaged position collection - positionSource.averagedPosition = false; + } else { + displayToast( qsTr( "Coordinate cursor unlocked" ) ) + positioningSettings.positioningCoordinateLock = false; + // deactivate any active averaged position collection + positionSource.averagedPosition = false; + } } } } - } - QfToolButton { - id: gnssButton - state: positionSource.active ? "On" : "Off" - visible: positionSource.valid - round: true - - anchors.right: parent.right + QfToolButton { + id: gnssButton + state: positionSource.active ? "On" : "Off" + visible: positionSource.valid + round: true - onIconSourceChanged: { - if( state === "On" ){ - if( positionSource.positionInformation && positionSource.positionInformation.latitudeValid ) { - displayToast( qsTr( "Received position" ) ) - } else { - displayToast( qsTr( "Searching for position" ) ) - } - } - } + anchors.right: parent.right - /* - / When set to true, the map will follow the device's current position; the map - / will stop following the position whe the user manually drag the map. - */ - property bool followActive: false - /* - / When set to true, map canvas extent changes will not result in the - / deactivation of the above followActive mode. - */ - property bool followActiveSkipExtentChanged: false - /* - / When set to true, the map will rotate to match the device's current magnetometer/compass orientatin. - */ - property bool followOrientationActive: false - /* - / When set to true, map canvas rotation changes will not result in the - / deactivation of the above followOrientationActive mode. - */ - property bool followActiveSkipRotationChanged: false - - states: [ - State { - name: "Off" - PropertyChanges { - target: gnssButton - iconSource: Theme.getThemeVectorIcon( "ic_location_disabled_white_24dp" ) - bgcolor: Theme.darkGraySemiOpaque - } - }, - - State { - name: "On" - PropertyChanges { - target: gnssButton - iconSource: positionSource.positionInformation && positionSource.positionInformation.latitudeValid - ? Theme.getThemeVectorIcon( "ic_location_valid_white_24dp" ) - : Theme.getThemeVectorIcon( "ic_location_white_24dp" ) - iconColor: followActive ? "white" : Theme.positionColor - bgcolor: followActive ? Theme.positionColor : Theme.darkGray + onIconSourceChanged: { + if( state === "On" ){ + if( positionSource.positionInformation && positionSource.positionInformation.latitudeValid ) { + displayToast( qsTr( "Received position" ) ) + } else { + displayToast( qsTr( "Searching for position" ) ) + } } } - ] - onClicked: { - if (followActive) { - followOrientationActive = true - followOrientation(); - displayToast( qsTr( "Canvas follows location and compass orientation" ) ) - } else { - followActive = true - if ( positionSource.projectedPosition.x ) - { - if ( !positionSource.active ) - { - positioningSettings.positioningActivated = true + /* + / When set to true, the map will follow the device's current position; the map + / will stop following the position whe the user manually drag the map. + */ + property bool followActive: false + /* + / When set to true, map canvas extent changes will not result in the + / deactivation of the above followActive mode. + */ + property bool followActiveSkipExtentChanged: false + /* + / When set to true, the map will rotate to match the device's current magnetometer/compass orientatin. + */ + property bool followOrientationActive: false + /* + / When set to true, map canvas rotation changes will not result in the + / deactivation of the above followOrientationActive mode. + */ + property bool followActiveSkipRotationChanged: false + + states: [ + State { + name: "Off" + PropertyChanges { + target: gnssButton + iconSource: Theme.getThemeVectorIcon( "ic_location_disabled_white_24dp" ) + bgcolor: Theme.darkGraySemiOpaque } - else - { - followLocation(true); - displayToast( qsTr( "Canvas follows location" ) ) + }, + + State { + name: "On" + PropertyChanges { + target: gnssButton + iconSource: positionSource.positionInformation && positionSource.positionInformation.latitudeValid + ? Theme.getThemeVectorIcon( "ic_location_valid_white_24dp" ) + : Theme.getThemeVectorIcon( "ic_location_white_24dp" ) + iconColor: followActive ? "white" : Theme.positionColor + bgcolor: followActive ? Theme.positionColor : Theme.darkGray } } - else - { - if ( positionSource.valid ) + ] + + onClicked: { + if (followActive) { + followOrientationActive = true + followOrientation(); + displayToast( qsTr( "Canvas follows location and compass orientation" ) ) + } else { + followActive = true + if ( positionSource.projectedPosition.x ) { - if ( positionSource.active ) + if ( !positionSource.active ) { - displayToast( qsTr( "Waiting for location" ) ) + positioningSettings.positioningActivated = true } else { - positioningSettings.positioningActivated = true + followLocation(true); + displayToast( qsTr( "Canvas follows location" ) ) + } + } + else + { + if ( positionSource.valid ) + { + if ( positionSource.active ) + { + displayToast( qsTr( "Waiting for location" ) ) + } + else + { + positioningSettings.positioningActivated = true + } } } } } - } - - onPressAndHold: { - gnssMenu.popup(locationToolbar.x + locationToolbar.width - gnssMenu.width, locationToolbar.y + locationToolbar.height - gnssMenu.height) - } - - property int followLocationMinScale: 125 - property int followLocationMinMargin: 40 - property int followLocationScreenFraction: settings ? settings.value( "/QField/Positioning/FollowScreenFraction", 5 ) : 5 - function followLocation(forceRecenter) { - var screenLocation = mapCanvas.mapSettings.coordinateToScreen(positionSource.projectedPosition); - if (navigation.isActive && navigationButton.followIncludeDestination) { - if (mapCanvas.mapSettings.scale > followLocationMinScale) { - var screenDestination = mapCanvas.mapSettings.coordinateToScreen(navigation.destination); - if (forceRecenter - || screenDestination.x < followLocationMinMargin - || screenDestination.x > (mainWindow.width - followLocationMinMargin) - || screenDestination.y < followLocationMinMargin - || screenDestination.y > (mainWindow.height - followLocationMinMargin) - || screenLocation.x < followLocationMinMargin - || screenLocation.x > (mainWindow.width - followLocationMinMargin) - || screenLocation.y < followLocationMinMargin - || screenLocation.y > (mainWindow.height - followLocationMinMargin) - || (Math.abs(screenDestination.x - screenLocation.x) < mainWindow.width / 3 - && Math.abs(screenDestination.y - screenLocation.y) < mainWindow.height / 3)) { + onPressAndHold: { + gnssMenu.popup(locationToolbar.x + locationToolbar.width - gnssMenu.width, locationToolbar.y + locationToolbar.height - gnssMenu.height) + } + + property int followLocationMinScale: 125 + property int followLocationMinMargin: 40 + property int followLocationScreenFraction: settings ? settings.value( "/QField/Positioning/FollowScreenFraction", 5 ) : 5 + + function followLocation(forceRecenter) { + var screenLocation = mapCanvas.mapSettings.coordinateToScreen(positionSource.projectedPosition); + if (navigation.isActive && navigationButton.followIncludeDestination) { + if (mapCanvas.mapSettings.scale > followLocationMinScale) { + var screenDestination = mapCanvas.mapSettings.coordinateToScreen(navigation.destination); + if (forceRecenter + || screenDestination.x < followLocationMinMargin + || screenDestination.x > (mainWindow.width - followLocationMinMargin) + || screenDestination.y < followLocationMinMargin + || screenDestination.y > (mainWindow.height - followLocationMinMargin) + || screenLocation.x < followLocationMinMargin + || screenLocation.x > (mainWindow.width - followLocationMinMargin) + || screenLocation.y < followLocationMinMargin + || screenLocation.y > (mainWindow.height - followLocationMinMargin) + || (Math.abs(screenDestination.x - screenLocation.x) < mainWindow.width / 3 + && Math.abs(screenDestination.y - screenLocation.y) < mainWindow.height / 3)) { + gnssButton.followActiveSkipExtentChanged = true; + var points = [positionSource.projectedPosition, navigation.destination]; + mapCanvas.mapSettings.setExtentFromPoints(points, followLocationMinScale) + } + } + } else { + var threshold = Math.min( mainWindow.width, mainWindow.height ) / followLocationScreenFraction; + if ( forceRecenter + || screenLocation.x < mapCanvas.x + threshold + || screenLocation.x > mapCanvas.width - threshold + || screenLocation.y < mapCanvas.y + threshold + || screenLocation.y > mapCanvas.height - threshold ) + { gnssButton.followActiveSkipExtentChanged = true; - var points = [positionSource.projectedPosition, navigation.destination]; - mapCanvas.mapSettings.setExtentFromPoints(points, followLocationMinScale) + mapCanvas.mapSettings.setCenter(positionSource.projectedPosition); } } - } else { - var threshold = Math.min( mainWindow.width, mainWindow.height ) / followLocationScreenFraction; - if ( forceRecenter - || screenLocation.x < mapCanvas.x + threshold - || screenLocation.x > mapCanvas.width - threshold - || screenLocation.y < mapCanvas.y + threshold - || screenLocation.y > mapCanvas.height - threshold ) - { - gnssButton.followActiveSkipExtentChanged = true; - mapCanvas.mapSettings.setCenter(positionSource.projectedPosition); - } } - } - function followOrientation() { - if (!isNaN(positionSource.orientation) && Math.abs(-positionSource.orientation - mapCanvas.mapSettings.rotation) >= 10) { - gnssButton.followActiveSkipRotationChanged = true - mapCanvas.mapSettings.rotation = -positionSource.orientation + function followOrientation() { + if (!isNaN(positionSource.orientation) && Math.abs(-positionSource.orientation - mapCanvas.mapSettings.rotation) >= 10) { + gnssButton.followActiveSkipRotationChanged = true + mapCanvas.mapSettings.rotation = -positionSource.orientation + } } - } - Rectangle { + Rectangle { anchors { - top: parent.top - right: parent.right - rightMargin: 2 - topMargin: 2 + top: parent.top + right: parent.right + rightMargin: 2 + topMargin: 2 } width: 12 @@ -1951,121 +1883,120 @@ ApplicationWindow { color: !positionSource.positionInformation || !positionSource.positionInformation.haccValid || positionSource.positionInformation.hacc > positioningSettings.accuracyBad - ? Theme.accuracyBad - : positionSource.positionInformation.hacc > positioningSettings.accuracyExcellent - ? Theme.accuracyTolerated - : Theme.accuracyExcellent + ? Theme.accuracyBad + : positionSource.positionInformation.hacc > positioningSettings.accuracyExcellent + ? Theme.accuracyTolerated + : Theme.accuracyExcellent + } } - } - Connections { + Connections { target: mapCanvas.mapSettings function onExtentChanged() { - if ( gnssButton.followActive ) { - if ( gnssButton.followActiveSkipExtentChanged ) { - gnssButton.followActiveSkipExtentChanged = false; - } else { - gnssButton.followActive = false - gnssButton.followOrientationActive = false - displayToast( qsTr( "Canvas stopped following location" ) ) - } + if ( gnssButton.followActive ) { + if ( gnssButton.followActiveSkipExtentChanged ) { + gnssButton.followActiveSkipExtentChanged = false; + } else { + gnssButton.followActive = false + gnssButton.followOrientationActive = false + displayToast( qsTr( "Canvas stopped following location" ) ) } + } } function onRotationChanged() { - if ( gnssButton.followOrientationActive ) { - if ( gnssButton.followActiveSkipRotationChanged ) { - gnssButton.followActiveSkipRotationChanged = false - } else { - gnssButton.followOrientationActive = false - } + if ( gnssButton.followOrientationActive ) { + if ( gnssButton.followActiveSkipRotationChanged ) { + gnssButton.followActiveSkipRotationChanged = false + } else { + gnssButton.followOrientationActive = false } + } } + } } - } - Column { - id: digitizingToolbarContainer - anchors.right: mapCanvas.right - anchors.rightMargin: 4 - anchors.bottom: mapCanvas.bottom - anchors.bottomMargin: informationDrawer.openRequested - ? informationDrawer.realtimeHeight - : mainWindow.sceneBottomMargin + 4 - spacing: 4 - - DigitizingToolbar { - id: digitizingToolbar - - stateVisible: !screenLocker.enabled && - ((stateMachine.state === "digitize" - && dashBoard.activeLayer - && !dashBoard.activeLayer.readOnly - // unfortunately there is no way to call QVariant::toBool in QML so the value is a string - && dashBoard.activeLayer.customProperty( 'QFieldSync/is_geometry_locked' ) !== 'true' - && !geometryEditorsToolbar.stateVisible - && !moveFeaturesToolbar.stateVisible - && (projectInfo.editRights || projectInfo.insertRights)) - || stateMachine.state === 'measure' - || (stateMachine.state === "digitize" && digitizingToolbar.geometryRequested)) - rubberbandModel: currentRubberband ? currentRubberband.model : null - mapSettings: mapCanvas.mapSettings - showConfirmButton: stateMachine.state === "digitize" - screenHovering: mapCanvasMap.hovered + Column { + id: digitizingToolbarContainer + anchors.right: parent.right + anchors.rightMargin: 4 + anchors.bottom: parent.bottom + anchors.bottomMargin: 4 - digitizingLogger.type: stateMachine.state === 'measure' ? '' : 'add' + spacing: 4 - FeatureModel { - id: digitizingFeature - project: qgisProject - currentLayer: digitizingToolbar.geometryRequested ? digitizingToolbar.geometryRequestedLayer : dashBoard.activeLayer - positionInformation: positionSource.positionInformation - topSnappingResult: coordinateLocator.topSnappingResult - positionLocked: positionSource.active && positioningSettings.positioningCoordinateLock - cloudUserInformation: projectInfo.cloudUserInformation - geometry: Geometry { - id: digitizingGeometry - rubberbandModel: digitizingRubberband.model - vectorLayer: digitizingToolbar.geometryRequested ? digitizingToolbar.geometryRequestedLayer : dashBoard.activeLayer + DigitizingToolbar { + id: digitizingToolbar + + stateVisible: !screenLocker.enabled && + ((stateMachine.state === "digitize" + && dashBoard.activeLayer + && !dashBoard.activeLayer.readOnly + // unfortunately there is no way to call QVariant::toBool in QML so the value is a string + && dashBoard.activeLayer.customProperty( 'QFieldSync/is_geometry_locked' ) !== 'true' + && !geometryEditorsToolbar.stateVisible + && !moveFeaturesToolbar.stateVisible + && (projectInfo.editRights || projectInfo.insertRights)) + || stateMachine.state === 'measure' + || (stateMachine.state === "digitize" && digitizingToolbar.geometryRequested)) + rubberbandModel: currentRubberband ? currentRubberband.model : null + mapSettings: mapCanvas.mapSettings + showConfirmButton: stateMachine.state === "digitize" + screenHovering: mapCanvasMap.hovered + + digitizingLogger.type: stateMachine.state === 'measure' ? '' : 'add' + + FeatureModel { + id: digitizingFeature + project: qgisProject + currentLayer: digitizingToolbar.geometryRequested ? digitizingToolbar.geometryRequestedLayer : dashBoard.activeLayer + positionInformation: positionSource.positionInformation + topSnappingResult: coordinateLocator.topSnappingResult + positionLocked: positionSource.active && positioningSettings.positioningCoordinateLock + cloudUserInformation: projectInfo.cloudUserInformation + geometry: Geometry { + id: digitizingGeometry + rubberbandModel: digitizingRubberband.model + vectorLayer: digitizingToolbar.geometryRequested ? digitizingToolbar.geometryRequestedLayer : dashBoard.activeLayer + } } - } - property string previousStateMachineState: '' - onGeometryRequestedChanged: { + property string previousStateMachineState: '' + onGeometryRequestedChanged: { if ( geometryRequested ) { - digitizingRubberband.model.reset() - previousStateMachineState = stateMachine.state - stateMachine.state = "digitize" + digitizingRubberband.model.reset() + previousStateMachineState = stateMachine.state + stateMachine.state = "digitize" } else { - stateMachine.state = previousStateMachineState + stateMachine.state = previousStateMachineState } - } + } - onVertexCountChanged: { - if ( stateMachine.state === 'measure' && elevationProfileButton.elevationProfileActive ) { - if ( rubberbandModel.vertexCount > 2 ) { - // Clear the pre-existing profile to trigger a zoom to full updated profile curve - elevationProfile.clear(); - elevationProfile.profileCurve = GeometryUtils.lineFromRubberband(rubberbandModel, elevationProfile.crs) - elevationProfile.refresh(); - } - } else if( qfieldSettings.autoSave && stateMachine.state === "digitize" ) { - if ( digitizingToolbar.geometryValid ) { - if (digitizingRubberband.model.geometryType === Qgis.GeometryType.Null) - { - digitizingRubberband.model.reset() - } - else - { - digitizingFeature.geometry.applyRubberband() - digitizingFeature.applyGeometry() + onVertexCountChanged: { + if ( stateMachine.state === 'measure' && elevationProfileButton.elevationProfileActive ) { + if ( rubberbandModel.vertexCount > 2 ) { + // Clear the pre-existing profile to trigger a zoom to full updated profile curve + elevationProfile.clear(); + elevationProfile.profileCurve = GeometryUtils.lineFromRubberband(rubberbandModel, elevationProfile.crs) + elevationProfile.refresh(); } + } else if( qfieldSettings.autoSave && stateMachine.state === "digitize" ) { + if ( digitizingToolbar.geometryValid ) { + if (digitizingRubberband.model.geometryType === Qgis.GeometryType.Null) + { + digitizingRubberband.model.reset() + } + else + { + digitizingFeature.geometry.applyRubberband() + digitizingFeature.applyGeometry() + } - if ( !overlayFeatureFormDrawer.featureForm.featureCreated ) - { + if ( !overlayFeatureFormDrawer.featureForm.featureCreated ) + { overlayFeatureFormDrawer.featureModel.geometry = digitizingFeature.geometry overlayFeatureFormDrawer.featureModel.applyGeometry() overlayFeatureFormDrawer.featureModel.resetAttributes() @@ -2074,42 +2005,42 @@ ApplicationWindow { // indirect action, no need to check for success and display a toast, the log is enough overlayFeatureFormDrawer.featureForm.featureCreated = overlayFeatureFormDrawer.featureForm.create() } + } else { + // indirect action, no need to check for success and display a toast, the log is enough + overlayFeatureFormDrawer.featureModel.geometry = digitizingFeature.geometry + overlayFeatureFormDrawer.featureModel.applyGeometry() + overlayFeatureFormDrawer.featureForm.save() + } } else { - // indirect action, no need to check for success and display a toast, the log is enough - overlayFeatureFormDrawer.featureModel.geometry = digitizingFeature.geometry - overlayFeatureFormDrawer.featureModel.applyGeometry() - overlayFeatureFormDrawer.featureForm.save() - } - } else { - if ( overlayFeatureFormDrawer.featureForm.featureCreated ) { - // delete the feature when the geometry gets invalid again - // indirect action, no need to check for success and display a toast, the log is enough - overlayFeatureFormDrawer.featureForm.featureCreated = !overlayFeatureFormDrawer.featureForm.deleteFeature() + if ( overlayFeatureFormDrawer.featureForm.featureCreated ) { + // delete the feature when the geometry gets invalid again + // indirect action, no need to check for success and display a toast, the log is enough + overlayFeatureFormDrawer.featureForm.featureCreated = !overlayFeatureFormDrawer.featureForm.deleteFeature() + } } } } - } - onCancel: { + onCancel: { coordinateLocator.sourceLocation = undefined if ( stateMachine.state === 'measure' && elevationProfileButton.elevationProfileActive ) { - elevationProfile.clear() - elevationProfile.refresh() + elevationProfile.clear() + elevationProfile.refresh() } else { - if ( geometryRequested ) { - if ( overlayFeatureFormDrawer.isAdding ) { - overlayFeatureFormDrawer.open() - } - geometryRequested = false + if ( geometryRequested ) { + if ( overlayFeatureFormDrawer.isAdding ) { + overlayFeatureFormDrawer.open() } + geometryRequested = false + } } - } + } - onConfirmed: { - if ( geometryRequested ) - { + onConfirmed: { + if ( geometryRequested ) + { if ( overlayFeatureFormDrawer.isAdding ) { - overlayFeatureFormDrawer.open() + overlayFeatureFormDrawer.open() } coordinateLocator.flash() @@ -2119,92 +2050,171 @@ ApplicationWindow { geometryRequested = false coordinateLocator.sourceLocation = undefined return; - } + } - if (digitizingRubberband.model.geometryType === Qgis.GeometryType.Null) - { - digitizingRubberband.model.reset() - } - else - { - coordinateLocator.flash() - digitizingFeature.geometry.applyRubberband() - digitizingFeature.applyGeometry() - digitizingRubberband.model.frozen = true - digitizingFeature.updateRubberband() - } + if (digitizingRubberband.model.geometryType === Qgis.GeometryType.Null) + { + digitizingRubberband.model.reset() + } + else + { + coordinateLocator.flash() + digitizingFeature.geometry.applyRubberband() + digitizingFeature.applyGeometry() + digitizingRubberband.model.frozen = true + digitizingFeature.updateRubberband() + } - if ( !digitizingFeature.suppressFeatureForm() ) - { - overlayFeatureFormDrawer.featureModel.geometry = digitizingFeature.geometry - overlayFeatureFormDrawer.featureModel.applyGeometry() - overlayFeatureFormDrawer.featureModel.resetAttributes() - overlayFeatureFormDrawer.open() - overlayFeatureFormDrawer.state = "Add" - } - else - { - if ( !overlayFeatureFormDrawer.featureForm.featureCreated ) { + if ( !digitizingFeature.suppressFeatureForm() ) + { + overlayFeatureFormDrawer.featureModel.geometry = digitizingFeature.geometry + overlayFeatureFormDrawer.featureModel.applyGeometry() + overlayFeatureFormDrawer.featureModel.resetAttributes() + overlayFeatureFormDrawer.open() + overlayFeatureFormDrawer.state = "Add" + } + else + { + if ( !overlayFeatureFormDrawer.featureForm.featureCreated ) { overlayFeatureFormDrawer.featureModel.geometry = digitizingFeature.geometry overlayFeatureFormDrawer.featureModel.applyGeometry() overlayFeatureFormDrawer.featureModel.resetAttributes() if ( !overlayFeatureFormDrawer.featureModel.create() ) { displayToast( qsTr( "Failed to create feature!" ), 'error' ) } - } else { + } else { if ( !overlayFeatureFormDrawer.featureModel.save() ) { displayToast( qsTr( "Failed to save feature!" ), 'error' ) } + } + digitizingRubberband.model.reset() + digitizingFeature.resetFeature(); } - digitizingRubberband.model.reset() - digitizingFeature.resetFeature(); + coordinateLocator.sourceLocation = undefined } - coordinateLocator.sourceLocation = undefined } - } - GeometryEditorsToolbar { - id: geometryEditorsToolbar + GeometryEditorsToolbar { + id: geometryEditorsToolbar - featureModel: geometryEditingFeature - mapSettings: mapCanvas.mapSettings - editorRubberbandModel: geometryEditorsRubberband.model - editorRenderer: geometryEditorRenderer - screenHovering: mapCanvasMap.hovered + featureModel: geometryEditingFeature + mapSettings: mapCanvas.mapSettings + editorRubberbandModel: geometryEditorsRubberband.model + editorRenderer: geometryEditorRenderer + screenHovering: mapCanvasMap.hovered - stateVisible: !screenLocker.enabled && (stateMachine.state === "digitize" && geometryEditingVertexModel.vertexCount > 0) - } + stateVisible: !screenLocker.enabled && (stateMachine.state === "digitize" && geometryEditingVertexModel.vertexCount > 0) + } - ConfirmationToolbar { - id: moveFeaturesToolbar + ConfirmationToolbar { + id: moveFeaturesToolbar - property bool moveFeaturesRequested: false - property var startPoint: undefined // QgsPoint or undefined - property var endPoint: undefined // QgsPoint or undefined - signal moveConfirmed - signal moveCanceled + property bool moveFeaturesRequested: false + property var startPoint: undefined // QgsPoint or undefined + property var endPoint: undefined // QgsPoint or undefined + signal moveConfirmed + signal moveCanceled - stateVisible: moveFeaturesRequested + stateVisible: moveFeaturesRequested - onConfirm: { - endPoint = GeometryUtils.point(mapCanvas.mapSettings.center.x, mapCanvas.mapSettings.center.y) - moveFeaturesRequested = false - moveConfirmed() - } - onCancel: { - startPoint = undefined - endPoint = undefined - moveFeaturesRequested = false - moveCanceled() + onConfirm: { + endPoint = GeometryUtils.point(mapCanvas.mapSettings.center.x, mapCanvas.mapSettings.center.y) + moveFeaturesRequested = false + moveConfirmed() + } + onCancel: { + startPoint = undefined + endPoint = undefined + moveFeaturesRequested = false + moveCanceled() + } + + function initializeMoveFeatures() { + if ( featureForm && featureForm.selection.model.selectedCount === 1 ) { + featureForm.extentController.zoomToSelected() + } + + startPoint = GeometryUtils.point(mapCanvas.mapSettings.center.x, mapCanvas.mapSettings.center.y) + moveFeaturesRequested = true + } } + } + } - function initializeMoveFeatures() { - if ( featureForm && featureForm.selection.model.selectedCount === 1 ) { - featureForm.extentController.zoomToSelected() + LocatorSettings { + id: locatorSettings + locatorFiltersModel: locatorItem.locatorFiltersModel + + modal: true + closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside + parent: Overlay.overlay + } + + PluginManagerSettings { + id: pluginManagerSettings + + modal: true + closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside + parent: Overlay.overlay + } + + DashBoard { + id: dashBoard + allowLayerChange: !digitizingToolbar.isDigitizing + mapSettings: mapCanvas.mapSettings + interactive: !welcomeScreen.visible + && !qfieldSettings.visible + && !qfieldCloudScreen.visible + && !qfieldLocalDataPickerScreen.visible + && !codeReader.visible + && !screenLocker.enabled + + onOpenedChanged: { + if ( !opened ) { + if ( featureForm.visible ) { + featureForm.focus = true; } + } + } - startPoint = GeometryUtils.point(mapCanvas.mapSettings.center.x, mapCanvas.mapSettings.center.y) - moveFeaturesRequested = true + function ensureEditableLayerSelected() { + var firstEditableLayer = null; + var activeLayerLocked = false; + for (var i = 0; i < layerTree.rowCount(); i++) + { + var index = layerTree.index(i, 0) + if (firstEditableLayer === null) + { + if ( + layerTree.data(index,FlatLayerTreeModel.Type) === 'layer' + && layerTree.data(index, FlatLayerTreeModel.ReadOnly) === false + && layerTree.data(index, FlatLayerTreeModel.GeometryLocked) === false) + { + firstEditableLayer = layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer); + } + } + if (activeLayer != null && activeLayer === layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer)) + { + if ( + layerTree.data(index, FlatLayerTreeModel.ReadOnly) === true + || layerTree.data(index, FlatLayerTreeModel.GeometryLocked) === true + ) + { + activeLayerLocked = true; + } + else + { + break; + } + } + if ( + firstEditableLayer !== null + && (activeLayer == null || activeLayerLocked === true) + ) + { + activeLayer = firstEditableLayer; + break; + } } } } @@ -2633,19 +2643,6 @@ ApplicationWindow { } } - PositioningSettings { - id: positioningSettings - - onPositioningActivatedChanged: { - if (positioningActivated) { - displayToast( qsTr( "Activating positioning service" ) ) - positionSource.active = true - } else { - positionSource.active = false - } - } - } - Menu { id: canvasMenu objectName: "canvasMenu" @@ -3316,6 +3313,15 @@ ApplicationWindow { } } + QfDropShadow { + anchors.fill: featureForm + horizontalOffset: mainWindow.width >= mainWindow.height ? -2: 0 + verticalOffset: mainWindow.width < mainWindow.height ? -2: 0 + radius: 6.0 + color: "#80000000" + source: featureForm + } + OverlayFeatureFormDrawer { id: overlayFeatureFormDrawer digitizingToolbar: digitizingToolbar @@ -3520,15 +3526,6 @@ ApplicationWindow { property bool editRights: hasEditRights } - BusyIndicator { - id: busyIndicator - anchors.left: mainMenuBar.left - anchors.top: mainToolbar.bottom - width: menuButton.width + 10 - height: width - running: mapCanvasMap.isRendering - } - MessageLog { id: messageLog objectName: 'messageLog' From aa55b5fd5c3235ffe90f0e35b50faefe8db0d2ed Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Sun, 19 May 2024 10:39:09 +0700 Subject: [PATCH 15/17] Make pre-commit happy --- src/qml/NavigationInformationView.qml | 2 +- src/qml/PositioningInformationView.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qml/NavigationInformationView.qml b/src/qml/NavigationInformationView.qml index 1377075d8f..99e835bdbc 100644 --- a/src/qml/NavigationInformationView.qml +++ b/src/qml/NavigationInformationView.qml @@ -17,7 +17,7 @@ Rectangle { property int ceilsCount: 4 property double rowHeight: 30 - property color backgroundColor: "transparent" + property color backgroundColor: "transparent" property color alternateBackgroundColor: Theme.navigationBackgroundColor property color textColor: Theme.mainTextColor property real contentHeight: content.height diff --git a/src/qml/PositioningInformationView.qml b/src/qml/PositioningInformationView.qml index bc9aaeb910..665d2c7b61 100644 --- a/src/qml/PositioningInformationView.qml +++ b/src/qml/PositioningInformationView.qml @@ -19,7 +19,7 @@ Rectangle { property double antennaHeight: NaN property double rowHeight: 30 - property color backgroundColor: "transparent" + property color backgroundColor: "transparent" property color alternateBackgroundColor: Theme.positionBackgroundColor property color textColor: positionSource.currentness ? Theme.mainTextColor : Theme.secondaryTextColor From 6411205071ce4e20b2b3cf7c2cb7c45f2527cba4 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Sun, 19 May 2024 12:16:43 +0700 Subject: [PATCH 16/17] Move away from a Drawer into an Item to avoid bad stacking --- src/qml/InformationDrawer.qml | 79 ++++++----------------------------- src/qml/qgismobileapp.qml | 7 +--- 2 files changed, 13 insertions(+), 73 deletions(-) diff --git a/src/qml/InformationDrawer.qml b/src/qml/InformationDrawer.qml index 4e86a89698..f47bf64c97 100644 --- a/src/qml/InformationDrawer.qml +++ b/src/qml/InformationDrawer.qml @@ -4,19 +4,21 @@ import QtQuick.Controls 2.14 import org.qfield 1.0 import Theme 1.0 -Drawer { +Item { id: controller + + anchors.bottom: parent.bottom + anchors.leftMargin: 10 + anchors.rightMargin: 10 + width: parent.width - height: mainContent.height - Overlay.modal: null - modal: false - edge: Qt.BottomEdge - dragMargin: 0 - closePolicy: Popup.NoAutoClose + height: mainContent.height + (mainContent.height > 0 ? 10 : 0) + Behavior on height { + PropertyAnimation { + easing.type: Easing.OutQuart + } + } - property real realtimeHeight: controller.height * controller.position - property bool closeRequested: true - property bool openRequested: false property real itemRadius: 8 property bool uiConflictFree: false @@ -42,63 +44,6 @@ Drawer { || ( positioningPreciseView.hasAcceptableAccuracy && positioningPreciseView.projectDistance < positioningPreciseView.precision )) - - function resetHeight() { - let newHeight = 0 - newHeight += (navigationInformationView.height + 8) - newHeight += (positioningInformationView.height + 8) - newHeight += (positioningPreciseView.height + 8) - newHeight += (sensorInformationView.height + 8) - newHeight += 16 - controller.height = newHeight - } - - function updateDrawerHeight(visibleView, viewHeight){ - if (!visibleView) { - controller.height -= (viewHeight + 8) - controller.open() - } else if (openRequested) { - controller.height += (viewHeight + 8) - controller.open() - } - } - - onNavigationInformationViewEnabledChanged: updateDrawerHeight(navigationInformationViewEnabled, navigationInformationView.contentHeight) - - onPositioningInformationViewEnabledChanged: updateDrawerHeight(positioningInformationViewEnabled, positioningInformationView.contentHeight) - - onPositioningPreciseEnabledChanged: updateDrawerHeight(positioningPreciseEnabled, positioningPreciseViewHeight) - - onSensorInformationViewEnabledChanged: updateDrawerHeight(sensorInformationViewEnabled, sensorInformationView.contentHeight) - - onOpenRequestedChanged: { - if (openRequested) { - closeRequested = false - resetHeight() - open() - } else { - closeRequested = true - close() - } - } - - onOpened: { - if (closeRequested) { - controller.close() - } - } - - onClosed: { - if (!closeRequested) { - // view is dragged down but we must bring it back - controller.open() - } - } - - background: Item { - anchors.fill: parent - } - Column { id: mainContent width: parent.width - 8 diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index b67dc5d138..b1f9f42c79 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -946,11 +946,6 @@ ApplicationWindow { InformationDrawer { id: informationDrawer - openRequested: (navigation.isActive || - positioningSettings.showPositionInformation || - sensorInformationViewEnabled) && - uiConflictFree && - mapCanvasMap.isEnabled navigation: navigation positionSource: positionSource @@ -991,7 +986,7 @@ ApplicationWindow { Item { id: mapCanvasOverlays anchors.fill: mapCanvas - anchors.bottomMargin: informationDrawer.openRequested ? informationDrawer.realtimeHeight : 0 + anchors.bottomMargin: informationDrawer.height Text { id: coordinateLocatorInformationOverlay From f8cd5a8a39caf2c407e606c1fb2a2693f1759a99 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Sun, 19 May 2024 15:56:35 +0330 Subject: [PATCH 17/17] Remove uiConflictFree. also add elevationProfile.visible to navigationInformationViewEnabled. because when elevationProfile is enabled, navigationInformation causes more margin. we should hide it in background. --- src/qml/InformationDrawer.qml | 7 +++---- src/qml/qgismobileapp.qml | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/qml/InformationDrawer.qml b/src/qml/InformationDrawer.qml index f47bf64c97..0a71620cb2 100644 --- a/src/qml/InformationDrawer.qml +++ b/src/qml/InformationDrawer.qml @@ -20,24 +20,23 @@ Item { } property real itemRadius: 8 - property bool uiConflictFree: false // SensorInformationView property bool sensorInformationViewEnabled: sensorInformationView.activeSensors > 0 // NavigationInformationView - property bool navigationInformationViewEnabled: navigation.isActive + property bool navigationInformationViewEnabled: navigation.isActive && !elevationProfile.visible // PositioningInformationView property Navigation navigation - property bool positioningInformationViewEnabled: positioningSettings.showPositionInformation && uiConflictFree + property bool positioningInformationViewEnabled: positioningSettings.showPositionInformation && !elevationProfile.visible // PositioningPreciseView property alias positioningPreciseView: positioningPreciseView property PositioningSettings positioningSettings property Positioning positionSource property real positioningPreciseViewHeight - property bool positioningPreciseEnabled: uiConflictFree + property bool positioningPreciseEnabled: !elevationProfile.visible && !isNaN(navigation.distance) && navigation.isActive && (positioningSettings.alwaysShowPreciseView diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index b1f9f42c79..12aa92179a 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -951,7 +951,6 @@ ApplicationWindow { positionSource: positionSource positioningSettings: positioningSettings positioningPreciseViewHeight: Math.min(mainWindow.height / 2.5, 400) - uiConflictFree: !elevationProfile.visible && !messageLog.visible } Column {