mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Remove sidebar controller implementation in favor of stages
This commit is contained in:
parent
a5b99bd862
commit
f1b9a17611
5 changed files with 101 additions and 197 deletions
|
@ -76,10 +76,6 @@ from cura.Settings.ContainerManager import ContainerManager
|
||||||
from cura.Settings.GlobalStack import GlobalStack
|
from cura.Settings.GlobalStack import GlobalStack
|
||||||
from cura.Settings.ExtruderStack import ExtruderStack
|
from cura.Settings.ExtruderStack import ExtruderStack
|
||||||
|
|
||||||
from cura.Sidebar.SidebarController import SidebarController
|
|
||||||
from cura.Sidebar.SidebarControllerProxy import SidebarControllerProxy
|
|
||||||
from cura.Sidebar.SidebarViewModel import SidebarViewModel
|
|
||||||
|
|
||||||
from PyQt5.QtCore import QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
from PyQt5.QtCore import QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
||||||
from UM.FlameProfiler import pyqtSlot
|
from UM.FlameProfiler import pyqtSlot
|
||||||
from PyQt5.QtGui import QColor, QIcon
|
from PyQt5.QtGui import QColor, QIcon
|
||||||
|
@ -200,10 +196,6 @@ class CuraApplication(QtApplication):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
## As of Cura 3.2, the sidebar is controlled by a controller.
|
|
||||||
# This functionality was added to allow plugins registering custom sidebar views.
|
|
||||||
self._sidebar_controller = SidebarController(self)
|
|
||||||
|
|
||||||
self._currently_loading_files = []
|
self._currently_loading_files = []
|
||||||
self._non_sliceable_extensions = []
|
self._non_sliceable_extensions = []
|
||||||
|
|
||||||
|
@ -727,10 +719,6 @@ class CuraApplication(QtApplication):
|
||||||
if not run_headless:
|
if not run_headless:
|
||||||
self.initializeEngine()
|
self.initializeEngine()
|
||||||
|
|
||||||
# Now that the SidebarViewModel has been created we can set the default sidebar view
|
|
||||||
# TODO: put this in a more elegant place
|
|
||||||
self._setDefaultSidebarView()
|
|
||||||
|
|
||||||
if run_headless or self._engine.rootObjects:
|
if run_headless or self._engine.rootObjects:
|
||||||
self.closeSplash()
|
self.closeSplash()
|
||||||
|
|
||||||
|
@ -743,11 +731,6 @@ class CuraApplication(QtApplication):
|
||||||
|
|
||||||
self.exec_()
|
self.exec_()
|
||||||
|
|
||||||
## Get the SidebarController of this application.
|
|
||||||
# \returns SidebarControllers \type{SidebarController}
|
|
||||||
def getSidebarController(self) -> SidebarController:
|
|
||||||
return self._sidebar_controller
|
|
||||||
|
|
||||||
def getMachineManager(self, *args):
|
def getMachineManager(self, *args):
|
||||||
if self._machine_manager is None:
|
if self._machine_manager is None:
|
||||||
self._machine_manager = MachineManager.createMachineManager()
|
self._machine_manager = MachineManager.createMachineManager()
|
||||||
|
@ -807,7 +790,6 @@ class CuraApplication(QtApplication):
|
||||||
|
|
||||||
qmlRegisterUncreatableType(CuraApplication, "Cura", 1, 0, "ResourceTypes", "Just an Enum type")
|
qmlRegisterUncreatableType(CuraApplication, "Cura", 1, 0, "ResourceTypes", "Just an Enum type")
|
||||||
|
|
||||||
qmlRegisterType(SidebarViewModel, "Cura", 1, 0, "SidebarViewModel")
|
|
||||||
qmlRegisterType(ExtrudersModel, "Cura", 1, 0, "ExtrudersModel")
|
qmlRegisterType(ExtrudersModel, "Cura", 1, 0, "ExtrudersModel")
|
||||||
qmlRegisterType(ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel")
|
qmlRegisterType(ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel")
|
||||||
qmlRegisterSingletonType(ProfilesModel, "Cura", 1, 0, "ProfilesModel", ProfilesModel.createProfilesModel)
|
qmlRegisterSingletonType(ProfilesModel, "Cura", 1, 0, "ProfilesModel", ProfilesModel.createProfilesModel)
|
||||||
|
@ -819,7 +801,6 @@ class CuraApplication(QtApplication):
|
||||||
qmlRegisterType(MachineNameValidator, "Cura", 1, 0, "MachineNameValidator")
|
qmlRegisterType(MachineNameValidator, "Cura", 1, 0, "MachineNameValidator")
|
||||||
qmlRegisterType(UserChangesModel, "Cura", 1, 1, "UserChangesModel")
|
qmlRegisterType(UserChangesModel, "Cura", 1, 1, "UserChangesModel")
|
||||||
qmlRegisterSingletonType(ContainerManager, "Cura", 1, 0, "ContainerManager", ContainerManager.createContainerManager)
|
qmlRegisterSingletonType(ContainerManager, "Cura", 1, 0, "ContainerManager", ContainerManager.createContainerManager)
|
||||||
qmlRegisterSingletonType(SidebarControllerProxy, "Cura", 1, 0, "SidebarController", SidebarControllerProxy.createSidebarControllerProxy)
|
|
||||||
|
|
||||||
# As of Qt5.7, it is necessary to get rid of any ".." in the path for the singleton to work.
|
# As of Qt5.7, it is necessary to get rid of any ".." in the path for the singleton to work.
|
||||||
actions_url = QUrl.fromLocalFile(os.path.abspath(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, "Actions.qml")))
|
actions_url = QUrl.fromLocalFile(os.path.abspath(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, "Actions.qml")))
|
||||||
|
@ -1318,13 +1299,6 @@ class CuraApplication(QtApplication):
|
||||||
def _addProfileWriter(self, profile_writer):
|
def _addProfileWriter(self, profile_writer):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
## Set the default sidebar view to "default"
|
|
||||||
def _setDefaultSidebarView(self):
|
|
||||||
preferences = Preferences.getInstance()
|
|
||||||
preferences.addPreference("cura/active_sidebar_view", "default")
|
|
||||||
active_sidebar_view = preferences.getValue("cura/active_sidebar_view")
|
|
||||||
self._sidebar_controller.setActiveSidebarView(active_sidebar_view)
|
|
||||||
|
|
||||||
@pyqtSlot("QSize")
|
@pyqtSlot("QSize")
|
||||||
def setMinimumWindowSize(self, size):
|
def setMinimumWindowSize(self, size):
|
||||||
self.getMainWindow().setMinimumSize(size)
|
self.getMainWindow().setMinimumSize(size)
|
||||||
|
|
|
@ -90,7 +90,7 @@ Rectangle
|
||||||
SidebarHeader {
|
SidebarHeader {
|
||||||
id: header
|
id: header
|
||||||
width: parent.width
|
width: parent.width
|
||||||
visible: (machineExtruderCount.properties.value > 1 || Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariants) && Cura.SidebarController.activeSidebarId == "default"
|
visible: machineExtruderCount.properties.value > 1 || Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariantst
|
||||||
onShowTooltip: base.showTooltip(item, location, text)
|
onShowTooltip: base.showTooltip(item, location, text)
|
||||||
onHideTooltip: base.hideTooltip()
|
onHideTooltip: base.hideTooltip()
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ Rectangle
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: headerSeparator
|
id: headerSeparator
|
||||||
width: parent.width
|
width: parent.width
|
||||||
visible: settingsModeSelection.visible && header.visible && Cura.SidebarController.activeSidebarId == "default"
|
visible: settingsModeSelection.visible && header.visible
|
||||||
height: visible ? UM.Theme.getSize("sidebar_lining").height : 0
|
height: visible ? UM.Theme.getSize("sidebar_lining").height : 0
|
||||||
color: UM.Theme.getColor("sidebar_lining")
|
color: UM.Theme.getColor("sidebar_lining")
|
||||||
anchors.top: header.bottom
|
anchors.top: header.bottom
|
||||||
|
@ -115,7 +115,7 @@ Rectangle
|
||||||
width: Math.floor(parent.width * 0.45)
|
width: Math.floor(parent.width * 0.45)
|
||||||
font: UM.Theme.getFont("large")
|
font: UM.Theme.getFont("large")
|
||||||
color: UM.Theme.getColor("text")
|
color: UM.Theme.getColor("text")
|
||||||
visible: !monitoringPrint && !hideView && Cura.SidebarController.activeSidebarId == "default"
|
visible: !monitoringPrint && !hideView
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -137,7 +137,7 @@ Rectangle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
|
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
|
||||||
visible: !monitoringPrint && !hideSettings && !hideView && Cura.SidebarController.activeSidebarId == "default"
|
visible: !monitoringPrint && !hideSettings && !hideView
|
||||||
Component{
|
Component{
|
||||||
id: wizardDelegate
|
id: wizardDelegate
|
||||||
Button {
|
Button {
|
||||||
|
@ -218,7 +218,7 @@ Rectangle
|
||||||
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
|
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
|
||||||
anchors.left: base.left
|
anchors.left: base.left
|
||||||
anchors.right: base.right
|
anchors.right: base.right
|
||||||
visible: !monitoringPrint && !hideSettings && Cura.SidebarController.activeSidebarId == "default"
|
visible: !monitoringPrint && !hideSettings
|
||||||
|
|
||||||
delegate: StackViewDelegate
|
delegate: StackViewDelegate
|
||||||
{
|
{
|
||||||
|
@ -249,29 +249,6 @@ Rectangle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The sidebarRepeater exposes sidebar views provided by plugins.
|
|
||||||
// Whenever a plugin sidebar view is active (e.g. not "default"), that sidebar view is shown.
|
|
||||||
Repeater
|
|
||||||
{
|
|
||||||
id: sidebarRepeater
|
|
||||||
|
|
||||||
model: Cura.SidebarViewModel { }
|
|
||||||
|
|
||||||
delegate: Loader
|
|
||||||
{
|
|
||||||
id: delegate
|
|
||||||
asynchronous: true
|
|
||||||
visible: model.active
|
|
||||||
|
|
||||||
// dynamically get the component from the sidebar controller or set the default sidebar
|
|
||||||
sourceComponent: {
|
|
||||||
if (model.id !== "default") {
|
|
||||||
return Cura.SidebarController.getSidebarComponent(model.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Loader
|
Loader
|
||||||
{
|
{
|
||||||
id: controlItem
|
id: controlItem
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
// Copyright (c) 2017 Ultimaker B.V.
|
|
||||||
// Cura is released under the terms of the LGPLv3 or higher.
|
|
||||||
|
|
||||||
import QtQuick 2.2
|
|
||||||
import QtQuick.Controls 1.1
|
|
||||||
import QtQuick.Controls.Styles 1.1
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
|
|
||||||
import UM 1.2 as UM
|
|
||||||
import Cura 1.0 as Cura
|
|
||||||
|
|
||||||
Item
|
|
||||||
{
|
|
||||||
id: printerOutputSection
|
|
||||||
|
|
||||||
UM.I18nCatalog {
|
|
||||||
id: catalog
|
|
||||||
name: "cura"
|
|
||||||
}
|
|
||||||
|
|
||||||
color: UM.Theme.getColor("sidebar")
|
|
||||||
|
|
||||||
// status
|
|
||||||
property bool isMonitoring: false
|
|
||||||
|
|
||||||
// printer data
|
|
||||||
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
|
|
||||||
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
|
|
||||||
property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
|
||||||
property int backendState: UM.Backend.state
|
|
||||||
|
|
||||||
// print job data
|
|
||||||
property variant printDuration: PrintInformation.currentPrintTime
|
|
||||||
property variant printMaterialLengths: PrintInformation.materialLengths
|
|
||||||
property variant printMaterialWeights: PrintInformation.materialWeights
|
|
||||||
property variant printMaterialCosts: PrintInformation.materialCosts
|
|
||||||
property variant printMaterialNames: PrintInformation.materialNames
|
|
||||||
|
|
||||||
// helper function for padding pretty time
|
|
||||||
function strPadLeft(string, pad, length) {
|
|
||||||
return (new Array(length + 1).join(pad) + string).slice(-length);
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert a timestamp to a human readable pretty time
|
|
||||||
function getPrettyTime (time) {
|
|
||||||
var hours = Math.floor(time / 3600)
|
|
||||||
time -= hours * 3600
|
|
||||||
var minutes = Math.floor(time / 60)
|
|
||||||
time -= minutes * 60
|
|
||||||
var seconds = Math.floor(time)
|
|
||||||
var finalTime = strPadLeft(hours, "0", 2) + ":" + strPadLeft(minutes, "0", 2) + ":" + strPadLeft(seconds, "0", 2)
|
|
||||||
return finalTime
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: change name of this component
|
|
||||||
MonitorButton
|
|
||||||
{
|
|
||||||
id: monitorButton
|
|
||||||
implicitWidth: base.width
|
|
||||||
anchors.top: footerSeparator.bottom
|
|
||||||
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
visible: monitoringPrint
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -67,91 +67,109 @@ Rectangle
|
||||||
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||||
spacing: UM.Theme.getSize("default_margin").width
|
spacing: UM.Theme.getSize("default_margin").width
|
||||||
|
|
||||||
Button
|
// The topbar is dynamically filled with all available stages
|
||||||
|
Repeater
|
||||||
{
|
{
|
||||||
id: showSettings
|
id: stagesMenu
|
||||||
height: UM.Theme.getSize("sidebar_header").height
|
|
||||||
text: catalog.i18nc("@title:tab", "Prepare")
|
|
||||||
checkable: true
|
|
||||||
checked: isChecked()
|
|
||||||
exclusiveGroup: sidebarHeaderBarGroup
|
|
||||||
style: UM.Theme.styles.topbar_header_tab
|
|
||||||
|
|
||||||
// We use a Qt.binding to re-bind the checkbox state after manually setting it
|
model: UM.StageModel{}
|
||||||
// https://stackoverflow.com/questions/38798450/qt-5-7-qml-why-are-my-checkbox-property-bindings-disappearing
|
|
||||||
onClicked: {
|
|
||||||
base.stopMonitoringPrint()
|
|
||||||
checked = Qt.binding(isChecked)
|
|
||||||
}
|
|
||||||
|
|
||||||
function isChecked () {
|
delegate: Button
|
||||||
return !base.monitoringPrint
|
|
||||||
}
|
|
||||||
|
|
||||||
property color overlayColor: "transparent"
|
|
||||||
property string overlayIconSource: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
Button
|
|
||||||
{
|
|
||||||
id: showMonitor
|
|
||||||
width: UM.Theme.getSize("topbar_button").width
|
|
||||||
height: UM.Theme.getSize("sidebar_header").height
|
|
||||||
text: catalog.i18nc("@title:tab", "Monitor")
|
|
||||||
checkable: true
|
|
||||||
checked: isChecked()
|
|
||||||
exclusiveGroup: sidebarHeaderBarGroup
|
|
||||||
style: UM.Theme.styles.topbar_header_tab_no_overlay
|
|
||||||
|
|
||||||
// We use a Qt.binding to re-bind the checkbox state after manually setting it
|
|
||||||
// https://stackoverflow.com/questions/38798450/qt-5-7-qml-why-are-my-checkbox-property-bindings-disappearing
|
|
||||||
onClicked: {
|
|
||||||
base.startMonitoringPrint()
|
|
||||||
checked = Qt.binding(isChecked)
|
|
||||||
}
|
|
||||||
|
|
||||||
function isChecked () {
|
|
||||||
return base.monitoringPrint
|
|
||||||
}
|
|
||||||
|
|
||||||
property string iconSource:
|
|
||||||
{
|
{
|
||||||
if (!printerConnected)
|
text: model.name
|
||||||
{
|
checkable: true
|
||||||
return UM.Theme.getIcon("tab_status_unknown");
|
checked: model.active
|
||||||
}
|
exclusiveGroup: sidebarHeaderBarGroup
|
||||||
else if (!printerAcceptsCommands)
|
style: UM.Theme.styles.topbar_header_tab
|
||||||
{
|
height: UM.Theme.getSize("sidebar_header").height
|
||||||
return UM.Theme.getIcon("tab_status_unknown");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Cura.MachineManager.printerOutputDevices[0].printerState == "maintenance")
|
|
||||||
{
|
|
||||||
return UM.Theme.getIcon("tab_status_busy");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Cura.MachineManager.printerOutputDevices[0].jobState)
|
|
||||||
{
|
|
||||||
case "printing":
|
|
||||||
case "pre_print":
|
|
||||||
case "pausing":
|
|
||||||
case "resuming":
|
|
||||||
return UM.Theme.getIcon("tab_status_busy");
|
|
||||||
case "wait_cleanup":
|
|
||||||
return UM.Theme.getIcon("tab_status_finished");
|
|
||||||
case "ready":
|
|
||||||
case "":
|
|
||||||
return UM.Theme.getIcon("tab_status_connected")
|
|
||||||
case "paused":
|
|
||||||
return UM.Theme.getIcon("tab_status_paused")
|
|
||||||
case "error":
|
|
||||||
return UM.Theme.getIcon("tab_status_stopped")
|
|
||||||
default:
|
|
||||||
return UM.Theme.getIcon("tab_status_unknown")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Button
|
||||||
|
// {
|
||||||
|
// id: showSettings
|
||||||
|
// height: UM.Theme.getSize("sidebar_header").height
|
||||||
|
// text: catalog.i18nc("@title:tab", "Prepare")
|
||||||
|
// checkable: true
|
||||||
|
// checked: isChecked()
|
||||||
|
// exclusiveGroup: sidebarHeaderBarGroup
|
||||||
|
// style: UM.Theme.styles.topbar_header_tab
|
||||||
|
//
|
||||||
|
// // We use a Qt.binding to re-bind the checkbox state after manually setting it
|
||||||
|
// // https://stackoverflow.com/questions/38798450/qt-5-7-qml-why-are-my-checkbox-property-bindings-disappearing
|
||||||
|
// onClicked: {
|
||||||
|
// base.stopMonitoringPrint()
|
||||||
|
// checked = Qt.binding(isChecked)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// function isChecked () {
|
||||||
|
// return !base.monitoringPrint
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// property color overlayColor: "transparent"
|
||||||
|
// property string overlayIconSource: ""
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Button
|
||||||
|
// {
|
||||||
|
// id: showMonitor
|
||||||
|
// width: UM.Theme.getSize("topbar_button").width
|
||||||
|
// height: UM.Theme.getSize("sidebar_header").height
|
||||||
|
// text: catalog.i18nc("@title:tab", "Monitor")
|
||||||
|
// checkable: true
|
||||||
|
// checked: isChecked()
|
||||||
|
// exclusiveGroup: sidebarHeaderBarGroup
|
||||||
|
// style: UM.Theme.styles.topbar_header_tab_no_overlay
|
||||||
|
//
|
||||||
|
// // We use a Qt.binding to re-bind the checkbox state after manually setting it
|
||||||
|
// // https://stackoverflow.com/questions/38798450/qt-5-7-qml-why-are-my-checkbox-property-bindings-disappearing
|
||||||
|
// onClicked: {
|
||||||
|
// base.startMonitoringPrint()
|
||||||
|
// checked = Qt.binding(isChecked)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// function isChecked () {
|
||||||
|
// return base.monitoringPrint
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// property string iconSource:
|
||||||
|
// {
|
||||||
|
// if (!printerConnected)
|
||||||
|
// {
|
||||||
|
// return UM.Theme.getIcon("tab_status_unknown");
|
||||||
|
// }
|
||||||
|
// else if (!printerAcceptsCommands)
|
||||||
|
// {
|
||||||
|
// return UM.Theme.getIcon("tab_status_unknown");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (Cura.MachineManager.printerOutputDevices[0].printerState == "maintenance")
|
||||||
|
// {
|
||||||
|
// return UM.Theme.getIcon("tab_status_busy");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// switch (Cura.MachineManager.printerOutputDevices[0].jobState)
|
||||||
|
// {
|
||||||
|
// case "printing":
|
||||||
|
// case "pre_print":
|
||||||
|
// case "pausing":
|
||||||
|
// case "resuming":
|
||||||
|
// return UM.Theme.getIcon("tab_status_busy");
|
||||||
|
// case "wait_cleanup":
|
||||||
|
// return UM.Theme.getIcon("tab_status_finished");
|
||||||
|
// case "ready":
|
||||||
|
// case "":
|
||||||
|
// return UM.Theme.getIcon("tab_status_connected")
|
||||||
|
// case "paused":
|
||||||
|
// return UM.Theme.getIcon("tab_status_paused")
|
||||||
|
// case "error":
|
||||||
|
// return UM.Theme.getIcon("tab_status_stopped")
|
||||||
|
// default:
|
||||||
|
// return UM.Theme.getIcon("tab_status_unknown")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
ExclusiveGroup { id: sidebarHeaderBarGroup }
|
ExclusiveGroup { id: sidebarHeaderBarGroup }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue