Warning, /pim/merkuro/src/contacts/qml/Sidebar.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org> 0002 // SPDX-License-Identifier: LGPL-3.0-or-later 0003 0004 import QtQuick 2.15 0005 import QtQuick.Controls 2.15 as QQC2 0006 import QtQuick.Layouts 1.15 0007 import org.kde.kirigami 2.20 as Kirigami 0008 import org.kde.kirigamiaddons.delegates 1.0 as Delegates 0009 import org.kde.merkuro.contact 1.0 as Contact 0010 import org.kde.akonadi 1.0 as Akonadi 0011 import org.kde.merkuro.components 1.0 0012 import Qt.labs.qmlmodels 1.0 0013 import org.kde.kitemmodels 1.0 0014 0015 Kirigami.OverlayDrawer { 0016 id: root 0017 0018 signal collectionCheckChanged 0019 signal closeParentDrawer 0020 signal deleteCollection(int collectionId, var collectionDetails) 0021 0022 property Akonadi.AgentConfiguration agentConfiguration: Akonadi.AgentConfiguration {} 0023 0024 edge: Qt.application.layoutDirection === Qt.RightToLeft ? Qt.RightEdge : Qt.LeftEdge 0025 modal: !enabled || Kirigami.Settings.isMobile || (applicationWindow().width < Kirigami.Units.gridUnit * 50 && !collapsed) // Only modal when not collapsed, otherwise collapsed won't show. 0026 onModalChanged: drawerOpen = !modal; 0027 0028 z: modal ? Math.round(position * 10000000) : 100 0029 0030 drawerOpen: !Kirigami.Settings.isMobile && enabled 0031 0032 handleClosedIcon.source: modal ? null : "sidebar-expand-left" 0033 handleOpenIcon.source: modal ? null : "sidebar-collapse-left" 0034 handleVisible: modal && enabled 0035 0036 width: Kirigami.Units.gridUnit * 16 0037 Behavior on width { 0038 NumberAnimation { 0039 duration: Kirigami.Units.longDuration 0040 easing.type: Easing.InOutQuad 0041 } 0042 } 0043 0044 Kirigami.Theme.colorSet: Kirigami.Theme.View 0045 Kirigami.Theme.inherit: false 0046 0047 leftPadding: 0 0048 rightPadding: 0 0049 topPadding: 0 0050 bottomPadding: 0 0051 0052 contentItem: ColumnLayout { 0053 id: container 0054 0055 spacing: 0 0056 clip: true 0057 0058 QQC2.ToolBar { 0059 id: toolbar 0060 0061 Layout.fillWidth: true 0062 Layout.preferredHeight: pageStack.globalToolBar.preferredHeight 0063 0064 leftPadding: root.collapsed ? 0 : Kirigami.Units.smallSpacing 0065 rightPadding: root.collapsed ? Kirigami.Units.smallSpacing / 2 : Kirigami.Units.smallSpacing 0066 topPadding: 0 0067 bottomPadding: 0 0068 0069 contentItem: RowLayout { 0070 Kirigami.SearchField { 0071 Layout.fillWidth: true 0072 0073 opacity: root.collapsed ? 0 : 1 0074 onTextChanged: Contact.ContactManager.filteredContacts.setFilterFixedString(text) 0075 0076 Behavior on opacity { 0077 OpacityAnimator { 0078 duration: Kirigami.Units.longDuration 0079 easing.type: Easing.InOutQuad 0080 } 0081 } 0082 } 0083 } 0084 } 0085 0086 QQC2.ScrollView { 0087 Layout.fillWidth: true 0088 Layout.fillHeight: true 0089 0090 ListView { 0091 id: collectionList 0092 0093 activeFocusOnTab: true 0094 currentIndex: -1 0095 onActiveFocusChanged: if (currentIndex === -1 && activeFocus) { 0096 currentIndex = 0; 0097 } 0098 0099 header: Delegates.RoundedItemDelegate { 0100 id: collectionHeadingItem 0101 0102 hoverEnabled: false 0103 width: parent.width 0104 text: i18n("Contacts") 0105 0106 contentItem: RowLayout { 0107 Kirigami.Icon { 0108 implicitWidth: Kirigami.Units.iconSizes.smallMedium 0109 implicitHeight: Kirigami.Units.iconSizes.smallMedium 0110 source: "view-pim-contacts" 0111 isMask: true 0112 color: Kirigami.Theme.disabledTextColor 0113 } 0114 0115 Kirigami.Heading { 0116 level: 4 0117 text: collectionHeadingItem.text 0118 color: Kirigami.Theme.disabledTextColor 0119 Layout.fillWidth: true 0120 } 0121 } 0122 } 0123 0124 model: KDescendantsProxyModel { 0125 model: Contact.ContactManager.contactCollections 0126 } 0127 0128 delegate: DelegateChooser { 0129 role: 'kDescendantExpandable' 0130 0131 DelegateChoice { 0132 roleValue: true 0133 0134 Delegates.RoundedItemDelegate { 0135 id: collectionSourceItem 0136 0137 required property int index 0138 required property var decoration 0139 required property var model 0140 required property var collection 0141 required property int kDescendantLevel 0142 required property bool kDescendantExpanded 0143 required property int collectionId 0144 required property var checkState 0145 required property color collectionColor 0146 0147 topInset: 2 * Kirigami.Units.largeSpacing + Math.round(Kirigami.Units.smallSpacing / 2) 0148 topPadding: 2 * Kirigami.Units.largeSpacing + verticalPadding 0149 leftInset: Qt.application.layoutDirection !== Qt.RightToLeft ? (kDescendantLevel - 1) * padding * 2 + Kirigami.Units.smallSpacing : 0 0150 leftPadding: (Qt.application.layoutDirection !== Qt.RightToLeft ? (kDescendantLevel - 1) * padding * 2 + Math.round(Kirigami.Units.smallSpacing / 2) : 0) + Kirigami.Units.smallSpacing 0151 0152 rightInset: (Qt.application.layoutDirection === Qt.RightToLeft ? (kDescendantLevel - 1) * padding * 2 + horizontalPadding : 0) + Kirigami.Units.smallSpacing 0153 rightPadding: (Qt.application.layoutDirection === Qt.RightToLeft ? (kDescendantLevel - 1) * padding * 2 + horizontalPadding : 0) + Math.round(Kirigami.Units.smallSpacing * 2.5) 0154 0155 text: model.display 0156 highlighted: activeFocus 0157 0158 hoverEnabled: false 0159 Accessible.checkable: true 0160 Accessible.checked: collectionSourceItem.kDescendantExpanded 0161 0162 onClicked: collectionList.model.toggleChildren(collectionSourceItem.index) 0163 0164 contentItem: RowLayout { 0165 Kirigami.Icon { 0166 implicitWidth: Kirigami.Units.iconSizes.smallMedium 0167 implicitHeight: Kirigami.Units.iconSizes.smallMedium 0168 isMask: true 0169 source: collectionSourceItem.decoration 0170 color: Kirigami.Theme.disabledTextColor 0171 Layout.leftMargin: Math.round(Kirigami.Units.smallSpacing / 2) 0172 } 0173 0174 Kirigami.Heading { 0175 text: collectionSourceItem.text 0176 elide: Text.ElideRight 0177 color: Kirigami.Theme.disabledTextColor 0178 level: 4 0179 0180 Layout.fillWidth: true 0181 } 0182 0183 QQC2.BusyIndicator { 0184 id: loadingIndicator 0185 Layout.fillHeight: true 0186 padding: 0 0187 visible: false 0188 running: visible 0189 } 0190 0191 Kirigami.Icon { 0192 implicitWidth: Kirigami.Units.iconSizes.small 0193 implicitHeight: Kirigami.Units.iconSizes.small 0194 source: collectionSourceItem.kDescendantExpanded ? 'arrow-up' : 'arrow-down' 0195 isMask: true 0196 } 0197 0198 ColoredCheckbox { 0199 id: collectionCheckbox 0200 0201 visible: model.checkState != null 0202 color: collectionSourceItem.collectionColor ?? Kirigami.Theme.highlightedTextColor 0203 checked: model.checkState === 2 0204 onCheckedChanged: root.collectionCheckChanged() 0205 onClicked: { 0206 model.checkState = model.checkState === 0 ? 2 : 0 0207 root.collectionCheckChanged() 0208 } 0209 0210 Layout.alignment: Qt.AlignVCenter 0211 } 0212 } 0213 0214 Connections { 0215 target: root.agentConfiguration 0216 0217 function onAgentProgressChanged(agentData) { 0218 if (agentData.instanceId === collectionSourceItem.collection.resource && 0219 agentData.status === Akonadi.AgentConfiguration.Running) { 0220 0221 loadingIndicator.visible = true; 0222 } else if (agentData.instanceId === collectionSourceItem.collection.resource) { 0223 loadingIndicator.visible = false; 0224 } 0225 } 0226 } 0227 } 0228 } 0229 0230 DelegateChoice { 0231 roleValue: false 0232 0233 Delegates.RoundedItemDelegate { 0234 id: collectionItem 0235 0236 required property int index 0237 required property var decoration 0238 required property var model 0239 required property var collection 0240 required property int kDescendantLevel 0241 required property bool kDescendantExpanded 0242 required property int collectionId 0243 required property var checkState 0244 required property color collectionColor 0245 0246 text: model.display 0247 enabled: !root.drawerCollapsed 0248 highlighted: activeFocus 0249 0250 leftInset: Qt.application.layoutDirection !== Qt.RightToLeft ? Math.max(0, kDescendantLevel - 2) * padding * 2 + Kirigami.Units.smallSpacing : 0 0251 leftPadding: (Qt.application.layoutDirection !== Qt.RightToLeft ? Math.max(0, kDescendantLevel - 2) * padding * 2 + Math.round(Kirigami.Units.smallSpacing / 2) : 0) + Kirigami.Units.smallSpacing 0252 0253 rightInset: (Qt.application.layoutDirection === Qt.RightToLeft ? Math.max(0, kDescendantLevel - 2) * padding * 2 + horizontalPadding : 0) + Kirigami.Units.smallSpacing 0254 rightPadding: (Qt.application.layoutDirection === Qt.RightToLeft ? Math.max(0, kDescendantLevel - 2) * padding * 2 + horizontalPadding : 0) + Math.round(Kirigami.Units.smallSpacing * 2.5) 0255 0256 Accessible.checkable: true 0257 Accessible.checked: model.checkState === 2 0258 Accessible.onToggleAction: clicked() 0259 0260 contentItem: RowLayout { 0261 Kirigami.Icon { 0262 implicitWidth: Kirigami.Units.iconSizes.smallMedium 0263 implicitHeight: Kirigami.Units.iconSizes.smallMedium 0264 source: collectionItem.decoration 0265 Layout.leftMargin: Math.round(Kirigami.Units.smallSpacing / 2) 0266 } 0267 0268 QQC2.Label { 0269 text: collectionItem.text 0270 elide: Text.ElideRight 0271 Layout.fillWidth: true 0272 } 0273 0274 ColoredCheckbox { 0275 id: collectionCheckbox 0276 0277 Layout.alignment: Qt.AlignVCenter 0278 visible: model.checkState != null 0279 color: collectionItem.collectionColor 0280 checked: model.checkState === 2 0281 onCheckedChanged: root.collectionCheckChanged() 0282 activeFocusOnTab: false 0283 onClicked: { 0284 model.checkState = model.checkState === 0 ? 2 : 0 0285 root.collectionCheckChanged() 0286 } 0287 } 0288 } 0289 0290 onClicked: { 0291 collectionItem.model.checkState = collectionItem.checkState === 0 ? 2 : 0 0292 root.collectionCheckChanged() 0293 } 0294 } 0295 } 0296 } 0297 } 0298 } 0299 } 0300 }