2020-05-01 19:21:50 +10:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
2020-07-02 13:27:50 +10:00
|
|
|
import QtQuick.Controls 2.12
|
2020-07-03 15:28:27 +10:00
|
|
|
import QtQuick.Layouts 1.12
|
2020-05-01 19:21:50 +10:00
|
|
|
import Clipboard 0.1
|
|
|
|
import "../Base"
|
|
|
|
|
|
|
|
HMenu {
|
2020-07-03 15:28:27 +10:00
|
|
|
id: accountMenu
|
|
|
|
|
2020-05-01 19:21:50 +10:00
|
|
|
property string userId
|
2020-07-02 13:27:50 +10:00
|
|
|
property string presence
|
2020-07-03 15:28:27 +10:00
|
|
|
property string statusMsg
|
2020-07-02 13:27:50 +10:00
|
|
|
|
2020-07-08 06:03:07 +10:00
|
|
|
onOpened: statusText.forceActiveFocus()
|
|
|
|
|
2020-07-02 13:27:50 +10:00
|
|
|
|
2020-07-11 00:59:26 +10:00
|
|
|
function setPresence(presence, statusMsg=undefined) {
|
2020-07-03 15:28:27 +10:00
|
|
|
py.callClientCoro(userId, "set_presence", [presence, statusMsg])
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HLabeledItem {
|
|
|
|
id: statusMsgLabel
|
2020-07-10 06:06:14 +10:00
|
|
|
enabled: presence && presence !== "offline"
|
2020-07-03 15:28:27 +10:00
|
|
|
width: parent.width
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
label.text: qsTr("Status message:")
|
|
|
|
label.horizontalAlignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
HRowLayout {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
HTextField {
|
|
|
|
id: statusText
|
|
|
|
maximumLength: 255
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
onAccepted: {
|
|
|
|
setPresence(presence, statusText.text)
|
|
|
|
accountMenu.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultText: statusMsg
|
2020-07-11 00:59:26 +10:00
|
|
|
placeholderText: presence ? "" : "Unsupported server"
|
2020-07-03 15:28:27 +10:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HButton {
|
|
|
|
id: button
|
2020-07-10 06:06:14 +10:00
|
|
|
visible: presence
|
2020-07-03 15:28:27 +10:00
|
|
|
|
|
|
|
icon.name: "apply"
|
|
|
|
icon.color: theme.colors.positiveBackground
|
|
|
|
onClicked: {
|
|
|
|
setPresence(presence, statusText.text)
|
|
|
|
accountMenu.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-10 09:53:25 +10:00
|
|
|
HMenuSeparator { }
|
|
|
|
|
|
|
|
HMenuItem {
|
2020-07-11 00:59:26 +10:00
|
|
|
icon.name: "presence-online"
|
2020-07-10 09:53:25 +10:00
|
|
|
icon.color: theme.controls.presence.online
|
|
|
|
text: qsTr("Online")
|
|
|
|
onTriggered: setPresence("online")
|
|
|
|
}
|
|
|
|
|
|
|
|
HMenuItem {
|
|
|
|
enabled: presence
|
|
|
|
icon.name: "presence-busy"
|
|
|
|
icon.color: theme.controls.presence.unavailable
|
|
|
|
text: qsTr("Unavailable")
|
|
|
|
onTriggered: setPresence("unavailable")
|
|
|
|
}
|
|
|
|
|
|
|
|
HMenuItem {
|
|
|
|
enabled: presence
|
|
|
|
icon.name: "presence-invisible"
|
|
|
|
icon.color: theme.controls.presence.offline
|
|
|
|
text: qsTr("Invisible")
|
|
|
|
onTriggered: setPresence("invisible")
|
|
|
|
}
|
|
|
|
|
|
|
|
HMenuItem {
|
|
|
|
icon.name: "presence-offline"
|
|
|
|
icon.color: theme.controls.presence.offline
|
|
|
|
text: qsTr("Offline")
|
|
|
|
onTriggered: setPresence("offline")
|
|
|
|
}
|
|
|
|
|
2020-07-03 15:28:27 +10:00
|
|
|
HMenuSeparator {
|
|
|
|
visible: statusMsgLabel.visible
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
}
|
2020-05-01 19:21:50 +10:00
|
|
|
|
|
|
|
HMenuItem {
|
|
|
|
icon.name: "account-settings"
|
|
|
|
text: qsTr("Account settings")
|
2020-07-10 03:13:17 +10:00
|
|
|
onTriggered: pageLoader.showPage(
|
2020-05-01 19:21:50 +10:00
|
|
|
"AccountSettings/AccountSettings", { "userId": userId },
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
HMenuItem {
|
|
|
|
icon.name: "menu-add-chat"
|
|
|
|
text: qsTr("Add new chat")
|
2020-07-10 03:13:17 +10:00
|
|
|
onTriggered: pageLoader.showPage("AddChat/AddChat", {userId: userId})
|
2020-05-01 19:21:50 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
HMenuItem {
|
|
|
|
icon.name: "copy-user-id"
|
|
|
|
text: qsTr("Copy user ID")
|
|
|
|
onTriggered: Clipboard.text = userId
|
|
|
|
}
|
|
|
|
|
|
|
|
HMenuItemPopupSpawner {
|
|
|
|
icon.name: "sign-out"
|
|
|
|
icon.color: theme.colors.negativeBackground
|
|
|
|
text: qsTr("Sign out")
|
|
|
|
|
|
|
|
popup: "Popups/SignOutPopup.qml"
|
|
|
|
properties: { "userId": userId }
|
|
|
|
}
|
|
|
|
}
|