From df7996eaa1b0c2e8cbcd5ec3c64bf110141ed671 Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 19 Oct 2023 11:16:24 +0200 Subject: [PATCH] Added MMMapLabel for labels on map --- app/qmlV2/Style.js | 1 + app/qmlV2/component/MMMapLabel.qml | 55 ++++++++++++++++++++++++++++++ gallery/qml.qrc | 1 + gallery/qml/pages/MapPage.qml | 9 +++++ 4 files changed, 66 insertions(+) create mode 100644 app/qmlV2/component/MMMapLabel.qml diff --git a/app/qmlV2/Style.js b/app/qmlV2/Style.js index cf2bf63f0..7ee0e965e 100644 --- a/app/qmlV2/Style.js +++ b/app/qmlV2/Style.js @@ -83,6 +83,7 @@ const shadowColor = "#66777777" // Spacing const commonSpacing = 20 * __dp +const commonItemHeight = 50 * __dp function dynamicText() { return "Dynamic text" diff --git a/app/qmlV2/component/MMMapLabel.qml b/app/qmlV2/component/MMMapLabel.qml new file mode 100644 index 000000000..1e7d6f8a9 --- /dev/null +++ b/app/qmlV2/component/MMMapLabel.qml @@ -0,0 +1,55 @@ +/*************************************************************************** + * * + * 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 Qt5Compat.GraphicalEffects +import "../Style.js" as Style +import "." + +Item { + id: control + + width: text.width + height: Style.commonItemHeight + visible: control.text.length > 0 + + signal clicked + + required property string text + property color bgColor: Style.positive + property color textColor: Style.forest + + Rectangle { + width: parent.width + height: parent.height + radius: control.height / 2 + color: control.bgColor + + layer.enabled: true + layer.effect: MMShadow {} + + Text { + id: text + + anchors.centerIn: parent + color: control.textColor + text: control.text + font: Qt.font(Style.t3) + leftPadding: Style.commonSpacing + rightPadding: Style.commonSpacing + } + + MouseArea { + anchors.fill: parent + onClicked: control.clicked() + } + } +} diff --git a/gallery/qml.qrc b/gallery/qml.qrc index eb566369f..0faf13953 100644 --- a/gallery/qml.qrc +++ b/gallery/qml.qrc @@ -27,5 +27,6 @@ qml/pages/MapPage.qml ../app/qmlV2/component/MMMapButton.qml ../app/qmlV2/component/MMShadow.qml + ../app/qmlV2/component/MMMapLabel.qml diff --git a/gallery/qml/pages/MapPage.qml b/gallery/qml/pages/MapPage.qml index 5e0427ef1..898a5e849 100644 --- a/gallery/qml/pages/MapPage.qml +++ b/gallery/qml/pages/MapPage.qml @@ -93,4 +93,13 @@ Page { MMMapButton { } } + + MMMapLabel { + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.leftMargin: 20 + anchors.bottomMargin: 50 + + text: "20.0 m" + } }