| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- /*
- * Copyright (C) 2019 by Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
- import QtQuick 2.15
- import QtQuick.Window 2.15
- import QtQuick.Controls 2.15
- import QtQuick.Layouts 1.15
- // Custom qml modules are in /theme (and included by resources.qrc)
- import Style 1.0
- import com.nextcloud.desktopclient 1.0
- AbstractButton {
- id: userLine
- signal showUserStatusSelector(int id)
- property variant dialog;
- property variant comp;
- Accessible.role: Accessible.MenuItem
- Accessible.name: qsTr("Switch to account") + " " + model.name
- height: Style.trayWindowHeaderHeight
- background: Rectangle {
- anchors.fill: parent
- anchors.margins: 1
- color: (userLine.hovered || userLine.visualFocus) && !(userMoreButton.hovered || userMoreButton.visualFocus) ? Style.lightHover : Style.backgroundColor
- }
- contentItem: RowLayout {
- id: userLineLayout
- spacing: Style.userStatusSpacing
- Image {
- id: accountAvatar
- Layout.leftMargin: 7
- verticalAlignment: Qt.AlignCenter
- cache: false
- source: model.avatar !== "" ? model.avatar : Theme.darkMode ? "image://avatars/fallbackWhite" : "image://avatars/fallbackBlack"
- Layout.preferredHeight: Style.accountAvatarSize
- Layout.preferredWidth: Style.accountAvatarSize
- Rectangle {
- id: accountStatusIndicatorBackground
- visible: model.isConnected && model.serverHasUserStatus
- width: accountStatusIndicator.sourceSize.width + 2
- height: width
- anchors.bottom: accountAvatar.bottom
- anchors.right: accountAvatar.right
- color: userLine.hovered || userLine.visualFocus ? "#f6f6f6" : "white"
- radius: width*0.5
- }
- Image {
- id: accountStatusIndicator
- visible: model.isConnected && model.serverHasUserStatus
- source: model.statusIcon
- cache: false
- x: accountStatusIndicatorBackground.x + 1
- y: accountStatusIndicatorBackground.y + 1
- sourceSize.width: Style.accountAvatarStateIndicatorSize
- sourceSize.height: Style.accountAvatarStateIndicatorSize
- Accessible.role: Accessible.Indicator
- Accessible.name: model.desktopNotificationsAllowed ? qsTr("Current account status is online") : qsTr("Current account status is do not disturb")
- }
- }
- ColumnLayout {
- id: accountLabels
- Layout.leftMargin: Style.accountLabelsSpacing
- Layout.fillWidth: true
- Layout.fillHeight: true
- EnforcedPlainTextLabel {
- id: accountUser
- Layout.fillWidth: true
- Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
- verticalAlignment: Text.AlignBottom
- text: name
- elide: Text.ElideRight
- color: Style.ncTextColor
- font.pixelSize: Style.topLinePixelSize
- font.bold: true
- }
- RowLayout {
- id: statusLayout
- Layout.fillWidth: true
- height: visible ? implicitHeight : 0
- visible: model.isConnected &&
- model.serverHasUserStatus &&
- (model.statusEmoji !== "" || model.statusMessage !== "")
- EnforcedPlainTextLabel {
- id: emoji
- visible: model.statusEmoji !== ""
- text: statusEmoji
- topPadding: -Style.accountLabelsSpacing
- }
- EnforcedPlainTextLabel {
- id: message
- Layout.fillWidth: true
- visible: model.statusMessage !== ""
- text: statusMessage
- elide: Text.ElideRight
- color: Style.ncTextColor
- font.pixelSize: Style.subLinePixelSize
- leftPadding: Style.accountLabelsSpacing
- }
- }
- EnforcedPlainTextLabel {
- id: accountServer
- Layout.fillWidth: true
- Layout.alignment: Qt.AlignLeft | Qt.AlignTop
- verticalAlignment: Text.AlignTop
- text: server
- elide: Text.ElideRight
- color: Style.ncTextColor
- font.pixelSize: Style.subLinePixelSize
- }
- }
- Button {
- id: userMoreButton
- Layout.preferredWidth: Style.headerButtonIconSize
- Layout.fillHeight: true
- flat: true
- icon.source: "qrc:///client/theme/more.svg"
- icon.color: Style.ncTextColor
- Accessible.role: Accessible.ButtonMenu
- Accessible.name: qsTr("Account actions")
- Accessible.onPressAction: userMoreButtonMouseArea.clicked()
- onClicked: userMoreButtonMenu.visible ? userMoreButtonMenu.close() : userMoreButtonMenu.popup()
- background: Rectangle {
- anchors.fill: parent
- anchors.margins: 1
- color: userMoreButton.hovered || userMoreButton.visualFocus ? Style.lightHover : "transparent"
- }
- AutoSizingMenu {
- id: userMoreButtonMenu
- closePolicy: Menu.CloseOnPressOutsideParent | Menu.CloseOnEscape
- background: Rectangle {
- border.color: Style.menuBorder
- color: Style.backgroundColor
- radius: 2
- }
- MenuItem {
- visible: model.isConnected && model.serverHasUserStatus
- height: visible ? implicitHeight : 0
- text: qsTr("Set status")
- font.pixelSize: Style.topLinePixelSize
- palette.windowText: Style.ncTextColor
- hoverEnabled: true
- onClicked: showUserStatusSelector(index)
- background: Item {
- height: parent.height
- width: parent.menu.width
- Rectangle {
- anchors.fill: parent
- anchors.margins: 1
- color: parent.parent.hovered ? Style.lightHover : "transparent"
- }
- }
- }
- MenuItem {
- text: model.isConnected ? qsTr("Log out") : qsTr("Log in")
- font.pixelSize: Style.topLinePixelSize
- palette.windowText: Style.ncTextColor
- hoverEnabled: true
- onClicked: {
- model.isConnected ? UserModel.logout(index) : UserModel.login(index)
- accountMenu.close()
- }
- background: Item {
- height: parent.height
- width: parent.menu.width
- Rectangle {
- anchors.fill: parent
- anchors.margins: 1
- color: parent.parent.hovered ? Style.lightHover : "transparent"
- }
- }
- Accessible.role: Accessible.Button
- Accessible.name: model.isConnected ? qsTr("Log out") : qsTr("Log in")
- onPressed: {
- if (model.isConnected) {
- UserModel.logout(index)
- } else {
- UserModel.login(index)
- }
- accountMenu.close()
- }
- }
- MenuItem {
- id: removeAccountButton
- text: qsTr("Remove account")
- font.pixelSize: Style.topLinePixelSize
- palette.windowText: Style.ncTextColor
- hoverEnabled: true
- onClicked: {
- UserModel.removeAccount(index)
- accountMenu.close()
- }
- background: Item {
- height: parent.height
- width: parent.menu.width
- Rectangle {
- anchors.fill: parent
- anchors.margins: 1
- color: parent.parent.hovered ? Style.lightHover : "transparent"
- }
- }
- Accessible.role: Accessible.Button
- Accessible.name: text
- Accessible.onPressAction: removeAccountButton.clicked()
- }
- }
- }
- }
- } // MenuItem userLine
|