2019-12-08 13:32:22 +03:00
|
|
|
import QtQuick 2.9
|
2020-01-21 15:54:04 +03:00
|
|
|
import QtQuick.Window 2.3
|
2019-12-08 13:32:22 +03:00
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Layouts 1.2
|
|
|
|
|
2020-01-19 22:40:49 +03:00
|
|
|
// Custom qml modules are in /theme (and included by resources.qrc)
|
|
|
|
import Style 1.0
|
2020-06-15 18:01:39 +03:00
|
|
|
import com.nextcloud.desktopclient 1.0
|
2020-01-19 22:40:49 +03:00
|
|
|
|
2019-12-08 13:32:22 +03:00
|
|
|
MenuItem {
|
|
|
|
id: userLine
|
2020-01-19 22:40:49 +03:00
|
|
|
height: Style.trayWindowHeaderHeight
|
2019-12-08 13:32:22 +03:00
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: userLineLayout
|
|
|
|
spacing: 0
|
2020-01-19 22:40:49 +03:00
|
|
|
width: Style.currentAccountButtonWidth
|
|
|
|
height: parent.height
|
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) {
|
2020-06-15 18:01:39 +03:00
|
|
|
UserModel.switchCurrentUser(id)
|
2020-01-17 18:30:27 +03:00
|
|
|
} 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-19 22:40:49 +03:00
|
|
|
sourceSize.width: Style.accountAvatarStateIndicatorSize
|
|
|
|
sourceSize.height: Style.accountAvatarStateIndicatorSize
|
2020-01-12 11:10:06 +03:00
|
|
|
}
|
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
|
|
|
|
|
2020-01-18 19:47:17 +03:00
|
|
|
icon.source: "qrc:///client/theme/more.svg"
|
2020-01-10 18:28:53 +03:00
|
|
|
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 {
|
2020-06-15 20:06:59 +03:00
|
|
|
border.color: Style.menuBorder
|
2020-01-10 18:28:53 +03:00
|
|
|
radius: 2
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuItem {
|
2020-01-14 09:59:28 +03:00
|
|
|
text: isConnected ? qsTr("Log out") : qsTr("Log in")
|
2020-01-19 22:40:49 +03:00
|
|
|
font.pixelSize: Style.topLinePixelSize
|
2020-01-10 18:28:53 +03:00
|
|
|
onClicked: {
|
2020-06-15 18:01:39 +03:00
|
|
|
isConnected ? UserModel.logout(index) : UserModel.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-19 22:40:49 +03:00
|
|
|
font.pixelSize: Style.topLinePixelSize
|
2020-01-11 17:32:59 +03:00
|
|
|
onClicked: {
|
2020-06-15 18:01:39 +03:00
|
|
|
UserModel.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
|