Spectral/qml/component/RoomDrawer.qml

204 lines
5.0 KiB
QML
Raw Normal View History

2018-09-06 05:25:39 +00:00
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import QtQuick.Layouts 1.3
import Spectral 0.1
2018-09-06 05:25:39 +00:00
2018-09-10 00:06:32 +00:00
import "qrc:/js/util.js" as Util
2018-09-06 05:25:39 +00:00
Drawer {
property var room
id: roomDrawer
edge: Qt.RightEdge
interactive: false
ToolButton {
contentItem: MaterialIcon { icon: "\ue5c4" }
onClicked: roomDrawer.close()
}
ColumnLayout {
anchors.fill: parent
anchors.margins: 32
2018-09-10 01:51:02 +00:00
ImageItem {
2018-09-06 05:25:39 +00:00
Layout.preferredWidth: 64
Layout.preferredHeight: 64
Layout.alignment: Qt.AlignHCenter
2018-09-10 01:51:02 +00:00
hint: room ? room.displayName : "No name"
image: spectralController.safeImage(room ? room.avatar : null)
2018-09-06 05:25:39 +00:00
}
Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: room && room.id ? room.id : ""
}
Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: room && room.canonicalAlias ? room.canonicalAlias : "No Canonical Alias"
}
2018-09-10 10:29:41 +00:00
Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: room ? room.memberCount + " Members" : "No Member Count"
}
2018-09-06 05:25:39 +00:00
RowLayout {
Layout.fillWidth: true
TextField {
Layout.fillWidth: true
id: roomNameField
text: room && room.name ? room.name : ""
2018-09-10 07:01:01 +00:00
selectByMouse: true
2018-09-06 05:25:39 +00:00
}
ItemDelegate {
Layout.preferredWidth: height
Layout.preferredHeight: parent.height
contentItem: MaterialIcon { icon: "\ue5ca" }
onClicked: room.setName(roomNameField.text)
}
}
RowLayout {
Layout.fillWidth: true
TextField {
Layout.fillWidth: true
id: roomTopicField
text: room && room.topic ? room.topic : ""
2018-09-10 07:01:01 +00:00
selectByMouse: true
2018-09-06 05:25:39 +00:00
}
ItemDelegate {
Layout.preferredWidth: height
Layout.preferredHeight: parent.height
contentItem: MaterialIcon { icon: "\ue5ca" }
onClicked: room.setTopic(roomTopicField.text)
}
}
ListView {
Layout.fillWidth: true
Layout.fillHeight: true
2018-09-26 23:37:09 +00:00
id: userListView
2018-09-06 05:25:39 +00:00
clip: true
boundsBehavior: Flickable.DragOverBounds
2018-09-10 00:06:32 +00:00
model: UserListModel {
room: roomDrawer.room
}
2018-09-26 23:37:09 +00:00
delegate: Column {
property bool expanded: false
2018-09-06 05:25:39 +00:00
2018-09-26 23:37:09 +00:00
ItemDelegate {
width: userListView.width
height: 48
2018-09-06 05:25:39 +00:00
2018-09-26 23:37:09 +00:00
RowLayout {
anchors.fill: parent
anchors.margins: 8
spacing: 12
2018-09-06 05:25:39 +00:00
2018-09-26 23:37:09 +00:00
ImageItem {
Layout.preferredWidth: height
Layout.fillHeight: true
2018-09-06 05:25:39 +00:00
2018-09-26 23:37:09 +00:00
image: avatar
hint: name
}
Label {
Layout.fillWidth: true
2018-09-06 05:25:39 +00:00
2018-09-26 23:37:09 +00:00
text: name
}
2018-09-06 05:25:39 +00:00
}
2018-09-26 23:37:09 +00:00
onClicked: expanded = !expanded
2018-09-06 05:25:39 +00:00
}
2018-09-11 05:14:56 +00:00
2018-09-26 23:37:09 +00:00
ColumnLayout {
width: parent.width - 32
height: expanded ? implicitHeight : 0
anchors.horizontalCenter: parent.horizontalCenter
2018-09-11 05:14:56 +00:00
2018-09-26 23:37:09 +00:00
spacing: 0
2018-09-11 05:14:56 +00:00
2018-09-26 23:37:09 +00:00
clip: true
Button {
Layout.fillWidth: true
2018-09-11 05:14:56 +00:00
2018-09-26 23:37:09 +00:00
text: "Kick"
highlighted: true
onClicked: room.kickMember(userId)
2018-09-11 05:14:56 +00:00
}
2018-09-26 23:37:09 +00:00
Behavior on height {
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
}
2018-09-11 05:14:56 +00:00
}
2018-09-06 05:25:39 +00:00
}
ScrollBar.vertical: ScrollBar {}
}
Button {
Layout.fillWidth: true
text: "Invite User"
flat: true
highlighted: true
onClicked: inviteUserDialog.open()
Dialog {
x: (window.width - width) / 2
y: (window.height - height) / 2
width: 360
id: inviteUserDialog
parent: ApplicationWindow.overlay
title: "Input User ID"
modal: true
standardButtons: Dialog.Ok | Dialog.Cancel
contentItem: TextField {
id: inviteUserDialogTextField
placeholderText: "@bot:matrix.org"
}
onAccepted: room.inviteToRoom(inviteUserDialogTextField.text)
}
}
}
}