From db6873c327f96fca5fa61256344e607e10d3532e Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Mon, 23 Jan 2017 11:47:19 +0100 Subject: enable maillistdrag --- components/package/contents/ui/MailListView.qml | 238 ++++++++++++---------- components/package/contents/ui/SingleMailView.qml | 4 +- 2 files changed, 134 insertions(+), 108 deletions(-) (limited to 'components/package/contents') diff --git a/components/package/contents/ui/MailListView.qml b/components/package/contents/ui/MailListView.qml index 0066ca6c..6ec86aee 100644 --- a/components/package/contents/ui/MailListView.qml +++ b/components/package/contents/ui/MailListView.qml @@ -119,138 +119,162 @@ Item { parentFolder: root.parentFolder } - delegate: Kirigami.AbstractListItem { - id: mailListDelegate + delegate: Item { + id: origin - width: scrollbar.visible ? listView.width - scrollbar.width : listView.width - height: Kirigami.Units.gridUnit * 4.5 + width: delegateRoot.width + height: delegateRoot.height - enabled: true - supportsMouseEvents: true - - checked: listView.currentIndex == index - onClicked: { - listView.currentIndex = model.index + QtQml.Binding { + target: root + property: "currentMail" + when: listView.currentIndex == index + value: model.domainObject + } + QtQml.Binding { + target: root + property: "isDraft" + when: listView.currentIndex == index + value: model.draft } - //Content Item { - width: parent.width - height: parent.height - - QtQml.Binding { - target: root - property: "currentMail" - when: listView.currentIndex == index - value: model.domainObject - } - QtQml.Binding { - target: root - property: "isDraft" - when: listView.currentIndex == index - value: model.draft + id: delegateRoot + + width: scrollbar.visible ? listView.width - scrollbar.width : listView.width + height: Kirigami.Units.gridUnit * 5 + + states: [ + State { + name: "dnd" + when: mouseArea.drag.active + + PropertyChanges {target: mouseArea; cursorShape: Qt.ClosedHandCursor} + PropertyChanges {target: delegateRoot; x: x; y:y} + PropertyChanges {target: delegateRoot; parent: root} + + PropertyChanges {target: delegateRoot; opacity: 0.7} + PropertyChanges {target: background; color: Kirigami.Theme.highlightColor} + PropertyChanges {target: subject; color: Kirigami.Theme.highlightedTextColor} + PropertyChanges {target: sender; color: Kirigami.Theme.highlightedTextColor} + PropertyChanges {target: date; color: Kirigami.Theme.highlightedTextColor} + PropertyChanges {target: threadCounter; color: Kirigami.Theme.highlightedTextColor} + }, + State { + name: "selected" + when: listView.currentIndex == index && !mouseArea.drag.active + + PropertyChanges {target: background; color: Kirigami.Theme.highlightColor} + PropertyChanges {target: subject; color: Kirigami.Theme.highlightedTextColor} + PropertyChanges {target: sender; color: Kirigami.Theme.highlightedTextColor} + PropertyChanges {target: date; color: Kirigami.Theme.highlightedTextColor} + PropertyChanges {target: threadCounter; color: Kirigami.Theme.highlightedTextColor} + }, + State { + name: "hovered" + when: mouseArea.containsMouse && !mouseArea.drag.active + + PropertyChanges {target: background; color: Kirigami.Theme.buttonHoverColor; opacity: 0.7} + PropertyChanges {target: subject; color: Kirigami.Theme.highlightedTextColor} + PropertyChanges {target: sender; color: Kirigami.Theme.highlightedTextColor} + PropertyChanges {target: date; color: Kirigami.Theme.highlightedTextColor} + PropertyChanges {target: threadCounter; color: Kirigami.Theme.highlightedTextColor} } + ] - //TODO implement bulk action -// CheckBox { -// id: checkBox -// -// anchors.verticalCenter: parent.verticalCenter -// -// visible: mailListDelegate.containsMouse == true || checked -// } + Drag.active: mouseArea.drag.active + Drag.hotSpot.x: Kirigami.Units.gridUnit * 2 + Drag.hotSpot.y: height / 2 - Column { - id: mainContent + MouseArea { + id: mouseArea - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - leftMargin: Kirigami.Units.largeSpacing - } + anchors.fill: parent - Text{ - text: model.subject - color: mailListDelegate.checked ? Kirigami.Theme.highlightedTextColor : model.unread ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor + hoverEnabled: true + drag.target: parent - maximumLineCount: 2 - width: mailListDelegate.width - Kirigami.Units.largeSpacing * 2 - unreadCounter.width - wrapMode: Text.Wrap - elide: Text.ElideRight - } - - Text { - width: mailListDelegate.width - Kirigami.Units.largeSpacing * 2 - unreadCounter.width - text: model.senderName - font.italic: true - color: mailListDelegate.checked ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor - elide: Text.ElideRight + onClicked: { + listView.currentIndex = index } } - Text { - anchors { - right: parent.right - bottom: parent.bottom - } - text: Qt.formatDateTime(model.date, "dd MMM yyyy") - font.italic: true - color: mailListDelegate.checked ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.disabledTextColor - font.pointSize: 9 + Rectangle { + id: background + + anchors.fill: parent - //visible: mailListDelegate.containsMouse == false + color: Kirigami.Theme.viewBackgroundColor + border.color: Kirigami.Theme.backgroundColor + border.width: 1 } - Text { - id: unreadCounter + Item { + id: content anchors { + top: parent.top + bottom: parent.bottom + left: parent.left right: parent.right + margins: Kirigami.Units.smallSpacing } - visible: model.threadSize > 1 + Column { + anchors { + verticalCenter: parent.verticalCenter + left: parent.left + leftMargin: Kirigami.Units.largeSpacing + } + + Text{ + id: subject + + text: model.subject + color: model.unread ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor + + maximumLineCount: 2 + width: content.width - Kirigami.Units.gridUnit * 3 + wrapMode: Text.WrapAnywhere + elide: Text.ElideRight + } + + Text { + id: sender + + text: model.senderName + font.italic: true + color: Kirigami.Theme.textColor + width: delegateRoot.width - Kirigami.Units.gridUnit * 3 + elide: Text.ElideRight + } + } - font.italic: true - text: model.threadSize - color: mailListDelegate.checked ? Kirigami.Theme.highlightedTextColor : model.unread ? "#1d99f3" : Kirigami.Theme.disabledTextColor - } + Text { + id: date -// Row { -// id: actionButtons -// -// anchors { -// right: parent.right -// bottom: parent.bottom -// } -// -// visible: mailListDelegate.containsMouse == true -// spacing: Kirigami.Units.smallSpacing -// -// Controls.ToolButton { -// iconName: "mail-mark-unread" -// enabled: mailController.markAsReadAction.enabled -// onClicked: { -// //mailController.markAsReadAction.execute() -// } -// } -// -// Controls.ToolButton { -// iconName: "mail-mark-important" -// enabled: mailController.markAsImportantAction.enabled -// onClicked: { -// //mailController.markAsImportantAction.execute() -// } -// } -// -// Controls.ToolButton { -// iconName: "edit-delete" -// enabled: mailController.moveToTrashAction.enabled -// onClicked: { -// //mailController.moveToTrashAction.execute() -// } -// } -// } + anchors { + right: parent.right + bottom: parent.bottom + } + text: Qt.formatDateTime(model.date, "dd MMM yyyy") + font.italic: true + color: Kirigami.Theme.disabledTextColor + font.pointSize: 9 + } + + Text { + id: threadCounter + + anchors { + right: parent.right + } + text: model.threadSize + color: model.unread ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor + visible: model.threadSize > 1 + } + } } } } diff --git a/components/package/contents/ui/SingleMailView.qml b/components/package/contents/ui/SingleMailView.qml index d7c3193c..0b70ddfe 100644 --- a/components/package/contents/ui/SingleMailView.qml +++ b/components/package/contents/ui/SingleMailView.qml @@ -27,11 +27,13 @@ import QtQml 2.2 as QtQml import org.kube.framework.domain 1.0 as KubeFramework import org.kube.framework.actions 1.0 as KubeAction -Item { +Rectangle { id: root property variant mail; + color: Kirigami.Theme.backgroundColor + ListView { id: listView anchors { -- cgit v1.2.3