Working cancel button in settings

This commit is contained in:
miruka
2019-12-13 10:14:54 -04:00
parent 0ab7a008cf
commit 8a4c160df6
3 changed files with 66 additions and 17 deletions

View File

@@ -69,7 +69,7 @@ HDrawer {
Item {}
Item {}
Item {}
SettingsView {}
SettingsView { fillAvailableHeight: true }
}
}
}

View File

@@ -3,11 +3,55 @@ import QtQuick.Layouts 1.12
import "../../Base"
import "../../utils.js" as Utils
// TODO: hide roompane until room is loaded & expand if too small
// TODO: expand pane if too small
HBox {
color: "transparent"
Component.onCompleted: Utils.debug(this) // XXX
// Component.onCompleted: Utils.debug(this) // XXX
buttonModel: [
{
name: "apply",
text: qsTr("Save"),
iconName: "apply",
enabled: anyChange,
loading: saveFuture !== null,
disableWhileLoading: false,
},
{
name: "cancel",
text: qsTr("Cancel"),
iconName: "cancel",
enabled: anyChange || saveFuture !== null,
},
]
buttonCallbacks: ({
apply: button => {
if (saveFuture) saveFuture.cancel()
},
cancel: button => {
if (saveFuture) {
saveFuture.cancel()
saveFuture = null
}
nameField.reset()
topicField.reset()
encryptCheckBox.reset()
requireInviteCheckbox.reset()
forbidGuestsCheckBox.reset()
},
})
property var saveFuture: null
readonly property bool anyChange:
nameField.changed || topicField.changed || encryptCheckBox.changed ||
requireInviteCheckbox.changed || forbidGuestsCheckBox.changed
HRoomAvatar {
id: avatar
@@ -24,7 +68,7 @@ HBox {
id: nameField
placeholderText: qsTr("Room name")
maximumLength: 255
text: chat.roomInfo.given_name
defaultText: chat.roomInfo.given_name
enabled: chat.roomInfo.can_set_name
Layout.fillWidth: true
@@ -33,7 +77,7 @@ HBox {
HScrollableTextArea {
id: topicField
placeholderText: qsTr("Room topic")
text: chat.roomInfo.plain_topic
defaultText: chat.roomInfo.plain_topic
enabled: chat.roomInfo.can_set_topic
Layout.fillWidth: true
@@ -53,7 +97,7 @@ HBox {
) +
"</font>"
subtitle.textFormat: Text.StyledText
checked: chat.roomInfo.encrypted
defaultChecked: chat.roomInfo.encrypted
enabled: chat.roomInfo.can_set_encryption && ! chat.roomInfo.encrypted
Layout.fillWidth: true
@@ -63,16 +107,17 @@ HBox {
id: requireInviteCheckbox
text: qsTr("Require being invited")
subtitle.text: qsTr("Users will need an invite to join the room")
checked: chat.roomInfo.invite_required
defaultChecked: chat.roomInfo.invite_required
enabled: chat.roomInfo.can_set_join_rules
Layout.fillWidth: true
}
HCheckBox {
id: forbidGuestsCheckBox
text: qsTr("Forbid guests")
subtitle.text: qsTr("Users without an account won't be able to join")
checked: ! chat.roomInfo.guests_allowed
defaultChecked: ! chat.roomInfo.guests_allowed
enabled: chat.roomInfo.can_set_guest_access
Layout.fillWidth: true
@@ -85,4 +130,5 @@ HBox {
// Layout.fillWidth: true
// }
HSpacer {}
}