2019-12-08 13:32:22 +03:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Window 2.2
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Layouts 1.2
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
id: userLine
|
2020-01-05 23:06:42 +03:00
|
|
|
height: 60
|
2019-12-08 13:32:22 +03:00
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: userLineLayout
|
|
|
|
spacing: 0
|
2020-01-10 18:28:53 +03:00
|
|
|
width: 220
|
|
|
|
height: 60
|
2019-12-08 13:32:22 +03:00
|
|
|
|
|
|
|
Button {
|
|
|
|
id: accountButton
|
2020-01-10 18:28:53 +03:00
|
|
|
Layout.preferredWidth: (userLineLayout.width * (5/6))
|
|
|
|
Layout.preferredHeight: (userLineLayout.height)
|
2019-12-08 13:32:22 +03:00
|
|
|
display: AbstractButton.IconOnly
|
|
|
|
flat: true
|
|
|
|
|
2020-01-17 18:30:27 +03:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onContainsMouseChanged: {
|
|
|
|
accountStateIndicatorBackground.color = (containsMouse ? "#f6f6f6" : "white")
|
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
if (!isCurrentUser) {
|
|
|
|
userModelBackend.switchCurrentUser(id)
|
|
|
|
} else {
|
|
|
|
accountMenu.close()
|
|
|
|
}
|
|
|
|
}
|
2020-01-15 22:11:50 +03:00
|
|
|
}
|
|
|
|
|
2019-12-08 13:32:22 +03:00
|
|
|
background: Rectangle {
|
|
|
|
color: "transparent"
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: accountControlRowLayout
|
|
|
|
height: accountButton.height
|
|
|
|
width: accountButton.width
|
|
|
|
spacing: 0
|
|
|
|
Image {
|
|
|
|
id: accountAvatar
|
2020-01-10 18:28:53 +03:00
|
|
|
Layout.leftMargin: 4
|
2019-12-08 13:32:22 +03:00
|
|
|
verticalAlignment: Qt.AlignCenter
|
2020-01-10 18:28:53 +03:00
|
|
|
cache: false
|
2020-01-12 18:16:24 +03:00
|
|
|
source: ("image://avatars/" + id)
|
2020-01-10 18:28:53 +03:00
|
|
|
Layout.preferredHeight: (userLineLayout.height -16)
|
|
|
|
Layout.preferredWidth: (userLineLayout.height -16)
|
2020-01-15 22:11:50 +03:00
|
|
|
Rectangle {
|
|
|
|
id: accountStateIndicatorBackground
|
|
|
|
width: accountStateIndicator.sourceSize.width + 2
|
|
|
|
height: width
|
|
|
|
anchors.bottom: accountAvatar.bottom
|
|
|
|
anchors.right: accountAvatar.right
|
|
|
|
color: "white"
|
|
|
|
radius: width*0.5
|
|
|
|
}
|
2020-01-12 11:10:06 +03:00
|
|
|
Image {
|
|
|
|
id: accountStateIndicator
|
2020-01-12 18:16:24 +03:00
|
|
|
source: isConnected ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg"
|
2020-01-12 11:10:06 +03:00
|
|
|
cache: false
|
2020-01-15 22:11:50 +03:00
|
|
|
x: accountStateIndicatorBackground.x + 1
|
|
|
|
y: accountStateIndicatorBackground.y + 1
|
2020-01-12 11:10:06 +03:00
|
|
|
sourceSize.width: 16
|
|
|
|
sourceSize.height: 16
|
|
|
|
}
|
2019-12-08 13:32:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: accountLabels
|
|
|
|
spacing: 4
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
2020-01-10 18:28:53 +03:00
|
|
|
Layout.leftMargin: 6
|
2019-12-08 13:32:22 +03:00
|
|
|
Label {
|
|
|
|
id: accountUser
|
2020-01-10 18:28:53 +03:00
|
|
|
width: 128
|
2019-12-08 13:32:22 +03:00
|
|
|
text: name
|
2020-01-05 23:06:42 +03:00
|
|
|
elide: Text.ElideRight
|
2019-12-08 13:32:22 +03:00
|
|
|
color: "black"
|
2020-01-04 19:22:56 +03:00
|
|
|
font.pixelSize: 12
|
2019-12-08 13:32:22 +03:00
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
id: accountServer
|
2020-01-10 18:28:53 +03:00
|
|
|
width: 128
|
2019-12-08 13:32:22 +03:00
|
|
|
text: server
|
2020-01-05 23:06:42 +03:00
|
|
|
elide: Text.ElideRight
|
2019-12-08 13:32:22 +03:00
|
|
|
color: "black"
|
2020-01-04 19:22:56 +03:00
|
|
|
font.pixelSize: 10
|
2019-12-08 13:32:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-05 23:31:09 +03:00
|
|
|
} // accountButton
|
2020-01-10 18:28:53 +03:00
|
|
|
|
|
|
|
Button {
|
|
|
|
id: userMoreButton
|
|
|
|
Layout.preferredWidth: (userLineLayout.width * (1/6))
|
|
|
|
Layout.preferredHeight: userLineLayout.height
|
|
|
|
flat: true
|
|
|
|
|
|
|
|
icon.source: "qrc:///client/resources/more.svg"
|
|
|
|
icon.color: "transparent"
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: userMoreButtonMouseArea
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked:
|
|
|
|
{
|
|
|
|
userMoreButtonMenu.popup()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
background:
|
|
|
|
Rectangle {
|
|
|
|
color: userMoreButtonMouseArea.containsMouse ? "grey" : "transparent"
|
|
|
|
opacity: 0.2
|
2020-01-11 16:57:22 +03:00
|
|
|
height: userMoreButton.height - 2
|
|
|
|
y: userMoreButton.y + 1
|
2020-01-10 18:28:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
id: userMoreButtonMenu
|
2020-01-11 16:57:22 +03:00
|
|
|
width: 120
|
2020-01-10 18:28:53 +03:00
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
border.color: "#0082c9"
|
|
|
|
radius: 2
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuItem {
|
2020-01-14 09:59:28 +03:00
|
|
|
text: isConnected ? qsTr("Log out") : qsTr("Log in")
|
2020-01-16 02:45:31 +03:00
|
|
|
font.pixelSize: 12
|
2020-01-10 18:28:53 +03:00
|
|
|
onClicked: {
|
2020-01-12 18:16:24 +03:00
|
|
|
isConnected ? userModelBackend.logout(index) : userModelBackend.login(index)
|
2020-01-12 13:06:48 +03:00
|
|
|
accountMenu.close()
|
2020-01-10 18:28:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuItem {
|
2020-01-14 09:59:28 +03:00
|
|
|
text: qsTr("Remove Account")
|
2020-01-16 02:45:31 +03:00
|
|
|
font.pixelSize: 12
|
2020-01-11 17:32:59 +03:00
|
|
|
onClicked: {
|
|
|
|
userModelBackend.removeAccount(index)
|
2020-01-12 18:16:24 +03:00
|
|
|
accountMenu.close()
|
2020-01-11 17:32:59 +03:00
|
|
|
}
|
2020-01-10 18:28:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-08 13:32:22 +03:00
|
|
|
}
|
|
|
|
} // MenuItem userLine
|