Fix dark mode issues Post processing plugin

Also revamped the post-processing list a bit.

CURA-8688
This commit is contained in:
casper 2022-02-28 11:41:21 +01:00
parent e2fe50baf1
commit 0a214b2c47

View file

@ -15,14 +15,15 @@ UM.Dialog
id: dialog id: dialog
title: catalog.i18nc("@title:window", "Post Processing Plugin") title: catalog.i18nc("@title:window", "Post Processing Plugin")
width: 700 * screenScaleFactor; width: 700 * screenScaleFactor
height: 500 * screenScaleFactor; height: 500 * screenScaleFactor
minimumWidth: 400 * screenScaleFactor; minimumWidth: 400 * screenScaleFactor
minimumHeight: 250 * screenScaleFactor; minimumHeight: 250 * screenScaleFactor
onVisibleChanged: onVisibleChanged:
{ {
if(!visible) //Whenever the window is closed (either via the "Close" button or the X on the window frame), we want to update it in the stack. // Whenever the window is closed (either via the "Close" button or the X on the window frame), we want to update it in the stack.
if (!visible)
{ {
manager.writeScriptsToStack() manager.writeScriptsToStack()
} }
@ -35,8 +36,7 @@ UM.Dialog
property int columnWidth: Math.round((base.width / 2) - UM.Theme.getSize("default_margin").width) property int columnWidth: Math.round((base.width / 2) - UM.Theme.getSize("default_margin").width)
property int textMargin: UM.Theme.getSize("narrow_margin").width property int textMargin: UM.Theme.getSize("narrow_margin").width
property string activeScriptName property string activeScriptName
SystemPalette{ id: palette }
SystemPalette{ id: disabledPalette; colorGroup: SystemPalette.Disabled }
anchors.fill: parent anchors.fill: parent
ButtonGroup ButtonGroup
@ -51,14 +51,12 @@ UM.Dialog
spacing: base.textMargin spacing: base.textMargin
Label UM.Label
{ {
id: activeScriptsHeader id: activeScriptsHeader
text: catalog.i18nc("@label", "Post Processing Scripts") text: catalog.i18nc("@label", "Post Processing Scripts")
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: base.textMargin
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: base.textMargin
font: UM.Theme.getFont("large_bold") font: UM.Theme.getFont("large_bold")
elide: Text.ElideRight elide: Text.ElideRight
} }
@ -79,17 +77,15 @@ UM.Dialog
id: activeScriptsScrollBar id: activeScriptsScrollBar
} }
model: manager.scriptList model: manager.scriptList
delegate: Item
{ delegate: Button
width: parent.width - activeScriptsScrollBar.width
height: activeScriptButton.height
Button
{ {
id: activeScriptButton id: activeScriptButton
text: manager.getScriptLabelByKey(modelData.toString())
width: parent.width - activeScriptsScrollBar.width
height: UM.Theme.getSize("standard_list_lineheight").height
ButtonGroup.group: selectedScriptGroup ButtonGroup.group: selectedScriptGroup
width: parent.width
height: UM.Theme.getSize("setting").height
checkable: true checkable: true
checked: checked:
@ -104,6 +100,12 @@ UM.Dialog
return false return false
} }
} }
background: Rectangle
{
color: activeScriptButton.checked ? UM.Theme.getColor("background_3") : "transparent"
}
onClicked: onClicked:
{ {
forceActiveFocus() forceActiveFocus()
@ -111,53 +113,27 @@ UM.Dialog
base.activeScriptName = manager.getScriptLabelByKey(modelData.toString()) base.activeScriptName = manager.getScriptLabelByKey(modelData.toString())
} }
background: Rectangle RowLayout
{ {
color: activeScriptButton.checked ? palette.highlight : "transparent" anchors.fill: parent
} height: childrenRect.height
contentItem: Label
UM.Label
{ {
wrapMode: Text.Wrap Layout.fillWidth: true
text: activeScriptButton.text text: manager.getScriptLabelByKey(modelData.toString())
elide: Text.ElideRight
color: activeScriptButton.checked ? palette.highlightedText : palette.text
} }
} Item
Button
{
id: removeButton
text: "x"
width: 20 * screenScaleFactor
height: 20 * screenScaleFactor
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
onClicked: manager.removeScriptByIndex(index)
contentItem: Item
{
UM.RecolorImage
{
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
width: Math.round(removeButton.width / 2.7)
height: Math.round(removeButton.height / 2.7)
sourceSize.height: width
color: palette.text
source: UM.Theme.getIcon("Cancel")
}
}
}
Button
{ {
id: downButton id: downButton
text: "" Layout.preferredWidth: height
anchors.right: removeButton.left Layout.fillHeight: true
anchors.verticalCenter: parent.verticalCenter
enabled: index != manager.scriptList.length - 1 enabled: index != manager.scriptList.length - 1
width: 20 * screenScaleFactor
height: 20 * screenScaleFactor MouseArea
{
anchors.fill: parent
onClicked: onClicked:
{ {
if (manager.selectedScriptIndex == index) if (manager.selectedScriptIndex == index)
@ -166,29 +142,30 @@ UM.Dialog
} }
return manager.moveScript(index, index + 1) return manager.moveScript(index, index + 1)
} }
contentItem: Item }
{
UM.RecolorImage UM.RecolorImage
{ {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: Math.round(downButton.width / 2.5) width: UM.Theme.getSize("standard_arrow").width
height: Math.round(downButton.height / 2.5) height: UM.Theme.getSize("standard_arrow").height
sourceSize.height: width sourceSize.width: width
color: downButton.enabled ? palette.text : disabledPalette.text sourceSize.height: height
color: parent.enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("text_disabled")
source: UM.Theme.getIcon("ChevronSingleDown") source: UM.Theme.getIcon("ChevronSingleDown")
} }
} }
} Item
Button
{ {
id: upButton id: upButton
text: "" Layout.preferredWidth: height
Layout.fillHeight: true
enabled: index != 0 enabled: index != 0
width: 20 * screenScaleFactor
height: 20 * screenScaleFactor MouseArea
anchors.right: downButton.left {
anchors.verticalCenter: parent.verticalCenter anchors.fill: parent
onClicked: onClicked:
{ {
if (manager.selectedScriptIndex == index) if (manager.selectedScriptIndex == index)
@ -197,19 +174,45 @@ UM.Dialog
} }
return manager.moveScript(index, index - 1) return manager.moveScript(index, index - 1)
} }
contentItem: Item }
{
UM.RecolorImage UM.RecolorImage
{ {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: Math.round(upButton.width / 2.5) width: UM.Theme.getSize("standard_arrow").width
height: Math.round(upButton.height / 2.5) height: UM.Theme.getSize("standard_arrow").height
sourceSize.height: width sourceSize.width: width
color: upButton.enabled ? palette.text : disabledPalette.text sourceSize.height: height
color: upButton.enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("text_disabled")
source: UM.Theme.getIcon("ChevronSingleUp") source: UM.Theme.getIcon("ChevronSingleUp")
} }
} }
Item
{
id: removeButton
Layout.preferredWidth: height
Layout.fillHeight: true
MouseArea
{
anchors.fill: parent
onClicked: manager.removeScriptByIndex(index)
}
UM.RecolorImage
{
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
width: UM.Theme.getSize("standard_arrow").width
height: UM.Theme.getSize("standard_arrow").height
sourceSize.width: width
sourceSize.height: height
color: UM.Theme.getColor("text")
source: UM.Theme.getIcon("Cancel")
}
}
} }
} }
} }
@ -217,20 +220,19 @@ UM.Dialog
{ {
id: addButton id: addButton
text: catalog.i18nc("@action", "Add a script") text: catalog.i18nc("@action", "Add a script")
anchors.left: parent.left
anchors.leftMargin: base.textMargin
onClicked: scriptsMenu.open() onClicked: scriptsMenu.open()
} }
Menu }
Cura.Menu
{ {
id: scriptsMenu id: scriptsMenu
width: parent.width
Models.Instantiator Models.Instantiator
{ {
model: manager.loadedScriptList model: manager.loadedScriptList
MenuItem Cura.MenuItem
{ {
text: manager.getScriptLabelByKey(modelData.toString()) text: manager.getScriptLabelByKey(modelData.toString())
onTriggered: manager.addScriptToList(modelData.toString()) onTriggered: manager.addScriptToList(modelData.toString())
@ -240,7 +242,6 @@ UM.Dialog
onObjectRemoved: scriptsMenu.removeItem(object) onObjectRemoved: scriptsMenu.removeItem(object)
} }
} }
}
Rectangle Rectangle
{ {
@ -303,16 +304,9 @@ UM.Dialog
width: listview.width width: listview.width
height: height:
{ {
if(provider.properties.enabled == "True") if (provider.properties.enabled == "True" && model.type != undefined)
{ {
if(model.type != undefined) return UM.Theme.getSize("section").height;
{
return UM.Theme.getSize("section").height
}
else
{
return 0
}
} }
else else
{ {
@ -392,10 +386,10 @@ UM.Dialog
function onShowTooltip(text) function onShowTooltip(text)
{ {
tooltip.text = text tooltip.text = text;
var position = settingLoader.mapToItem(settingsPanel, settingsPanel.x, 0) var position = settingLoader.mapToItem(settingsPanel, settingsPanel.x, 0);
tooltip.show(position) tooltip.show(position);
tooltip.target.x = position.x + 1 tooltip.target.x = position.x + 1;
} }
function onHideTooltip() { tooltip.hide() } function onHideTooltip() { tooltip.hide() }
@ -452,7 +446,7 @@ UM.Dialog
} }
} }
rightButtons: Cura.PrimaryButton rightButtons: Cura.TertiaryButton
{ {
text: catalog.i18nc("@action:button", "Close") text: catalog.i18nc("@action:button", "Close")
onClicked: dialog.accept() onClicked: dialog.accept()