Browse Source

Merge branch '3.5'

Diego Prado Gesto 6 years ago
parent
commit
c0c66649b8

+ 11 - 1
cura/Settings/ExtruderManager.py

@@ -360,8 +360,19 @@ class ExtruderManager(QObject):
     # After 3.4, all single-extrusion machines have their own extruder definition files instead of reusing
     # "fdmextruder". We need to check a machine here so its extruder definition is correct according to this.
     def _fixSingleExtrusionMachineExtruderDefinition(self, global_stack: "GlobalStack") -> None:
+        container_registry = ContainerRegistry.getInstance()
         expected_extruder_definition_0_id = global_stack.getMetaDataEntry("machine_extruder_trains")["0"]
         extruder_stack_0 = global_stack.extruders.get("0")
+        # At this point, extruder stacks for this machine may not have been loaded yet. In this case, need to look in
+        # the container registry as well.
+        if not global_stack.extruders:
+            extruder_trains = container_registry.findContainerStacks(type = "extruder_train",
+                                                                     machine = global_stack.getId())
+            if extruder_trains:
+                for extruder in extruder_trains:
+                    if extruder.getMetaDataEntry("position") == "0":
+                        extruder_stack_0 = extruder
+                        break
 
         if extruder_stack_0 is None:
             Logger.log("i", "No extruder stack for global stack [%s], create one", global_stack.getId())
@@ -372,7 +383,6 @@ class ExtruderManager(QObject):
         elif extruder_stack_0.definition.getId() != expected_extruder_definition_0_id:
             Logger.log("e", "Single extruder printer [{printer}] expected extruder [{expected}], but got [{got}]. I'm making it [{expected}].".format(
                 printer = global_stack.getId(), expected = expected_extruder_definition_0_id, got = extruder_stack_0.definition.getId()))
-            container_registry = ContainerRegistry.getInstance()
             extruder_definition = container_registry.findDefinitionContainers(id = expected_extruder_definition_0_id)[0]
             extruder_stack_0.definition = extruder_definition
 

+ 6 - 0
plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml

@@ -185,6 +185,12 @@ Item {
                         {
                             selectedObjectId: UM.ActiveTool.properties.getValue("SelectedObjectId")
                         }
+
+                        // For some reason the model object is updated after removing him from the memory and
+                        // it happens only on Windows. For this reason, set the destroyed value manually.
+                        Component.onDestruction: {
+                            setDestroyed(true);
+                        }
                     }
 
                     delegate: Row

+ 14 - 9
plugins/SliceInfoPlugin/SliceInfo.py

@@ -33,30 +33,35 @@ class SliceInfo(QObject, Extension):
     def __init__(self, parent = None):
         QObject.__init__(self, parent)
         Extension.__init__(self)
-        Application.getInstance().getOutputDeviceManager().writeStarted.connect(self._onWriteStarted)
-        Application.getInstance().getPreferences().addPreference("info/send_slice_info", True)
-        Application.getInstance().getPreferences().addPreference("info/asked_send_slice_info", False)
+
+        self._application = Application.getInstance()
+
+        self._application.getOutputDeviceManager().writeStarted.connect(self._onWriteStarted)
+        self._application.getPreferences().addPreference("info/send_slice_info", True)
+        self._application.getPreferences().addPreference("info/asked_send_slice_info", False)
 
         self._more_info_dialog = None
         self._example_data_content = None
 
