Skip to content

Commit

Permalink
Add support for Cura 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
fieldOfView committed Feb 22, 2023
1 parent 3128c7e commit 99dc0cf
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 59 deletions.
1 change: 1 addition & 0 deletions SidebarGUIPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
class SidebarGUIPlugin(Extension):
def __init__(self):
super().__init__()

self._prepare_stage_view_id = "SolidView" # can be "SolidView" or "XRayView"

Application.getInstance().pluginsLoaded.connect(self._onPluginsLoaded)
Expand Down
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"author": "fieldOfView",
"version": "4.5.1-DEV",
"minimum_cura_version": "4.0",
"maximum_cura_version": "5.2",
"maximum_cura_version": "5.3",
"description": "Provides an alternative, setting-centric interface based around a fixed sidebar",
"api": "6.0.0",
"supported_sdk_versions": [
"6.0.0", "6.1.0", "6.2.0", "6.3.0",
"7.0.0", "7.1.0", "7.2.0", "7.3.0", "7.4.0", "7.5.0", "7.6.0", "7.7.0", "7.8.0", "7.9.0",
"8.0.0", "8.1.0", "8.2.0"
"8.0.0", "8.1.0", "8.2.0", "8.3.0"
],
"i18n-catalog": "cura"
}
33 changes: 33 additions & 0 deletions resources/qml/MachineSelector40.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2022 Aldo Hoeben / fieldOfView
// SidebarGUIPlugin is released under the terms of the AGPLv3 or higher.

import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3

import UM 1.3 as UM
import Cura 1.1 as Cura

Cura.MachineSelector
{
id: machineSelection
headerCornerSide: Cura.RoundedRectangle.Direction.All

Component.onCompleted:
{
if(isLE410)
{
machineSelection.children[1].visible = false // remove shadow
}

if(isLE46)
{
var machineSelectionHeader = machineSelection.children[0].children[3].children[0]
} else {
var machineSelectionHeader = machineSelection.children[0].children[3].children[1]
}
// adjust header margins, because the height is smaller than designed
machineSelectionHeader.anchors.topMargin = 0
machineSelectionHeader.anchors.bottomMargin = 0
}
}
75 changes: 75 additions & 0 deletions resources/qml/MachineSelector53.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) 2022 Aldo Hoeben / fieldOfView
// SidebarGUIPlugin is released under the terms of the AGPLv3 or higher.

import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3

import UM 1.3 as UM
import Cura 1.1 as Cura

Cura.MachineSelector
{
id: machineSelection
headerCornerSide: Cura.RoundedRectangle.Direction.All

machineManager: Cura.MachineManager
onSelectPrinter: function(machine)
{
toggleContent();
Cura.MachineManager.setActiveMachine(machine.id);
}
machineListModel: Cura.MachineListModel {}
buttons: [
Cura.SecondaryButton
{
id: addPrinterButton
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@button", "Add printer")
// The maximum width of the button is half of the total space, minus the padding of the parent, the left
// padding of the component and half the spacing because of the space between buttons.
fixedWidthMode: true
width: Math.round(parent.width / 2 - leftPadding * 1.5)
onClicked:
{
machineSelection.toggleContent()
Cura.Actions.addMachine.trigger()
}
},
Cura.SecondaryButton
{
id: managePrinterButton
leftPadding: UM.Theme.getSize("default_margin").width
rightPadding: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@button", "Manage printers")
fixedWidthMode: true
// The maximum width of the button is half of the total space, minus the padding of the parent, the right
// padding of the component and half the spacing because of the space between buttons.
width: Math.round(parent.width / 2 - rightPadding * 1.5)
onClicked:
{
machineSelection.toggleContent()
Cura.Actions.configureMachines.trigger()
}
}
]

Component.onCompleted:
{
if(isLE410)
{
machineSelection.children[1].visible = false // remove shadow
}

if(isLE46)
{
var machineSelectionHeader = machineSelection.children[0].children[3].children[0]
} else {
var machineSelectionHeader = machineSelection.children[0].children[3].children[1]
}
// adjust header margins, because the height is smaller than designed
machineSelectionHeader.anchors.topMargin = 0
machineSelectionHeader.anchors.bottomMargin = 0
}
}
35 changes: 15 additions & 20 deletions resources/qml/MonitorStageMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Item
property bool isLE410
property bool isLE413
property bool isLE51
property bool isLE52

