Changeset View
Changeset View
Standalone View
Standalone View
src/controls/ContextDrawer.qml
Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | 124 | anchors { | |||
---|---|---|---|---|---|
127 | margins: Units.largeSpacing | 127 | margins: Units.largeSpacing | ||
128 | } | 128 | } | ||
129 | elide: Text.ElideRight | 129 | elide: Text.ElideRight | ||
130 | level: 2 | 130 | level: 2 | ||
131 | text: root.title | 131 | text: root.title | ||
132 | } | 132 | } | ||
133 | } | 133 | } | ||
134 | delegate: BasicListItem { | 134 | delegate: BasicListItem { | ||
135 | id: listItem | ||||
136 | | ||||
137 | readonly property bool isSeparator: modelData.hasOwnProperty("separator") && modelData.separator | ||||
138 | | ||||
135 | checked: modelData.checked | 139 | checked: modelData.checked | ||
136 | icon: modelData.icon | 140 | icon: modelData.icon | ||
137 | supportsMouseEvents: true | 141 | supportsMouseEvents: true | ||
138 | separatorVisible: false | 142 | separatorVisible: false | ||
143 | reserveSpaceForIcon: !isSeparator | ||||
144 | reserveSpaceForLabel: !isSeparator | ||||
145 | | ||||
139 | label: model ? (model.tooltip ? model.tooltip : model.text) : (modelData.tooltip ? modelData.tooltip : modelData.text) | 146 | label: model ? (model.tooltip ? model.tooltip : model.text) : (modelData.tooltip ? modelData.tooltip : modelData.text) | ||
140 | enabled: model ? model.enabled : modelData.enabled | 147 | enabled: !isSeparator && (model ? model.enabled : modelData.enabled) | ||
141 | visible: model ? model.visible : modelData.visible | 148 | visible: model ? model.visible : modelData.visible | ||
142 | opacity: enabled ? 1.0 : 0.6 | 149 | opacity: enabled ? 1.0 : 0.6 | ||
150 | | ||||
151 | Separator { | ||||
152 | id: separatorAction | ||||
153 | | ||||
154 | visible: listItem.isSeparator | ||||
155 | Layout.fillWidth: true | ||||
156 | } | ||||
157 | | ||||
143 | onClicked: { | 158 | onClicked: { | ||
144 | root.drawerOpen = false; | 159 | root.drawerOpen = false; | ||
145 | if (modelData && modelData.trigger !== undefined) { | 160 | if (modelData && modelData.trigger !== undefined) { | ||
146 | modelData.trigger(); | 161 | modelData.trigger(); | ||
147 | // assume the model is a list of QAction or Action | 162 | // assume the model is a list of QAction or Action | ||
148 | } else if (menu.model.length > index) { | 163 | } else if (menu.model.length > index) { | ||
149 | menu.model[index].trigger(); | 164 | menu.model[index].trigger(); | ||
150 | } else { | 165 | } else { | ||
151 | console.warning("Don't know how to trigger the action") | 166 | console.warning("Don't know how to trigger the action") | ||
152 | } | 167 | } | ||
153 | } | 168 | } | ||
154 | } | 169 | } | ||
155 | } | 170 | } | ||
156 | } | 171 | } | ||
157 | } | 172 | } |