Changeset View
Changeset View
Standalone View
Standalone View
src/controls/templates/SwipeListItem.qml
Show First 20 Lines • Show All 232 Lines • ▼ Show 20 Line(s) | 232 | if (listItem.actions.length === 0) { | |||
---|---|---|---|---|---|
233 | return null; | 233 | return null; | ||
234 | } else { | 234 | } else { | ||
235 | return listItem.actions[0].text !== undefined && | 235 | return listItem.actions[0].text !== undefined && | ||
236 | listItem.actions[0].trigger !== undefined ? | 236 | listItem.actions[0].trigger !== undefined ? | ||
237 | listItem.actions : | 237 | listItem.actions : | ||
238 | listItem.actions[0]; | 238 | listItem.actions[0]; | ||
239 | } | 239 | } | ||
240 | } | 240 | } | ||
241 | delegate: Icon { | 241 | delegate: Controls.ToolButton { | ||
242 | height: actionsLayout.height | 242 | anchors.verticalCenter: parent.verticalCenter | ||
243 | width: height | 243 | icon.name: modelData.iconName !== "" ? modelData.iconName : undefined | ||
244 | source: modelData.iconName !== "" ? modelData.iconName : modelData.iconSource | 244 | icon.source: modelData.iconSource !== "" ? modelData.iconSource : undefined | ||
245 | enabled: (modelData && modelData.enabled !== undefined) ? modelData.enabled : true; | 245 | enabled: (modelData && modelData.enabled !== undefined) ? modelData.enabled : true; | ||
246 | visible: (modelData && modelData.visible !== undefined) ? modelData.visible : true; | 246 | visible: (modelData && modelData.visible !== undefined) ? modelData.visible : true; | ||
247 | onVisibleChanged: { | 247 | onVisibleChanged: { | ||
248 | if (visible) { | 248 | if (visible) { | ||
249 | actionsLayout.visibleActions++; | 249 | actionsLayout.visibleActions++; | ||
250 | } else { | 250 | } else { | ||
251 | actionsLayout.visibleActions--; | 251 | actionsLayout.visibleActions--; | ||
252 | } | 252 | } | ||
253 | } | 253 | } | ||
254 | Component.onCompleted: { | 254 | Component.onCompleted: { | ||
255 | if (visible) { | 255 | if (visible) { | ||
256 | actionsLayout.visibleActions++; | 256 | actionsLayout.visibleActions++; | ||
257 | } | 257 | } | ||
258 | } | 258 | } | ||
259 | Component.onDestruction: { | 259 | Component.onDestruction: { | ||
260 | if (visible) { | 260 | if (visible) { | ||
261 | actionsLayout.visibleActions--; | 261 | actionsLayout.visibleActions--; | ||
262 | } | 262 | } | ||
263 | } | 263 | } | ||
264 | MouseArea { | 264 | hoverEnabled: Settings.tabletMode ? undefined : true | ||
apol: This undefined will just warn on tablet mode. I'd remove it, do we need to specify it? A… | |||||
265 | id: actionMouse | 265 | Controls.ToolTip.delay: 1000 | ||
apol: Should move these values to Units, can be done in a separate patch. | |||||
ngraham: Sure, will do that after this lands. | |||||
266 | anchors { | 266 | Controls.ToolTip.timeout: 5000 | ||
267 | fill: parent; | 267 | Controls.ToolTip.visible: listItem.visible && (Settings.tabletMode ? pressed : hovered) && Controls.ToolTip.text.length > 0 | ||
268 | margins: Settings.tabletMode ? -Units.smallSpacing : 0; | 268 | Controls.ToolTip.text: modelData.tooltip || modelData.text | ||
269 | } | 269 | | ||
270 | enabled: (modelData && modelData.enabled !== undefined) ? modelData.enabled : true; | | |||
271 | hoverEnabled: !Settings.tabletMode | | |||
272 | onClicked: { | 270 | onClicked: { | ||
273 | if (modelData && modelData.trigger !== undefined) { | 271 | if (modelData && modelData.trigger !== undefined) { | ||
274 | modelData.trigger(); | 272 | modelData.trigger(); | ||
275 | } | 273 | } | ||
276 | positionAnimation.from = background.x; | 274 | positionAnimation.from = background.x; | ||
277 | positionAnimation.to = 0; | 275 | positionAnimation.to = 0; | ||
278 | positionAnimation.running = true; | 276 | positionAnimation.running = true; | ||
279 | } | 277 | } | ||
280 | Controls.ToolTip.delay: 1000 | | |||
281 | Controls.ToolTip.timeout: 5000 | | |||
282 | Controls.ToolTip.visible: listItem.visible && (Settings.tabletMode ? actionMouse.pressed : actionMouse.containsMouse) && Controls.ToolTip.text.length > 0 | | |||
283 | Controls.ToolTip.text: modelData.tooltip || modelData.text | | |||
284 | } | | |||
285 | } | 278 | } | ||
286 | } | 279 | } | ||
287 | } | 280 | } | ||
288 | } | 281 | } | ||
289 | 282 | | |||
290 | MouseArea { | 283 | MouseArea { | ||
291 | id: handleMouse | 284 | id: handleMouse | ||
292 | parent: listItem.background | 285 | parent: listItem.background | ||
▲ Show 20 Lines • Show All 156 Lines • Show Last 20 Lines |
This undefined will just warn on tablet mode. I'd remove it, do we need to specify it? A ToolButton should already behave properly.