Warning, /network/neochat/src/qml/CompletionMenu.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.de> 0002 // SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com> 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 import QtQuick 0006 import QtQuick.Layouts 0007 import QtQuick.Controls as QQC2 0008 import Qt.labs.qmlmodels 0009 0010 import org.kde.kirigami as Kirigami 0011 import org.kde.kirigamiaddons.delegates as Delegates 0012 import org.kde.kirigamiaddons.labs.components as KirigamiComponents 0013 0014 import org.kde.neochat 0015 0016 QQC2.Popup { 0017 id: root 0018 0019 required property NeoChatConnection connection 0020 required property var chatDocumentHandler 0021 0022 visible: completions.count > 0 0023 0024 onVisibleChanged: if (visible) root.open() 0025 0026 RoomListModel { 0027 id: roomListModel 0028 connection: root.connection 0029 } 0030 0031 Component.onCompleted: { 0032 chatDocumentHandler.completionModel.roomListModel = roomListModel; 0033 } 0034 0035 function incrementIndex() { 0036 completions.incrementCurrentIndex() 0037 } 0038 0039 function decrementIndex() { 0040 completions.decrementCurrentIndex() 0041 } 0042 0043 function complete() { 0044 root.chatDocumentHandler.complete(completions.currentIndex) 0045 } 0046 0047 leftPadding: 0 0048 rightPadding: 0 0049 topPadding: 0 0050 bottomPadding: 0 0051 0052 implicitHeight: Math.min(completions.contentHeight, Kirigami.Units.gridUnit * 10) 0053 0054 contentItem: ColumnLayout { 0055 spacing: 0 0056 Kirigami.Separator { 0057 Layout.fillWidth: true 0058 } 0059 QQC2.ScrollView { 0060 Layout.fillWidth: true 0061 Layout.preferredHeight: contentHeight 0062 Layout.maximumHeight: Kirigami.Units.gridUnit * 10 0063 0064 background: Rectangle { 0065 color: Kirigami.Theme.backgroundColor 0066 } 0067 0068 ListView { 0069 id: completions 0070 0071 model: root.chatDocumentHandler.completionModel 0072 currentIndex: 0 0073 keyNavigationWraps: true 0074 highlightMoveDuration: 100 0075 onCountChanged: currentIndex = 0 0076 delegate: Delegates.RoundedItemDelegate { 0077 id: completionDelegate 0078 0079 required property int index 0080 required property string displayName 0081 required property string subtitle 0082 required property string iconName 0083 0084 text: displayName 0085 0086 contentItem: RowLayout { 0087 KirigamiComponents.Avatar { 0088 visible: completionDelegate.iconName !== "invalid" 0089 Layout.preferredWidth: Kirigami.Units.iconSizes.medium 0090 Layout.preferredHeight: Kirigami.Units.iconSizes.medium 0091 source: completionDelegate.iconName === "invalid" ? "" : completionDelegate.iconName 0092 name: completionDelegate.text 0093 } 0094 Delegates.SubtitleContentItem { 0095 itemDelegate: completionDelegate 0096 labelItem.textFormat: Text.PlainText 0097 subtitle: completionDelegate.subtitle ?? "" 0098 subtitleItem.textFormat: Text.PlainText 0099 } 0100 } 0101 onClicked: root.chatDocumentHandler.complete(completionDelegate.index) 0102 } 0103 } 0104 } 0105 } 0106 0107 background: Rectangle { 0108 color: Kirigami.Theme.backgroundColor 0109 } 0110 }