summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-25 05:06:44 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-25 05:06:44 +0200
commita7163fd03a98d164ee572d187771be9d78ad44a9 (patch)
tree23d83745f843c5e2122c83ec1ddfeba92bfb529c
parentb1e49b5bad02f6dbab9578d2cdd0ad73b18e1c4a (diff)
downloadkube-a7163fd03a98d164ee572d187771be9d78ad44a9.tar.gz
kube-a7163fd03a98d164ee572d187771be9d78ad44a9.zip
Use the ListDelegate
-rw-r--r--components/kube/contents/ui/ComposerView.qml132
-rw-r--r--components/kube/contents/ui/LogView.qml2
-rw-r--r--framework/qml/ListDelegate.qml35
3 files changed, 68 insertions, 101 deletions
diff --git a/components/kube/contents/ui/ComposerView.qml b/components/kube/contents/ui/ComposerView.qml
index b295bf4a..89d78399 100644
--- a/components/kube/contents/ui/ComposerView.qml
+++ b/components/kube/contents/ui/ComposerView.qml
@@ -143,110 +143,64 @@ Kube.View {
143 showDrafts: true 143 showDrafts: true
144 } 144 }
145 145
146 delegate: Item { 146 delegate: Kube.ListDelegate {
147 property variant currentData: model 147 id: delegateRoot
148 148
149 width: delegateRoot.width 149 color: Kube.Colors.textColor
150 height: delegateRoot.height 150 border.width: 0
151 onClicked: listView.currentIndex = index
151 152
152 Item { 153 Item {
153 id: delegateRoot 154 id: content
154 155
155 property variant mail : model.domainObject 156 anchors {
156 157 fill: parent
157 width: listView.width 158 margins: Kube.Units.smallSpacing
158 height: Kube.Units.gridUnit * 3
159
160 states: [
161 State {
162 name: "selected"
163 when: listView.currentIndex == index
164
165 PropertyChanges {target: background; color: Kube.Colors.highlightColor}
166 PropertyChanges {target: subject; color: Kube.Colors.highlightedTextColor}
167 },
168 State {
169 name: "hovered"
170 when: ( mouseArea.containsMouse || buttons.containsMouse )
171
172 PropertyChanges {target: background; color: Kube.Colors.highlightColor; opacity: 0.6}
173 PropertyChanges {target: subject; color: Kube.Colors.highlightedTextColor}
174 PropertyChanges {target: date; visible: false}
175 PropertyChanges {target: buttons; visible: true}
176 }
177 ]
178
179 MouseArea {
180 id: mouseArea
181 anchors.fill: parent
182 hoverEnabled: true
183 onClicked: listView.currentIndex = index
184 } 159 }
185 160
186 Rectangle { 161 Kube.Label{
187 id: background 162 width: content.width - Kube.Units.largeSpacing * 2
188 anchors.fill: parent 163 text: model.subject
189 color: Kube.Colors.textColor 164 color: Kube.Colors.highlightedTextColor
165 maximumLineCount: 2
166 wrapMode: Text.WrapAnywhere
167 elide: Text.ElideRight
190 } 168 }
191 169
192 Item { 170 Kube.Label {
193 id: content
194
195 anchors { 171 anchors {
196 top: parent.top
197 bottom: parent.bottom
198 left: parent.left
199 right: parent.right 172 right: parent.right
200 margins: Kube.Units.smallSpacing 173 bottom: parent.bottom
201 }
202
203
204 Kube.Label{
205 id: subject
206 width: content.width - Kube.Units.largeSpacing * 2
207 text: model.subject
208 color: Kube.Colors.highlightedTextColor
209 maximumLineCount: 2
210 wrapMode: Text.WrapAnywhere
211 elide: Text.ElideRight
212 }
213
214 Kube.Label {
215 id: date
216
217 anchors {
218 right: parent.right
219 bottom: parent.bottom
220 }
221 text: Qt.formatDateTime(model.date, "dd MMM yyyy")
222 font.italic: true
223 color: Kube.Colors.disabledTextColor
224 font.pointSize: 9
225 } 174 }
175 text: Qt.formatDateTime(model.date, "dd MMM yyyy")
176 font.italic: true
177 color: Kube.Colors.disabledTextColor
178 font.pointSize: 9
179 visible: !delegateRoot.hovered
226 } 180 }
227 Row { 181 }
228 id: buttons 182 Row {
183 id: buttons
229 184
230 property bool containsMouse: deleteButton.hovered 185 property bool containsMouse: deleteButton.hovered
231 186
232 anchors { 187 anchors {
233 right: parent.right 188 right: parent.right
234 bottom: parent.bottom 189 bottom: parent.bottom
235 margins: Kube.Units.smallSpacing 190 margins: Kube.Units.smallSpacing
236 } 191 }
237 192
238 visible: false 193 visible: delegateRoot.hovered
239 spacing: Kube.Units.smallSpacing 194 spacing: Kube.Units.smallSpacing
240 opacity: 0.7 195 opacity: 0.7
241 196
242 Kube.IconButton { 197 Kube.IconButton {
243 id: deleteButton 198 id: deleteButton
244 activeFocusOnTab: true 199 activeFocusOnTab: true
245 iconName: Kube.Icons.moveToTrash 200 iconName: Kube.Icons.moveToTrash
246 visible: enabled 201 visible: enabled
247 enabled: !!model.mail 202 enabled: !!model.mail
248 onClicked: Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": model.mail}) 203 onClicked: Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": model.mail})
249 }
250 } 204 }
251 } 205 }
252 } 206 }
diff --git a/components/kube/contents/ui/LogView.qml b/components/kube/contents/ui/LogView.qml
index b71d3692..98d92ccd 100644
--- a/components/kube/contents/ui/LogView.qml
+++ b/components/kube/contents/ui/LogView.qml
@@ -55,6 +55,8 @@ Controls.SplitView {
55 details.timestamp = currentItem.currentData.timestamp 55 details.timestamp = currentItem.currentData.timestamp
56 } 56 }
57 delegate: Kube.ListDelegate { 57 delegate: Kube.ListDelegate {
58 border.color: Kube.Colors.buttonColor
59 border.width: 1
58 Kube.Label { 60 Kube.Label {
59 id: description 61 id: description
60 anchors { 62 anchors {
diff --git a/framework/qml/ListDelegate.qml b/framework/qml/ListDelegate.qml
index 3c63ccbe..002027d6 100644
--- a/framework/qml/ListDelegate.qml
+++ b/framework/qml/ListDelegate.qml
@@ -19,23 +19,34 @@
19 19
20import QtQuick 2.7 20import QtQuick 2.7
21import org.kube.framework 1.0 as Kube 21import org.kube.framework 1.0 as Kube
22import QtQuick.Templates 2.0 as T
22 23
23Rectangle { 24T.ItemDelegate {
24 id: root 25 id: root
25 property variant currentData: model 26 property variant currentData: model
26 property var listView: root.parent 27 property alias color: background.color
27 default property alias contentItem: root.children 28 property alias border: background.border
28 29
29 height: Kube.Units.gridUnit * 3 30 height: Kube.Units.gridUnit * 3
30 width: listView.width 31 width: root.ListView.view.width
32 hoverEnabled: true
31 33
32 border.color: Kube.Colors.buttonColor 34 background: Rectangle {
33 border.width: 1 35 id: background
34 color: listView.currentIndex == root.index ? Kube.Colors.highlightColor : Kube.Colors.viewBackgroundColor 36 border.color: Kube.Colors.buttonColor
35 37 border.width: 1
36 MouseArea { 38 color: Kube.Colors.viewBackgroundColor
37 id: mouseArea 39 Rectangle {
38 anchors.fill: parent 40 anchors.fill: parent
39 onClicked: listView.currentIndex = root.index 41 visible: root.ListView.isCurrentItem
42 color: Kube.Colors.highlightColor
43 }
44 Rectangle {
45 anchors.fill: parent
46 visible: root.hovered || root.activeFocus
47 border.color: Kube.Colors.focusedButtonColor
48 border.width: 2
49 color: "transparent"
50 }
40 } 51 }
41} 52}