mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 05:39:02 +08:00
Remake: Change to "sign in" button
CURA-6132
This commit is contained in:
parent
949a687a07
commit
6aebdade73
@ -1,46 +1,91 @@
|
|||||||
// Copyright (c) 2018 Ultimaker B.V.
|
// Copyright (c) 2018 Ultimaker B.V.
|
||||||
// Cura is released under the terms of the LGPLv3 or higher.
|
// Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import QtQuick 2.7
|
import QtQuick 2.10
|
||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.3
|
||||||
|
|
||||||
import UM 1.4 as UM
|
import UM 1.4 as UM
|
||||||
import Cura 1.1 as Cura
|
import Cura 1.1 as Cura
|
||||||
|
|
||||||
Button
|
Item
|
||||||
{
|
{
|
||||||
id: accountWidget
|
|
||||||
property var profile: Cura.API.account.userProfile
|
property var profile: Cura.API.account.userProfile
|
||||||
property var loggedIn: Cura.API.account.isLoggedIn
|
property var loggedIn: Cura.API.account.isLoggedIn
|
||||||
|
|
||||||
implicitHeight: UM.Theme.getSize("main_window_header").height
|
height: signInButton.height > accountWidget.height ? signInButton.height : accountWidget.height
|
||||||
implicitWidth: UM.Theme.getSize("main_window_header").height
|
width: signInButton.width > accountWidget.width ? signInButton.width : accountWidget.width
|
||||||
|
|
||||||
background: AvatarImage
|
Button
|
||||||
{
|
{
|
||||||
id: avatar
|
id: signInButton
|
||||||
|
|
||||||
width: Math.round(0.8 * accountWidget.width)
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
height: Math.round(0.8 * accountWidget.height)
|
|
||||||
anchors.verticalCenter: accountWidget.verticalCenter
|
|
||||||
anchors.horizontalCenter: accountWidget.horizontalCenter
|
|
||||||
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
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
|
Popup
|
||||||
{
|
{
|
||||||
|
@ -122,6 +122,7 @@ Item
|
|||||||
id: accountWidget
|
id: accountWidget
|
||||||
anchors
|
anchors
|
||||||
{
|
{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: UM.Theme.getSize("default_margin").width
|
rightMargin: UM.Theme.getSize("default_margin").width
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user