Warning, /pim/kube/framework/qml/ConversationView.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> 0003 * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsystems.com> 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 2 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License along 0016 * with this program; if not, write to the Free Software Foundation, Inc., 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 */ 0019 0020 import QtQuick 2.9 0021 import QtQuick.Controls 2 0022 import QtQuick.Layouts 1.1 0023 import org.kube.framework 1.0 as Kube 0024 0025 import QtQml 2.2 as QtQml 0026 0027 0028 FocusScope { 0029 id: root 0030 0031 property alias model: listView.model 0032 property bool hideTrash: true; 0033 property bool hideNonTrash: false; 0034 property string searchString: "" 0035 property bool autoLoadImages: true 0036 0037 Kube.Listener { 0038 filter: Kube.Messages.searchString 0039 onMessageReceived: root.searchString = message.searchString 0040 } 0041 0042 Kube.Listener { 0043 filter: Kube.Messages.selectNextMessage 0044 onMessageReceived: { 0045 listView.incrementCurrentIndex() 0046 listView.forceActiveFocus() 0047 } 0048 } 0049 0050 Kube.Listener { 0051 filter: Kube.Messages.selectPreviousMessage 0052 onMessageReceived: { 0053 listView.decrementCurrentIndex() 0054 listView.forceActiveFocus() 0055 } 0056 } 0057 0058 Kube.Listener { 0059 filter: Kube.Messages.scrollConversationDown 0060 onMessageReceived: listView.scrollDown() 0061 } 0062 0063 Kube.Listener { 0064 filter: Kube.Messages.scrollConversationUp 0065 onMessageReceived: listView.scrollUp() 0066 } 0067 0068 Rectangle { 0069 anchors.fill: parent 0070 color: Kube.Colors.backgroundColor 0071 0072 Kube.ConversationListView { 0073 id: listView 0074 objectName: "listView" 0075 focus: true 0076 0077 anchors { 0078 top: parent.top 0079 left: parent.left 0080 right: parent.right 0081 } 0082 0083 //Shrink the listview if the content doesn't fill the full height, so the email appears on top instead of on the bottom. 0084 height: Math.min(contentHeight, parent.height) 0085 0086 Keys.onPressed: { 0087 //Not implemented as a shortcut because we want it only to apply if we have the focus 0088 if (event.text == "d" || event.key == Qt.Key_Delete) { 0089 Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": listView.currentItem.currentData.mail}) 0090 } else if (event.text == "r") { 0091 Kube.Fabric.postMessage(Kube.Messages.reply, {"mail": listView.currentItem.currentData.mail}) 0092 } 0093 } 0094 0095 0096 delegate: FocusScope { 0097 id: delegateRoot 0098 0099 property var currentData: model 0100 property bool isCurrentItem: false 0101 0102 focus: true 0103 activeFocusOnTab: false 0104 onActiveFocusChanged: { 0105 if (activeFocus && index) { 0106 listView.currentIndex = index 0107 } 0108 } 0109 0110 height: sheet.height + Kube.Units.gridUnit 0111 width: listView.width 0112 0113 NumberAnimation on opacity { 0114 id: fadeIn 0115 from: 0 0116 to: 1 0117 duration: 100 0118 } 0119 0120 Component.onCompleted: fadeIn.start() 0121 0122 MouseArea { 0123 anchors.fill: parent 0124 acceptedButtons: Qt.NoButton 0125 hoverEnabled: true 0126 onEntered: { 0127 delegateRoot.forceActiveFocus(Qt.MouseFocusReason) 0128 } 0129 } 0130 0131 MailViewer { 0132 id: sheet 0133 anchors.centerIn: parent 0134 width: parent.width - Kube.Units.largeSpacing * 2 0135 0136 mail: model.mail 0137 message: model.mimeMessage 0138 subject: model.subject 0139 sender: model.sender 0140 senderName: model.senderName 0141 to: model.to 0142 cc: model.cc 0143 bcc: model.bcc 0144 date: model.date 0145 unread: model.unread 0146 trash: model.trash 0147 draft: model.draft 0148 sent: model.sent 0149 busy: model.incomplete 0150 current: delegateRoot.isCurrentItem 0151 searchString: root.searchString 0152 autoLoadImages: root.autoLoadImages 0153 // Collapse all but the latest sent message by default 0154 collapsed: (listView.count > 1) && (index < (listView.count - 1)) && (draft || sent) 0155 0156 states: [ 0157 State { 0158 name: "inprogress"; when: model.status == Kube.MailListModel.InProgressStatus 0159 PropertyChanges { target: sheet; busyMessage: qsTr("Downloading message...") } 0160 }, 0161 State { 0162 name: "error"; when: model.status == Kube.MailListModel.ErrorStatus 0163 PropertyChanges { target: sheet; busyMessage: qsTr("Failed to download message...") } 0164 } 0165 ] 0166 } 0167 } 0168 0169 } 0170 } 0171 }