Skip to content

Commit 99dc0cf

Browse files
committed
Add support for Cura 5.3
1 parent 3128c7e commit 99dc0cf

File tree

7 files changed

+187
-59
lines changed

7 files changed

+187
-59
lines changed

SidebarGUIPlugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
class SidebarGUIPlugin(Extension):
2525
def __init__(self):
2626
super().__init__()
27+
2728
self._prepare_stage_view_id = "SolidView" # can be "SolidView" or "XRayView"
2829

2930
Application.getInstance().pluginsLoaded.connect(self._onPluginsLoaded)

plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"author": "fieldOfView",
44
"version": "4.5.1-DEV",
55
"minimum_cura_version": "4.0",
6-
"maximum_cura_version": "5.2",
6+
"maximum_cura_version": "5.3",
77
"description": "Provides an alternative, setting-centric interface based around a fixed sidebar",
88
"api": "6.0.0",
99
"supported_sdk_versions": [
1010
"6.0.0", "6.1.0", "6.2.0", "6.3.0",
1111
"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",
12-
"8.0.0", "8.1.0", "8.2.0"
12+
"8.0.0", "8.1.0", "8.2.0", "8.3.0"
1313
],
1414
"i18n-catalog": "cura"
1515
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) 2022 Aldo Hoeben / fieldOfView
2+
// SidebarGUIPlugin is released under the terms of the AGPLv3 or higher.
3+
4+
import QtQuick 2.10
5+
import QtQuick.Controls 2.3
6+
import QtQuick.Layouts 1.3
7+
8+
import UM 1.3 as UM
9+
import Cura 1.1 as Cura
10+
11+
Cura.MachineSelector
12+
{
13+
id: machineSelection
14+
headerCornerSide: Cura.RoundedRectangle.Direction.All
15+
16+
Component.onCompleted:
17+
{
18+
if(isLE410)
19+
{
20+
machineSelection.children[1].visible = false // remove shadow
21+
}
22+
23+
if(isLE46)
24+
{
25+
var machineSelectionHeader = machineSelection.children[0].children[3].children[0]
26+
} else {
27+
var machineSelectionHeader = machineSelection.children[0].children[3].children[1]
28+
}
29+
// adjust header margins, because the height is smaller than designed
30+
machineSelectionHeader.anchors.topMargin = 0
31+
machineSelectionHeader.anchors.bottomMargin = 0
32+
}
33+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright (c) 2022 Aldo Hoeben / fieldOfView
2+
// SidebarGUIPlugin is released under the terms of the AGPLv3 or higher.
3+
4+
import QtQuick 2.10
5+
import QtQuick.Controls 2.3
6+
import QtQuick.Layouts 1.3
7+
8+
import UM 1.3 as UM
9+
import Cura 1.1 as Cura
10+
11+
Cura.MachineSelector
12+
{
13+
id: machineSelection
14+
headerCornerSide: Cura.RoundedRectangle.Direction.All
15+
16+
machineManager: Cura.MachineManager
17+
onSelectPrinter: function(machine)
18+
{
19+
toggleContent();
20+
Cura.MachineManager.setActiveMachine(machine.id);
21+
}
22+
machineListModel: Cura.MachineListModel {}
23+
buttons: [
24+
Cura.SecondaryButton
25+
{
26+
id: addPrinterButton
27+
leftPadding: UM.Theme.getSize("default_margin").width
28+
rightPadding: UM.Theme.getSize("default_margin").width
29+
text: catalog.i18nc("@button", "Add printer")
30+
// The maximum width of the button is half of the total space, minus the padding of the parent, the left
31+
// padding of the component and half the spacing because of the space between buttons.
32+
fixedWidthMode: true
33+
width: Math.round(parent.width / 2 - leftPadding * 1.5)
34+
onClicked:
35+
{
36+
machineSelection.toggleContent()
37+
Cura.Actions.addMachine.trigger()
38+
}
39+
},
40+
Cura.SecondaryButton
41+
{
42+
id: managePrinterButton
43+
leftPadding: UM.Theme.getSize("default_margin").width
44+
rightPadding: UM.Theme.getSize("default_margin").width
45+
text: catalog.i18nc("@button", "Manage printers")
46+
fixedWidthMode: true
47+
// The maximum width of the button is half of the total space, minus the padding of the parent, the right
48+
// padding of the component and half the spacing because of the space between buttons.
49+
width: Math.round(parent.width / 2 - rightPadding * 1.5)
50+
onClicked:
51+
{
52+
machineSelection.toggleContent()
53+
Cura.Actions.configureMachines.trigger()
54+
}
55+
}
56+
]
57+
58+
Component.onCompleted:
59+
{
60+
if(isLE410)
61+
{
62+
machineSelection.children[1].visible = false // remove shadow
63+
}
64+
65+
if(isLE46)
66+
{
67+
var machineSelectionHeader = machineSelection.children[0].children[3].children[0]
68+
} else {
69+
var machineSelectionHeader = machineSelection.children[0].children[3].children[1]
70+
}
71+
// adjust header margins, because the height is smaller than designed
72+
machineSelectionHeader.anchors.topMargin = 0
73+
machineSelectionHeader.anchors.bottomMargin = 0
74+
}
75+
}

resources/qml/MonitorStageMenu.qml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Item
2020
property bool isLE410
2121
property bool isLE413
2222
property bool isLE51
23+
property bool isLE52
2324

2425
Component.onCompleted:
2526
{
@@ -28,7 +29,8 @@ Item
2829
isLE46 = (CuraSDKVersion <= "7.2.0")
2930
isLE410 = (CuraSDKVersion <= "7.6.0")
3031
isLE413 = (CuraSDKVersion <= "7.9.0")
31-
isLE51 = (CuraSDKVersion <= "8.1.0") && UM.Application.version != "master" && UM.Application.version != "dev"
32+
isLE51 = (CuraSDKVersion <= "8.1.0")
33+
isLE52 = (CuraSDKVersion <= "8.2.0") && UM.Application.version != "master" && UM.Application.version != "dev"
3234

3335
// adjust message stack position for sidebar
3436
var messageStack
@@ -44,10 +46,14 @@ Item
4446
{
4547
messageStack = base.contentItem.children[2].children[3].children[8]
4648
}
47-
else
49+
else if(isLE52)
4850
{
4951
messageStack = base.contentItem.children[3].children[3].children[8]
5052
}
53+
else
54+
{
55+
messageStack = base.contentItem.children[4].children[3].children[8]
56+
}
5157
messageStack.anchors.horizontalCenter = undefined
5258
messageStack.anchors.left = messageStack.parent.left
5359
messageStack.anchors.leftMargin = Qt.binding(function()
@@ -72,10 +78,10 @@ Item
7278
})
7379
}
7480

