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

0001 // SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
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.kirigamiaddons.delegates as Delegates
0010 
0011 import org.kde.neochat
0012 
0013 RowLayout {
0014     id: root
0015 
0016     property var desiredWidth
0017     property bool collapsed: false
0018     required property NeoChatConnection connection
0019 
0020     property Kirigami.Action exploreAction: Kirigami.Action {
0021         text: i18n("Explore rooms")
0022         icon.name: "compass"
0023         onTriggered: {
0024             let dialog = pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/JoinRoomPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")})
0025             dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
0026                 if (isJoined) {
0027                     RoomManager.enterRoom(root.connection.room(roomId))
0028                 } else {
0029                     RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, "join")
0030                 }
0031             })
0032         }
0033     }
0034     property Kirigami.Action chatAction: Kirigami.Action {
0035         text: i18n("Start a Chat")
0036         icon.name: "list-add-user"
0037         onTriggered: pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/StartChatPage.qml", {connection: root.connection}, {title: i18nc("@title", "Start a Chat")})
0038     }
0039     property Kirigami.Action roomAction: Kirigami.Action {
0040         text: i18n("Create a Room")
0041         icon.name: "system-users-symbolic"
0042         onTriggered: {
0043             pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/CreateRoomDialog.qml", {connection: root.connection}, {title: i18nc("@title", "Create a Room")})
0044         }
0045         shortcut: StandardKey.New
0046     }
0047     property Kirigami.Action spaceAction: Kirigami.Action {
0048         text: i18n("Create a Space")
0049         icon.name: "list-add"
0050         onTriggered: {
0051             pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/CreateRoomDialog.qml", {connection: root.connection, isSpace: true, title: i18nc("@title", "Create a Space")}, {title: i18nc("@title", "Create a Space")})
0052         }
0053     }
0054 
0055     Kirigami.SearchField {
0056         Layout.topMargin: Kirigami.Units.smallSpacing
0057         Layout.bottomMargin: Kirigami.Units.smallSpacing
0058         Layout.fillWidth: true
0059         Layout.preferredWidth: root.desiredWidth ? root.desiredWidth - menuButton.width - root.spacing : -1
0060         visible: !root.collapsed
0061         onTextChanged: sortFilterRoomListModel.filterText = text
0062         KeyNavigation.tab: listView
0063     }
0064 
0065     QQC2.ToolButton {
0066         id: menuButton
0067         Accessible.role: Accessible.ButtonMenu
0068         display: QQC2.AbstractButton.IconOnly
0069         checkable: true
0070         action: Kirigami.Action {
0071             text: i18n("Create rooms and chats")
0072             icon.name: "irc-join-channel"
0073             onTriggered: {
0074                 if (Kirigami.isMobile) {
0075                     const menu = mobileMenu.createObject();
0076                     menu.open();
0077                 } else {
0078                     const menu = desktopMenu.createObject(menuButton);
0079                     menu.closed.connect(menuButton.toggle)
0080                     menu.open();
0081                 }
0082             }
0083         }
0084 
0085         QQC2.ToolTip {
0086             text: parent.text
0087         }
0088     }
0089 
0090     Component {
0091         id: desktopMenu
0092         QQC2.Menu {
0093             x: mirrored ? parent.width - width : 0
0094             y: parent ? parent.height : 0
0095 
0096             modal: true
0097             dim: false
0098 
0099             QQC2.MenuItem {
0100                 action: exploreAction
0101             }
0102             QQC2.MenuItem {
0103                 action: chatAction
0104             }
0105             QQC2.MenuItem {
0106                 action: roomAction
0107             }
0108             QQC2.MenuItem {
0109                 action: spaceAction
0110             }
0111         }
0112     }
0113     Component {
0114         id: mobileMenu
0115 
0116         Kirigami.OverlayDrawer {
0117             id: menuRoot
0118 
0119             edge: Qt.BottomEdge
0120             parent: applicationWindow().overlay
0121 
0122             leftPadding: 0
0123             rightPadding: 0
0124             bottomPadding: 0
0125             topPadding: 0
0126 
0127             ColumnLayout {
0128                 width: parent.width
0129                 spacing: 0
0130 
0131                 Kirigami.ListSectionHeader {
0132                     label: i18n("Create rooms and chats")
0133                 }
0134 
0135                 Delegates.RoundedItemDelegate {
0136                     action: exploreAction
0137                     onClicked: menuRoot.close()
0138                     Layout.fillWidth: true
0139                 }
0140 
0141                 Delegates.RoundedItemDelegate {
0142                     action: chatAction
0143                     onClicked: menuRoot.close()
0144                     Layout.fillWidth: true
0145                 }
0146 
0147                 Delegates.RoundedItemDelegate {
0148                     action: roomAction
0149                     onClicked: menuRoot.close()
0150                     Layout.fillWidth: true
0151                 }
0152 
0153                 Delegates.RoundedItemDelegate {
0154                     action: roomAction
0155                     onClicked: menuRoot.close()
0156                     Layout.fillWidth: true
0157                 }
0158             }
0159         }
0160     }
0161 }