diff options
Diffstat (limited to 'prototype_2016/third_party/fluid/controls/NavigationDrawer.qml')
-rw-r--r-- | prototype_2016/third_party/fluid/controls/NavigationDrawer.qml | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/prototype_2016/third_party/fluid/controls/NavigationDrawer.qml b/prototype_2016/third_party/fluid/controls/NavigationDrawer.qml new file mode 100644 index 0000000..36d3547 --- /dev/null +++ b/prototype_2016/third_party/fluid/controls/NavigationDrawer.qml | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | * This file is part of Fluid. | ||
3 | * | ||
4 | * Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> | ||
5 | * | ||
6 | * $BEGIN_LICENSE:MPL2$ | ||
7 | * | ||
8 | * This Source Code Form is subject to the terms of the Mozilla Public | ||
9 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
11 | * | ||
12 | * $END_LICENSE$ | ||
13 | */ | ||
14 | |||
15 | import QtQuick 2.0 | ||
16 | import QtQuick.Layouts 1.0 | ||
17 | import QtQuick.Controls 2.0 | ||
18 | import QtQml 2.2 | ||
19 | import Fluid.Core 1.0 | ||
20 | import Fluid.Controls 1.0 | ||
21 | |||
22 | /*! | ||
23 | \qmltype NavigationDrawer | ||
24 | \inqmlmodule Fluid.Controls | ||
25 | \ingroup fluidcontrols | ||
26 | |||
27 | \brief The navigation drawer slides in from the left and is a common pattern in apps. | ||
28 | |||
29 | \code | ||
30 | import QtQuick.Window 2.2 | ||
31 | import Fluid.Controls 2.0 as FluidControls | ||
32 | |||
33 | Window { | ||
34 | id: window | ||
35 | width: 400 | ||
36 | height: 400 | ||
37 | visible: true | ||
38 | |||
39 | Button { | ||
40 | text: "Open" | ||
41 | onClicked: drawer.open() | ||
42 | } | ||
43 | |||
44 | FluidControls.NavigationDrawer { | ||
45 | topContent: [ | ||
46 | Button { | ||
47 | text: "Push me" | ||
48 | onClicked: console.log("Pushed") | ||
49 | } | ||
50 | ] | ||
51 | |||
52 | actions: [ | ||
53 | Action { | ||
54 | text: "Action 1" | ||
55 | }, | ||
56 | Action { | ||
57 | text: "Action 1" | ||
58 | } | ||
59 | ] | ||
60 | } | ||
61 | } | ||
62 | \endcode | ||
63 | */ | ||
64 | |||
65 | Drawer { | ||
66 | id: drawer | ||
67 | |||
68 | /*! | ||
69 | \qmlproperty list<Item> topContent | ||
70 | |||
71 | The items added to this list will be displayed on top of the | ||
72 | actions list. | ||
73 | |||
74 | \code | ||
75 | import QtQuick.Window 2.2 | ||
76 | import Fluid.Controls 2.0 as FluidControls | ||
77 | |||
78 | Window { | ||
79 | id: window | ||
80 | width: 400 | ||
81 | height: 400 | ||
82 | visible: true | ||
83 | |||
84 | Button { | ||
85 | text: "Open" | ||
86 | onClicked: drawer.open() | ||
87 | } | ||
88 | |||
89 | FluidControls.NavigationDrawer { | ||
90 | topContent: [ | ||
91 | Button { | ||
92 | text: "Push me" | ||
93 | onClicked: console.log("Pushed") | ||
94 | } | ||
95 | ] | ||
96 | } | ||
97 | } | ||
98 | \endcode | ||
99 | */ | ||
100 | property alias topContent: topContent.data | ||
101 | |||
102 | /*! | ||
103 | \qmlproperty list<QtObject> actions | ||
104 | |||
105 | List of actions to be displayed by the drawer. | ||
106 | |||
107 | \code | ||
108 | import QtQuick.Window 2.2 | ||
109 | import Fluid.Controls 2.0 as FluidControls | ||
110 | |||
111 | Window { | ||
112 | id: window | ||
113 | width: 400 | ||
114 | height: 400 | ||
115 | visible: true | ||
116 | |||
117 | Button { | ||
118 | text: "Open" | ||
119 | onClicked: drawer.open() | ||
120 | } | ||
121 | |||
122 | FluidControls.NavigationDrawer { | ||
123 | actions: [ | ||
124 | Action { | ||
125 | text: "Action 1" | ||
126 | }, | ||
127 | Action { | ||
128 | text: "Action 1" | ||
129 | } | ||
130 | ] | ||
131 | } | ||
132 | } | ||
133 | \endcode | ||
134 | */ | ||
135 | property list<QtObject> actions | ||
136 | |||
137 | width: { | ||
138 | switch (Device.formFactor) { | ||
139 | case Device.Phone: | ||
140 | return 280 | ||
141 | case Device.Tablet: | ||
142 | return 320 | ||
143 | default: | ||
144 | break | ||
145 | } | ||
146 | return 56 * 4 | ||
147 | } | ||
148 | height: ApplicationWindow.height | ||
149 | |||
150 | padding: 0 | ||
151 | |||
152 | Pane { | ||
153 | id: pane | ||
154 | |||
155 | anchors.fill: parent | ||
156 | padding: 0 | ||
157 | |||
158 | ColumnLayout { | ||
159 | anchors.fill: parent | ||
160 | spacing: 0 | ||
161 | |||
162 | ColumnLayout { | ||
163 | id: topContent | ||
164 | |||
165 | height: childrenRect.height + 2 * drawer.padding | ||
166 | |||
167 | spacing: 0 | ||
168 | visible: children.length > 0 | ||
169 | |||
170 | Layout.margins: drawer.padding | ||
171 | Layout.fillWidth: true | ||
172 | } | ||
173 | |||
174 | ListView { | ||
175 | currentIndex: -1 | ||
176 | spacing: 0 | ||
177 | |||
178 | model: drawer.actions | ||
179 | |||
180 | delegate: ListItem { | ||
181 | iconName: modelData.iconName | ||
182 | text: modelData.text | ||
183 | onClicked: modelData.triggered(drawer) | ||
184 | } | ||
185 | |||
186 | visible: count > 0 | ||
187 | |||
188 | Layout.fillWidth: true | ||
189 | Layout.fillHeight: true | ||
190 | |||
191 | ScrollBar.vertical: ScrollBar {} | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | } | ||