Changeset View
Changeset View
Standalone View
Standalone View
src/controls/ContextDrawer.qml
Show All 15 Lines | |||||
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.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
22 | import org.kde.kirigami 2.4 | 22 | import org.kde.kirigami 2.4 | ||
23 | 23 | | |||
24 | import "private" | ||||
24 | import "templates/private" | 25 | import "templates/private" | ||
25 | 26 | | |||
26 | /** | 27 | /** | ||
27 | * A drawer specialization that will show a list of actions that are | 28 | * A drawer specialization that will show a list of actions that are | ||
28 | * specific of the current page shown by the application | 29 | * specific of the current page shown by the application | ||
29 | * | 30 | * | ||
30 | * Example usage: | 31 | * Example usage: | ||
31 | * @code | 32 | * @code | ||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 127 | anchors { | |||
128 | right: parent.right | 129 | right: parent.right | ||
129 | margins: Units.largeSpacing | 130 | margins: Units.largeSpacing | ||
130 | } | 131 | } | ||
131 | elide: Text.ElideRight | 132 | elide: Text.ElideRight | ||
132 | level: 2 | 133 | level: 2 | ||
133 | text: root.title | 134 | text: root.title | ||
134 | } | 135 | } | ||
135 | } | 136 | } | ||
136 | delegate: BasicListItem { | 137 | delegate: Column { | ||
137 | id: listItem | 138 | width: parent.width | ||
138 | 139 | ContextDrawerActionItem { | |||
139 | readonly property bool isSeparator: modelData.hasOwnProperty("separator") && modelData.separator | 140 | width: parent.width | ||
140 | 141 | } | |||
141 | checked: modelData.checked | 142 | Repeater { | ||
142 | icon: modelData.icon | 143 | model: modelData.hasOwnProperty("expandible") && modelData.expandible ? modelData.children : null | ||
143 | supportsMouseEvents: true | 144 | delegate: ContextDrawerActionItem { | ||
144 | separatorVisible: false | 145 | width: parent.width | ||
145 | reserveSpaceForIcon: !isSeparator | 146 | leftPadding: Units.largeSpacing * 2 | ||
146 | reserveSpaceForLabel: !isSeparator | 147 | opacity: !root.collapsed | ||
147 | | ||||
148 | label: model ? (model.tooltip ? model.tooltip : model.text) : (modelData.tooltip ? modelData.tooltip : modelData.text) | | |||
149 | enabled: !isSeparator && (model ? model.enabled : modelData.enabled) | | |||
150 | visible: model ? model.visible : modelData.visible | | |||
151 | opacity: enabled ? 1.0 : 0.6 | | |||
152 | | ||||
153 | Separator { | | |||
154 | id: separatorAction | | |||
155 | | ||||
156 | visible: listItem.isSeparator | | |||
157 | Layout.fillWidth: true | | |||
158 | } | | |||
159 | | ||||
160 | onClicked: { | | |||
161 | root.drawerOpen = false; | | |||
162 | if (modelData && modelData.trigger !== undefined) { | | |||
163 | modelData.trigger(); | | |||
164 | // assume the model is a list of QAction or Action | | |||
165 | } else if (menu.model.length > index) { | | |||
166 | menu.model[index].trigger(); | | |||
167 | } else { | | |||
168 | console.warning("Don't know how to trigger the action") | | |||
169 | } | 148 | } | ||
170 | } | 149 | } | ||
171 | } | 150 | } | ||
172 | } | 151 | } | ||
173 | } | 152 | } | ||
174 | } | 153 | } |