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
|
|
|
|
2020-08-25 13:54:56 +03:00
|
|
|
Accessible.role: Accessible.MenuItem
|
|
|
|
Accessible.name: qsTr("Account entry")
|
|
|
|
|
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
|
2020-07-06 14:55:14 +03:00
|
|
|
hoverEnabled: true
|
2019-12-08 13:32:22 +03:00
|
|
|
flat: true
|
|
|
|
|
2020-08-25 13:54:56 +03:00
|
|
|
Accessible.role: Accessible.Button
|
2020-08-25 17:52:05 +03:00
|
|
|
Accessible.name: qsTr("Switch to account") + " " + name
|
2020-08-25 13:54:56 +03:00
|
|
|
|
2020-01-17 18:30:27 +03:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onContainsMouseChanged: {
|
2021-03-16 22:24:11 +03:00
|
|
|
accountStatusIndicatorBackground.color = (containsMouse ? "#f6f6f6" : "white")
|
2020-01-17 18:30:27 +03:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-07-06 14:55:14 +03:00
|
|
|
|
|
|
|
background: Item {
|
|
|
|
height: parent.height
|
2020-09-14 18:36:08 +03:00
|
|
|
width: userLine.menu ? userLine.menu.width : 0
|
2020-07-06 14:55:14 +03:00
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 1
|
|
|
|
color: parent.parent.hovered ? Style.lightHover : "transparent"
|
|
|
|
}
|
2019-12-08 13:32:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: accountControlRowLayout
|
|
|
|
height: accountButton.height
|
|
|
|
width: accountButton.width
|
2021-05-25 23:17:33 +03:00
|
|
|
spacing: Style.userStatusSpacing
|
2019-12-08 13:32:22 +03:00
|
|
|
Image {
|
|
|
|
id: accountAvatar
|
2021-04-27 14:09:51 +03:00
|
|
|
Layout.leftMargin: 7
|
2019-12-08 13:32:22 +03:00
|
|
|
verticalAlignment: Qt.AlignCenter
|
2020-01-10 18:28:53 +03:00
|
|
|
cache: false
|
2020-07-21 14:24:59 +03:00
|
|
|
source: model.avatar != "" ? model.avatar : "image://avatars/fallbackBlack"
|
2021-04-27 14:09:51 +03:00
|
|
|
Layout.preferredHeight: Style.accountAvatarSize
|
|
|
|
Layout.preferredWidth: Style.accountAvatarSize
|
2020-01-15 22:11:50 +03:00
|
|
|
Rectangle {
|
2021-03-16 22:24:11 +03:00
|
|
|
id: accountStatusIndicatorBackground
|
2021-04-19 18:19:04 +03:00
|
|
|
visible: model.isConnected &&
|
2021-05-17 22:33:00 +03:00
|
|
|
model.serverHasUserStatus
|
2021-03-16 22:24:11 +03:00
|
|
|
width: accountStatusIndicator.sourceSize.width + 2
|
2020-01-15 22:11:50 +03:00
|
|
|
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 {
|
2021-03-16 22:24:11 +03:00
|
|
|
id: accountStatusIndicator
|
2021-04-19 18:19:04 +03:00
|
|
|
visible: model.isConnected &&
|
2021-05-17 22:33:00 +03:00
|
|
|
model.serverHasUserStatus
|
2021-04-19 18:19:04 +03:00
|
|
|
source: model.statusIcon
|
2020-01-12 11:10:06 +03:00
|
|
|
cache: false
|
2021-03-16 22:24:11 +03:00
|
|
|
x: accountStatusIndicatorBackground.x + 1
|
|
|
|
y: accountStatusIndicatorBackground.y + 1
|
2020-01-19 22:40:49 +03:00
|
|
|
sourceSize.width: Style.accountAvatarStateIndicatorSize
|
|
|
|
sourceSize.height: Style.accountAvatarStateIndicatorSize
|
2020-08-25 13:54:56 +03:00
|
|
|
|
|
|
|
Accessible.role: Accessible.Indicator
|
2021-04-26 21:40:38 +03:00
|
|
|
Accessible.name: model.desktopNotificationsAllowed ? qsTr("Current user status is online") : qsTr("Current user status is do not disturb")
|
2020-01-12 11:10:06 +03:00
|
|
|
}
|
2019-12-08 13:32:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: accountLabels
|
2021-05-25 23:17:33 +03:00
|
|
|
Layout.leftMargin: Style.accountLabelsSpacing
|
2019-12-08 13:32:22 +03:00
|
|
|
Label {
|
|
|
|
id: accountUser
|
2021-05-25 23:17:33 +03:00
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
|
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"
|
2021-05-18 23:28:59 +03:00
|
|
|
font.pixelSize: Style.topLinePixelSize
|
2019-12-08 13:32:22 +03:00
|
|
|
font.bold: true
|
|
|
|
}
|
2021-05-25 23:17:33 +03:00
|
|
|
RowLayout {
|
2021-05-18 21:45:34 +03:00
|
|
|
id: userStatus
|
2021-04-26 21:40:38 +03:00
|
|
|
visible: model.isConnected &&
|
2021-05-18 21:45:34 +03:00
|
|
|
model.serverHasUserStatus
|
2021-05-25 23:17:33 +03:00
|
|
|
spacing: Style.userStatusAnchorsMargin
|
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
2021-05-18 21:45:34 +03:00
|
|
|
Label {
|
|
|
|
id: emoji
|
|
|
|
visible: model.statusEmoji !== ""
|
|
|
|
width: Style.userStatusEmojiSize
|
|
|
|
text: statusEmoji
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
id: message
|
2021-05-25 23:17:33 +03:00
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
|
|
|
|
Layout.leftMargin: Style.userStatusAnchorsMargin
|
2021-05-18 21:45:34 +03:00
|
|
|
visible: model.statusMessage !== ""
|
2021-05-18 23:28:59 +03:00
|
|
|
width: Style.currentAccountLabelWidth
|
2021-05-18 21:45:34 +03:00
|
|
|
text: statusMessage
|
|
|
|
elide: Text.ElideRight
|
|
|
|
color: "black"
|
2021-05-18 23:28:59 +03:00
|
|
|
font.pixelSize: Style.subLinePixelSize
|
2021-05-18 21:45:34 +03:00
|
|
|
}
|
2020-10-03 18:12:16 +03:00
|
|
|
}
|
2019-12-08 13:32:22 +03:00
|
|
|
Label {
|
|
|
|
id: accountServer
|
2021-05-25 23:17:33 +03:00
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
|
2021-05-18 23:28:59 +03:00
|
|
|
width: Style.currentAccountLabelWidth
|
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"
|
2021-05-18 23:28:59 +03:00
|
|
|
font.pixelSize: Style.subLinePixelSize
|
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"
|
|
|
|
|
2020-08-25 13:54:56 +03:00
|
|
|
Accessible.role: Accessible.ButtonMenu
|
2020-08-25 17:52:05 +03:00
|
|
|
Accessible.name: qsTr("Account actions")
|
2020-09-15 17:45:22 +03:00
|
|
|
Accessible.onPressAction: userMoreButtonMouseArea.clicked()
|
2020-08-25 13:54:56 +03:00
|
|
|
|
2020-01-10 18:28:53 +03:00
|
|
|
MouseArea {
|
|
|
|
id: userMoreButtonMouseArea
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
2020-09-14 19:03:57 +03:00
|
|
|
onClicked: {
|
|
|
|
if (userMoreButtonMenu.visible) {
|
|
|
|
userMoreButtonMenu.close()
|
|
|
|
} else {
|
|
|
|
userMoreButtonMenu.popup()
|
|
|
|
}
|
2020-01-10 18:28:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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-09-14 19:03:57 +03:00
|
|
|
closePolicy: Menu.CloseOnPressOutsideParent | Menu.CloseOnEscape
|
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-11-23 08:45:26 +03:00
|
|
|
text: model.isConnected ? qsTr("Log out") : qsTr("Log in")
|
2020-01-19 22:40:49 +03:00
|
|
|
font.pixelSize: Style.topLinePixelSize
|
2020-07-06 14:55:14 +03:00
|
|
|
hoverEnabled: true
|
2020-01-10 18:28:53 +03:00
|
|
|
onClicked: {
|
2020-11-23 08:45:26 +03:00
|
|
|
model.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
|
|
|
}
|
2020-07-06 14:55:14 +03:00
|
|
|
|
|
|
|
background: Item {
|
|
|
|
height: parent.height
|
|
|
|
width: parent.menu.width
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 1
|
|
|
|
color: parent.parent.hovered ? Style.lightHover : "transparent"
|
|
|
|
}
|
|
|
|
}
|
2020-08-25 13:54:56 +03:00
|
|
|
|
|
|
|
Accessible.role: Accessible.Button
|
2020-11-23 08:45:26 +03:00
|
|
|
Accessible.name: model.isConnected ? qsTr("Log out") : qsTr("Log in")
|
2020-08-25 13:54:56 +03:00
|
|
|
|
|
|
|
onPressed: {
|
2020-11-23 08:45:26 +03:00
|
|
|
if (model.isConnected) {
|
2020-09-15 17:45:22 +03:00
|
|
|
UserModel.logout(index)
|
|
|
|
} else {
|
|
|
|
UserModel.login(index)
|
|
|
|
}
|
2020-08-25 13:54:56 +03:00
|
|
|
accountMenu.close()
|
|
|
|
}
|
2020-01-10 18:28:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
MenuItem {
|
2020-09-15 17:45:22 +03:00
|
|
|
id: removeAccountButton
|
2020-08-25 17:52:05 +03:00
|
|
|
text: qsTr("Remove account")
|
2020-01-19 22:40:49 +03:00
|
|
|
font.pixelSize: Style.topLinePixelSize
|
2020-07-06 14:55:14 +03:00
|
|
|
hoverEnabled: true
|
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-07-06 14:55:14 +03:00
|
|
|
|
|
|
|
background: Item {
|
|
|
|
height: parent.height
|
|
|
|
width: parent.menu.width
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 1
|
|
|
|
color: parent.parent.hovered ? Style.lightHover : "transparent"
|
|
|
|
}
|
|
|
|
}
|
2020-08-25 13:54:56 +03:00
|
|
|
|
|
|
|
Accessible.role: Accessible.Button
|
2020-08-25 17:52:05 +03:00
|
|
|
Accessible.name: text
|
2020-09-15 17:45:22 +03:00
|
|
|
Accessible.onPressAction: removeAccountButton.clicked()
|
2020-01-10 18:28:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-08 13:32:22 +03:00
|
|
|
}
|
|
|
|
} // MenuItem userLine
|