Changeset View
Changeset View
Standalone View
Standalone View
src/controls/GlobalDrawer.qml
Show All 12 Lines | |||||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.1 | 20 | import QtQuick 2.1 | ||
21 | import QtQuick.Controls 1.4 as Controls | 21 | import QtQuick.Controls 2.0 as QQC2 | ||
22 | import QtQuick.Layouts 1.2 | 22 | import QtQuick.Layouts 1.2 | ||
23 | import QtGraphicalEffects 1.0 | 23 | import QtGraphicalEffects 1.0 | ||
24 | import org.kde.kirigami 1.0 | 24 | import org.kde.kirigami 2.0 | ||
25 | 25 | | |||
26 | import "private" | 26 | import "private" | ||
27 | import "templates/private" | ||||
27 | 28 | | |||
28 | /** | 29 | /** | ||
29 | * A drawer specialization intended for the global actions of the application | 30 | * A drawer specialization intended for the global actions of the application | ||
30 | * valid regardless of the application state (think about the menubar | 31 | * valid regardless of the application state (think about the menubar | ||
31 | * of a desktop application). | 32 | * of a desktop application). | ||
32 | * | 33 | * | ||
33 | * Example usage: | 34 | * Example usage: | ||
34 | * @code | 35 | * @code | ||
35 | * import org.kde.kirigami 1.0 as Kirigami | 36 | * import org.kde.kirigami 2.0 as Kirigami | ||
36 | * | 37 | * | ||
37 | * Kirigami.ApplicationWindow { | 38 | * Kirigami.ApplicationWindow { | ||
38 | * [...] | 39 | * [...] | ||
39 | * globalDrawer: Kirigami.GlobalDrawer { | 40 | * globalDrawer: Kirigami.GlobalDrawer { | ||
40 | * actions: [ | 41 | * actions: [ | ||
41 | * Kirigami.Action { | 42 | * Kirigami.Action { | ||
42 | * text: "View" | 43 | * text: "View" | ||
43 | * iconName: "view-list-icons" | 44 | * iconName: "view-list-icons" | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 67 | OverlayDrawer { | |||
90 | 91 | | |||
91 | /** | 92 | /** | ||
92 | * actions: list<Action> | 93 | * actions: list<Action> | ||
93 | * The list of actions can be nested having a tree structure. | 94 | * The list of actions can be nested having a tree structure. | ||
94 | * A tree depth bigger than 2 is discouraged. | 95 | * A tree depth bigger than 2 is discouraged. | ||
95 | * | 96 | * | ||
96 | * Example usage: | 97 | * Example usage: | ||
97 | * @code | 98 | * @code | ||
98 | * import org.kde.kirigami 1.0 as Kirigami | 99 | * import org.kde.kirigami 2.0 as Kirigami | ||
99 | * | 100 | * | ||
100 | * Kirigami.ApplicationWindow { | 101 | * Kirigami.ApplicationWindow { | ||
101 | * [...] | 102 | * [...] | ||
102 | * globalDrawer: Kirigami.GlobalDrawer { | 103 | * globalDrawer: Kirigami.GlobalDrawer { | ||
103 | * actions: [ | 104 | * actions: [ | ||
104 | * Kirigami.Action { | 105 | * Kirigami.Action { | ||
105 | * text: "View" | 106 | * text: "View" | ||
106 | * iconName: "view-list-icons" | 107 | * iconName: "view-list-icons" | ||
Show All 22 Lines | |||||
129 | 130 | | |||
130 | /** | 131 | /** | ||
131 | * content: list<Item> default property | 132 | * content: list<Item> default property | ||
132 | * Any random Item can be instantiated inside the drawer and | 133 | * Any random Item can be instantiated inside the drawer and | ||
133 | * will be displayed underneath the actions list. | 134 | * will be displayed underneath the actions list. | ||
134 | * | 135 | * | ||
135 | * Example usage: | 136 | * Example usage: | ||
136 | * @code | 137 | * @code | ||
137 | * import org.kde.kirigami 1.0 as Kirigami | 138 | * import org.kde.kirigami 2.0 as Kirigami | ||
138 | * | 139 | * | ||
139 | * Kirigami.ApplicationWindow { | 140 | * Kirigami.ApplicationWindow { | ||
140 | * [...] | 141 | * [...] | ||
141 | * globalDrawer: Kirigami.GlobalDrawer { | 142 | * globalDrawer: Kirigami.GlobalDrawer { | ||
142 | * actions: [...] | 143 | * actions: [...] | ||
143 | * Button { | 144 | * Button { | ||
144 | * text: "Button" | 145 | * text: "Button" | ||
145 | * onClicked: //do stuff | 146 | * onClicked: //do stuff | ||
146 | * } | 147 | * } | ||
147 | * } | 148 | * } | ||
148 | * [...] | 149 | * [...] | ||
149 | * } | 150 | * } | ||
150 | * @endcode | 151 | * @endcode | ||
151 | */ | 152 | */ | ||
152 | default property alias content: mainContent.data | 153 | default property alias content: mainContent.data | ||
153 | 154 | | |||
154 | /** | 155 | /** | ||
155 | * topContent: list<Item> default property | 156 | * topContent: list<Item> default property | ||
156 | * Items that will be instantiated inside the drawer and | 157 | * Items that will be instantiated inside the drawer and | ||
157 | * will be displayed on top of the actions list. | 158 | * will be displayed on top of the actions list. | ||
158 | * | 159 | * | ||
159 | * Example usage: | 160 | * Example usage: | ||
160 | * @code | 161 | * @code | ||
161 | * import org.kde.kirigami 1.0 as Kirigami | 162 | * import org.kde.kirigami 2.0 as Kirigami | ||
162 | * | 163 | * | ||
163 | * Kirigami.ApplicationWindow { | 164 | * Kirigami.ApplicationWindow { | ||
164 | * [...] | 165 | * [...] | ||
165 | * globalDrawer: Kirigami.GlobalDrawer { | 166 | * globalDrawer: Kirigami.GlobalDrawer { | ||
166 | * actions: [...] | 167 | * actions: [...] | ||
167 | * topContent: [Button { | 168 | * topContent: [Button { | ||
168 | * text: "Button" | 169 | * text: "Button" | ||
169 | * onClicked: //do stuff | 170 | * onClicked: //do stuff | ||
Show All 26 Lines | |||||
196 | signal bannerClicked() | 197 | signal bannerClicked() | ||
197 | 198 | | |||
198 | /** | 199 | /** | ||
199 | * Reverts the menu back to its initial state | 200 | * Reverts the menu back to its initial state | ||
200 | */ | 201 | */ | ||
201 | function resetMenu() { | 202 | function resetMenu() { | ||
202 | stackView.pop(stackView.initialItem); | 203 | stackView.pop(stackView.initialItem); | ||
203 | if (root.modal) { | 204 | if (root.modal) { | ||
204 | root.opened = false; | 205 | root.drawerOpen = false; | ||
205 | } | 206 | } | ||
206 | } | 207 | } | ||
207 | 208 | | |||
208 | contentItem: Controls.ScrollView { | 209 | contentItem: ScrollView { | ||
209 | id: scrollView | 210 | id: scrollView | ||
210 | anchors.fill: parent | 211 | anchors.fill: parent | ||
211 | implicitWidth: Math.min (Units.gridUnit * 20, root.parent.width * 0.8) | 212 | implicitWidth: Math.min (Units.gridUnit * 20, root.parent.width * 0.8) | ||
212 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | 213 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | ||
213 | Flickable { | 214 | Flickable { | ||
214 | id: mainFlickable | 215 | id: mainFlickable | ||
215 | contentWidth: width | 216 | contentWidth: width | ||
216 | contentHeight: mainColumn.Layout.minimumHeight | 217 | contentHeight: mainColumn.Layout.minimumHeight | ||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 301 | ColumnLayout { | |||
308 | Layout.fillWidth: true | 309 | Layout.fillWidth: true | ||
309 | Layout.fillHeight: true | 310 | Layout.fillHeight: true | ||
310 | //NOTE: why this? just Layout.fillWidth: true doesn't seem sufficient | 311 | //NOTE: why this? just Layout.fillWidth: true doesn't seem sufficient | ||
311 | //as items are added only after this column creation | 312 | //as items are added only after this column creation | ||
312 | Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding | 313 | Layout.minimumWidth: parent.width - root.leftPadding - root.rightPadding | ||
313 | visible: children.length > 0 && childrenRect.height > 0 | 314 | visible: children.length > 0 && childrenRect.height > 0 | ||
314 | } | 315 | } | ||
315 | 316 | | |||
316 | Controls.StackView { | 317 | QQC2.StackView { | ||
317 | id: stackView | 318 | id: stackView | ||
318 | Layout.fillWidth: true | 319 | Layout.fillWidth: true | ||
319 | Layout.minimumHeight: currentItem ? currentItem.implicitHeight : 0 | 320 | Layout.minimumHeight: currentItem ? currentItem.implicitHeight : 0 | ||
320 | Layout.maximumHeight: Layout.minimumHeight | 321 | Layout.maximumHeight: Layout.minimumHeight | ||
321 | initialItem: menuComponent | 322 | initialItem: menuComponent | ||
322 | } | 323 | } | ||
323 | Item { | 324 | Item { | ||
324 | Layout.fillWidth: true | 325 | Layout.fillWidth: true | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 370 | delegate: BasicListItem { | |||
373 | icon: modelData.iconName | 374 | icon: modelData.iconName | ||
374 | label: modelData.text | 375 | label: modelData.text | ||
375 | separatorVisible: false | 376 | separatorVisible: false | ||
376 | visible: model ? model.visible || model.visible===undefined : modelData.visible | 377 | visible: model ? model.visible || model.visible===undefined : modelData.visible | ||
377 | enabled: model ? model.enabled : modelData.enabled | 378 | enabled: model ? model.enabled : modelData.enabled | ||
378 | opacity: enabled ? 1.0 : 0.3 | 379 | opacity: enabled ? 1.0 : 0.3 | ||
379 | Icon { | 380 | Icon { | ||
380 | anchors { | 381 | anchors { | ||
381 | verticalCenter: parent.verticalCenter | 382 | verticalCenter: contentItem.verticalCenter | ||
382 | right: parent.right | 383 | right: contentItem.right | ||
383 | } | 384 | } | ||
384 | height: Units.iconSizes.smallMedium | 385 | height: Units.iconSizes.smallMedium | ||
385 | selected: listItem.checked || listItem.pressed | 386 | selected: listItem.checked || listItem.pressed | ||
386 | width: height | 387 | width: height | ||
387 | source: "go-next" | 388 | source: "go-next" | ||
388 | visible: modelData.children!==undefined && modelData.children.length > 0 | 389 | visible: modelData.children!==undefined && modelData.children.length > 0 | ||
389 | } | 390 | } | ||
390 | 391 | | |||
Show All 18 Lines |