aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols/wearable/Wearable/MenuHeader.qml
blob: ade7cabe128ff2686b3dbc6ebf9dcff54f50d766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls as QQC2
import WearableStyle
import QtQuick.Shapes

Item {
    id: header
    property alias title: labelText.text
    signal backClicked()

    height: 50

    Shape {//Shape because Rectangle does not support diagonal gradient
        id: background
        preferredRendererType: Shape.CurveRenderer

        ShapePath {
            strokeWidth: 0

            startX: 0
            startY: 0
            PathLine {
                x: header.width
                y: 0
            }
            PathLine {
                x: header.width
                y: header.height
            }
            PathLine {
                x: 0
                y: header.height
            }
            fillGradient: LinearGradient {
                x1: header.width / 3
                y1: 0
                x2: header.width
                y2: 1.3 * header.parent.height
                GradientStop {
                    position: 0.0
                    color: UIStyle.background1
                }
                GradientStop {
                    position: 0.5
                    color: UIStyle.background2
                }
                GradientStop {
                    position: 1.0
                    color: UIStyle.background3
                }
            }
        }
    }

    QQC2.AbstractButton {
        id: backButton
        anchors.verticalCenter: parent.verticalCenter
        anchors.left: parent.left
        anchors.topMargin: 0
        anchors.leftMargin: 0

        width: height
        height: 40

        onClicked: header.backClicked()

        Image {
            width: 40
            height: 40
            anchors.centerIn: parent
            source: UIStyle.iconPath("back")
        }
    }

    QQC2.Label {
        id: labelText
        anchors.verticalCenter: parent.verticalCenter
        anchors.horizontalCenter: parent.horizontalCenter
        color: UIStyle.textColor
        font: UIStyle.h2
    }

    transform: Translate {
        Behavior on y { NumberAnimation { } }
        y: header.enabled ? 0 : -52
    }


}