mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-20 13:17:51 -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.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtNetwork import QLocalServer
|
||||
from PyQt5.QtNetwork import QLocalSocket
|
||||
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# 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
|
||||
|
||||
class CuraStage(Stage):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
|
||||
@pyqtProperty(QObject, constant = True)
|
||||
@pyqtProperty(str, constant = True)
|
||||
def stageId(self):
|
||||
return self.getPluginId()
|
||||
|
||||
@pyqtProperty(QUrl, constant = True)
|
||||
def mainComponent(self):
|
||||
return self.getDisplayComponent("main")
|
||||
|
||||
@pyqtProperty(QObject, constant = True)
|
||||
@pyqtProperty(QUrl, constant = True)
|
||||
def sidebarComponent(self):
|
||||
return self.getDisplayComponent("sidebar")
|
||||
|
|
|
@ -9,14 +9,13 @@ from cura.Stages.CuraStage import CuraStage
|
|||
## Stage for monitoring a 3D printing while it's printing.
|
||||
class MonitorStage(CuraStage):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
Application.getInstance().engineCreatedSignal.connect(self._engineCreated)
|
||||
# TODO: connect output device state to icon source
|
||||
|
||||
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!
|
||||
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)
|
||||
self.addDisplayComponent("sidebar", sidebar_component_path)
|
||||
self.setIconSource(Application.getInstance().getTheme().getIcon("tab_status_connected"))
|
||||
|
|
|
@ -9,11 +9,10 @@ from cura.Stages.CuraStage import CuraStage
|
|||
## Stage for preparing model (slicing).
|
||||
class PrepareStage(CuraStage):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
Application.getInstance().engineCreatedSignal.connect(self._engineCreated)
|
||||
|
||||
def _engineCreated(self):
|
||||
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)
|
||||
self.addDisplayComponent("sidebar", sidebar_component_path)
|
||||
|
|
|
@ -377,7 +377,8 @@ UM.MainWindow
|
|||
width: UM.Theme.getSize("sidebar").width
|
||||
z: 1
|
||||
|
||||
sourceComponent: UM.Controller.activeStage.sidebarComponent
|
||||
source: UM.Controller.activeStage.sidebarComponent
|
||||
asynchronous: true
|
||||
}
|
||||
|
||||
Loader
|
||||
|
@ -390,10 +391,6 @@ UM.MainWindow
|
|||
bottom: parent.bottom
|
||||
left: parent.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
|
||||
|
@ -403,7 +400,8 @@ UM.MainWindow
|
|||
// onWheel: wheel.accepted = true
|
||||
// }
|
||||
|
||||
sourceComponent: UM.Controller.activeStage.mainComponent
|
||||
source: UM.Controller.activeStage.mainComponent
|
||||
asynchronous: true
|
||||
}
|
||||
|
||||
UM.MessageStack
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -403,8 +403,6 @@ Item
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Infill
|
||||
//
|
||||
|
@ -568,18 +566,24 @@ Item
|
|||
model: infillModel
|
||||
anchors.fill: parent
|
||||
|
||||
property int activeIndex: {
|
||||
function activeIndex () {
|
||||
for (var i = 0; i < infillModel.count; i++) {
|
||||
var density = parseInt(infillDensity.properties.value)
|
||||
var steps = parseInt(infillSteps.properties.value)
|
||||
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
|
||||
&& steps >= infillModelItem.stepsMin
|
||||
&& steps <= infillModelItem.stepsMax){
|
||||
return i
|
||||
}
|
||||
&& steps <= infillModelItem.stepsMax
|
||||
){
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
@ -587,7 +591,7 @@ Item
|
|||
Rectangle
|
||||
{
|
||||
anchors.fill: parent
|
||||
visible: infillIconList.activeIndex == index
|
||||
visible: infillIconList.activeIndex() == index
|
||||
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
border.color: UM.Theme.getColor("quality_slider_unavailable")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue