Skip to content

Commit e8b6e8a

Browse files
committed
Add revert/store buttons to profile selector in 5.3
1 parent 99dc0cf commit e8b6e8a

File tree

3 files changed

+224
-3
lines changed

3 files changed

+224
-3
lines changed

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Sidebar GUI",
33
"author": "fieldOfView",
4-
"version": "4.5.1-DEV",
4+
"version": "4.6.0",
55
"minimum_cura_version": "4.0",
66
"maximum_cura_version": "5.3",
77
"description": "Provides an alternative, setting-centric interface based around a fixed sidebar",
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
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+
Item
12+
{
13+
width: parent.width
14+
height: UM.Theme.getSize("setting_control").height + UM.Theme.getSize("default_margin").height
15+
16+
anchors
17+
{
18+
top: parent.top
19+
left: parent.left
20+
leftMargin: parent.padding
21+
right: parent.right
22+
rightMargin: parent.padding
23+
}
24+
25+
Button
26+
{
27+
id: intentSelection
28+
onClicked: menu.opened ? menu.close() : menu.open()
29+
30+
anchors.left: parent.left
31+
anchors.leftMargin: UM.Theme.getSize("narrow_margin").width + UM.Theme.getSize("default_margin").width
32+
anchors.right: modeToggleSwitch.left
33+
anchors.rightMargin: UM.Theme.getSize("default_margin").width
34+
height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height
35+
hoverEnabled: true
36+
visible: printSetupSelector.contentItem.currentModeIndex == Cura.PrintSetupSelectorContents.Mode.Custom
37+
38+
baselineOffset: 0 // If we don't do this, there is a binding loop. WHich is a bit weird, since we override the contentItem anyway...
39+
40+
contentItem: RowLayout
41+
{
42+
spacing: 0
43+
anchors.left: parent.left
44+
anchors.right: customisedSettings.left
45+
anchors.leftMargin: UM.Theme.getSize("default_margin").width
46+
47+
Label
48+
{
49+
id: textLabel
50+
text:
51+
{
52+
if(isLE52) {
53+
return Cura.MachineManager.activeQualityDisplayNameMap["main"]
54+
} else {
55+
return Cura.MachineManager.activeQualityDisplayNameMainStringParts.join(" - ")
56+
}
57+
}
58+
font: UM.Theme.getFont("default")
59+
color: UM.Theme.getColor("text")
60+
Layout.margins: 0
61+
Layout.maximumWidth: Math.floor(parent.width * 0.7) // Always leave >= 30% for the rest of the row.
62+
height: contentHeight
63+
verticalAlignment: Text.AlignVCenter
64+
renderType: Text.NativeRendering
65+
elide: Text.ElideRight
66+
}
67+
68+
Label
69+
{
70+
text: activeQualityDetailText()
71+
font: UM.Theme.getFont("default")
72+
color: UM.Theme.getColor("text_detail")
73+
Layout.margins: 0
74+
Layout.fillWidth: true
75+
76+
height: contentHeight
77+
verticalAlignment: Text.AlignVCenter
78+
renderType: Text.NativeRendering
79+
elide: Text.ElideRight
80+
81+
function activeQualityDetailText()
82+
{
83+
if(isLE52) {
84+
var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
85+
var resultSuffix = resultMap["suffix"]
86+
var result = ""
87+
88+
if (Cura.MachineManager.isActiveQualityExperimental)
89+
{
90+
resultSuffix += " (Experimental)"
91+
}
92+
93+
if (Cura.MachineManager.isActiveQualitySupported)
94+
{
95+
if (Cura.MachineManager.activeQualityLayerHeight > 0)
96+
{
97+
if (resultSuffix)
98+
{
99+
result += " - " + resultSuffix
100+
}
101+
result += " - "
102+
result += Cura.MachineManager.activeQualityLayerHeight + "mm"
103+
}
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(" - ")}`
115+
}
116+
}
117+
}
118+
}
119+
}
120+
121+
background: Rectangle
122+
{
123+
id: backgroundItem
124+
border.color: intentSelection.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border")
125+
border.width: UM.Theme.getSize("default_lining").width
126+
radius: UM.Theme.getSize("default_radius").width
127+
color: UM.Theme.getColor("main_background")
128+
}
129+
130+
Cura.ProfileWarningReset
131+
{
132+
id: customisedSettings
133+
fullWarning: false
134+
visible: Cura.MachineManager.hasUserSettings
135+
136+
anchors.verticalCenter: parent.verticalCenter
137+
anchors.right: downArrow.left
138+
anchors.rightMargin: UM.Theme.getSize("default_margin").width
139+
}
140+
141+
UM.ColorImage
142+
{
143+
id: downArrow
144+
145+
source: UM.Theme.getIcon("ChevronSingleDown")
146+
width: UM.Theme.getSize("standard_arrow").width
147+
height: UM.Theme.getSize("standard_arrow").height
148+
149+
anchors
150+
{
151+
right: parent.right
152+
verticalCenter: parent.verticalCenter
153+
rightMargin: UM.Theme.getSize("default_margin").width
154+
}
155+
156+
color: UM.Theme.getColor("setting_control_button")
157+
}
158+
}
159+
160+
Cura.QualitiesWithIntentMenu
161+
{
162+
id: menu
163+
y: intentSelection.y + intentSelection.height
164+
x: intentSelection.x
165+
width: intentSelection.width
166+
}
167+
168+
ModeToggleSwitch
169+
{
170+
id: modeToggleSwitch
171+
anchors.right: dockButton.left
172+
anchors.rightMargin: UM.Theme.getSize("default_margin").width
173+
}
174+
175+
UM.SimpleButton
176+
{
177+
id: dockButton
178+
anchors
179+
{
180+
verticalCenter: modeToggleSwitch.verticalCenter
181+
182+
right: collapseButton.left
183+
rightMargin: UM.Theme.getSize("thin_margin").width
184+
}
185+
iconSource: Qt.resolvedUrl(settingsDocked ? "../icons/settings_undock.svg" : "../icons/settings_dock.svg")
186+
width: UM.Theme.getSize("default_arrow").width + 2 * UM.Theme.getSize("default_lining").width
187+
height: width
188+
color: UM.Theme.getColor("small_button_text")
189+
190+
onClicked:
191+
{
192+
UM.Preferences.setValue("sidebargui/docked_sidebar", !UM.Preferences.getValue("sidebargui/docked_sidebar"))
193+
stageMenu.settingsDocked = UM.Preferences.getValue("sidebargui/docked_sidebar")
194+
}
195+
}
196+
197+
UM.SimpleButton
198+
{
199+
id: collapseButton
200+
anchors
201+
{
202+
verticalCenter: modeToggleSwitch.verticalCenter
203+
204+
right: parent.right
205+
rightMargin: UM.Theme.getSize("default_margin").width
206+
}
207+
iconSource: UM.Theme.getIcon("Cancel")
208+
width: UM.Theme.getSize("default_arrow").width + 2 * UM.Theme.getSize("default_lining").width
209+
height: width
210+
color: UM.Theme.getColor("small_button_text")
211+
212+
onClicked:
213+
{
214+
UM.Preferences.setValue("view/settings_visible", false)
215+
stageMenu.settingsVisible = false
216+
}
217+
}
218+
}

resources/qml/SidebarContents.qml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ Cura.RoundedRectangle
3535
{
3636
var isGE44 = (CuraSDKVersion >= "7.0.0");
3737
var isGE50 = (CuraSDKVersion >= "8.0.0");
38-
var isGE51 = (CuraSDKVersion >= "8.1.0") || UM.Application.version == "master" || UM.Application.version == "dev";
39-
if (isGE51) {
38+
var isGE51 = (CuraSDKVersion >= "8.1.0");
39+
var isGE53 = (CuraSDKVersion >= "8.3.0") || UM.Application.version == "master" || UM.Application.version == "dev";
40+
if (isGE53) {
41+
return "ProfileSelector53.qml";
42+
}else if (isGE51) {
4043
return "ProfileSelector51.qml";
4144
} else if(isGE50) {
4245
return "ProfileSelector50.qml";

0 commit comments

Comments
 (0)