mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-09 23:05:01 -06:00
Remake: Change to "sign in" button
CURA-6132
This commit is contained in:
parent
949a687a07
commit
6aebdade73
2 changed files with 66 additions and 20 deletions
|
@ -1,46 +1,91 @@
|
|||
// Copyright (c) 2018 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
|
||||
import UM 1.4 as UM
|
||||
import Cura 1.1 as Cura
|
||||
|
||||
Button
|
||||
Item
|
||||
{
|
||||
id: accountWidget
|
||||
property var profile: Cura.API.account.userProfile
|
||||
property var loggedIn: Cura.API.account.isLoggedIn
|
||||
|
||||
implicitHeight: UM.Theme.getSize("main_window_header").height
|
||||
implicitWidth: UM.Theme.getSize("main_window_header").height
|
||||
height: signInButton.height > accountWidget.height ? signInButton.height : accountWidget.height
|
||||
width: signInButton.width > accountWidget.width ? signInButton.width : accountWidget.width
|
||||
|
||||
background: AvatarImage
|
||||
Button
|
||||
{
|
||||
id: avatar
|
||||
id: signInButton
|
||||
|
||||
width: Math.round(0.8 * accountWidget.width)
|
||||
height: Math.round(0.8 * accountWidget.height)
|
||||
anchors.verticalCenter: accountWidget.verticalCenter
|
||||
anchors.horizontalCenter: accountWidget.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
source:
|
||||
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
|
||||
{
|
||||
if(loggedIn)
|
||||
radius: UM.Theme.getSize("action_button_radius").width
|
||||
color: signInButton.hovered ? UM.Theme.getColor("primary_text") : UM.Theme.getColor("main_window_header_background")
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
border.color: UM.Theme.getColor("primary_text")
|
||||
}
|
||||
|
||||
contentItem: Label
|
||||
{
|
||||
id: label
|
||||
text: signInButton.text
|
||||
font: UM.Theme.getFont("default")
|
||||
color: signInButton.hovered ? UM.Theme.getColor("main_window_header_background") : UM.Theme.getColor("primary_text")
|
||||
width: contentWidth
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
Button
|
||||
{
|
||||
id: accountWidget
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
implicitHeight: UM.Theme.getSize("main_window_header").height
|
||||
implicitWidth: UM.Theme.getSize("main_window_header").height
|
||||
|
||||
visible: loggedIn
|
||||
|
||||
background: AvatarImage
|
||||
{
|
||||
id: avatar
|
||||
|
||||
width: Math.round(0.8 * accountWidget.width)
|
||||
height: Math.round(0.8 * accountWidget.height)
|
||||
anchors.verticalCenter: accountWidget.verticalCenter
|
||||
anchors.horizontalCenter: accountWidget.horizontalCenter
|
||||
|
||||
source:
|
||||
{
|
||||
if(profile["profile_image_url"])
|
||||
if(loggedIn)
|
||||
{
|
||||
return profile["profile_image_url"]
|
||||
if(profile["profile_image_url"])
|
||||
{
|
||||
return profile["profile_image_url"]
|
||||
}
|
||||
return UM.Theme.getImage("avatar_no_user")
|
||||
}
|
||||
return UM.Theme.getImage("avatar_no_user")
|
||||
}
|
||||
return UM.Theme.getImage("avatar_no_user")
|
||||
outlineColor: loggedIn ? UM.Theme.getColor("account_widget_outline_active") : UM.Theme.getColor("lining")
|
||||
}
|
||||
outlineColor: loggedIn ? UM.Theme.getColor("account_widget_outline_active") : UM.Theme.getColor("lining")
|
||||
}
|
||||
|
||||
onClicked: popup.opened ? popup.close() : popup.open()
|
||||
onClicked: popup.opened ? popup.close() : popup.open()
|
||||
}
|
||||
|
||||
Popup
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue