forked from papyros/qml-material
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStandard.qml
More file actions
152 lines (110 loc) · 3.89 KB
/
Copy pathStandard.qml
File metadata and controls
152 lines (110 loc) · 3.89 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
* QML Material - An application framework implementing Material Design.
*
* Copyright (C) 2014-2016 Michael Spencer <sonrisesoftware@gmail.com>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import QtQuick 2.4
import QtGraphicalEffects 1.0
import QtQuick.Layouts 1.1
import Material 0.3
/*!
\qmltype Standard
\inqmlmodule Material.ListItems
\brief A simple list item with a single line of text and optional primary and secondary actions.
*/
BaseListItem {
id: listItem
implicitHeight: 48 * Units.dp
height: 48 * Units.dp
property alias text: label.text
property alias valueText: valueLabel.text
property alias action: actionItem.children
property alias iconName: icon.name
property alias iconSource: icon.source
property alias secondaryItem: secondaryItem.children
property alias content: contentItem.children
property alias itemLabel: label
property alias itemValueLabel: valueLabel
property alias textColor: label.color
property alias iconColor: icon.color
dividerInset: actionItem.visible ? listItem.height : 0
interactive: contentItem.children.length === 0
implicitWidth: {
var width = listItem.margins * 2
if (actionItem.visible)
width += actionItem.width + row.spacing
if (contentItem.visible)
width += contentItem.implicitWidth + row.spacing
else
width += label.implicitWidth + row.spacing
if (valueLabel.visible)
width += valueLabel.width + row.spacing
if (secondaryItem.visible)
width += secondaryItem.width + row.spacing
return width
}
RowLayout {
id: row
anchors.fill: parent
anchors.leftMargin: listItem.margins
anchors.rightMargin: listItem.margins
spacing: 16 * Units.dp
Item {
id: actionItem
Layout.preferredWidth: 40 * Units.dp
Layout.preferredHeight: width
Layout.alignment: Qt.AlignCenter
visible: children.length > 1 || icon.valid
Icon {
id: icon
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
}
visible: valid
color: listItem.selected ? Theme.primaryColor
: darkBackground ? Theme.dark.iconColor : Theme.light.iconColor
size: 24 * Units.dp
}
}
ColumnLayout {
Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: parent.height
Item {
id: contentItem
Layout.fillWidth: true
Layout.preferredHeight: parent.height
visible: children.length > 0
}
Label {
id: label
Layout.alignment: Qt.AlignVCenter
Layout.fillWidth: true
elide: Text.ElideRight
style: "subheading"
color: listItem.selected ? Theme.primaryColor
: darkBackground ? Theme.dark.textColor : Theme.light.textColor
visible: !contentItem.visible
}
}
Label {
id: valueLabel
Layout.alignment: Qt.AlignVCenter
color: darkBackground ? Theme.dark.subTextColor : Theme.light.subTextColor
elide: Text.ElideRight
style: "body1"
visible: text != ""
}
Item {
id: secondaryItem
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: childrenRect.width
Layout.preferredHeight: parent.height
visible: children.length > 0
}
}
}