Warning, /network/neochat/src/qml/ExploreRoomsPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
0002 // SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
0003 // SPDX-License-Identifier: GPL-3.0-only
0004
0005 import QtQuick
0006 import QtQuick.Controls as QQC2
0007 import QtQuick.Layouts
0008 import Qt.labs.qmlmodels
0009
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.kirigamiaddons.delegates as Delegates
0012
0013 import org.kde.neochat
0014
0015 /**
0016 * @brief Component for finding rooms for the public list.
0017 *
0018 * This component is based on a SearchPage, adding the functionality to select or
0019 * enter a server in the header, as well as the ability to manually type a room in
0020 * if the public room search cannot find it.
0021 *
0022 * @sa SearchPage
0023 */
0024 SearchPage {
0025 id: root
0026
0027 /**
0028 * @brief The connection for the current local user.
0029 */
0030 required property NeoChatConnection connection
0031
0032 /**
0033 * @brief Whether results should only includes spaces.
0034 */
0035 property bool showOnlySpaces: false
0036
0037 /**
0038 * @brief Signal emitted when a room is selected.
0039 *
0040 * The signal contains all the room's info so that it can be acted
0041 * upon as required, e.g. joining or entering the room or adding the room as
0042 * the child of a space.
0043 */
0044 signal roomSelected(string roomId, string displayName, url avatarUrl, string alias, string topic, int memberCount, bool isJoined)
0045
0046 title: i18nc("@action:title", "Explore Rooms")
0047
0048 Component.onCompleted: focusSearch()
0049
0050 headerTrailing: ServerComboBox {
0051 id: serverComboBox
0052 connection: root.connection
0053 }
0054
0055 model: PublicRoomListModel {
0056 id: publicRoomListModel
0057
0058 connection: root.connection
0059 server: serverComboBox.server
0060 showOnlySpaces: root.showOnlySpaces
0061 }
0062
0063 modelDelegate: ExplorerDelegate {
0064 onRoomSelected: (roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
0065 root.roomSelected(roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined);
0066 root.closeDialog();
0067 }
0068 }
0069
0070 listHeaderDelegate: Delegates.RoundedItemDelegate {
0071 onClicked: _private.openManualRoomDialog()
0072
0073 text: i18n("Enter a room address")
0074 icon.name: "compass"
0075 icon.width: Kirigami.Units.gridUnit * 2
0076 icon.height: Kirigami.Units.gridUnit * 2
0077 }
0078
0079 listFooterDelegate: QQC2.ProgressBar {
0080 width: ListView.view.width
0081 leftInset: Kirigami.Units.largeSpacing
0082 rightInset: Kirigami.Units.largeSpacing
0083 visible: root.count !== 0 && publicRoomListModel.searching
0084 indeterminate: true
0085 }
0086
0087 searchFieldPlaceholder: i18n("Find a room…")
0088 noResultPlaceholderMessage: i18nc("@info:label", "No public rooms found")
0089
0090 Component {
0091 id: manualRoomDialog
0092 ManualRoomDialog {}
0093 }
0094
0095 QtObject {
0096 id: _private
0097 function openManualRoomDialog() {
0098 let dialog = manualRoomDialog.createObject(applicationWindow().overlay, {
0099 connection: root.connection
0100 });
0101 dialog.roomSelected.connect((roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined) => {
0102 root.roomSelected(roomId, displayName, avatarUrl, alias, topic, memberCount, isJoined);
0103 root.closeDialog();
0104 });
0105 dialog.open();
0106 }
0107 }
0108 }