blob: d738c5c474a062003a2ac6415b2d67dded50936d (
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
|
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.10
import QtQuick.Controls 2.3
import UM 1.5 as UM
import Cura 1.1 as Cura
Item
{
property var profile: Cura.API.account.userProfile
property var loggedIn: Cura.API.account.isLoggedIn
height: signInButton.visible ? signInButton.height : accountWidget.height
width: signInButton.visible ? signInButton.width : accountWidget.width
Button
{
id: signInButton
anchors.verticalCenter: parent.verticalCenter
text: catalog.i18nc("@action:button", "Sign in")
height: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
onClicked: popup.opened ? popup.close() : popup.open()
visible: !loggedIn
hoverEnabled: true
background: Rectangle
{
radius: UM.Theme.getSize("action_button_radius").width
color: UM.Theme.getColor("main_window_header_background")
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("primary_text")
Rectangle
{
anchors.fill: parent
radius: parent.radius
color: UM.Theme.getColor("primary_text")
opacity: signInButton.hovered ? 0.2 : 0
Behavior on opacity { NumberAnimation { duration: 100 } }
}
}
contentItem: UM.Label
{
id: label
text: signInButton.text
color: UM.Theme.getColor("primary_text")
width: contentWidth
}
}
Button
{
id: accountWidget
anchors.verticalCenter: parent.verticalCenter
implicitHeight: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
implicitWidth: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
hoverEnabled: true
visible: loggedIn
text: (loggedIn && profile["profile_image_url"] == "") ? profile["username"].charAt(0).toUpperCase() : ""
background: AvatarImage
{
id: avatar
width: accountWidget.width
height: accountWidget.height
anchors.verticalCenter: accountWidget.verticalCenter
anchors.horizontalCenter: accountWidget.horizontalCenter
source: (loggedIn && profile["profile_image_url"]) ? profile["profile_image_url"] : ""
outlineColor: loggedIn ? UM.Theme.getColor("account_widget_outline_active") : UM.Theme.getColor("lining")
}
contentItem: Item
{
anchors.verticalCenter: accountWidget.verticalCenter
anchors.horizontalCenter: accountWidget.horizontalCenter
visible: avatar.source == ""
Rectangle
{
id: initialCircle
anchors.centerIn: parent
width: Math.min(accountWidget.width, accountWidget.height)
height: width
radius: width
color: UM.Theme.getColor("main_window_header_background")
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("primary_text")
Rectangle
{
id: initialCircleFill
anchors.fill: parent
radius: parent.radius
color: UM.Theme.getColor("primary_text")
opacity: accountWidget.hovered ? 0.2 : 0
Behavior on opacity { NumberAnimation { duration: 100 } }
}
}
UM.Label
{
id: initialLabel
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
text: accountWidget.text
font: UM.Theme.getFont("large_bold")
color: UM.Theme.getColor("primary_text")
horizontalAlignment: Text.AlignHCenter
}
}
onClicked: {
if (popup.opened)
{
popup.close()
} else {
Cura.API.account.popupOpened()
popup.open()
}
}
}
Popup
{
id: popup
y: parent.height + UM.Theme.getSize("default_arrow").height
x: parent.width - width
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
onOpened: Cura.API.account.popupOpened()
opacity: opened ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 100 } }
padding: 0
contentItem: AccountDetails
{}
background: UM.PointingRectangle
{
color: UM.Theme.getColor("tool_panel_background")
borderColor: UM.Theme.getColor("lining")
borderWidth: UM.Theme.getSize("default_lining").width
target: Qt.point(width - ((signInButton.visible ? signInButton.width : accountWidget.width) / 2), -10)
arrowSize: UM.Theme.getSize("default_arrow").width
}
}
}
|