Improve public room list and add search functionalities.

This commit is contained in:
Black Hat
2019-12-25 15:38:26 +08:00
parent e5032c686a
commit 273e993bdb
5 changed files with 263 additions and 55 deletions

View File

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

View File

@@ -3,6 +3,7 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import Spectral.Component 2.0
import Spectral.Effect 2.0
import Spectral.Setting 0.1
import Spectral 0.1
@@ -11,8 +12,11 @@ Dialog {
property var controller
property var connection
property string keyword
property string server
anchors.centerIn: parent
width: 360
width: 480
height: window.height - 100
id: root
@@ -20,12 +24,46 @@ Dialog {
title: "Start a Chat"
contentItem: ColumnLayout {
AutoTextField {
spacing: 0
RowLayout {
Layout.fillWidth: true
id: identifierField
AutoTextField {
Layout.fillWidth: true
placeholderText: "Room Alias/User ID"
id: identifierField
placeholderText: "Room Alias/User ID"
Keys.onReturnPressed: {
keyword = text
}
}
ComboBox {
Layout.maximumWidth: 120
id: serverField
editable: currentIndex == 1
model: ["Local", "Global", "matrix.org"]
onCurrentIndexChanged: {
if (currentIndex == 0) {
server = ""
} else if (currentIndex == 2) {
server = "matrix.org"
}
}
Keys.onReturnPressed: {
if (currentIndex == 1) {
server = editText
}
}
}
}
MenuSeparator {
@@ -38,55 +76,96 @@ Dialog {
id: publicRoomsListView
spacing: 8
clip: true
spacing: 4
model: PublicRoomListModel {
id: publicRoomListModel
connection: root.connection
server: root.server
keyword: root.keyword
}
delegate: ColumnLayout {
delegate: Item {
width: publicRoomsListView.width
height: 40
Label {
Layout.fillWidth: true
RowLayout {
anchors.fill: parent
anchors.margins: 4
text: name ? name : "No name"
color: MPalette.foreground
font.pixelSize: 13
textFormat: Text.PlainText
elide: Text.ElideRight
wrapMode: Text.NoWrap
spacing: 8
Avatar {
Layout.preferredWidth: height
Layout.fillHeight: true
source: avatar
hint: name
}
ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter
spacing: 0
Label {
Layout.fillWidth: true
Layout.fillHeight: true
text: name
color: MPalette.foreground
font.pixelSize: 13
textFormat: Text.PlainText
elide: Text.ElideRight
wrapMode: Text.NoWrap
}
Label {
Layout.fillWidth: true
Layout.fillHeight: 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
}
}
}
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
RippleEffect {
anchors.fill: parent
}
}
ScrollBar.vertical: ScrollBar {}
onContentYChanged: {
if(publicRoomListModel.hasMore && contentHeight - contentY < publicRoomsListView.height + 200)
publicRoomListModel.next();
}
}
}
// standardButtons: Dialog.Ok | Dialog.Cancel
// 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)
// }
// }
// 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()
}