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/JoinRoomPage.qml", {connection: root.connection}, {title: i18nc("@title", "Explore Rooms")}) 0056 dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => { 0057 if (isJoined) { 0058 RoomManager.enterRoom(root.connection.room(roomId)); 0059 } else { 0060 RoomManager.resolveResource(roomId.length > 0 ? roomId : alias, "join"); 0061 } 0062 }) 0063 exploreTabBar.currentIndex = -1; 0064 } 0065 }, 0066 Kirigami.Action { 0067 text: i18n("Start a Chat") 0068 icon.name: "list-add-user" 0069 onTriggered: { 0070 pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/StartChatPage.qml", {connection: root.connection}, {title: i18nc("@title", "Start a Chat")}) 0071 exploreTabBar.currentIndex = -1; 0072 } 0073 }, 0074 Kirigami.Action { 0075 text: i18n("Create New") 0076 icon.name: "list-add" 0077 onTriggered: { 0078 if (explorePopup.visible && explorePopupLoader.sourceComponent == create) { 0079 explorePopup.close(); 0080 exploreTabBar.currentIndex = -1; 0081 } else if (explorePopup.visible && explorePopupLoader.sourceComponent != create) { 0082 explorePopup.close(); 0083 explorePopup.open(); 0084 } else { 0085 explorePopup.open(); 0086 } 0087 explorePopupLoader.sourceComponent = create; 0088 } 0089 } 0090 ] 0091 } 0092 0093 QQC2.Popup { 0094 id: explorePopup 0095 parent: root 0096 0097 y: -height + 1 0098 width: root.width 0099 leftPadding: Kirigami.Units.largeSpacing 0100 rightPadding: Kirigami.Units.largeSpacing 0101 bottomPadding: Kirigami.Units.largeSpacing 0102 topPadding: Kirigami.Units.largeSpacing 0103 0104 closePolicy: QQC2.Popup.CloseOnEscape 0105 0106 contentItem: Loader { 0107 id: explorePopupLoader 0108 sourceComponent: search 0109 } 0110 0111 background: ColumnLayout { 0112 spacing: 0 0113 Kirigami.Separator { 0114 Layout.fillWidth: true 0115 } 0116 Rectangle { 0117 Layout.fillWidth: true 0118 Layout.fillHeight: true 0119 color: Kirigami.Theme.backgroundColor 0120 } 0121 } 0122 0123 Component { 0124 id: search 0125 Kirigami.SearchField { 0126 onTextChanged: root.textChanged(text) 0127 } 0128 } 0129 Component { 0130 id: create 0131 ColumnLayout { 0132 spacing: 0 0133 Delegates.RoundedItemDelegate { 0134 Layout.fillWidth: true 0135 action: Kirigami.Action { 0136 text: i18n("Create a Room") 0137 icon.name: "system-users-symbolic" 0138 onTriggered: { 0139 pageStack.pushDialogLayer("qrc:/org/kde/neochat/qml/CreateRoomDialog.qml", {connection: root.connection}, {title: i18nc("@title", "Create a Room")}) 0140 explorePopup.close() 0141 } 0142 shortcut: StandardKey.New 0143 } 0144 } 0145 Delegates.RoundedItemDelegate { 0146 Layout.fillWidth: true 0147 action: Kirigami.Action { 0148 text: i18n("Create a Space") 0149 icon.name: "list-add" 0150 onTriggered: { 0151 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")}) 0152 explorePopup.close() 0153 } 0154 } 0155 } 0156 } 0157 } 0158 } 0159 }