75-
Cura.MachineSelector
81+
Loader
7682
{
77-
id: machineSelection
78-
headerCornerSide: Cura.RoundedRectangle.Direction.All
83+
anchors.right: parent.right
84+
anchors.rightMargin: UM.Theme.getSize("print_setup_widget").width - width
7985
width: UM.Theme.getSize("machine_selector_widget").width
8086
height:
8187
{
@@ -86,26 +92,15 @@ Item
8692
return Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
8793
}
8894
}
89-
anchors.right: parent.right
90-
anchors.rightMargin: UM.Theme.getSize("print_setup_widget").width - width
9195
y: - Math.floor((UM.Theme.getSize("main_window_header").height + height) / 2)
9296

93-
Component.onCompleted:
97+
source:
9498
{
95-
if(isLE410)
96-
{
97-
machineSelection.children[1].visible = false // remove shadow
98-
}
99-
100-
if(isLE46)
101-
{
102-
var machineSelectionHeader = machineSelection.children[0].children[3].children[0]
99+
if(isLE52) {
100+
return "MachineSelector40.qml";
103101
} else {
104-
var machineSelectionHeader = machineSelection.children[0].children[3].children[1]
102+
return "MachineSelector53.qml";
105103
}
106-
// adjust header margins, because the height is smaller than designed
107-
machineSelectionHeader.anchors.topMargin = 0
108-
machineSelectionHeader.anchors.bottomMargin = 0
109104
}
110105
}
111106
}

resources/qml/ProfileSelector51.qml

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ Item
4747
Label
4848
{
4949
id: textLabel
50-
text: Cura.MachineManager.activeQualityDisplayNameMap["main"]
50+
text:
51+
{
52+
if(isLE52) {
53+
return Cura.MachineManager.activeQualityDisplayNameMap["main"]
54+
} else {
55+
return Cura.MachineManager.activeQualityDisplayNameMainStringParts.join(" - ")
56+
}
57+
}
5158
font: UM.Theme.getFont("default")
5259
color: UM.Theme.getColor("text")
5360
Layout.margins: 0
@@ -73,29 +80,40 @@ Item
7380

7481
function activeQualityDetailText()
7582
{
76-
var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
77-
var resultSuffix = resultMap["suffix"]
78-
var result = ""
83+
if(isLE52) {
84+
var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
85+
var resultSuffix = resultMap["suffix"]
86+
var result = ""
7987

80-
if (Cura.MachineManager.isActiveQualityExperimental)
81-
{
82-
resultSuffix += " (Experimental)"
83-
}
88+
if (Cura.MachineManager.isActiveQualityExperimental)
89+
{
90+
resultSuffix += " (Experimental)"
91+
}
8492

85-
if (Cura.MachineManager.isActiveQualitySupported)
86-
{
87-
if (Cura.MachineManager.activeQualityLayerHeight > 0)
93+
if (Cura.MachineManager.isActiveQualitySupported)
8894
{
89-
if (resultSuffix)
95+
if (Cura.MachineManager.activeQualityLayerHeight > 0)
9096
{
91-
result += " - " + resultSuffix
97+
if (resultSuffix)
98+
{
99+
result += " - " + resultSuffix
100+
}
101+
result += " - "
102+
result += Cura.MachineManager.activeQualityLayerHeight + "mm"
92103
}
93-
result += " - "
94-
result += Cura.MachineManager.activeQualityLayerHeight + "mm"
104+
}
105+
return result
106+
} else {
107+
const string_parts = Cura.MachineManager.activeQualityDisplayNameTailStringParts;
108+
if (string_parts.length === 0)
109+
{
110+
return "";
111+
}
112+
else
113+
{
114+
return ` - ${string_parts.join(" - ")}`
95115
}
96116
}
97-
98-
return result
99117
}
100118
}
101119
}

