Add the callout panel to the account panel, with the two components that

will show up when the user is logged in or when not.

Contributes to CURA-5784.
This commit is contained in:
Diego Prado Gesto 2018-10-09 15:58:13 +02:00
parent 2ffcf03f43
commit 77a1b08f38
9 changed files with 143 additions and 15 deletions

View file

@ -5,10 +5,14 @@ import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import UM 1.4 as UM import UM 1.4 as UM
import Cura 1.1 as Cura
Item Item
{ {
id: base id: accountWidget
property var profile: Cura.API.account.userProfile
property var loggedIn: Cura.API.account.isLoggedIn
property var logoutCallback: Cura.API.account.logout
height: UM.Theme.getSize("topheader").height height: UM.Theme.getSize("topheader").height
width: UM.Theme.getSize("topheader").height width: UM.Theme.getSize("topheader").height
@ -19,24 +23,21 @@ Item
height: Math.round(0.8 * parent.height) height: Math.round(0.8 * parent.height)
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
source: loggedIn ? profile["profile_image_url"] : UM.Theme.getImage("avatar_default")
} }
MouseArea MouseArea
{ {
anchors.fill: avatar anchors.fill: parent
onClicked: onClicked: accountManagementPanel.visible = !accountManagementPanel.visible // Collapse/Expand the dropdown panel
{
// Collapse/Expand the dropdown panel
accountManagementPanel.visible = !accountManagementPanel.visible
}
} }
UM.PointingRectangle UM.PointingRectangle
{ {
id: accountManagementPanel id: accountManagementPanel
width: 250 width: panel.width
height: 250 height: panel.height
anchors anchors
{ {
@ -56,16 +57,23 @@ Item
borderColor: UM.Theme.getColor("lining") borderColor: UM.Theme.getColor("lining")
borderWidth: UM.Theme.getSize("default_lining").width borderWidth: UM.Theme.getSize("default_lining").width
// Shows the user management options or general options to create account
Loader Loader
{ {
id: panel id: panel
sourceComponent: login sourceComponent: loggedIn ? userManagementWidget : generalManagementWidget
} }
} }
Component Component
{ {
id: login id: userManagementWidget
Label {text: "HOLA"} UserManagementWidget { }
}
Component
{
id: generalManagementWidget
GeneralManagementWidget { }
} }
} }

View file

@ -9,10 +9,12 @@ Item
{ {
id: avatar id: avatar
property var source
Image Image
{ {
id: profileImage id: profileImage
source: UM.Theme.getImage("avatar_default") source: avatar.source ? avatar.source : UM.Theme.getImage("avatar_default")
sourceSize: Qt.size(parent.width, parent.height) sourceSize: Qt.size(parent.width, parent.height)
width: parent.width width: parent.width
height: parent.height height: parent.height

View file

@ -0,0 +1,23 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.1
import UM 1.4 as UM
import Cura 1.1 as Cura
import "../components"
Column
{
ActionButton
{
text: catalog.i18nc("@button", "Sign In")
color: "transparent"
hoverColor: "transparent"
textColor: UM.Theme.getColor("text")
textHoverColor: UM.Theme.getColor("text_link")
onClicked: Cura.API.account.login()
}
}

View file

@ -0,0 +1,33 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.1
import UM 1.4 as UM
import Cura 1.1 as Cura
import "../components"
Column
{
ActionButton
{
text: catalog.i18nc("@button", "Manage Profile")
color: "transparent"
hoverColor: "transparent"
textColor: UM.Theme.getColor("text")
textHoverColor: UM.Theme.getColor("text_link")
onClicked: Qt.openUrlExternally("https://account.ultimaker.com")
}
ActionButton
{
text: catalog.i18nc("@button", "Sign Out")
color: "transparent"
hoverColor: "transparent"
textColor: UM.Theme.getColor("text")
textHoverColor: UM.Theme.getColor("text_link")
onClicked: Cura.API.account.logout()
}
}

View file

@ -105,6 +105,7 @@ UM.MainWindow
width: parent.width width: parent.width
height: parent.height - menu.height - topHeader.height height: parent.height - menu.height - topHeader.height
z: topHeader.z - 1
Keys.forwardTo: menu Keys.forwardTo: menu

View file

@ -9,7 +9,7 @@ import QtQuick.Layouts 1.1
import UM 1.4 as UM import UM 1.4 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
import "components" import "../components"
// This item contains the views selector, a combobox that is dinamically created from // This item contains the views selector, a combobox that is dinamically created from
// the list of available Views (packages that create different visualizactions of the // the list of available Views (packages that create different visualizactions of the

View file

@ -8,7 +8,7 @@ import QtQuick.Controls.Styles 1.1
import UM 1.4 as UM import UM 1.4 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
import "components" import "../Accounts"
Rectangle Rectangle
{ {

View file

@ -0,0 +1,61 @@
// 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.Layouts 1.3
import UM 1.1 as UM
Button
{
id: button
property alias cursorShape: mouseArea.cursorShape
property var iconSource: ""
property var color: UM.Theme.getColor("primary")
property var hoverColor: UM.Theme.getColor("primary_hover")
property var disabledColor: color
property var textColor: UM.Theme.getColor("button_text")
property var textHoverColor: UM.Theme.getColor("button_text_hover")
property var textDisabledColor: textColor
property var textFont: UM.Theme.getFont("action_button")
contentItem: Row
{
UM.RecolorImage
{
id: buttonIcon
source: button.iconSource
width: 16 * screenScaleFactor
height: 16 * screenScaleFactor
sourceSize.width: width
sourceSize.height: height
color: button.hovered ? button.textHoverColor : button.textColor
visible: button.iconSource != ""
}
Label
{
id: buttonText
text: button.text
color: button.enabled ? (button.hovered ? button.textHoverColor : button.textColor): button.textDisabledColor
font: button.textFont
visible: button.text != ""
renderType: Text.NativeRendering
}
}
background: Rectangle
{
color: button.enabled ? (button.hovered ? button.hoverColor : button.color) : button.disabledColor
}
MouseArea
{
id: mouseArea
anchors.fill: parent
onPressed: mouse.accepted = false
hoverEnabled: true
cursorShape: button.enabled ? (hovered ? Qt.PointingHandCursor : Qt.ArrowCursor) : Qt.ForbiddenCursor
}
}