2019-07-13 19:34:58 +10:00
|
|
|
// Copyright 2019 miruka
|
|
|
|
// This file is part of harmonyqml, licensed under LGPLv3.
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../../Base"
|
|
|
|
import "../../utils.js" as Utils
|
|
|
|
|
2019-07-14 10:15:20 +10:00
|
|
|
HGridLayout {
|
|
|
|
function applyChanges() {
|
2019-07-16 06:14:08 +10:00
|
|
|
if (nameField.changed) {
|
|
|
|
saveButton.nameChangeRunning = true
|
2019-07-14 10:15:20 +10:00
|
|
|
|
2019-07-16 06:14:08 +10:00
|
|
|
py.callClientCoro(
|
|
|
|
userId, "set_displayname", [nameField.field.text], () => {
|
|
|
|
saveButton.nameChangeRunning = false
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (avatar.changed) {
|
|
|
|
saveButton.avatarChangeRunning = true
|
|
|
|
var path = Qt.resolvedUrl(avatar.imageUrl).replace(/^file:/, "")
|
|
|
|
|
|
|
|
py.callClientCoro(
|
|
|
|
userId, "set_avatar_from_file", [path], response => {
|
|
|
|
saveButton.avatarChangeRunning = false
|
|
|
|
if (response != true) { print(response) }
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2019-07-14 10:15:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
columns: 2
|
|
|
|
flow: wide ? GridLayout.LeftToRight : GridLayout.TopToBottom
|
|
|
|
rowSpacing: currentSpacing
|
|
|
|
|
|
|
|
Component.onCompleted: nameField.field.forceActiveFocus()
|
|
|
|
|
|
|
|
HUserAvatar {
|
2019-07-16 06:14:08 +10:00
|
|
|
property bool changed: avatar.imageUrl != avatar.defaultImageUrl
|
|
|
|
|
2019-07-14 10:15:20 +10:00
|
|
|
id: avatar
|
|
|
|
userId: editAccount.userId
|
2019-07-16 06:14:08 +10:00
|
|
|
imageUrl: fileDialog.selectedFile || defaultImageUrl
|
2019-07-14 10:15:20 +10:00
|
|
|
toolTipImageUrl: null
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
2019-07-16 07:43:53 +10:00
|
|
|
Layout.preferredWidth:
|
|
|
|
Math.min(flickable.height, theme.minimumSupportedWidth)
|
2019-07-14 10:15:20 +10:00
|
|
|
Layout.preferredHeight: Layout.preferredWidth
|
2019-07-16 06:14:08 +10:00
|
|
|
|
|
|
|
HFileDialogOpener {
|
|
|
|
id: fileDialog
|
|
|
|
fileType: HFileDialogOpener.FileType.Images
|
|
|
|
dialog.title: qsTr("Select profile picture for %1")
|
|
|
|
.arg(userInfo.displayName)
|
|
|
|
}
|
2019-07-14 10:15:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
HColumnLayout {
|
|
|
|
id: profileInfo
|
|
|
|
spacing: normalSpacing
|
|
|
|
|
|
|
|
HColumnLayout {
|
|
|
|
spacing: normalSpacing
|
|
|
|
Layout.margins: currentSpacing
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
text: qsTr("User ID:<br>%1")
|
|
|
|
.arg(Utils.coloredNameHtml(userId, userId))
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HLabeledTextField {
|
2019-07-16 06:14:08 +10:00
|
|
|
property bool changed: field.text != userInfo.displayName
|
|
|
|
|
2019-07-14 10:15:20 +10:00
|
|
|
id: nameField
|
|
|
|
label.text: qsTr("Display name:")
|
|
|
|
field.text: userInfo.displayName
|
|
|
|
field.onAccepted: applyChanges()
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.maximumWidth: 480
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HSpacer {}
|
|
|
|
|
|
|
|
HRowLayout {
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
|
|
|
|
HUIButton {
|
2019-07-16 06:14:08 +10:00
|
|
|
property bool nameChangeRunning: false
|
|
|
|
property bool avatarChangeRunning: false
|
|
|
|
|
2019-07-14 10:15:20 +10:00
|
|
|
id: saveButton
|
|
|
|
iconName: "save"
|
|
|
|
text: qsTr("Save")
|
|
|
|
centerText: false
|
2019-07-16 06:14:08 +10:00
|
|
|
loading: nameChangeRunning || avatarChangeRunning
|
|
|
|
enabled: nameField.changed || avatar.changed
|
2019-07-14 10:15:20 +10:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
|
|
|
|
onClicked: applyChanges()
|
|
|
|
}
|
|
|
|
|
|
|
|
HUIButton {
|
|
|
|
iconName: "cancel"
|
|
|
|
text: qsTr("Cancel")
|
|
|
|
centerText: false
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
enabled: saveButton.enabled && ! saveButton.loading
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
nameField.field.text = userInfo.displayName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-13 19:34:58 +10:00
|
|
|
}
|
|
|
|
}
|