Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'resources/qml/PrinterSelector/MachineSelector.qml')
-rw-r--r--resources/qml/PrinterSelector/MachineSelector.qml118
1 files changed, 96 insertions, 22 deletions
diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml
index 2a101e4ae3..17bb80906a 100644
--- a/resources/qml/PrinterSelector/MachineSelector.qml
+++ b/resources/qml/PrinterSelector/MachineSelector.qml
@@ -5,16 +5,67 @@ import QtQuick 2.7
import QtQuick.Controls 2.3
import UM 1.2 as UM
-import Cura 1.0 as Cura
+import Cura 1.1 as Cura
Cura.ExpandablePopup
{
id: machineSelector
property bool isNetworkPrinter: Cura.MachineManager.activeMachineHasNetworkConnection
- property bool isCloudPrinter: Cura.MachineManager.activeMachineHasCloudConnection
+ property bool isConnectedCloudPrinter: Cura.MachineManager.activeMachineHasCloudConnection
+ property bool isCloudRegistered: Cura.MachineManager.activeMachineHasCloudRegistration
property bool isGroup: Cura.MachineManager.activeMachineIsGroup
+ readonly property string connectionStatus: {
+ if (isNetworkPrinter)
+ {
+ return "printer_connected"
+ }
+ else if (isConnectedCloudPrinter && Cura.API.connectionStatus.isInternetReachable)
+ {
+ return "printer_cloud_connected"
+ }
+ else if (isCloudRegistered)
+ {
+ return "printer_cloud_not_available"
+ }
+ else
+ {
+ return ""
+ }
+ }
+
+ function getConnectionStatusMessage() {
+ if (connectionStatus == "printer_cloud_not_available")
+ {
+ if(Cura.API.connectionStatus.isInternetReachable)
+ {
+ if (Cura.API.account.isLoggedIn)
+ {
+ if (Cura.MachineManager.activeMachineIsLinkedToCurrentAccount)
+ {
+ return catalog.i18nc("@status", "The cloud printer is offline. Please check if the printer is turned on and connected to the internet.")
+ }
+ else
+ {
+ return catalog.i18nc("@status", "This printer is not linked to your account. Please visit the Ultimaker Digital Factory to establish a connection.")
+ }
+ }
+ else
+ {
+ return catalog.i18nc("@status", "The cloud connection is currently unavailable. Please sign in to connect to the cloud printer.")
+ }
+ } else
+ {
+ return catalog.i18nc("@status", "The cloud connection is currently unavailable. Please check your internet connection.")
+ }
+ }
+ else
+ {
+ return ""
+ }
+ }
+
contentPadding: UM.Theme.getSize("default_lining").width
contentAlignment: Cura.ExpandablePopup.ContentAlignment.AlignLeft
@@ -44,7 +95,7 @@ Cura.ExpandablePopup
{
return UM.Theme.getIcon("printer_group")
}
- else if (isNetworkPrinter || isCloudPrinter)
+ else if (isNetworkPrinter || isCloudRegistered)
{
return UM.Theme.getIcon("printer_single")
}
@@ -59,6 +110,7 @@ Cura.ExpandablePopup
UM.RecolorImage
{
+ id: connectionStatusImage
anchors
{
bottom: parent.bottom
@@ -66,27 +118,14 @@ Cura.ExpandablePopup
leftMargin: UM.Theme.getSize("thick_margin").width
}
- source:
- {
- if (isNetworkPrinter)
- {
- return UM.Theme.getIcon("printer_connected")
- }
- else if (isCloudPrinter)
- {
- return UM.Theme.getIcon("printer_cloud_connected")
- }
- else
- {
- return ""
- }
- }
+ source: UM.Theme.getIcon(connectionStatus)
width: UM.Theme.getSize("printer_status_icon").width
height: UM.Theme.getSize("printer_status_icon").height
- color: UM.Theme.getColor("primary")
- visible: isNetworkPrinter || isCloudPrinter
+ color: connectionStatus == "printer_cloud_not_available" ? UM.Theme.getColor("cloud_unavailable") : UM.Theme.getColor("primary")
+
+ visible: isNetworkPrinter || isCloudRegistered
// Make a themable circle in the background so we can change it in other themes
Rectangle
@@ -100,6 +139,39 @@ Cura.ExpandablePopup
color: UM.Theme.getColor("main_background")
z: parent.z - 1
}
+
+ }
+
+ MouseArea // Connection status tooltip hover area
+ {
+ id: connectionStatusTooltipHoverArea
+ anchors.fill: parent
+ hoverEnabled: getConnectionStatusMessage() !== ""
+ acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks
+
+ onEntered:
+ {
+ machineSelector.mouseArea.entered() // we want both this and the outer area to be entered
+ tooltip.tooltipText = getConnectionStatusMessage()
+ tooltip.show()
+ }
+ onExited: { tooltip.hide() }
+ }
+
+ Cura.ToolTip
+ {
+ id: tooltip
+
+ width: 250 * screenScaleFactor
+ tooltipText: getConnectionStatusMessage()
+ arrowSize: UM.Theme.getSize("button_tooltip_arrow").width
+ x: connectionStatusImage.x - UM.Theme.getSize("narrow_margin").width
+ y: connectionStatusImage.y + connectionStatusImage.height + UM.Theme.getSize("narrow_margin").height
+ z: popup.z + 1
+ targetPoint: Qt.point(
+ connectionStatusImage.x + Math.round(connectionStatusImage.width / 2),
+ connectionStatusImage.y
+ )
}
}
@@ -166,7 +238,8 @@ Cura.ExpandablePopup
text: catalog.i18nc("@button", "Add printer")
// The maximum width of the button is half of the total space, minus the padding of the parent, the left
// padding of the component and half the spacing because of the space between buttons.
- maximumWidth: UM.Theme.getSize("machine_selector_widget_content").width / 2 - parent.padding - leftPadding - parent.spacing / 2
+ fixedWidthMode: true
+ width: UM.Theme.getSize("machine_selector_widget_content").width / 2 - leftPadding
onClicked:
{
toggleContent()
@@ -180,9 +253,10 @@ Cura.ExpandablePopup
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@button", "Manage printers")
+ fixedWidthMode: true
// The maximum width of the button is half of the total space, minus the padding of the parent, the right
// padding of the component and half the spacing because of the space between buttons.
- maximumWidth: UM.Theme.getSize("machine_selector_widget_content").width / 2 - parent.padding - rightPadding - parent.spacing / 2
+ width: UM.Theme.getSize("machine_selector_widget_content").width / 2 - leftPadding
onClicked:
{
toggleContent()