Component.onCompleted:
{
Expand All @@ -28,7 +29,8 @@ Item
isLE46 = (CuraSDKVersion <= "7.2.0")
isLE410 = (CuraSDKVersion <= "7.6.0")
isLE413 = (CuraSDKVersion <= "7.9.0")
isLE51 = (CuraSDKVersion <= "8.1.0") && UM.Application.version != "master" && UM.Application.version != "dev"
isLE51 = (CuraSDKVersion <= "8.1.0")
isLE52 = (CuraSDKVersion <= "8.2.0") && UM.Application.version != "master" && UM.Application.version != "dev"

// adjust message stack position for sidebar
var messageStack
Expand All @@ -44,10 +46,14 @@ Item
{
messageStack = base.contentItem.children[2].children[3].children[8]
}
else
else if(isLE52)
{
messageStack = base.contentItem.children[3].children[3].children[8]
}
else
{
messageStack = base.contentItem.children[4].children[3].children[8]
}
messageStack.anchors.horizontalCenter = undefined
messageStack.anchors.left = messageStack.parent.left
messageStack.anchors.leftMargin = Qt.binding(function()
Expand All @@ -72,10 +78,10 @@ Item
})
}

Cura.MachineSelector
Loader
{
id: machineSelection
headerCornerSide: Cura.RoundedRectangle.Direction.All
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("print_setup_widget").width - width
width: UM.Theme.getSize("machine_selector_widget").width
height:
{
Expand All @@ -86,26 +92,15 @@ Item
return Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
}
}
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("print_setup_widget").width - width
y: - Math.floor((UM.Theme.getSize("main_window_header").height + height) / 2)

Component.onCompleted:
source:
{
if(isLE410)
{
machineSelection.children[1].visible = false // remove shadow
}

if(isLE46)
{
var machineSelectionHeader = machineSelection.children[0].children[3].children[0]
if(isLE52) {
return "MachineSelector40.qml";
} else {
var machineSelectionHeader = machineSelection.children[0].children[3].children[1]
return "MachineSelector53.qml";
}
// adjust header margins, because the height is smaller than designed
machineSelectionHeader.anchors.topMargin = 0
machineSelectionHeader.anchors.bottomMargin = 0
}
}
}
52 changes: 35 additions & 17 deletions resources/qml/ProfileSelector51.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ Item
Label
{
id: textLabel
text: Cura.MachineManager.activeQualityDisplayNameMap["main"]
text:
{
if(isLE52) {
return Cura.MachineManager.activeQualityDisplayNameMap["main"]
} else {
return Cura.MachineManager.activeQualityDisplayNameMainStringParts.join(" - ")
}
}
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
Layout.margins: 0
Expand All @@ -73,29 +80,40 @@ Item

function activeQualityDetailText()
{
var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
var resultSuffix = resultMap["suffix"]
var result = ""
if(isLE52) {
var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
var resultSuffix = resultMap["suffix"]
var result = ""

if (Cura.MachineManager.isActiveQualityExperimental)
{
resultSuffix += " (Experimental)"
}
if (Cura.MachineManager.isActiveQualityExperimental)
{
resultSuffix += " (Experimental)"
}

if (Cura.MachineManager.isActiveQualitySupported)
{
if (Cura.MachineManager.activeQualityLayerHeight > 0)
if (Cura.MachineManager.isActiveQualitySupported)
{
if (resultSuffix)
if (Cura.MachineManager.activeQualityLayerHeight > 0)
{
result += " - " + resultSuffix
if (resultSuffix)
{
result += " - " + resultSuffix
}
result += " - "
result += Cura.MachineManager.activeQualityLayerHeight + "mm"
}
result += " - "
result += Cura.MachineManager.activeQualityLayerHeight + "mm"
}
return result
} else {
const string_parts = Cura.MachineManager.activeQualityDisplayNameTailStringParts;
if (string_parts.length === 0)
{
return "";
}
else
{
return ` - ${string_parts.join(" - ")}`
}
}

return result
}
}
}
Expand Down
46 changes: 26 additions & 20 deletions resources/qml/SidebarStageMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Item
property bool isLE410
property bool isLE413
property bool isLE51
property bool isLE52

property bool prepareStageActive: UM.Controller.activeStage.toString().indexOf("PrepareStage") == 0
property bool preSlicedData: PrintInformation !== null && PrintInformation.preSliced
Expand All @@ -34,7 +35,8 @@ Item
isLE46 = (CuraSDKVersion <= "7.2.0")
isLE410 = (CuraSDKVersion <= "7.6.0")
isLE413 = (CuraSDKVersion <= "7.9.0")
isLE51 = (CuraSDKVersion <= "8.1.0") && UM.Application.version != "master" && UM.Application.version != "dev"
isLE51 = (CuraSDKVersion <= "8.1.0")
isLE52 = (CuraSDKVersion <= "8.2.0") && UM.Application.version != "master" && UM.Application.version != "dev"
if(is40)
{
CuraApplication.log("SidebarGUIPlugin patching interface for Cura 4.0")
Expand All @@ -59,10 +61,14 @@ Item
{
CuraApplication.log("SidebarGUIPlugin patching interface for Cura 5.0 - 5.1")
}
else
else if(isLE52)
{
CuraApplication.log("SidebarGUIPlugin patching interface for Cura 5.2 and newer")
}
else
{
CuraApplication.log("SidebarGUIPlugin patching interface for Cura 5.3 and newer")
}

// top-align toolbar (defined in Cura.qml)
toolbar.visible = true
Expand All @@ -89,10 +95,14 @@ Item
{
messageStack = base.contentItem.children[2].children[3].children[8]
}
else
else if(isLE52)
{
messageStack = base.contentItem.children[3].children[3].children[8]
}
else
{
messageStack = base.contentItem.children[4].children[3].children[8]
}
messageStack.anchors.horizontalCenter = undefined
messageStack.anchors.left = messageStack.parent.left
messageStack.anchors.leftMargin = Qt.binding(function()
Expand Down Expand Up @@ -159,6 +169,13 @@ Item
customPrintSetup.children[0].height = 0
customPrintSetup.children[2].anchors.rightMargin = 0

var recommendedPrintSetup = printSetupChildren.children[0]
if(!isLE52)
{
recommendedPrintSetup.height = undefined
recommendedPrintSetup.children[0].contentItem.children[0].children[9].children[0].visible = false
}

// tweak header height
headerBackground.height = mainWindowHeader.height + UM.Theme.getSize("default_margin").height
main.anchors.top = main.parent.top
Expand Down Expand Up @@ -208,10 +225,9 @@ Item
}
}

Cura.MachineSelector
Loader
{
id: machineSelection
headerCornerSide: Cura.RoundedRectangle.Direction.All
anchors.left: printSetupSidebar.left
width: UM.Theme.getSize("machine_selector_widget").width
height:
{
Expand All @@ -222,25 +238,15 @@ Item
return Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
}
}
anchors.left: printSetupSidebar.left
y: - Math.floor((UM.Theme.getSize("main_window_header").height + height) / 2)

Component.onCompleted:
source:
{
if(isLE410)
{
machineSelection.children[1].visible = false // remove shadow
}

if(isLE46)
{
var machineSelectionHeader = machineSelection.children[0].children[3].children[0]
if(isLE52) {
return "MachineSelector40.qml";
} else {
var machineSelectionHeader = machineSelection.children[0].children[3].children[1]
return "MachineSelector53.qml";
}
// adjust header margins, because the height is smaller than designed
machineSelectionHeader.anchors.topMargin = 0
machineSelectionHeader.anchors.bottomMargin = 0
}
}

Expand Down

0 comments on commit 99dc0cf

Please sign in to comment.