Changeset View
Changeset View
Standalone View
Standalone View
src/styles/Material/SwipeListItem.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2010 Marco Martin <notmart@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Library General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU Library General Public License for more details | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Library General Public | ||||
15 | * License along with this program; if not, write to the | ||||
16 | * Free Software Foundation, Inc., | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | import QtQuick 2.5 | ||||
21 | import org.kde.kirigami 2.0 | ||||
22 | import "../../private" | ||||
23 | import "../../templates" as T | ||||
24 | | ||||
25 | /** | ||||
26 | * An item delegate Intended to support extra actions obtainable | ||||
27 | * by uncovering them by dragging away the item with the handle | ||||
28 | * This acts as a container for normal list items. | ||||
29 | * Any subclass of AbstractListItem can be assigned as the contentItem property. | ||||
30 | * @code | ||||
31 | * ListView { | ||||
32 | * model: myModel | ||||
33 | * delegate: SwipeListItem { | ||||
34 | * Label { | ||||
35 | * text: model.text | ||||
36 | * } | ||||
37 | * actions: [ | ||||
38 | * Action { | ||||
39 | * iconName: "document-decrypt" | ||||
40 | * onTriggered: print("Action 1 clicked") | ||||
41 | * }, | ||||
42 | * Action { | ||||
43 | * iconName: model.action2Icon | ||||
44 | * onTriggered: //do something | ||||
45 | * } | ||||
46 | * ] | ||||
47 | * } | ||||
48 | * | ||||
49 | * } | ||||
50 | * @endcode | ||||
51 | * | ||||
52 | * @inherit QtQuick.Item | ||||
53 | */ | ||||
54 | T.SwipeListItem { | ||||
55 | id: root | ||||
56 | | ||||
57 | onPressedChanged: { | ||||
58 | if (pressed) { | ||||
59 | clickAnim.running = true | ||||
60 | } | ||||
61 | } | ||||
62 | background: DefaultListItemBackground { | ||||
63 | clip: true | ||||
64 | //TODO: this will have to reuse QQC2.1 Ripple | ||||
65 | Rectangle { | ||||
66 | id: ripple | ||||
67 | anchors.centerIn: parent | ||||
68 | width: parent.width | ||||
69 | height: parent.width | ||||
70 | radius: width | ||||
71 | color: Qt.rgba(1,1,1,0.3) | ||||
72 | scale: 0 | ||||
73 | opacity: 1 | ||||
74 | ParallelAnimation { | ||||
75 | id: clickAnim | ||||
76 | ScaleAnimator { | ||||
77 | target: ripple | ||||
78 | from: 0 | ||||
79 | to: 1 | ||||
80 | duration: Units.longDuration | ||||
81 | } | ||||
82 | OpacityAnimator { | ||||
83 | target: ripple | ||||
84 | from: 0 | ||||
85 | to: 1 | ||||
86 | duration: Units.longDuration | ||||
87 | } | ||||
88 | } | ||||
89 | } | ||||
90 | } | ||||
91 | implicitHeight: contentItem.implicitHeight + Units.smallSpacing * 6 | ||||
92 | } |