blob: 6a064f5c829529de8a2de92c54d900c5d33a6af3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
import QtQuick 2.9
import QtQuick.Window 2.3
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.2
// 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: accountButton.hovered || accountButton.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
Label {
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 !== "")
Label {
id: emoji
visible: model.statusEmoji !== ""
text: statusEmoji
topPadding: -Style.accountLabelsSpacing
}
Label {
id: message
Layout.fillWidth: true
visible: model.statusMessage !== ""
text: statusMessage
elide: Text.ElideRight
color: Style.ncTextColor
font.pixelSize: Style.subLinePixelSize
leftPadding: Style.accountLabelsSpacing
}
}
Label {
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
|