Public room directory.

This commit is contained in:
Black Hat
2019-12-25 00:02:01 +08:00
parent 29b396add3
commit e5032c686a
12 changed files with 230 additions and 44 deletions

View File

@@ -111,7 +111,7 @@ Dialog {
RippleEffect {
anchors.fill: parent
onPrimaryClicked: joinRoomDialog.createObject(ApplicationWindow.overlay).open()
onPrimaryClicked: joinRoomDialog.createObject(ApplicationWindow.overlay, {"controller": spectralController, "connection": spectralController.connection}).open()
}
}

View File

@@ -3,10 +3,17 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import Spectral.Component 2.0
import Spectral.Setting 0.1
import Spectral 0.1
Dialog {
property var controller
property var connection
anchors.centerIn: parent
width: 360
height: window.height - 100
id: root
@@ -20,19 +27,66 @@ Dialog {
placeholderText: "Room Alias/User ID"
}
}
standardButtons: Dialog.Ok | Dialog.Cancel
MenuSeparator {
Layout.fillWidth: true
}
onAccepted: {
var identifier = identifierField.text
var firstChar = identifier.charAt(0)
if (firstChar == "@") {
spectralController.createDirectChat(spectralController.connection, identifier)
} else if (firstChar == "!" || firstChar == "#") {
spectralController.joinRoom(spectralController.connection, identifier)
AutoListView {
Layout.fillWidth: true
Layout.fillHeight: true
id: publicRoomsListView
spacing: 8
model: PublicRoomListModel {
connection: root.connection
}
delegate: ColumnLayout {
width: publicRoomsListView.width
Label {
Layout.fillWidth: true
text: name ? name : "No name"
color: MPalette.foreground
font.pixelSize: 13
textFormat: Text.PlainText
elide: Text.ElideRight
wrapMode: Text.NoWrap
}
Label {
Layout.fillWidth: true
visible: text
text: topic ? topic.replace(/(\r\n\t|\n|\r\t)/gm," ") : ""
color: MPalette.lighter
font.pixelSize: 10
textFormat: Text.PlainText
elide: Text.ElideRight
wrapMode: Text.NoWrap
}
}
ScrollBar.vertical: ScrollBar {}
}
}
// standardButtons: Dialog.Ok | Dialog.Cancel
// onAccepted: {
// var identifier = identifierField.text
// var firstChar = identifier.charAt(0)
// if (firstChar == "@") {
// spectralController.createDirectChat(spectralController.connection, identifier)
// } else if (firstChar == "!" || firstChar == "#") {
// spectralController.joinRoom(spectralController.connection, identifier)
// }
// }
onClosed: destroy()
}