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