Warning, /network/neochat/src/qml/ExploreComponentMobile.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 ColumnLayout {
0014     id: root
0015     spacing: 0
0016 
0017     /**
0018      * @brief The connection for the current user.
0019      */
0020     required property NeoChatConnection connection
0021 
0022     /**
0023      * @brief Emitted when the text is changed in the search field.
0024      */
0025     signal textChanged(string newText)
0026 
0027     Kirigami.Separator {
0028         Layout.fillWidth: true
0029     }
0030     Kirigami.NavigationTabBar {
0031         id: exploreTabBar
0032         Layout.fillWidth: true
0033         actions: [
0034             Kirigami.Action {
0035                 id: infoAction
0036                 text: i18n("Search")
0037                 icon.name: "search"
0038                 onTriggered: {
0039                     if (explorePopup.visible && explorePopupLoader.sourceComponent == search) {
0040                         explorePopup.close();
0041                         exploreTabBar.currentIndex = -1;
0042                     } else if (explorePopup.visible && explorePopupLoader.sourceComponent != search) {
0043                         explorePopup.close();
0044                         explorePopup.open();
0045                     } else {
0046                         explorePopup.open();
0047                     }
0048                     explorePopupLoader.sourceComponent = search;
0049                 }
0050             },
0051             Kirigami.Action {
0052                 text: i18n("Explore rooms")
0053                 icon.name: "compass"
0054                 onTriggered: {
0055                     let dialog = pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/ExploreRoomsPage.qml", {
0056                         connection: root.connection
0057                     }, {
0058                         title: i18nc("@title", "Explore Rooms")
0059                     });
0060                     dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
0061                         RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, isJoined ? "" : "join");
0062                     });
0063                     exploreTabBar.currentIndex = -1;
0064                 }
0065             },
0066             Kirigami.Action {
0067                 text: i18n("Find your friends")
0068                 icon.name: "list-add-user"
0069                 onTriggered: {
0070                     pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/UserSearchPage.qml", {
0071                         connection: root.connection
0072                     }, {
0073                         title: i18nc("@title", "Find your friends")
0074                     });
0075                     exploreTabBar.currentIndex = -1;
0076                 }
0077             },
0078             Kirigami.Action {
0079                 text: i18n("Create New")
0080                 icon.name: "list-add"
0081                 onTriggered: {
0082                     if (explorePopup.visible && explorePopupLoader.sourceComponent == create) {
0083                         explorePopup.close();
0084                         exploreTabBar.currentIndex = -1;
0085                     } else if (explorePopup.visible && explorePopupLoader.sourceComponent != create) {
0086                         explorePopup.close();
0087                         explorePopup.open();
0088                     } else {
0089                         explorePopup.open();
0090                     }
0091                     explorePopupLoader.sourceComponent = create;
0092                 }
0093             }
0094         ]
0095     }
0096 
0097     QQC2.Popup {
0098         id: explorePopup
0099         parent: root
0100 
0101         y: -height + 1
0102         width: root.width
0103         leftPadding: Kirigami.Units.largeSpacing
0104         rightPadding: Kirigami.Units.largeSpacing
0105         bottomPadding: Kirigami.Units.largeSpacing
0106         topPadding: Kirigami.Units.largeSpacing
0107 
0108         closePolicy: QQC2.Popup.CloseOnEscape
0109 
0110         contentItem: Loader {
0111             id: explorePopupLoader
0112             sourceComponent: search
0113         }
0114 
0115         background: ColumnLayout {
0116             spacing: 0
0117             Kirigami.Separator {
0118                 Layout.fillWidth: true
0119             }
0120             Rectangle {
0121                 Layout.fillWidth: true
0122                 Layout.fillHeight: true
0123                 color: Kirigami.Theme.backgroundColor
0124             }
0125         }
0126 
0127         Component {
0128             id: search
0129             Kirigami.SearchField {
0130                 onTextChanged: root.textChanged(text)
0131             }
0132         }
0133         Component {
0134             id: create
0135             ColumnLayout {
0136                 spacing: 0
0137                 Delegates.RoundedItemDelegate {
0138                     Layout.fillWidth: true
0139                     action: Kirigami.Action {
0140                         text: i18n("Create a Room")
0141                         icon.name: "system-users-symbolic"
0142                         onTriggered: {
0143                             pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/CreateRoomDialog.qml", {
0144                                 connection: root.connection
0145                             }, {
0146                                 title: i18nc("@title", "Create a Room")
0147                             });
0148                             explorePopup.close();
0149                         }
0150                         shortcut: StandardKey.New
0151                     }
0152                 }
0153                 Delegates.RoundedItemDelegate {
0154                     Layout.fillWidth: true
0155                     action: Kirigami.Action {
0156                         text: i18n("Create a Space")
0157                         icon.name: "list-add"
0158                         onTriggered: {
0159                             pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/CreateRoomDialog.qml", {
0160                                 connection: root.connection,
0161                                 isSpace: true,
0162                                 title: i18nc("@title", "Create a Space")
0163                             }, {
0164                                 title: i18nc("@title", "Create a Space")
0165                             });
0166                             explorePopup.close();
0167                         }
0168                     }
0169                 }
0170             }
0171         }
0172     }
0173 }