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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
/*
* Copyright 2015 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.2
import QtGraphicalEffects 1.0
import org.kde.plasma.mobilecomponents 0.2
OverlayDrawer {
id: root
edge: Qt.LeftEdge
default property alias content: mainContent.data
property alias title: heading.text
property alias titleIcon: headingIcon.source
property alias bannerImageSource: bannerImage.source
property list<Action> actions
contentItem: ColumnLayout {
id: mainColumn
anchors.fill: parent
spacing: 0
implicitWidth: Units.gridUnit * 12
Image {
id: bannerImage
Layout.fillWidth: true
Layout.preferredWidth: title.implicitWidth
Layout.preferredHeight: bannerImageSource != "" ? Math.max(title.implicitHeight, Math.floor(width / (sourceSize.width/sourceSize.height))) : title.implicitHeight
Layout.minimumHeight: Math.max(headingIcon.height, heading.height) + Units.smallSpacing * 2
fillMode: Image.PreserveAspectCrop
asynchronous: true
anchors {
left: parent.left
right: parent.right
top: parent.top
}
LinearGradient {
anchors {
left: parent.left
right: parent.right
top: parent.top
}
visible: bannerImageSource != ""
height: title.height * 1.3
start: Qt.point(0, 0)
end: Qt.point(0, height)
gradient: Gradient {
GradientStop {
position: 0.0
color: Qt.rgba(0, 0, 0, 0.8)
}
GradientStop {
position: 1.0
color: "transparent"
}
}
}
RowLayout {
id: title
anchors {
left: parent.left
top: parent.top
margins: Units.smallSpacing * 2
}
Icon {
id: headingIcon
Layout.minimumWidth: Units.iconSizes.large
Layout.minimumHeight: width
}
Heading {
id: heading
level: 1
color: bannerImageSource != "" ? "white" : Theme.textColor
}
Item {
height: 1
Layout.minimumWidth: heading.height
}
}
}
Rectangle {
color: Theme.textColor
opacity: 0.2
Layout.fillWidth: true
Layout.minimumHeight: 1
}
StackView {
id: pageRow
Layout.fillWidth: true
Layout.fillHeight: true
initialItem: menuComponent
}
ColumnLayout {
id: mainContent
Layout.alignment: Qt.AlignHCenter
Layout.minimumWidth: parent.width - Units.smallSpacing*2
Layout.maximumWidth: Layout.minimumWidth
Layout.fillWidth: false
Layout.fillHeight: true
visible: children.length > 0
}
Item {
Layout.minimumWidth: Units.smallSpacing
Layout.minimumHeight: Units.smallSpacing
}
Component {
id: menuComponent
ListView {
id: optionMenu
clip: true
model: actions
property int level: 0
interactive: contentHeight > height
footer: BasicListItem {
visible: level > 0
enabled: true
icon: "go-previous"
label: typeof i18n !== "undefined" ? i18n("Back") : "Back"
onClicked: pageRow.pop()
}
delegate: BasicListItem {
enabled: true
checked: modelData.checked
icon: modelData.iconName
label: modelData.text
Icon {
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
}
width: height
source: "go-next"
visible: modelData.children != undefined
}
onClicked: {
if (modelData.children) {
pageRow.push(menuComponent, {"model": modelData.children, "level": level + 1});
} else {
modelData.trigger();
pageRow.pop(pageRow.initialPage);
root.opened = false;
}
}
}
}
}
}
}
|