resources/qml/SidebarStageMenu.qml

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Item
1717
property bool isLE410
1818
property bool isLE413
1919
property bool isLE51
20+
property bool isLE52
2021

2122
property bool prepareStageActive: UM.Controller.activeStage.toString().indexOf("PrepareStage") == 0
2223
property bool preSlicedData: PrintInformation !== null && PrintInformation.preSliced
@@ -34,7 +35,8 @@ Item
3435
isLE46 = (CuraSDKVersion <= "7.2.0")
3536
isLE410 = (CuraSDKVersion <= "7.6.0")
3637
isLE413 = (CuraSDKVersion <= "7.9.0")
37-
isLE51 = (CuraSDKVersion <= "8.1.0") && UM.Application.version != "master" && UM.Application.version != "dev"
38+
isLE51 = (CuraSDKVersion <= "8.1.0")
39+
isLE52 = (CuraSDKVersion <= "8.2.0") && UM.Application.version != "master" && UM.Application.version != "dev"
3840
if(is40)
3941
{
4042
CuraApplication.log("SidebarGUIPlugin patching interface for Cura 4.0")
@@ -59,10 +61,14 @@ Item
5961
{
6062
CuraApplication.log("SidebarGUIPlugin patching interface for Cura 5.0 - 5.1")
6163
}
62-
else
64+
else if(isLE52)
6365
{
6466
CuraApplication.log("SidebarGUIPlugin patching interface for Cura 5.2 and newer")
6567
}
68+
else
69+
{
70+
CuraApplication.log("SidebarGUIPlugin patching interface for Cura 5.3 and newer")
71+
}
6672

6773
// top-align toolbar (defined in Cura.qml)
6874
toolbar.visible = true
@@ -89,10 +95,14 @@ Item
8995
{
9096
messageStack = base.contentItem.children[2].children[3].children[8]
9197
}
92-
else
98+
else if(isLE52)
9399
{
94100
messageStack = base.contentItem.children[3].children[3].children[8]
95101
}
102+
else
103+
{
104+
messageStack = base.contentItem.children[4].children[3].children[8]
105+
}
96106
messageStack.anchors.horizontalCenter = undefined
97107
messageStack.anchors.left = messageStack.parent.left
98108
messageStack.anchors.leftMargin = Qt.binding(function()
@@ -159,6 +169,13 @@ Item
159169
customPrintSetup.children[0].height = 0
160170
customPrintSetup.children[2].anchors.rightMargin = 0
161171

172+
var recommendedPrintSetup = printSetupChildren.children[0]
173+
if(!isLE52)
174+
{
175+
recommendedPrintSetup.height = undefined
176+
recommendedPrintSetup.children[0].contentItem.children[0].children[9].children[0].visible = false
177+
}
178+
162179
// tweak header height
163180
headerBackground.height = mainWindowHeader.height + UM.Theme.getSize("default_margin").height
164181
main.anchors.top = main.parent.top
@@ -208,10 +225,9 @@ Item
208225
}
209226
}
210227

211-
Cura.MachineSelector
228+
Loader
212229
{
213-
id: machineSelection
214-
headerCornerSide: Cura.RoundedRectangle.Direction.All
230+
anchors.left: printSetupSidebar.left
215231
width: UM.Theme.getSize("machine_selector_widget").width
216232
height:
217233
{
@@ -222,25 +238,15 @@ Item
222238
return Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
223239
}
224240
}
225-
anchors.left: printSetupSidebar.left
226241
y: - Math.floor((UM.Theme.getSize("main_window_header").height + height) / 2)
227242

228-
Component.onCompleted:
243+
source:
229244
{
230-
if(isLE410)
231-
{
232-
machineSelection.children[1].visible = false // remove shadow
233-
}
234-
235-
if(isLE46)
236-
{
237-
var machineSelectionHeader = machineSelection.children[0].children[3].children[0]
245+
if(isLE52) {
246+
return "MachineSelector40.qml";
238247
} else {
239-
var machineSelectionHeader = machineSelection.children[0].children[3].children[1]
248+
return "MachineSelector53.qml";
240249
}
241-
// adjust header margins, because the height is smaller than designed
242-
machineSelectionHeader.anchors.topMargin = 0
243-
machineSelectionHeader.anchors.bottomMargin = 0
244250
}
245251
}
246252

0 commit comments

Comments
 (0)