Debian Codegraph @

qml/components/BottomEdgeIndicators.qml

raw
1 /*
2 * Copyright 2015-2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.12
18 import Lomiri.Components 1.3
19
20 Item {
21 id: bottomEdgeIndicators
22
23 property var options
24 width: indicatorsRow.width + units.gu(2) + emptyIndicatorsHint.width
25 height: units.gu(3)
26
27 Image {
28 anchors {
29 left: parent.left
30 right: parent.right
31 top: parent.top
32 }
33 height: parent.height * 2
34 opacity: 0.3
35 source: "../../assets/lomiri_shape.svg"
36 sourceSize.width: width
37 sourceSize.height: height
38 cache: false
39 asynchronous: true
40 }
41
42 Icon {
43 id: emptyIndicatorsHint
44 objectName: "emptyIndicatorsHint"
45 name: "go-up"
46 opacity: 0.5
47 color: "white"
48 visible: indicatorsRow.visibleChildren.length <= 1
49 anchors {
50 top: parent.top
51 topMargin: units.gu(0.5)
52 bottom: parent.bottom
53 bottomMargin: units.gu(0.5)
54 horizontalCenter: parent.horizontalCenter
55 }
56 width: visible ? height * 1.5 : 0
57 asynchronous: true
58 }
59
60 Row {
61 id: indicatorsRow
62 objectName: "indicatorsRow"
63
64 anchors {
65 top: parent.top
66 bottom: parent.bottom
67 horizontalCenter: parent.horizontalCenter
68 }
69 spacing: units.gu(1)
70
71 Repeater {
72 model: bottomEdgeIndicators.options
73 delegate: Item {
74 anchors {
75 top: parent.top
76 topMargin: units.gu(0.5)
77 bottom: parent.bottom
78 bottomMargin: units.gu(0.5)
79 }
80 width: units.gu(2)
81 visible: modelData.showInIndicators && modelData.available && modelData.visible ? (modelData.isToggle ? modelData.get(model.selectedIndex).value : true) : false
82 opacity: 0.5
83 rotation: main.orientedRotationAngle
84
85 Behavior on rotation {
86 RotationAnimator {
87 duration: LomiriAnimation.BriskDuration
88 easing: LomiriAnimation.StandardEasing
89 direction: RotationAnimator.Shortest
90 }
91 }
92
93 Icon {
94 id: indicatorIcon
95 anchors.fill: parent
96 color: modelData.colorize ? "red" : "white"
97 name: modelData && modelData.isToggle ?
98 modelData.icon :
99 (modelData.get(model.selectedIndex) && modelData.get(model.selectedIndex).icon ? modelData.get(model.selectedIndex).icon : "")
100 source: name ? "image://theme/%1".arg(name) : (modelData.iconSource || "")
101 visible: source != ""
102 asynchronous: true
103 }
104
105 Label {
106 id: indicatorLabel
107 anchors.fill: parent
108 fontSize: "xx-small"
109 color: "white"
110 text: modelData.label
111 verticalAlignment: Text.AlignVCenter
112 visible: indicatorIcon.name === ""
113 }
114 }
115 }
116 }
117 }