Changeset View
Changeset View
Standalone View
Standalone View
kcms/activities/qml/activitiesTab/ActivitiesView.qml
Show All 12 Lines | |||||
13 | * GNU General Public License for more details | 13 | * GNU General Public License for more details | ||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU General Public | 15 | * You should have received a copy of the GNU General Public | ||
16 | * License along with this program; if not, write to the | 16 | * License along with this program; if not, write to the | ||
17 | * Free Software Foundation, Inc., | 17 | * Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.0 | 21 | import QtQuick 2.5 | ||
22 | import org.kde.kquickcontrolsaddons 2.0 | 22 | import QtQuick.Controls 2.5 as QQC2 | ||
23 | import QtQuick.Controls 1.0 as QtControls | 23 | import QtQuick.Layouts 1.0 | ||
24 | 24 | | |||
25 | import org.kde.activities 0.1 as Activities | 25 | import org.kde.activities 0.1 as Activities | ||
26 | import org.kde.activities.settings 0.1 | 26 | import org.kde.activities.settings 0.1 | ||
27 | import org.kde.plasma.core 2.0 as PlasmaCore | 27 | import org.kde.kirigami 2.5 as Kirigami | ||
28 | 28 | | |||
29 | Item { | 29 | ColumnLayout { | ||
30 | id: root | 30 | id: root | ||
31 | 31 | | |||
32 | anchors.fill: parent | 32 | QQC2.ScrollView { | ||
33 | 33 | Layout.fillHeight: true | |||
34 | QtControls.Button { | 34 | Layout.fillWidth: true | ||
35 | id: buttonCreateActivity | 35 | Component.onCompleted: background.visible = true; | ||
36 | | ||||
37 | text: i18nd("kcm_activities5", "Create activity...") | | |||
38 | iconName: "list-add" | | |||
39 | | ||||
40 | anchors { | | |||
41 | top: parent.top | | |||
42 | left: parent.left | | |||
43 | } | | |||
44 | | ||||
45 | onClicked: ActivitySettings.newActivity(); | | |||
46 | | ||||
47 | enabled: !dialogCreateActivityLoader.itemVisible | | |||
48 | visible: ActivitySettings.newActivityAuthorized | | |||
49 | } | | |||
50 | | ||||
51 | Loader { | | |||
52 | id: dialogCreateActivityLoader | | |||
53 | | ||||
54 | property bool itemVisible: status == Loader.Ready && item.visible | | |||
55 | | ||||
56 | z: 1 | | |||
57 | | ||||
58 | anchors { | | |||
59 | top: buttonCreateActivity.bottom | | |||
60 | left: buttonCreateActivity.left | | |||
61 | } | | |||
62 | } | | |||
63 | | ||||
64 | QtControls.ScrollView { | | |||
65 | anchors { | | |||
66 | top: buttonCreateActivity.bottom | | |||
67 | topMargin: units.smallSpacing | | |||
68 | left: parent.left | | |||
69 | right: parent.right | | |||
70 | bottom: parent.bottom | | |||
71 | } | | |||
72 | | ||||
73 | enabled: !dialogCreateActivityLoader.itemVisible | | |||
74 | 36 | | |||
75 | ListView { | 37 | ListView { | ||
76 | id: activitiesList | 38 | id: activitiesList | ||
77 | width: parent.width | | |||
78 | // anchors.fill: parent | | |||
79 | 39 | | |||
80 | model: Activities.ActivityModel { | 40 | model: Activities.ActivityModel { | ||
81 | id: kactivities | 41 | id: kactivities | ||
82 | } | 42 | } | ||
83 | 43 | | |||
84 | SystemPalette { | 44 | delegate: Kirigami.SwipeListItem { | ||
85 | id: palette | 45 | hoverEnabled: true | ||
86 | colorGroup: SystemPalette.Active | | |||
87 | } | | |||
88 | | ||||
89 | /////////////////////////////////////////////////////////////////// | | |||
90 | delegate: Rectangle { | | |||
91 | width: parent.width | | |||
92 | | ||||
93 | height: units.iconSizes.medium + units.smallSpacing * 2 | | |||
94 | 46 | | |||
95 | color: (model.index % 2 == 0) ? palette.base : palette.alternateBase | 47 | contentItem: RowLayout { | ||
48 | id: row | ||||
96 | 49 | | |||
97 | Item { | 50 | Kirigami.Icon { | ||
98 | id: header | | |||
99 | | ||||
100 | anchors { | | |||
101 | fill: parent | | |||
102 | margins: units.smallSpacing | | |||
103 | } | | |||
104 | | ||||
105 | QIconItem { | | |||
106 | id: icon | 51 | id: icon | ||
107 | icon: model.icon | 52 | height: Kirigami.Units.iconSizes.medium | ||
108 | | ||||
109 | width: height | 53 | width: height | ||
110 | height: parent.height | 54 | source: model.icon | ||
111 | | ||||
112 | anchors { | | |||
113 | left: parent.left | | |||
114 | top: parent.top | | |||
115 | } | | |||
116 | } | 55 | } | ||
117 | 56 | | |||
118 | QtControls.Label { | 57 | QQC2.Label { | ||
58 | Layout.fillWidth: true | ||||
119 | text: model.name | 59 | text: model.name | ||
120 | | ||||
121 | anchors { | | |||
122 | left: icon.right | | |||
123 | right: buttons.left | | |||
124 | leftMargin: units.largeSpacing | | |||
125 | verticalCenter: icon.verticalCenter | | |||
126 | } | 60 | } | ||
127 | } | 61 | } | ||
128 | 62 | | |||
129 | Row { | 63 | actions: [ | ||
130 | id: buttons | 64 | Kirigami.Action { | ||
131 | 65 | icon.name: "configure" | |||
132 | spacing: units.smallSpacing | 66 | tooltip: i18nc("@info:tooltip", "Configure " + model.name + " activity...") | ||
ngraham: Maybe "Configure <activity name> activity..."? | |||||
133 | height: parent.height | 67 | onTriggered: ActivitySettings.configureActivity(model.id); | ||
134 | 68 | }, | |||
135 | anchors { | 69 | Kirigami.Action { | ||
136 | right: parent.right | | |||
137 | | ||||
138 | verticalCenter: parent.verticalCenter | | |||
139 | } | | |||
140 | | ||||
141 | QtControls.Button { | | |||
142 | id: buttonConfigure | | |||
143 | | ||||
144 | iconName: "configure" | | |||
145 | | ||||
146 | onClicked: ActivitySettings.configureActivity(model.id); | | |||
147 | } | | |||
148 | | ||||
149 | QtControls.Button { | | |||
150 | id: buttonDelete | | |||
151 | | ||||
152 | iconName: "edit-delete" | | |||
153 | | ||||
154 | onClicked: ActivitySettings.deleteActivity(model.id); | | |||
155 | | ||||
156 | visible: ActivitySettings.newActivityAuthorized | 70 | visible: ActivitySettings.newActivityAuthorized | ||
157 | | ||||
158 | // Disable the button when there's only one activity | | |||
159 | enabled: activitiesList.count > 1 | 71 | enabled: activitiesList.count > 1 | ||
72 | icon.name: "edit-delete" | ||||
73 | tooltip: i18nc("@info:tooltip", "Delete " + model.name + " activity") | ||||
ngraham: Maybe "Delete <activity name> activity"? | |||||
74 | onTriggered: ActivitySettings.deleteActivity(model.id); | ||||
160 | } | 75 | } | ||
161 | 76 | ] | |||
162 | visible: !dialogDeleteLoader.itemVisible | | |||
163 | } | | |||
164 | | ||||
165 | visible: !dialogConfigureLoader.itemVisible | | |||
166 | } | 77 | } | ||
167 | | ||||
168 | Loader { | | |||
169 | id: dialogConfigureLoader | | |||
170 | | ||||
171 | property bool itemVisible: status == Loader.Ready && item.visible | | |||
172 | | ||||
173 | anchors { | | |||
174 | left: parent.left | | |||
175 | top: parent.top | | |||
176 | } | 78 | } | ||
177 | } | 79 | } | ||
178 | 80 | | |||
179 | Loader { | 81 | QQC2.Button { | ||
180 | id: dialogDeleteLoader | 82 | id: buttonCreateActivity | ||
181 | 83 | visible: ActivitySettings.newActivityAuthorized | |||
182 | property bool itemVisible: status == Loader.Ready && item.visible | 84 | text: i18nd("kcm_activities5", "Create New...") | ||
ngraham: How about "Create New..." just to emphasize that a new one is being made | |||||
183 | 85 | icon.name: "list-add" | |||
184 | anchors { | 86 | onClicked: ActivitySettings.newActivity(); | ||
185 | left: parent.left | | |||
186 | top: header.bottom | | |||
187 | } | | |||
188 | } | | |||
189 | } | | |||
190 | /////////////////////////////////////////////////////////////////// | | |||
191 | } | | |||
192 | } | 87 | } | ||
193 | } | 88 | } |
Maybe "Configure <activity name> activity..."?