Warning, /plasma-mobile/raven/src/contents/ui/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.kitemmodels 1.0 0013 import org.kde.raven 1.0 0014 0015 ListView { 0016 id: mailList 0017 0018 model: KDescendantsProxyModel { 0019 id: foldersModel 0020 model: MailManager.foldersModel 0021 } 0022 0023 onModelChanged: currentIndex = -1 0024 0025 signal folderChosen() 0026 0027 delegate: DelegateChooser { 0028 role: 'kDescendantExpandable' 0029 0030 DelegateChoice { 0031 roleValue: true 0032 0033 ColumnLayout { 0034 spacing: 0 0035 width: ListView.view.width 0036 0037 Item { 0038 Layout.topMargin: Kirigami.Units.largeSpacing 0039 visible: (model.kDescendantLevel === 1) && (model.index !== 0) 0040 } 0041 0042 QQC2.ItemDelegate { 0043 id: categoryHeader 0044 Layout.fillWidth: true 0045 topPadding: Kirigami.Units.largeSpacing 0046 bottomPadding: Kirigami.Units.largeSpacing 0047 leftPadding: Kirigami.Units.largeSpacing * (model.kDescendantLevel) 0048 0049 property string displayText: model.display 0050 0051 onClicked: mailList.model.toggleChildren(index) 0052 0053 contentItem: RowLayout { 0054 Kirigami.Icon { 0055 Layout.alignment: Qt.AlignVCenter 0056 visible: model.kDescendantLevel > 1 0057 source: "folder-symbolic" 0058 Layout.preferredHeight: Kirigami.Units.iconSizes.small 0059 Layout.preferredWidth: Layout.preferredHeight 0060 } 0061 0062 QQC2.Label { 0063 Layout.fillWidth: true 0064 0065 color: Kirigami.Theme.disabledTextColor 0066 text: categoryHeader.displayText 0067 font.weight: Font.DemiBold 0068 elide: Text.ElideRight 0069 } 0070 0071 Kirigami.Icon { 0072 implicitWidth: Kirigami.Units.iconSizes.small 0073 implicitHeight: Kirigami.Units.iconSizes.small 0074 source: model.kDescendantExpanded ? 'arrow-up' : 'arrow-down' 0075 } 0076 } 0077 } 0078 } 0079 } 0080 0081 DelegateChoice { 0082 roleValue: false 0083 0084 QQC2.ItemDelegate { 0085 id: controlRoot 0086 text: model.display 0087 width: ListView.view.width 0088 padding: Kirigami.Units.largeSpacing 0089 leftPadding: Kirigami.Units.largeSpacing * model.kDescendantLevel 0090 0091 property bool chosen: false 0092 0093 Connections { 0094 target: mailList 0095 0096 function onFolderChosen() { 0097 if (controlRoot.chosen) { 0098 controlRoot.chosen = false; 0099 controlRoot.highlighted = true; 0100 } else { 0101 controlRoot.highlighted = false; 0102 } 0103 } 0104 } 0105 0106 property bool showSelected: (controlRoot.pressed || (controlRoot.highlighted && applicationWindow().isWidescreen)) 0107 0108 background: Rectangle { 0109 color: Qt.rgba(Kirigami.Theme.highlightColor.r, Kirigami.Theme.highlightColor.g, Kirigami.Theme.highlightColor.b, controlRoot.showSelected ? 0.5 : hoverHandler.hovered ? 0.2 : 0) 0110 0111 // indicator rectangle 0112 Rectangle { 0113 anchors.left: parent.left 0114 anchors.top: parent.top 0115 anchors.topMargin: 1 0116 anchors.bottom: parent.bottom 0117 anchors.bottomMargin: 1 0118 0119 width: 4 0120 visible: controlRoot.highlighted 0121 color: Kirigami.Theme.highlightColor 0122 } 0123 0124 HoverHandler { 0125 id: hoverHandler 0126 // disable hover input on mobile because touchscreens trigger hover feedback and do not "unhover" in Qt 0127 enabled: !Kirigami.Settings.isMobile 0128 } 0129 } 0130 0131 contentItem: RowLayout { 0132 spacing: Kirigami.Units.smallSpacing 0133 0134 Kirigami.Icon { 0135 Layout.alignment: Qt.AlignVCenter 0136 source: model.decoration 0137 Layout.preferredHeight: Kirigami.Units.iconSizes.small 0138 Layout.preferredWidth: Layout.preferredHeight 0139 } 0140 0141 QQC2.Label { 0142 leftPadding: controlRoot.mirrored ? (controlRoot.indicator ? controlRoot.indicator.width : 0) + controlRoot.spacing : 0 0143 rightPadding: !controlRoot.mirrored ? (controlRoot.indicator ? controlRoot.indicator.width : 0) + controlRoot.spacing : 0 0144 0145 text: controlRoot.text 0146 font: controlRoot.font 0147 color: Kirigami.Theme.textColor 0148 elide: Text.ElideRight 0149 visible: controlRoot.text 0150 horizontalAlignment: Text.AlignLeft 0151 verticalAlignment: Text.AlignVCenter 0152 Layout.alignment: Qt.AlignLeft 0153 Layout.fillWidth: true 0154 } 0155 } 0156 0157 onClicked: { 0158 model.checkState = model.checkState === 0 ? 2 : 0 0159 MailManager.loadMailCollection(foldersModel.mapToSource(foldersModel.index(model.index, 0))); 0160 0161 controlRoot.chosen = true; 0162 mailList.folderChosen(); 0163 0164 // push list page if in narrow mode 0165 if (!applicationWindow().isWidescreen) { 0166 applicationWindow().pageStack.push(applicationWindow().getPage("FolderView")); 0167 } 0168 } 0169 } 0170 } 0171 } 0172 }