Reimplement room settings.

This commit is contained in:
Black Hat
2019-05-23 23:01:46 +08:00
parent 97db902dc5
commit 34186f153f

View File

@@ -14,7 +14,7 @@ Dialog {
id: root id: root
title: "Room Settings - " + (room ? room.displayName : "") title: "Room Settings - " + room.displayName
modal: true modal: true
contentItem: ColumnLayout { contentItem: ColumnLayout {
@@ -28,8 +28,8 @@ Dialog {
Layout.preferredHeight: 72 Layout.preferredHeight: 72
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
hint: room ? room.displayName : "No name" hint: room.displayName
source: room ? room.avatarMediaId : null source: room.avatarMediaId
} }
ColumnLayout { ColumnLayout {
@@ -39,14 +39,18 @@ Dialog {
AutoTextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
text: room ? room.name : "" id: roomNameField
text: room.name
placeholderText: "Room Name" placeholderText: "Room Name"
} }
AutoTextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
text: room ? room.topic : "" id: roomTopicField
text: room.topic
placeholderText: "Room Topic" placeholderText: "Room Topic"
} }
} }
@@ -55,7 +59,7 @@ Dialog {
Control { Control {
Layout.fillWidth: true Layout.fillWidth: true
visible: room ? room.predecessorId : false visible: room.predecessorId
padding: 8 padding: 8
@@ -106,7 +110,7 @@ Dialog {
Control { Control {
Layout.fillWidth: true Layout.fillWidth: true
visible: room ? room.successorId : false visible: room.successorId
padding: 8 padding: 8
@@ -175,9 +179,9 @@ Dialog {
ComboBox { ComboBox {
Layout.fillWidth: true Layout.fillWidth: true
model: room ? room.aliases : null model: room.aliases
currentIndex: room ? room.aliases.indexOf(room.canonicalAlias) : -1 currentIndex: room.aliases.indexOf(room.canonicalAlias)
} }
} }
@@ -197,7 +201,7 @@ Dialog {
Layout.fillWidth: true Layout.fillWidth: true
Repeater { Repeater {
model: room ? room.aliases : null model: room.aliases
delegate: Label { delegate: Label {
Layout.fillWidth: true Layout.fillWidth: true
@@ -247,6 +251,14 @@ Dialog {
onClicked: room.clearBackground() onClicked: room.clearBackground()
} }
} }
Button {
Layout.alignment: Qt.AlignRight
text: "Save"
onClicked: saveSettings()
}
} }
Component { Component {
@@ -256,5 +268,15 @@ Dialog {
} }
onClosed: destroy() onClosed: destroy()
function saveSettings() {
if (room.name != roomNameField.text) {
room.setName(roomNameField.text)
}
if (room.topic != roomTopicField.text) {
room.setTopic(roomTopicField.text)
}
}
} }