-        if not Application.getInstance().getPreferences().getValue("info/asked_send_slice_info"):
+        self._application.initializationFinished.connect(self._onAppInitialized)
+
+    def _onAppInitialized(self):
+        # DO NOT read any preferences values in the constructor because at the time plugins are created, no version
+        # upgrade has been performed yet because version upgrades are plugins too!
+        if not self._application.getPreferences().getValue("info/asked_send_slice_info"):
             self.send_slice_info_message = Message(catalog.i18nc("@info", "Cura collects anonymized usage statistics."),
                                                    lifetime = 0,
                                                    dismissable = False,
                                                    title = catalog.i18nc("@info:title", "Collecting Data"))
 
             self.send_slice_info_message.addAction("MoreInfo", name = catalog.i18nc("@action:button", "More info"), icon = None,
-                    description = catalog.i18nc("@action:tooltip", "See more information on what data Cura sends."), button_style = Message.ActionButtonStyle.LINK)
+                                                   description = catalog.i18nc("@action:tooltip", "See more information on what data Cura sends."), button_style = Message.ActionButtonStyle.LINK)
 
             self.send_slice_info_message.addAction("Dismiss", name = catalog.i18nc("@action:button", "Allow"), icon = None,
-                    description = catalog.i18nc("@action:tooltip", "Allow Cura to send anonymized usage statistics to help prioritize future improvements to Cura. Some of your preferences and settings are sent, the Cura version and a hash of the models you're slicing."))
+                                                   description = catalog.i18nc("@action:tooltip", "Allow Cura to send anonymized usage statistics to help prioritize future improvements to Cura. Some of your preferences and settings are sent, the Cura version and a hash of the models you're slicing."))
             self.send_slice_info_message.actionTriggered.connect(self.messageActionTriggered)
             self.send_slice_info_message.show()
 
-        Application.getInstance().initializationFinished.connect(self._onAppInitialized)
-
-    def _onAppInitialized(self):
         if self._more_info_dialog is None:
             self._more_info_dialog = self._createDialog("MoreInfoWindow.qml")
 

+ 1 - 1
plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml

@@ -15,7 +15,7 @@ Item
     {
         id: sidebar
     }
