aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/doc/snippets/qtquickcontrols-material-attributes.qml
blob: 1f0298de44481d23f6abb7560209feb42a8d46ee (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls.Material
import QtQuick.Shapes

Pane {
    width: 400
    height: 300

    Page {
        anchors.fill: parent
        anchors.margins: 40

        header: ToolBar {
            Label {
                text: "Material"
                anchors.centerIn: parent
            }
        }

        TextField {
            id: textField
            text: "TextField"
            anchors.centerIn: parent

            Component.onCompleted: forceActiveFocus()
        }
    }

    component Line: Shape {
        // Account for 1-pixel-wide lines.
        width: Math.max(1, endX - startX)
        height: Math.max(1, endY - startY)

        layer.enabled: true
        layer.samples: 4

        property alias startX: shapePath.startX
        property alias startY: shapePath.startY
        property alias endX: pathLine.x
        property alias endY: pathLine.y

        ShapePath {
            id: shapePath
            strokeWidth: 1
            strokeColor: "#444"

            PathLine {
                id: pathLine
            }
        }
    }

    Label {
        id: primaryLabel
        x: 40
        y: 3
        text: "Primary"
    }
    Line {
        id: primaryLine
        x: primaryLabel.x + primaryLabel.width / 2
        y: primaryLabel.y + primaryLabel.height
        startX: 0.5
        startY: 0
        endX: 0.5
        endY: 40
    }

    Label {
        id: foregroundLabel
        anchors.horizontalCenter: parent.horizontalCenter
        y: 3
        text: "Foreground"
    }
    Line {
        id: foregroundLine
        x: foregroundLabel.x + foregroundLabel.width / 2
        y: foregroundLabel.y + foregroundLabel.height
        // Lines are drawn at the center of the pixel.
        startX: 0.5
        startY: 0
        endX: 0.5
        endY: 34
    }

    Label {
        id: accentLabel
        anchors.horizontalCenter: parent.horizontalCenter
        y: parent.height * 0.825
        text: "Accent"
    }
    Line {
        id: accentLine
        x: accentLabel.x + accentLabel.width / 2
        y: parent.height * 0.7
        startX: 0.5
        startY: 0
        endX: 0.5
        endY: 38
    }

    Label {
        id: backgroundLabel
        x: parent.width - width - 10
        y: parent.height - height - 10
        text: "Background"
    }
    Line {
        id: backgroundLine
        x: backgroundLabel.x + backgroundLabel.width / 2
        y: backgroundLabel.y - height
        startX: 0.5
        startY: 0
        endX: 0.5
        endY: 40
    }
}