Warning, /network/neochat/src/qml/QuickSwitcher.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 import QtQuick
0005 import QtQuick.Controls as QQC2
0006 import QtQuick.Layouts
0007 
0008 import org.kde.kirigami as Kirigami
0009 import org.kde.kitemmodels
0010 
0011 import org.kde.neochat
0012 
0013 QQC2.Dialog {
0014     id: root
0015 
0016     required property NeoChatConnection connection
0017 
0018     parent: applicationWindow().overlay
0019     width: Math.min(700, parent.width)
0020     height: 400
0021 
0022     leftPadding: 0
0023     rightPadding: 0
0024     bottomPadding: 1
0025     topPadding: 0
0026 
0027     anchors.centerIn: applicationWindow().overlay
0028 
0029     Shortcut {
0030         sequence: "Ctrl+K"
0031         onActivated: root.open()
0032     }
0033 
0034     onVisibleChanged: {
0035         if (!visible) {
0036             return;
0037         }
0038         searchField.forceActiveFocus();
0039         searchField.text = "";
0040         roomList.currentIndex = 0;
0041     }
0042 
0043     header: Kirigami.SearchField {
0044         id: searchField
0045         Keys.onDownPressed: {
0046             roomList.forceActiveFocus();
0047             if (roomList.currentIndex < roomList.count - 1) {
0048                 roomList.currentIndex++;
0049             } else {
0050                 roomList.currentIndex = 0;
0051             }
0052         }
0053         Keys.onUpPressed: {
0054             if (roomList.currentIndex === 0) {
0055                 roomList.currentIndex = roomList.count - 1;
0056             } else {
0057                 roomList.currentIndex--;
0058             }
0059         }
0060         Keys.onEnterPressed: {
0061             RoomManager.resolveResource(roomList.currentItem.currentRoom.id);
0062             root.close();
0063         }
0064         Keys.onReturnPressed: {
0065             RoomManager.resolveResource(roomList.currentItem.currentRoom.id);
0066             root.close();
0067         }
0068         focusSequence: ""
0069     }
0070 
0071     QQC2.ScrollView {
0072         anchors.fill: parent
0073         clip: true
0074 
0075         Keys.forwardTo: searchField
0076 
0077         ListView {
0078             id: roomList
0079 
0080             currentIndex: 0
0081             highlightMoveDuration: 200
0082             Keys.forwardTo: searchField
0083             keyNavigationEnabled: true
0084             model: SortFilterRoomListModel {
0085                 filterText: searchField.text
0086                 sourceModel: RoomListModel {
0087                     id: roomListModel
0088                     connection: root.connection
0089                 }
0090             }
0091 
0092             delegate: RoomDelegate {
0093                 filterText: searchField.text
0094                 connection: root.connection
0095                 onSelected: root.close()
0096             }
0097         }
0098     }
0099 }