Browse Source

Add the digital factory button

CURA-7418
Jaime van Kessel 4 years ago
parent
commit
a7e7ddf4b5

+ 4 - 0
cura/CuraApplication.py

@@ -261,6 +261,10 @@ class CuraApplication(QtApplication):
     def ultimakerCloudAccountRootUrl(self) -> str:
         return UltimakerCloudAuthentication.CuraCloudAccountAPIRoot
 
+    @pyqtProperty(str, constant=True)
+    def ultimakerDigitalFactoryUrl(self) -> str:
+        return UltimakerCloudAuthentication.CuraDigitalFactoryURL
+
     def addCommandLineOptions(self):
         """Adds command line options to the command line parser.
 

+ 8 - 0
cura/UltimakerCloud/UltimakerCloudAuthentication.py

@@ -7,6 +7,7 @@
 DEFAULT_CLOUD_API_ROOT = "https://api.ultimaker.com"  # type: str
 DEFAULT_CLOUD_API_VERSION = "1"  # type: str
 DEFAULT_CLOUD_ACCOUNT_API_ROOT = "https://account.ultimaker.com"  # type: str
+DEFAULT_DIGITAL_FACTORY_URL = "https://digitalfactory.ultimaker.com"  # type: str
 
 try:
     from cura.CuraVersion import CuraCloudAPIRoot  # type: ignore
@@ -28,3 +29,10 @@ try:
         CuraCloudAccountAPIRoot = DEFAULT_CLOUD_ACCOUNT_API_ROOT
 except ImportError:
     CuraCloudAccountAPIRoot = DEFAULT_CLOUD_ACCOUNT_API_ROOT
+
+try:
+    from cura.CuraVersion import CuraDigitalFactoryURL
+    if CuraDigitalFactoryURL == "":
+        CuraDigitalFactoryURL = DEFAULT_DIGITAL_FACTORY_URL
+except ImportError:
+    CuraDigitalFactoryURL = DEFAULT_DIGITAL_FACTORY_URL

+ 4 - 0
resources/qml/Account/SyncState.qml

@@ -91,6 +91,8 @@ Row // Sync state icon + message
             color: UM.Theme.getColor("text")
             font: UM.Theme.getFont("medium")
             renderType: Text.NativeRendering
+            height: contentHeight
+            verticalAlignment: Text.AlignVCenter
             visible: !Cura.API.account.manualSyncEnabled
         }
 
@@ -101,6 +103,8 @@ Row // Sync state icon + message
             color: UM.Theme.getColor("secondary_button_text")
             font: UM.Theme.getFont("medium")
             renderType: Text.NativeRendering
+            verticalAlignment: Text.AlignVCenter
+            height: contentHeight
             visible: Cura.API.account.manualSyncEnabled
 
             MouseArea

+ 64 - 38
resources/qml/Account/UserOperations.qml

@@ -9,62 +9,88 @@ import Cura 1.1 as Cura
 
 Column
 {
-    spacing: UM.Theme.getSize("default_margin").height
+    spacing: UM.Theme.getSize("narrow_margin").height
 
-    Label
+    Item
     {
-        id: title
-        anchors.horizontalCenter: parent.horizontalCenter
-        horizontalAlignment: Text.AlignHCenter
-        renderType: Text.NativeRendering
-        text: catalog.i18nc("@label The argument is a username.", "Hi %1").arg(profile.username)
-        font: UM.Theme.getFont("large_bold")
-        color: UM.Theme.getColor("text")
+        width: childrenRect.width
+        height: childrenRect.height
+        AvatarImage
+        {
+            id: avatar
+
+            width: UM.Theme.getSize("main_window_header").height
+            height: UM.Theme.getSize("main_window_header").height
+
+            source: profile["profile_image_url"] ? profile["profile_image_url"] : ""
+            outlineColor: "transparent"
+        }
+        Column
+        {
+            anchors.left: avatar.right
+            anchors.leftMargin: UM.Theme.getSize("default_margin").width
+            spacing: UM.Theme.getSize("narrow_margin").height
+            Label
+            {
+                id: username
+                renderType: Text.NativeRendering
+                text: profile.username
+                font: UM.Theme.getFont("large_bold")
+                color: UM.Theme.getColor("text")
+            }
+
+            SyncState
+            {
+                id: syncRow
+            }
+            Label
+            {
+                id: lastSyncLabel
+                renderType: Text.NativeRendering
+                text: catalog.i18nc("@label The argument is a timestamp", "Last update: %1").arg(Cura.API.account.lastSyncDateTime)
+                font: UM.Theme.getFont("default")
+                color: UM.Theme.getColor("text_medium")
+            }
+        }
     }
 
-    SyncState
+    Rectangle
     {
-        id: syncRow
+        width: parent.width
+        color: UM.Theme.getColor("lining")
+        height: UM.Theme.getSize("default_lining").height
     }
-
-    Label
+    Cura.TertiaryButton
     {
-        id: lastSyncLabel
-        anchors.horizontalCenter: parent.horizontalCenter
-        horizontalAlignment: Text.AlignHCenter
-        renderType: Text.NativeRendering
-        text: catalog.i18nc("@label The argument is a timestamp", "Last update: %1").arg(Cura.API.account.lastSyncDateTime)
-        font: UM.Theme.getFont("default")
-        color: UM.Theme.getColor("text_medium")
+        id: cloudButton
+        width: UM.Theme.getSize("account_button").width
+        height: UM.Theme.getSize("account_button").height
+        text: catalog.i18nc("@button", "Ultimaker Digital Factory")
+        onClicked: Qt.openUrlExternally(CuraApplication.ultimakerDigitalFactoryUrl)
+        fixedWidthMode: false
     }
 
-    Cura.SecondaryButton
+    Cura.TertiaryButton
     {
         id: accountButton
-        anchors.horizontalCenter: parent.horizontalCenter
         width: UM.Theme.getSize("account_button").width
         height: UM.Theme.getSize("account_button").height
-        text: catalog.i18nc("@button", "Ultimaker account")
+        text: catalog.i18nc("@button", "Ultimaker Account")
         onClicked: Qt.openUrlExternally(CuraApplication.ultimakerCloudAccountRootUrl)
         fixedWidthMode: false
     }
 
-    Label
+    Rectangle
     {
-        id: signOutButton
-        anchors.horizontalCenter: parent.horizontalCenter
-        text: catalog.i18nc("@button", "Sign out")
-        color: UM.Theme.getColor("secondary_button_text")
-        font: UM.Theme.getFont("medium")
-        renderType: Text.NativeRendering
+        width: parent.width
+        color: UM.Theme.getColor("lining")
+        height: UM.Theme.getSize("default_lining").height
+    }
 
-        MouseArea
-        {
-            anchors.fill: parent
-            onClicked: Cura.API.account.logout()
-            hoverEnabled: true
-            onEntered: signOutButton.font.underline = true
-            onExited: signOutButton.font.underline = false
-        }
+    Cura.TertiaryButton
+    {
+        id: signOutButton
+        onClicked: Cura.API.account.logout()
+        text: catalog.i18nc("@button", "Sign Out")
     }
 }