From 0a91c56d2e946f87eb173355dabee8a1b76d4ce8 Mon Sep 17 00:00:00 2001 From: Vitor Vieira <155513369+VitorVieiraZ@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:15:20 -0300 Subject: [PATCH] Redesign of the GPS Data Page (#3039) Added new GpsDataDrawer - redesign of GpsDataPage to GalleryApp --- app/qml/CMakeLists.txt | 1 + app/qml/components/MMGpsDataDrawer.qml | 307 +++++++++++++++++++++++++ app/qml/components/MMGpsDataText.qml | 53 +++++ app/qml/components/MMLine.qml | 23 ++ gallery/CMakeLists.txt | 1 + gallery/main.cpp | 5 +- gallery/positionkit.h | 80 +++++++ gallery/qml.qrc | 4 + gallery/qml/Main.qml | 4 + gallery/qml/pages/DrawerPage.qml | 7 +- gallery/qml/pages/GpsInfoPage.qml | 35 +++ 11 files changed, 518 insertions(+), 2 deletions(-) create mode 100644 app/qml/components/MMGpsDataDrawer.qml create mode 100644 app/qml/components/MMGpsDataText.qml create mode 100644 app/qml/components/MMLine.qml create mode 100644 gallery/positionkit.h create mode 100644 gallery/qml/pages/GpsInfoPage.qml diff --git a/app/qml/CMakeLists.txt b/app/qml/CMakeLists.txt index 9477e47f6..bf0f78404 100644 --- a/app/qml/CMakeLists.txt +++ b/app/qml/CMakeLists.txt @@ -37,6 +37,7 @@ set(MM_QML components/MMButton.qml components/MMComponent_reachedDataLimit.qml components/MMDrawer.qml + components/MMGpsDataDrawer.qml components/MMHeader.qml components/MMHlineText.qml components/MMIcon.qml diff --git a/app/qml/components/MMGpsDataDrawer.qml b/app/qml/components/MMGpsDataDrawer.qml new file mode 100644 index 000000000..0ef7393c8 --- /dev/null +++ b/app/qml/components/MMGpsDataDrawer.qml @@ -0,0 +1,307 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Basic +import QtQuick.Layouts +import "." +import ".." +import lc 1.0 + +Drawer { + id: root + + property var title + property real rowHeight: 67 * __dp + + width: ApplicationWindow.window.width + height: (mainColumn.height > ApplicationWindow.window.height ? ApplicationWindow.window.height : mainColumn.height) - 20 * __dp + edge: Qt.BottomEdge + + Rectangle { + color: roundedRect.color + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: 2 * radius + anchors.topMargin: -radius + radius: 20 * __dp + } + + Rectangle { + + id: roundedRect + + anchors.fill: parent + color: __style.whiteColor + + ColumnLayout { + + id: mainColumn + + width: parent.width + spacing: 40 * __dp + + MMHeader { + id: header + + rightMarginShift: 0 + backVisible: false + + title: qsTr("GPS info") + titleFont: __style.h3 + + MMRoundButton { + id: backBtn + + anchors.right: parent.right + anchors.rightMargin: __style.pageMargins + anchors.verticalCenter: parent.verticalCenter + + iconSource: __style.closeIcon + iconColor: __style.forestColor + + bgndColor: __style.lightGreenColor + bgndHoverColor: __style.mediumGreenColor + + onClicked: root.visible = false + } + } + + ScrollView { + id: scrollView + + Layout.fillWidth: true + Layout.leftMargin: 20 * __dp + Layout.rightMargin: 20 * __dp + Layout.maximumWidth: __style.maxPageWidth + Layout.alignment: Qt.AlignHCenter + Layout.preferredHeight: { + if (ApplicationWindow.window){ + var availableHeight = ApplicationWindow.window.height - header.height - mainColumn.spacing + var totalHeight = scrollColumn.childrenRect.height + 20 * __dp + + if(totalHeight >= ApplicationWindow.window.height) { + return availableHeight + } + return totalHeight + } + return 0 + } + contentWidth: availableWidth + contentHeight: scrollColumn.childrenRect.height + + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + ScrollBar.vertical.policy: ScrollBar.AlwaysOff + + Column{ + id: scrollColumn + + width: parent.width + spacing: 0 + + Row { + width: parent.width + height: rowHeight + + MMGpsDataText{ + titleText: qsTr( "Source" ) + descriptionText: __positionKit.positionProvider ? __positionKit.providerName : qsTr( "No receiver" ) + } + + MMGpsDataText{ + titleText: qsTr( "Status" ) + descriptionText: __positionKit.positionProvider ? __positionKit.providerMessage : "" + alignmentRight: true + itemVisible: __positionKit.positionProvider && __positionKit.providerType === "external" + } + } + + MMLine {} + + Row { + width: parent.width + height: rowHeight + + MMGpsDataText{ + titleText: qsTr( "Latitude" ) + descriptionText: { + if ( !__positionKit.hasPosition || Number.isNaN( __positionKit.latitude ) ) { + qsTr( "N/A" ) + } + __positionKit.latitude + } + } + + MMGpsDataText{ + titleText: qsTr( "Longitude") + descriptionText: { + if ( !__positionKit.hasPosition || Number.isNaN( __positionKit.longitude ) ) { + qsTr( "N/A" ) + } + __positionKit.longitude + } + alignmentRight: true + } + } + + MMLine {} + + Row { + width: parent.width + height: rowHeight + + MMGpsDataText{ + titleText: qsTr( "X" ) + descriptionText: { + if ( !__positionKit.hasPosition || Number.isNaN( __positionKit.x ) ) { + qsTr( "N/A" ) + } + __positionKit.x.toFixed(2) + } + } + + MMGpsDataText{ + titleText: qsTr( "Y" ) + descriptionText: { + if ( !__positionKit.hasPosition || Number.isNaN( __positionKit.x ) ) { + qsTr( "N/A" ) + } + __positionKit.y.toFixed(2) + } + alignmentRight: true + } + } + + MMLine {} + + Row { + width: parent.width + height: rowHeight + + MMGpsDataText{ + titleText: qsTr( "Horizontal accuracy" ) + descriptionText: { + if ( !__positionKit.hasPosition || __positionKit.horizontalAccuracy < 0 ) { + return qsTr( "N/A" ) + } + + __positionKit.horizontalAccuracy.toFixed(2) + " m" + } + } + + MMGpsDataText{ + titleText: qsTr( "Vertical accuracy" ) + descriptionText: { + if ( !__positionKit.hasPosition || __positionKit.verticalAccuracy < 0 ) { + return qsTr( "N/A" ) + } + + __positionKit.verticalAccuracy.toFixed(2) + " m" + } + alignmentRight: true + } + } + + MMLine {} + + Row { + width: parent.width + height: rowHeight + + MMGpsDataText{ + titleText: qsTr( "Altitude" ) + descriptionText: { + if ( !__positionKit.hasPosition || Number.isNaN( __positionKit.altitude ) ) { + return qsTr( "N/A" ) + } + __positionKit.altitude.toString() + " m" + } + } + + MMGpsDataText{ + titleText: qsTr( "Satellites (in use/view)" ) + descriptionText: { + if ( __positionKit.satellitesUsed < 0 || __positionKit.satellitesVisible < 0 ) + { + return qsTr( "N/A" ) + } + + __positionKit.satellitesUsed + "/" + __positionKit.satellitesVisible + } + alignmentRight: true + } + } + + MMLine {} + + Row { + width: parent.width + height: rowHeight + + MMGpsDataText{ + titleText: qsTr( "Speed" ) + descriptionText: { + if ( !__positionKit.hasPosition || __positionKit.speed < 0 ) { + return qsTr( "N/A" ) + } + + __positionKit.speed.toString(2) + " km/h" + } + } + + MMGpsDataText{ + titleText: qsTr( "Last Fix" ) + descriptionText: __positionKit.lastRead || qsTr( "N/A" ) + alignmentRight: true + } + } + + MMLine {} + + Row { + width: parent.width + height: rowHeight + + MMGpsDataText{ + titleText: qsTr( "GPS antenna height" ) + descriptionText: __positionKit.gpsAntennaHeight > 0 ? __positionKit.gpsAntennaHeight.toString(3) + " m" : qsTr( "Not set" ) + } + } + + Item { + width: 1 + height: 20 * __dp + } + + MMButton { + id: primaryButton + + width: parent.width - 2 * 20 * __dp + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottomMargin: 20 + + text: qsTr("Manage GPS receivers") + + onClicked: { + console.log("GPS data drawer button test OK") + } + } + + Item { + width: 2 + height: 20 * __dp + } + } + } + } + } +} + diff --git a/app/qml/components/MMGpsDataText.qml b/app/qml/components/MMGpsDataText.qml new file mode 100644 index 000000000..ef9151dee --- /dev/null +++ b/app/qml/components/MMGpsDataText.qml @@ -0,0 +1,53 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +import QtQuick +import "." +import ".." +import lc 1.0 +import QtQuick.Layouts + +Item { + property string titleText: "title" + property string descriptionText: "description" + property bool alignmentRight: false + property bool itemVisible: true + + width: parent.width / 2 + height: parent.height + + ColumnLayout { + width: parent.width + height: parent.height + visible: itemVisible + spacing: 0 + + Text { + text: titleText + color: __style.nightColor + font: __style.p6 + elide: Text.ElideRight + horizontalAlignment: alignmentRight ? Text.AlignRight : Text.AlignLeft + Layout.fillWidth: true + width: parent.width + Layout.topMargin: 8 + } + + Text { + text: descriptionText + color: __style.nightColor + font: __style.t3 + elide: Text.ElideMiddle + horizontalAlignment: alignmentRight ? Text.AlignRight : Text.AlignLeft + Layout.fillWidth: true + width: parent.width + Layout.bottomMargin: 8 + } + } +} diff --git a/app/qml/components/MMLine.qml b/app/qml/components/MMLine.qml new file mode 100644 index 000000000..e5417c587 --- /dev/null +++ b/app/qml/components/MMLine.qml @@ -0,0 +1,23 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +import QtQuick +import lc 1.0 + +Item { + + width: parent.width + height: (1 * __dp) < 1 ? 1 : 1 * __dp + + Rectangle { + width: parent.width + height: parent.height + color: __style.greyColor + } +} diff --git a/gallery/CMakeLists.txt b/gallery/CMakeLists.txt index 24045d331..db08061c6 100644 --- a/gallery/CMakeLists.txt +++ b/gallery/CMakeLists.txt @@ -35,6 +35,7 @@ set(GALLERY_HDRS qrcodedecoder.h inpututils.h scalebarkit.h + positionkit.h ../app/notificationmodel.h ../app/mmstyle.h ../core/merginerrortypes.h diff --git a/gallery/main.cpp b/gallery/main.cpp index 0343d7e47..08ad70526 100644 --- a/gallery/main.cpp +++ b/gallery/main.cpp @@ -22,6 +22,7 @@ #include "qrcodedecoder.h" #include "inpututils.h" #include "scalebarkit.h" +#include "positionkit.h" int main( int argc, char *argv[] ) { @@ -53,8 +54,10 @@ int main( int argc, char *argv[] ) MMStyle style( dp ); NotificationModel notificationModel; - engine.rootContext()->setContextProperty( "__notificationModel", ¬ificationModel ); + PositionKit pk; + engine.rootContext()->setContextProperty( "__positionKit", &pk ); + engine.rootContext()->setContextProperty( "__notificationModel", ¬ificationModel ); // path to local wrapper pages engine.rootContext()->setContextProperty( "_qmlWrapperPath", QGuiApplication::applicationDirPath() + "/HotReload/qml/pages/" ); engine.rootContext()->setContextProperty( "__dp", dp ); diff --git a/gallery/positionkit.h b/gallery/positionkit.h new file mode 100644 index 000000000..e889f1a17 --- /dev/null +++ b/gallery/positionkit.h @@ -0,0 +1,80 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef POSITIONKIT_H +#define POSITIONKIT_H + +#include +#include + +class PositionKit : public QObject +{ + Q_OBJECT + + Q_PROPERTY( double latitude READ latitude CONSTANT ) + Q_PROPERTY( double longitude READ longitude CONSTANT ) + Q_PROPERTY( double verticalAccuracy READ verticalAccuracy CONSTANT ) + Q_PROPERTY( double horizontalAccuracy READ horizontalAccuracy CONSTANT ) + Q_PROPERTY( double altitude READ altitude CONSTANT ) + Q_PROPERTY( double speed READ speed CONSTANT ) + Q_PROPERTY( double x READ x CONSTANT ) + Q_PROPERTY( double y READ y CONSTANT ) + Q_PROPERTY( int satellitesUsed READ satellitesUsed CONSTANT ) + Q_PROPERTY( int satellitesVisible READ satellitesVisible CONSTANT ) + Q_PROPERTY( bool hasPosition READ hasPosition CONSTANT ) + Q_PROPERTY( bool positionProvider READ positionProvider CONSTANT ) + Q_PROPERTY( QString providerName READ providerName CONSTANT ) + Q_PROPERTY( QString providerType READ providerType CONSTANT ) + Q_PROPERTY( QString providerMessage READ providerMessage CONSTANT ) + Q_PROPERTY( QString stateMessage READ stateMessage CONSTANT ) + Q_PROPERTY( QString lastRead READ lastRead CONSTANT ) + + public: + explicit PositionKit( QObject *parent = nullptr ) {}; + + double latitude() const { return hLatitude; } + double longitude() const { return hLongitude; } + double verticalAccuracy() const { return pVerticalAccuracy; } + double horizontalAccuracy() const { return pHorizontalAccuracy; } + double altitude() const { return pAltitude; } + double speed() const { return pSpeed; } + double x() const { return pX; } + double y() const { return pY; } + int satellitesUsed() const { return pSatellitesUsed; } + int satellitesVisible() const { return pSatellitesVisible; } + bool positionProvider() const { return pPositionProvider; } + bool hasPosition() const { return true; } + QString providerName() const { return pProviderName; } + QString providerMessage() const { return pProviderMessage; } + QString providerType() const { return pProviderType; } + QString stateMessage() const { return pStateMessage; } + QString lastRead() const { return pLastRead; } + + private: + QString pProviderName = "Gps Source is ok!"; + QString pProviderType = "external"; + QString pProviderMessage = "Connected"; + QString pStateMessage = "Message"; + QString pLastRead = "17:19:08 CEST"; + bool pPositionProvider = true; + int pSatellitesVisible = 40; + int pSatellitesUsed = 1; + double pY = 20.00; + double pX = 20.00; + double hLatitude = -22.906; + double pVerticalAccuracy = 20; + double pHorizontalAccuracy = 20; + double hLongitude = -43.1729; + double pAltitude = 199.85; + double pSpeed = 27; + double pGpsAntennaHeight = 0; + +}; + +#endif // POSITIONKIT_H diff --git a/gallery/qml.qrc b/gallery/qml.qrc index fbcda5f12..d0e759ade 100644 --- a/gallery/qml.qrc +++ b/gallery/qml.qrc @@ -88,6 +88,10 @@ ../app/qml/inputs/MMPhotoEditor.qml qml/pages/FormPage.qml ../app/qml/form/MMFormTabBar.qml + ../app/qml/components/MMGpsDataDrawer.qml + ../app/qml/components/MMGpsDataText.qml + ../app/qml/components/MMLine.qml ../app/qml/components/MMLinkedFeaturesDrawer.qml + qml/pages/GpsInfoPage.qml diff --git a/gallery/qml/Main.qml b/gallery/qml/Main.qml index 8ef151678..e81ede966 100644 --- a/gallery/qml/Main.qml +++ b/gallery/qml/Main.qml @@ -182,6 +182,10 @@ ApplicationWindow { title: "Feature form" source: "FormPage.qml" } + ListElement { + title: "GPS Info" + source: "GpsInfoPage.qml" + } } ScrollIndicator.vertical: ScrollIndicator {} diff --git a/gallery/qml/pages/DrawerPage.qml b/gallery/qml/pages/DrawerPage.qml index c0f31ea92..6dea33250 100644 --- a/gallery/qml/pages/DrawerPage.qml +++ b/gallery/qml/pages/DrawerPage.qml @@ -55,7 +55,6 @@ Page { bigTitle: "You have reached a data limit" primaryButton: "Manage Subscription" specialComponent: component.comp - visible: true MMComponent_reachedDataLimit { id: component @@ -81,4 +80,10 @@ Page { onPrimaryButtonClicked: visible = false onSecondaryButtonClicked: visible = false } + + MMGpsDataDrawer { + id: drawer4 + title: "Gps Info" + visible: true + } } diff --git a/gallery/qml/pages/GpsInfoPage.qml b/gallery/qml/pages/GpsInfoPage.qml new file mode 100644 index 000000000..c9acde8c9 --- /dev/null +++ b/gallery/qml/pages/GpsInfoPage.qml @@ -0,0 +1,35 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Basic + +import "../../app/qml/components" +import "../../app/qml" + +Page { + id: pane + + Column { + width: parent.width + spacing: 10 + + MMButton { + text: "Gps Data Page" + onClicked: drawer1.visible = true + } + } + + MMGpsDataDrawer { + id: drawer1 + title: "Gps Info" + visible: false + } +}