mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
Fix sidebar loading and unloading depending on active stage
This commit is contained in:
parent
2d044a37ae
commit
ee643610e5
7 changed files with 601 additions and 603 deletions
|
@ -1,6 +1,5 @@
|
||||||
# Copyright (c) 2017 Ultimaker B.V.
|
# Copyright (c) 2017 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.
|
||||||
|
|
||||||
from PyQt5.QtNetwork import QLocalServer
|
from PyQt5.QtNetwork import QLocalServer
|
||||||
from PyQt5.QtNetwork import QLocalSocket
|
from PyQt5.QtNetwork import QLocalSocket
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,22 @@
|
||||||
# Copyright (c) 2017 Ultimaker B.V.
|
# Copyright (c) 2017 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.
|
||||||
from PyQt5.QtCore import pyqtProperty, QObject
|
from PyQt5.QtCore import pyqtProperty, QUrl, QObject
|
||||||
|
|
||||||
from UM.Stage import Stage
|
from UM.Stage import Stage
|
||||||
|
|
||||||
class CuraStage(Stage):
|
class CuraStage(Stage):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, parent = None):
|
||||||
super().__init__()
|
super().__init__(parent)
|
||||||
|
|
||||||
@pyqtProperty(QObject, constant = True)
|
@pyqtProperty(str, constant = True)
|
||||||
|
def stageId(self):
|
||||||
|
return self.getPluginId()
|
||||||
|
|
||||||
|
@pyqtProperty(QUrl, constant = True)
|
||||||
def mainComponent(self):
|
def mainComponent(self):
|
||||||
return self.getDisplayComponent("main")
|
return self.getDisplayComponent("main")
|
||||||
|
|
||||||
@pyqtProperty(QObject, constant = True)
|
@pyqtProperty(QUrl, constant = True)
|
||||||
def sidebarComponent(self):
|
def sidebarComponent(self):
|
||||||
return self.getDisplayComponent("sidebar")
|
return self.getDisplayComponent("sidebar")
|
||||||
|
|
|
@ -9,14 +9,13 @@ from cura.Stages.CuraStage import CuraStage
|
||||||
## Stage for monitoring a 3D printing while it's printing.
|
## Stage for monitoring a 3D printing while it's printing.
|
||||||
class MonitorStage(CuraStage):
|
class MonitorStage(CuraStage):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, parent = None):
|
||||||
super().__init__()
|
super().__init__(parent)
|
||||||
Application.getInstance().engineCreatedSignal.connect(self._engineCreated)
|
Application.getInstance().engineCreatedSignal.connect(self._engineCreated)
|
||||||
# TODO: connect output device state to icon source
|
# TODO: connect output device state to icon source
|
||||||
|
|
||||||
def _engineCreated(self):
|
def _engineCreated(self):
|
||||||
# Note: currently the sidebar component for prepare and monitor stages is the same, this will change with the printer output device refactor!
|
# Note: currently the sidebar component for prepare and monitor stages is the same, this will change with the printer output device refactor!
|
||||||
sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles), "Sidebar.qml")
|
sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles), "Sidebar.qml")
|
||||||
sidebar_component = Application.getInstance().createQmlComponent(sidebar_component_path)
|
self.addDisplayComponent("sidebar", sidebar_component_path)
|
||||||
self.addDisplayComponent("sidebar", sidebar_component)
|
|
||||||
self.setIconSource(Application.getInstance().getTheme().getIcon("tab_status_connected"))
|
self.setIconSource(Application.getInstance().getTheme().getIcon("tab_status_connected"))
|
||||||
|
|
|
@ -9,11 +9,10 @@ from cura.Stages.CuraStage import CuraStage
|
||||||
## Stage for preparing model (slicing).
|
## Stage for preparing model (slicing).
|
||||||
class PrepareStage(CuraStage):
|
class PrepareStage(CuraStage):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, parent = None):
|
||||||
super().__init__()
|
super().__init__(parent)
|
||||||
Application.getInstance().engineCreatedSignal.connect(self._engineCreated)
|
Application.getInstance().engineCreatedSignal.connect(self._engineCreated)
|
||||||
|
|
||||||
def _engineCreated(self):
|
def _engineCreated(self):
|
||||||
sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles), "Sidebar.qml")
|
sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles), "Sidebar.qml")
|
||||||
sidebar_component = Application.getInstance().createQmlComponent(sidebar_component_path)
|
self.addDisplayComponent("sidebar", sidebar_component_path)
|
||||||
self.addDisplayComponent("sidebar", sidebar_component)
|
|
||||||
|
|
|
@ -377,7 +377,8 @@ UM.MainWindow
|
||||||
width: UM.Theme.getSize("sidebar").width
|
width: UM.Theme.getSize("sidebar").width
|
||||||
z: 1
|
z: 1
|
||||||
|
|
||||||
sourceComponent: UM.Controller.activeStage.sidebarComponent
|
source: UM.Controller.activeStage.sidebarComponent
|
||||||
|
asynchronous: true
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader
|
Loader
|
||||||
|
@ -390,10 +391,6 @@ UM.MainWindow
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: sidebar.left
|
right: sidebar.left
|
||||||
// horizontalCenter: parent.horizontalCenter
|
|
||||||
// verticalCenter: parent.verticalCenter
|
|
||||||
// horizontalCenterOffset: - UM.Theme.getSize("sidebar").width / 2
|
|
||||||
// verticalCenterOffset: UM.Theme.getSize("sidebar_header").height / 2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MouseArea
|
// MouseArea
|
||||||
|
@ -403,7 +400,8 @@ UM.MainWindow
|
||||||
// onWheel: wheel.accepted = true
|
// onWheel: wheel.accepted = true
|
||||||
// }
|
// }
|
||||||
|
|
||||||
sourceComponent: UM.Controller.activeStage.mainComponent
|
source: UM.Controller.activeStage.mainComponent
|
||||||
|
asynchronous: true
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.MessageStack
|
UM.MessageStack
|
||||||
|
|
|
@ -10,10 +10,9 @@ import UM 1.2 as UM
|
||||||
import Cura 1.0 as Cura
|
import Cura 1.0 as Cura
|
||||||
import "Menus"
|
import "Menus"
|
||||||
|
|
||||||
Component
|
|
||||||
|
Rectangle
|
||||||
{
|
{
|
||||||
Rectangle
|
|
||||||
{
|
|
||||||
id: base;
|
id: base;
|
||||||
|
|
||||||
property int currentModeIndex;
|
property int currentModeIndex;
|
||||||
|
@ -26,7 +25,7 @@ Component
|
||||||
property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
||||||
property int backendState: UM.Backend.state
|
property int backendState: UM.Backend.state
|
||||||
|
|
||||||
property bool monitoringPrint: UM.Controller.activeStage.id == "MonitorStage"
|
property bool monitoringPrint: UM.Controller.activeStage.stageId == "MonitorStage"
|
||||||
|
|
||||||
property variant printDuration: PrintInformation.currentPrintTime
|
property variant printDuration: PrintInformation.currentPrintTime
|
||||||
property variant printMaterialLengths: PrintInformation.materialLengths
|
property variant printMaterialLengths: PrintInformation.materialLengths
|
||||||
|
@ -92,7 +91,7 @@ Component
|
||||||
SidebarHeader {
|
SidebarHeader {
|
||||||
id: header
|
id: header
|
||||||
width: parent.width
|
width: parent.width
|
||||||
visible: machineExtruderCount.properties.value > 1 || Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariantst
|
visible: machineExtruderCount.properties.value > 1 || Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariants
|
||||||
onShowTooltip: base.showTooltip(item, location, text)
|
onShowTooltip: base.showTooltip(item, location, text)
|
||||||
onHideTooltip: base.hideTooltip()
|
onHideTooltip: base.hideTooltip()
|
||||||
}
|
}
|
||||||
|
@ -541,7 +540,6 @@ Component
|
||||||
visible: monitoringPrint
|
visible: monitoringPrint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SidebarTooltip
|
SidebarTooltip
|
||||||
{
|
{
|
||||||
id: tooltip;
|
id: tooltip;
|
||||||
|
@ -595,7 +593,6 @@ Component
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
{
|
{
|
||||||
id: machineExtruderCount
|
id: machineExtruderCount
|
||||||
|
|
||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_extruder_count"
|
key: "machine_extruder_count"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
|
@ -605,11 +602,9 @@ Component
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
{
|
{
|
||||||
id: machineHeatedBed
|
id: machineHeatedBed
|
||||||
|
|
||||||
containerStackId: Cura.MachineManager.activeMachineId
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
key: "machine_heated_bed"
|
key: "machine_heated_bed"
|
||||||
watchedProperties: [ "value" ]
|
watchedProperties: [ "value" ]
|
||||||
storeIndex: 0
|
storeIndex: 0
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,8 +403,6 @@ Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Infill
|
// Infill
|
||||||
//
|
//
|
||||||
|
@ -568,16 +566,22 @@ Item
|
||||||
model: infillModel
|
model: infillModel
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
property int activeIndex: {
|
function activeIndex () {
|
||||||
for (var i = 0; i < infillModel.count; i++) {
|
for (var i = 0; i < infillModel.count; i++) {
|
||||||
var density = parseInt(infillDensity.properties.value)
|
var density = parseInt(infillDensity.properties.value)
|
||||||
var steps = parseInt(infillSteps.properties.value)
|
var steps = parseInt(infillSteps.properties.value)
|
||||||
var infillModelItem = infillModel.get(i)
|
var infillModelItem = infillModel.get(i)
|
||||||
|
|
||||||
if (density >= infillModelItem.percentageMin
|
// TODO: somehow this print causes this method not to crash QML when the sidebar view gets unloaded (when switching states)
|
||||||
|
// TODO: That should be fixed :P
|
||||||
|
print("test", density, steps, infillModelItem)
|
||||||
|
|
||||||
|
if (infillModelItem
|
||||||
|
&& density >= infillModelItem.percentageMin
|
||||||
&& density <= infillModelItem.percentageMax
|
&& density <= infillModelItem.percentageMax
|
||||||
&& steps >= infillModelItem.stepsMin
|
&& steps >= infillModelItem.stepsMin
|
||||||
&& steps <= infillModelItem.stepsMax){
|
&& steps <= infillModelItem.stepsMax
|
||||||
|
){
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,7 +591,7 @@ Item
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: infillIconList.activeIndex == index
|
visible: infillIconList.activeIndex() == index
|
||||||
|
|
||||||
border.width: UM.Theme.getSize("default_lining").width
|
border.width: UM.Theme.getSize("default_lining").width
|
||||||
border.color: UM.Theme.getColor("quality_slider_unavailable")
|
border.color: UM.Theme.getColor("quality_slider_unavailable")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue