Warning, /pim/merkuro/src/contacts/applet/package/contents/ui/ContactsPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <car@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0003 0004 import QtQuick 2.15 0005 import QtQml 2.15 0006 import QtQuick.Layouts 1.15 0007 0008 import org.kde.kirigami as Kirigami 0009 import org.kde.plasma.core 2.0 as PlasmaCore 0010 import org.kde.plasma.extras 2.0 as PlasmaExtras 0011 import org.kde.plasma.components 3.0 as PlasmaComponents3 0012 import org.kde.merkuro.contact 1.0 0013 import org.kde.kitemmodels 1.0 0014 0015 PlasmaComponents3.ScrollView { 0016 id: scrollView 0017 anchors.fill: parent 0018 property string title: i18n("Contacts") 0019 0020 property var header: PlasmaExtras.PlasmoidHeading { 0021 focus: true 0022 RowLayout { 0023 width: parent.width 0024 PlasmaExtras.SearchField { 0025 id: searchField 0026 Layout.fillWidth: true 0027 onTextChanged: contactsList.model.setFilterFixedString(text) 0028 } 0029 } 0030 } 0031 0032 Keys.onPressed: { 0033 function goToCurrent() { 0034 contactsList.positionViewAtIndex(contactsList.currentIndex, ListView.Contain); 0035 if (contactsList.currentIndex != -1) { 0036 contactsList.currentItem.forceActiveFocus(); 0037 } 0038 } 0039 if (event.modifiers & Qt.ControlModifier && event.key == Qt.Key_F) { 0040 toolbar.searchField.forceActiveFocus(); 0041 toolbar.searchField.selectAll(); 0042 event.accepted = true; 0043 } else if (event.key == Qt.Key_Down) { 0044 contactsList.incrementCurrentIndex(); 0045 goToCurrent() 0046 event.accepted = true; 0047 } else if (event.key == Qt.Key_Up) { 0048 if (contactsList.currentIndex == 0) { 0049 contactsList.currentIndex = -1; 0050 searchField.forceActiveFocus(); 0051 searchField.selectAll(); 0052 } else { 0053 contactsList.decrementCurrentIndex(); 0054 goToCurrent(); 0055 } 0056 event.accepted = true; 0057 } 0058 } 0059 0060 0061 // HACK: workaround for https://bugreports.qt.io/browse/QTBUG-83890 0062 PlasmaComponents3.ScrollBar.horizontal.policy: PlasmaComponents3.ScrollBar.AlwaysOff 0063 0064 contentWidth: availableWidth - contentItem.leftMargin - contentItem.rightMargin 0065 0066 contentItem: ListView { 0067 id: contactsList 0068 model: KSortFilterProxyModel { 0069 filterCaseSensitivity: Qt.CaseInsensitive 0070 sourceModel: ContactsModel {} 0071 } 0072 boundsBehavior: Flickable.StopAtBounds 0073 topMargin: PlasmaCore.Units.smallSpacing * 2 0074 bottomMargin: PlasmaCore.Units.smallSpacing * 2 0075 leftMargin: PlasmaCore.Units.smallSpacing * 2 0076 rightMargin: PlasmaCore.Units.smallSpacing * 2 0077 spacing: PlasmaCore.Units.smallSpacing 0078 activeFocusOnTab: true 0079 0080 section.property: "display" 0081 section.criteria: ViewSection.FirstCharacter 0082 section.delegate: PlasmaExtras.Heading {level: 4; text: section} 0083 highlight: PlasmaExtras.Highlight { } 0084 highlightMoveDuration: 0 0085 highlightResizeDuration: 0 0086 focus: true 0087 delegate: ContactListItem { 0088 width: contactsList.width - contactsList.leftMargin - contactsList.rightMargin 0089 height: Kirigami.Units.gridUnit * 2 0090 name: model && model.display 0091 avatarIcon: model && model.decoration 0092 onClicked: stack.push(Qt.resolvedUrl('./ContactPage.qml'), { 0093 itemId: model.itemId, 0094 }) 0095 Binding { 0096 target: contactsList; when: hovered 0097 property: "currentIndex"; value: index 0098 restoreMode: Binding.RestoreBinding 0099 } 0100 } 0101 } 0102 }