Warning, /pim/merkuro/src/mail/qml/mailboxselector/MailBoxList.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org> 0003 // SPDX-License-Identifier: LGPL-2.0-or-later 0004 0005 import QtQuick 2.15 0006 import QtQuick.Controls 2.15 as QQC2 0007 import QtQuick.Layouts 1.15 0008 0009 import Qt.labs.qmlmodels 1.0 0010 0011 import org.kde.kirigami 2.15 as Kirigami 0012 import org.kde.akonadi 1.0 as Akonadi 0013 import org.kde.kirigamiaddons.delegates 1.0 as Delegates 0014 import org.kde.kirigamiaddons.treeview 1.0 as Tree 0015 import org.kde.kitemmodels 1.0 0016 import org.kde.merkuro.mail 1.0 0017 import '../actions' 0018 0019 ListView { 0020 id: mailList 0021 0022 model: KDescendantsProxyModel { 0023 id: foldersModel 0024 model: MailManager.foldersModel 0025 } 0026 0027 onModelChanged: currentIndex = -1 0028 0029 required property var collectionId 0030 required property string name 0031 required property string resourceIdentifier 0032 property MailItemMenu mailActionsPopup: MailItemMenu { 0033 collectionId: mailList.collectionId 0034 name: mailList.name 0035 resourceIdentifier: mailList.resourceIdentifier 0036 } 0037 0038 signal folderChosen() 0039 0040 delegate: DelegateChooser { 0041 role: 'kDescendantExpandable' 0042 0043 DelegateChoice { 0044 roleValue: true 0045 0046 Delegates.RoundedTreeDelegate { 0047 id: categoryHeader 0048 0049 required property string displayName 0050 0051 text: displayName 0052 0053 contentItem: RowLayout { 0054 Kirigami.Icon { 0055 implicitWidth: Kirigami.Units.iconSizes.smallMedium 0056 implicitHeight: Kirigami.Units.iconSizes.smallMedium 0057 isMask: true 0058 source: "folder-symbolic" 0059 } 0060 0061 QQC2.Label { 0062 color: Kirigami.Theme.textColor 0063 font.weight: Font.DemiBold 0064 text: categoryHeader.displayName 0065 Layout.fillWidth: true 0066 } 0067 } 0068 0069 MouseArea { 0070 anchors.fill: parent 0071 acceptedButtons: Qt.LeftButton | Qt.RightButton 0072 onClicked: mouse => { 0073 if (mouse.button === Qt.LeftButton) { 0074 mailList.model.toggleChildren(index); 0075 } 0076 if (mouse.button === Qt.RightButton) { 0077 mailList.collectionId = foldersModel.mapToSource(foldersModel.index(index, 0)); 0078 mailList.name = categoryHeader.displayName; 0079 mailList.resourceIdentifier = MailManager.resourceIdentifier(mailList.collectionId); 0080 0081 mailActionsPopup.popup() 0082 } 0083 } 0084 } 0085 } 0086 } 0087 0088 DelegateChoice { 0089 roleValue: false 0090 0091 Delegates.RoundedTreeDelegate { 0092 id: controlRoot 0093 0094 required property string displayName 0095 required property var collection 0096 required property var model 0097 0098 property bool chosen: false 0099 0100 text: displayName 0101 0102 Connections { 0103 target: mailList 0104 0105 function onFolderChosen() { 0106 if (controlRoot.chosen) { 0107 controlRoot.chosen = false; 0108 controlRoot.highlighted = true; 0109 } else { 0110 controlRoot.highlighted = false; 0111 } 0112 } 0113 } 0114 0115 property bool showSelected: (controlRoot.pressed === true || (controlRoot.highlighted === true && applicationWindow().wideScreen)) 0116 0117 contentItem: RowLayout { 0118 Kirigami.Icon { 0119 Layout.alignment: Qt.AlignVCenter 0120 source: model.decoration 0121 Layout.preferredHeight: Kirigami.Units.iconSizes.small 0122 Layout.preferredWidth: Layout.preferredHeight 0123 } 0124 0125 QQC2.Label { 0126 leftPadding: controlRoot.mirrored ? (controlRoot.indicator ? controlRoot.indicator.width : 0) + controlRoot.spacing : 0 0127 rightPadding: !controlRoot.mirrored ? (controlRoot.indicator ? controlRoot.indicator.width : 0) + controlRoot.spacing : 0 0128 0129 text: controlRoot.text 0130 font: controlRoot.font 0131 color: Kirigami.Theme.textColor 0132 elide: Text.ElideRight 0133 visible: controlRoot.text 0134 horizontalAlignment: Text.AlignLeft 0135 verticalAlignment: Text.AlignVCenter 0136 Layout.alignment: Qt.AlignLeft 0137 Layout.fillWidth: true 0138 } 0139 0140 QQC2.Label { 0141 property int unreadCount: MailCollectionHelper.unreadCount(controlRoot.collection) 0142 0143 text: unreadCount > 0 ? unreadCount : '' 0144 padding: Kirigami.Units.smallSpacing 0145 color: Kirigami.Theme.textColor 0146 font: Kirigami.Theme.smallFont 0147 Layout.minimumWidth: height 0148 horizontalAlignment: Text.AlignHCenter 0149 background: Rectangle { 0150 visible: parent.unreadCount > 0 0151 Kirigami.Theme.colorSet: Kirigami.Theme.Button 0152 color: Kirigami.Theme.disabledTextColor 0153 opacity: 0.3 0154 radius: height / 2 0155 } 0156 } 0157 } 0158 0159 MouseArea { 0160 anchors.fill: parent 0161 acceptedButtons: Qt.LeftButton | Qt.RightButton 0162 onClicked: mouse => { 0163 if (mouse.button === Qt.LeftButton) { 0164 controlRoot.model.checkState = controlRoot.model.checkState === 0 ? 2 : 0 0165 MailManager.loadMailCollection(foldersModel.mapToSource(foldersModel.index(controlRoot.model.index, 0))); 0166 0167 controlRoot.chosen = true; 0168 mailList.folderChosen(); 0169 } 0170 if (mouse.button === Qt.RightButton) { 0171 mailList.collectionId = foldersModel.mapToSource(foldersModel.index(controlRoot.model.index, 0)); 0172 mailList.name = controlRoot.displayName; 0173 mailList.resourceIdentifier = MailManager.resourceIdentifier(mailList.collectionId); 0174 0175 mailActionsPopup.popup(); 0176 } 0177 } 0178 } 0179 } 0180 } 0181 } 0182 }