mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 10:47: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
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -403,8 +403,6 @@ Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Infill
|
// Infill
|
||||||
//
|
//
|
||||||
|
@ -568,18 +566,24 @@ 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
@ -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