-    Rectangle
+    Item
     {
         id: header
         anchors

+ 3 - 2
plugins/Toolbox/resources/qml/ToolboxBackColumn.qml

@@ -23,6 +23,7 @@ Item
     {
         id: button
         text: catalog.i18nc("@action:button", "Back")
+        enabled: !toolbox.isDownloading
         UM.RecolorImage
         {
             id: backArrow
@@ -39,7 +40,7 @@ Item
                 width: width
                 height: height
             }
-            color: button.hovered ? UM.Theme.getColor("primary") : UM.Theme.getColor("text")
+            color: button.enabled ? (button.hovered ? UM.Theme.getColor("primary") : UM.Theme.getColor("text")) : UM.Theme.getColor("text_inactive")
             source: UM.Theme.getIcon("arrow_left")
         }
         width: UM.Theme.getSize("toolbox_back_button").width
@@ -59,7 +60,7 @@ Item
             {
                 id: labelStyle
                 text: control.text
-                color: control.hovered ? UM.Theme.getColor("primary") : UM.Theme.getColor("text")
+                color: control.enabled ? (control.hovered ? UM.Theme.getColor("primary") : UM.Theme.getColor("text")) : UM.Theme.getColor("text_inactive")
                 font: UM.Theme.getFont("default_bold")
                 horizontalAlignment: Text.AlignRight
                 width: control.width

+ 1 - 2
plugins/Toolbox/resources/qml/ToolboxDetailPage.qml

@@ -9,9 +9,8 @@ import UM 1.1 as UM
 Item
 {
     id: page
-    property var details: base.selection
+    property var details: base.selection || {}
     anchors.fill: parent
-    width: parent.width
     ToolboxBackColumn
     {
         id: sidebar

+ 3 - 2
plugins/Toolbox/resources/qml/ToolboxHeader.qml

@@ -27,7 +27,7 @@ Item
             id: pluginsTabButton
             text: catalog.i18nc("@title:tab", "Plugins")
             active: toolbox.viewCategory == "plugin" && enabled
-            enabled: toolbox.viewPage != "loading" && toolbox.viewPage != "errored"
+            enabled: !toolbox.isDownloading && toolbox.viewPage != "loading" && toolbox.viewPage != "errored"
             onClicked:
             {
                 toolbox.filterModelByProp("packages", "type", "plugin")
@@ -41,7 +41,7 @@ Item
             id: materialsTabButton
             text: catalog.i18nc("@title:tab", "Materials")
             active: toolbox.viewCategory == "material" && enabled
-            enabled: toolbox.viewPage != "loading" && toolbox.viewPage != "errored"
+            enabled: !toolbox.isDownloading && toolbox.viewPage != "loading" && toolbox.viewPage != "errored"
             onClicked:
             {
                 toolbox.filterModelByProp("authors", "package_types", "material")
@@ -55,6 +55,7 @@ Item
         id: installedTabButton
         text: catalog.i18nc("@title:tab", "Installed")
         active: toolbox.viewCategory == "installed"
+        enabled: !toolbox.isDownloading
         anchors
         {
             right: parent.right

+ 2 - 1
plugins/Toolbox/src/Toolbox.py

@@ -603,7 +603,7 @@ class Toolbox(QObject, Extension):
 
     @pyqtSlot()
     def cancelDownload(self) -> None:
-        Logger.log("i", "Toolbox: User cancelled the download of a plugin.")
+        Logger.log("i", "Toolbox: User cancelled the download of a package.")
         self.resetDownload()
 
     def resetDownload(self) -> None:
@@ -755,6 +755,7 @@ class Toolbox(QObject, Extension):
         self._active_package = package
         self.activePackageChanged.emit()
 
+    ##  The active package is the package that is currently being downloaded
     @pyqtProperty(QObject, fset = setActivePackage, notify = activePackageChanged)
     def activePackage(self) -> Optional[Dict[str, Any]]:
         return self._active_package

+ 47 - 0
plugins/UM3NetworkPrinting/resources/qml/CameraButton.qml

@@ -0,0 +1,47 @@
+import QtQuick 2.3
+import QtQuick.Controls 1.4
+import QtQuick.Controls.Styles 1.3
+import QtQuick.Controls 2.0 as Controls2
+import QtGraphicalEffects 1.0
+
+import UM 1.3 as UM
+import Cura 1.0 as Cura
+
+Rectangle
+{
+    property var iconSource: null
+
+    width: 36 * screenScaleFactor
+    height: width
+    radius: 0.5 * width
+    color: clickArea.containsMouse ? UM.Theme.getColor("primary_hover") : UM.Theme.getColor("primary")
+
+    UM.RecolorImage
+    {
+        id: icon
+        width: parent.width / 2
+        height: width
+        anchors.verticalCenter: parent.verticalCenter
+        anchors.horizontalCenter: parent.horizontalCenter
+        color: UM.Theme.getColor("primary_text")
+        source: iconSource
+    }
+
+    MouseArea
+    {
+        id: clickArea
+        anchors.fill:parent
+        hoverEnabled: true
+        onClicked:
+        {
+            if (OutputDevice.activeCamera !== null)
+            {
+                OutputDevice.setActiveCamera(null)
+            }
+            else
+            {
+                OutputDevice.setActiveCamera(modelData.camera)
+            }
+        }
+    }
+}

+ 136 - 61
plugins/UM3NetworkPrinting/resources/qml/ClusterControlItem.qml

@@ -16,7 +16,7 @@ Component
     {
         id: base
         property var lineColor: "#DCDCDC" // TODO: Should be linked to theme.
-
+        property var shadowRadius: 5 * screenScaleFactor
         property var cornerRadius: 4 * screenScaleFactor // TODO: Should be linked to theme.
         visible: OutputDevice != null
         anchors.fill: parent
@@ -83,6 +83,8 @@ Component
 
             ListView
             {
+                id: printer_list
+                property var current_index: -1
                 anchors
                 {
                     top: parent.top
@@ -105,18 +107,35 @@ Component
                         height: childrenRect.height + UM.Theme.getSize("default_margin").height
                         anchors.horizontalCenter: parent.horizontalCenter
                         anchors.verticalCenter: parent.verticalCenter
+                        color:
+                        {
+                            if(modelData.state == "disabled")
+                            {
+                                return UM.Theme.getColor("monitor_background_inactive")
+                            }
+                            else
+                            {
+                                return UM.Theme.getColor("monitor_background_active") 
+                            }
+                        }
                         id: base
-                        property var shadowRadius: 5
+                        property var shadowRadius: 5 * screenScaleFactor
                         property var collapsed: true
 
                         layer.enabled: true
                         layer.effect: DropShadow
                         {
-                            radius: base.shadowRadius
+                            radius: 5 * screenScaleFactor
                             verticalOffset: 2
                             color: "#3F000000"  // 25% shadow
                         }
 
+                        Connections
+                        {
+                            target: printer_list
+                            onCurrent_indexChanged: { base.collapsed = printer_list.current_index != model.index }
+                        }
+
                         Item
                         {
                             id: printerInfo
@@ -132,7 +151,16 @@ Component
                             MouseArea
                             {
                                 anchors.fill: parent
-                                onClicked: base.collapsed = !base.collapsed
+                                onClicked:
+                                {
+                                    if (base.collapsed) {
+                                        printer_list.current_index = model.index
+                                    }
+                                    else
+                                    {
+                                        printer_list.current_index = -1
+                                    }
+                                }
                             }
 
                             Item
@@ -168,7 +196,7 @@ Component
                                     {
                                         if(modelData.state == "disabled")
                                         {
-                                            return UM.Theme.getColor("setting_control_disabled")
+                                            return UM.Theme.getColor("monitor_text_inactive")
                                         }
 
                                         if(modelData.activePrintJob != undefined)
@@ -176,7 +204,7 @@ Component
                                             return UM.Theme.getColor("primary")
                                         }
 
-                                        return UM.Theme.getColor("setting_control_disabled")
+                                        return UM.Theme.getColor("monitor_text_inactive")
                                     }
                                 }
                             }
@@ -224,7 +252,7 @@ Component
                                     width: parent.width
                                     elide: Text.ElideRight
                                     font: UM.Theme.getFont("default")
-                                    opacity: 0.6
+                                    color: UM.Theme.getColor("monitor_text_inactive")
                                 }
                             }
 
@@ -257,8 +285,16 @@ Component
                             Rectangle
                             {
                                 id: topSpacer
-                                color: UM.Theme.getColor("viewport_background")
-                                height: 2
+                                color:
+                                {
+                                    if(modelData.state == "disabled")
+                                    {
+                                        return UM.Theme.getColor("monitor_lining_inactive")
+                                    }
+                                    return UM.Theme.getColor("viewport_background")
+                                }
+                                // UM.Theme.getColor("viewport_background")
+                                height: 1
                                 anchors
                                 {
                                     left: parent.left
@@ -271,7 +307,14 @@ Component
                             PrinterFamilyPill
                             {
                                 id: printerFamilyPill
-                                color: UM.Theme.getColor("viewport_background")
+                                color:
+                                {
+                                    if(modelData.state == "disabled")
+                                    {
+                                        return "transparent"
+                                    }
+                                    return UM.Theme.getColor("viewport_background")
+                                }
                                 anchors.top: topSpacer.bottom
                                 anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height
                                 text: modelData.type
@@ -357,21 +400,13 @@ Component
 
                                 function switchPopupState()
                                 {
-                                    if (popup.visible)
-                                    {
-                                        popup.close()
-                                    }
-                                    else
-                                    {
-                                        popup.open()
-                                    }
+                                    popup.visible ? popup.close() : popup.open()
                                 }
 
                                 Controls2.Button
                                 {
                                     id: contextButton
                                     text: "\u22EE" //Unicode; Three stacked points.
-                                    font.pixelSize: 25
                                     width: 35
                                     height: width
                                     anchors
@@ -389,6 +424,14 @@ Component
                                         radius: 0.5 * width
                                         color: UM.Theme.getColor("viewport_background")
                                     }
+                                    contentItem: Label
+                                    {
+                                        text: contextButton.text
+                                        color: UM.Theme.getColor("monitor_text_inactive")
+                                        font.pixelSize: 25
+                                        verticalAlignment: Text.AlignVCenter
+                                        horizontalAlignment: Text.AlignHCenter
+                                    }
 
                                     onClicked: parent.switchPopupState()
                                 }
@@ -398,18 +441,21 @@ Component
                                     // TODO Change once updating to Qt5.10 - The 'opened' property is in 5.10 but the behavior is now implemented with the visible property
                                     id: popup
                                     clip: true
-                                    closePolicy: Controls2.Popup.CloseOnPressOutsideParent
-                                    x: parent.width - width
-                                    y: contextButton.height
-                                    width: 160
+                                    closePolicy: Popup.CloseOnPressOutside
+                                    x: (parent.width - width) + 26 * screenScaleFactor
+                                    y: contextButton.height - 5 * screenScaleFactor // Because shadow
+                                    width: 182 * screenScaleFactor
                                     height: contentItem.height + 2 * padding
                                     visible: false
+                                    padding: 5 * screenScaleFactor // Because shadow
 
-                                    transformOrigin: Controls2.Popup.Top
+                                    transformOrigin: Popup.Top
                                     contentItem: Item
                                     {
-                                        width: popup.width - 2 * popup.padding
-                                        height: childrenRect.height + 15
+                                        width: popup.width
+                                        height: childrenRect.height + 36 * screenScaleFactor
+                                        anchors.topMargin: 10 * screenScaleFactor
+                                        anchors.bottomMargin: 10 * screenScaleFactor
                                         Controls2.Button
                                         {
                                             id: pauseButton
@@ -428,14 +474,22 @@ Component
                                             }
                                             width: parent.width
                                             enabled: modelData.activePrintJob != null && ["paused", "printing"].indexOf(modelData.activePrintJob.state) >= 0
+                                            visible: enabled
                                             anchors.top: parent.top
-                                            anchors.topMargin: 10
+                                            anchors.topMargin: 18 * screenScaleFactor
+                                            height: visible ? 39 * screenScaleFactor : 0 * screenScaleFactor
                                             hoverEnabled: true
-                                            background:  Rectangle
+                                            background: Rectangle
                                             {
                                                 opacity: pauseButton.down || pauseButton.hovered ? 1 : 0
                                                 color: UM.Theme.getColor("viewport_background")
                                             }
+                                            contentItem: Label
+                                            {
+                                                text: pauseButton.text
+                                                horizontalAlignment: Text.AlignLeft
+                                                verticalAlignment: Text.AlignVCenter
+                                            }
                                         }
 
                                         Controls2.Button
@@ -448,6 +502,7 @@ Component
                                                 popup.close();
                                             }
                                             width: parent.width
+                                            height: 39 * screenScaleFactor
                                             anchors.top: pauseButton.bottom
                                             hoverEnabled: true
                                             enabled: modelData.activePrintJob != null && ["paused", "printing", "pre_print"].indexOf(modelData.activePrintJob.state) >= 0
@@ -456,6 +511,12 @@ Component
                                                 opacity: abortButton.down || abortButton.hovered ? 1 : 0
                                                 color: UM.Theme.getColor("viewport_background")
                                             }
+                                            contentItem: Label
+                                            {
+                                                text: abortButton.text
+                                                horizontalAlignment: Text.AlignLeft
+                                                verticalAlignment: Text.AlignVCenter
+                                            }
                                         }
 
                                         MessageDialog
@@ -488,19 +549,20 @@ Component
                                         Item
                                         {
                                             id: pointedRectangle
-                                            width: parent.width -10
-                                            height: parent.height -10
+                                            width: parent.width - 10 * screenScaleFactor // Because of the shadow
+                                            height: parent.height - 10 * screenScaleFactor // Because of the shadow
                                             anchors.horizontalCenter: parent.horizontalCenter
                                             anchors.verticalCenter: parent.verticalCenter
 
                                             Rectangle
                                             {
                                                 id: point
-                                                height: 13
-                                                width: 13
+                                                height: 14 * screenScaleFactor
+                                                width: 14 * screenScaleFactor
                                                 color: UM.Theme.getColor("setting_control")
                                                 transform: Rotation { angle: 45}
                                                 anchors.right: bloop.right
+                                                anchors.rightMargin: 24
                                                 y: 1
                                             }
 
@@ -510,9 +572,9 @@ Component
                                                 color: UM.Theme.getColor("setting_control")
                                                 width: parent.width
                                                 anchors.top: parent.top
-                                                anchors.topMargin: 10
+                                                anchors.topMargin: 8 * screenScaleFactor // Because of the shadow + point
                                                 anchors.bottom: parent.bottom
-                                                anchors.bottomMargin: 5
+                                                anchors.bottomMargin: 8 * screenScaleFactor // Because of the shadow
                                             }
                                         }
                                     }
@@ -595,30 +657,14 @@ Component
                                     color: "black"
                                 }
 
-                                Rectangle
+                                CameraButton
                                 {
-                                    id: showCameraIcon
-                                    width: 35 * screenScaleFactor
-                                    height: width
-                                    radius: 0.5 * width
-                                    anchors.left: parent.left
-                                    anchors.bottom: printJobPreview.bottom
-                                    color: UM.Theme.getColor("setting_control_border_highlight")
-                                    Image
-                                    {
-                                        width: parent.width
-                                        height: width
-                                        anchors.right: parent.right
-                                        anchors.rightMargin: parent.rightMargin
-                                        source: "../svg/camera-icon.svg"
-                                    }
-                                    MouseArea
+                                    id: showCameraButton
+                                    iconSource: "../svg/camera-icon.svg"
+                                    anchors
                                     {
-                                        anchors.fill:parent
-                                        onClicked:
-                                        {
-                                            OutputDevice.setActiveCamera(modelData.camera)
-                                        }
+                                        left: parent.left
+                                        bottom: printJobPreview.bottom
                                     }
                                 }
                             }
@@ -650,13 +696,24 @@ Component
 
                             style: ProgressBarStyle
                             {
+                                property var remainingTime:
+                                {
+                                    if(modelData.activePrintJob == null)
+                                    {
+                                        return 0
+                                    }
+                                    /* Sometimes total minus elapsed is less than 0. Use Math.max() to prevent remaining
+                                        time from ever being less than 0. Negative durations cause strange behavior such
+                                        as displaying "-1h -1m". */
+                                    var activeJob = modelData.activePrintJob
+                                    return Math.max(activeJob.timeTotal - activeJob.timeElapsed, 0);
+                                }
                                 property var progressText:
                                 {
                                     if(modelData.activePrintJob == null)
                                     {
                                         return ""
                                     }
-
                                     switch(modelData.activePrintJob.state)
                                     {
                                         case "wait_cleanup":
@@ -669,18 +726,19 @@ Component
                                         case "sent_to_printer":
                                             return catalog.i18nc("@label:status", "Preparing")
                                         case "aborted":
+                                            return catalog.i18nc("@label:status", "Aborted")
                                         case "wait_user_action":
                                             return catalog.i18nc("@label:status", "Aborted")
                                         case "pausing":
                                             return catalog.i18nc("@label:status", "Pausing")
                                         case "paused":
-                                            return catalog.i18nc("@label:status", "Paused")
+                                            return OutputDevice.formatDuration( remainingTime )
                                         case "resuming":
                                             return catalog.i18nc("@label:status", "Resuming")
                                         case "queued":
                                             return catalog.i18nc("@label:status", "Action required")
                                         default:
-                                            OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed)
+                                            return OutputDevice.formatDuration( remainingTime )
                                     }
                                 }
 
@@ -693,11 +751,28 @@ Component
 
                                 progress: Rectangle
                                 {
-                                    color: UM.Theme.getColor("primary")
+                                    color:
+                                    {
+                                        var state = modelData.activePrintJob.state
+                                        var inactiveStates = [
+                                            "pausing",
+                                            "paused",
+                                            "resuming",
+                                            "wait_cleanup"
+                                        ]
+                                        if(inactiveStates.indexOf(state) > -1 && remainingTime > 0)
+                                        {
+                                            return UM.Theme.getColor("monitor_text_inactive")
+                                        }
+                                        else
+                                        {
+                                            return UM.Theme.getColor("primary")
+                                        }
+                                    }
                                     id: progressItem
                                     function getTextOffset()
                                     {
-                                        if(progressItem.width + progressLabel.width < control.width)
+                                        if(progressItem.width + progressLabel.width + 16 < control.width)
                                         {
                                             return progressItem.width + UM.Theme.getSize("default_margin").width
                                         }

Some files were not shown because too many files changed in this diff