2021-08-12 17:45:42 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2023-01-02 06:25:33 +03:00
|
|
|
// SPDX-FileCopyrightText: 2023 Nheko Contributors
|
2021-08-12 17:45:42 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-09-25 06:27:57 +03:00
|
|
|
import ".."
|
|
|
|
import "../ui"
|
2022-07-09 17:05:18 +03:00
|
|
|
import QtQuick 2.15
|
2021-08-12 17:45:42 +03:00
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.3
|
2022-07-09 17:05:18 +03:00
|
|
|
import QtQuick.Window 2.15
|
2021-08-12 17:45:42 +03:00
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
ApplicationWindow {
|
|
|
|
id: roomDirectoryWindow
|
|
|
|
|
|
|
|
visible: true
|
2022-02-22 00:27:35 +03:00
|
|
|
minimumWidth: 340
|
|
|
|
minimumHeight: 340
|
|
|
|
height: 420
|
|
|
|
width: 650
|
2021-08-12 17:45:42 +03:00
|
|
|
palette: Nheko.colors
|
|
|
|
color: Nheko.colors.window
|
2022-07-19 00:28:27 +03:00
|
|
|
modality: Qt.NonModal
|
2021-08-19 17:55:54 +03:00
|
|
|
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
2021-08-12 17:45:42 +03:00
|
|
|
title: qsTr("Explore Public Rooms")
|
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
sequence: StandardKey.Cancel
|
|
|
|
onActivated: roomDirectoryWindow.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: roomDirView
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
model: publicRooms
|
|
|
|
|
2021-08-14 16:49:18 +03:00
|
|
|
ScrollHelper {
|
2021-08-14 16:44:34 +03:00
|
|
|
flickable: parent
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
|
|
|
|
2021-08-12 17:45:42 +03:00
|
|
|
delegate: Rectangle {
|
|
|
|
id: roomDirDelegate
|
|
|
|
|
|
|
|
property color background: Nheko.colors.window
|
|
|
|
property color importantText: Nheko.colors.text
|
|
|
|
property color unimportantText: Nheko.colors.buttonText
|
2022-02-22 00:27:35 +03:00
|
|
|
property int avatarSize: fontMetrics.height * 3.2
|
2021-08-12 17:45:42 +03:00
|
|
|
|
|
|
|
color: background
|
2021-08-14 16:44:34 +03:00
|
|
|
height: avatarSize + Nheko.paddingLarge
|
2021-08-12 17:45:42 +03:00
|
|
|
width: ListView.view.width
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: Nheko.paddingMedium
|
|
|
|
anchors.fill: parent
|
2022-02-22 00:27:35 +03:00
|
|
|
anchors.margins: Nheko.paddingMedium
|
|
|
|
implicitHeight: textContent.implicitHeight
|
2021-08-12 17:45:42 +03:00
|
|
|
|
|
|
|
Avatar {
|
|
|
|
id: roomAvatar
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2022-02-22 00:27:35 +03:00
|
|
|
Layout.rightMargin: Nheko.paddingMedium
|
2021-08-12 17:45:42 +03:00
|
|
|
width: avatarSize
|
|
|
|
height: avatarSize
|
|
|
|
url: model.avatarUrl.replace("mxc://", "image://MxcImage/")
|
2021-09-01 04:53:12 +03:00
|
|
|
roomid: model.roomid
|
2021-08-12 17:45:42 +03:00
|
|
|
displayName: model.name
|
|
|
|
}
|
|
|
|
|
2022-02-22 00:27:35 +03:00
|
|
|
GridLayout {
|
2021-08-12 17:45:42 +03:00
|
|
|
id: textContent
|
2022-02-22 00:27:35 +03:00
|
|
|
rows: 2
|
|
|
|
columns: 2
|
2021-08-12 17:45:42 +03:00
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
width: parent.width - avatar.width
|
|
|
|
Layout.preferredWidth: parent.width - avatar.width
|
|
|
|
|
2021-08-15 04:47:11 +03:00
|
|
|
ElidedLabel {
|
2022-02-22 00:27:35 +03:00
|
|
|
Layout.row: 0
|
|
|
|
Layout.column: 0
|
|
|
|
Layout.fillWidth:true
|
2021-08-15 04:47:11 +03:00
|
|
|
color: roomDirDelegate.importantText
|
2022-02-22 00:27:35 +03:00
|
|
|
elideWidth: width
|
2021-08-15 04:47:11 +03:00
|
|
|
fullText: model.name
|
2021-08-12 17:45:42 +03:00
|
|
|
}
|
|
|
|
|
2022-02-22 00:27:35 +03:00
|
|
|
Label {
|
|
|
|
id: roomTopic
|
|
|
|
|
|
|
|
color: roomDirDelegate.unimportantText
|
|
|
|
Layout.row: 1
|
|
|
|
Layout.column: 0
|
|
|
|
font.pointSize: fontMetrics.font.pointSize*0.9
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 2
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: model.topic
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
}
|
2021-08-12 17:45:42 +03:00
|
|
|
|
2022-02-22 00:27:35 +03:00
|
|
|
Label {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.row: 0
|
|
|
|
Layout.column: 1
|
|
|
|
id: roomCount
|
2021-08-12 17:45:42 +03:00
|
|
|
|
2022-02-22 00:27:35 +03:00
|
|
|
color: roomDirDelegate.unimportantText
|
|
|
|
font.pointSize: fontMetrics.font.pointSize*0.9
|
|
|
|
text: model.numMembers.toString()
|
|
|
|
}
|
2021-08-12 17:45:42 +03:00
|
|
|
|
2022-02-22 00:27:35 +03:00
|
|
|
Button {
|
|
|
|
Layout.row: 1
|
|
|
|
Layout.column: 1
|
|
|
|
id: joinRoomButton
|
|
|
|
enabled: model.canJoin
|
|
|
|
text: "Join"
|
|
|
|
onClicked: publicRooms.joinRoom(model.index)
|
2021-08-12 17:45:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: Item {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width: parent.width
|
2021-08-15 04:47:11 +03:00
|
|
|
visible: !publicRooms.reachedEndOfPagination && publicRooms.loadingMoreRooms
|
2021-08-12 17:45:42 +03:00
|
|
|
// hacky but works
|
|
|
|
height: loadingSpinner.height + 2 * Nheko.paddingLarge
|
|
|
|
anchors.margins: Nheko.paddingLarge
|
|
|
|
|
|
|
|
Spinner {
|
|
|
|
id: loadingSpinner
|
|
|
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
anchors.margins: Nheko.paddingLarge
|
|
|
|
running: visible
|
|
|
|
foreground: Nheko.colors.mid
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
header: RowLayout {
|
|
|
|
id: searchBarLayout
|
|
|
|
|
|
|
|
spacing: Nheko.paddingMedium
|
|
|
|
width: parent.width
|
|
|
|
implicitHeight: roomSearch.height
|
|
|
|
|
|
|
|
MatrixTextField {
|
|
|
|
id: roomSearch
|
|
|
|
|
2021-10-29 04:44:24 +03:00
|
|
|
focus: true
|
2021-08-12 17:45:42 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
selectByMouse: true
|
|
|
|
font.pixelSize: fontMetrics.font.pixelSize
|
|
|
|
color: Nheko.colors.text
|
|
|
|
placeholderText: qsTr("Search for public rooms")
|
|
|
|
onTextChanged: searchTimer.restart()
|
2022-04-18 21:44:35 +03:00
|
|
|
|
|
|
|
Component.onCompleted: forceActiveFocus()
|
2021-08-12 17:45:42 +03:00
|
|
|
}
|
|
|
|
|
2021-09-17 13:12:56 +03:00
|
|
|
MatrixTextField {
|
|
|
|
id: chooseServer
|
2021-09-18 01:21:14 +03:00
|
|
|
|
2021-09-17 13:12:56 +03:00
|
|
|
Layout.minimumWidth: 0.3 * header.width
|
|
|
|
Layout.maximumWidth: 0.3 * header.width
|
|
|
|
color: Nheko.colors.text
|
|
|
|
placeholderText: qsTr("Choose custom homeserver")
|
|
|
|
onTextChanged: publicRooms.setMatrixServer(text)
|
|
|
|
}
|
|
|
|
|
2021-08-12 17:45:42 +03:00
|
|
|
Timer {
|
|
|
|
id: searchTimer
|
|
|
|
|
|
|
|
interval: 350
|
|
|
|
onTriggered: roomDirView.model.setSearchTerm(roomSearch.text)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|