Convert postprocessing plugin to controls 2

This commit is contained in:
Jaime van Kessel 2021-11-16 10:07:58 +01:00
parent 75cd792b00
commit ef9b5506ce

View file

@ -2,9 +2,7 @@
// The PostProcessingPlugin is released under the terms of the AGPLv3 or higher. // The PostProcessingPlugin is released under the terms of the AGPLv3 or higher.
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.15
import QtQuick.Controls 2.15 as QQC2
import QtQuick.Controls.Styles 1.1
import QtQml.Models 2.15 as Models import QtQml.Models 2.15 as Models
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
@ -42,7 +40,7 @@ UM.Dialog
SystemPalette{ id: disabledPalette; colorGroup: SystemPalette.Disabled } SystemPalette{ id: disabledPalette; colorGroup: SystemPalette.Disabled }
anchors.fill: parent anchors.fill: parent
ExclusiveGroup ButtonGroup
{ {
id: selectedScriptGroup id: selectedScriptGroup
} }
@ -90,7 +88,7 @@ UM.Dialog
{ {
id: activeScriptButton id: activeScriptButton
text: manager.getScriptLabelByKey(modelData.toString()) text: manager.getScriptLabelByKey(modelData.toString())
exclusiveGroup: selectedScriptGroup ButtonGroup.group: selectedScriptGroup
width: parent.width width: parent.width
height: UM.Theme.getSize("setting").height height: UM.Theme.getSize("setting").height
checkable: true checkable: true
@ -114,22 +112,18 @@ UM.Dialog
base.activeScriptName = manager.getScriptLabelByKey(modelData.toString()) base.activeScriptName = manager.getScriptLabelByKey(modelData.toString())
} }
style: ButtonStyle
{
background: Rectangle background: Rectangle
{ {
color: activeScriptButton.checked ? palette.highlight : "transparent" color: activeScriptButton.checked ? palette.highlight : "transparent"
width: parent.width
height: parent.height
} }
label: Label contentItem: Label
{ {
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: control.text text: activeScriptButton.text
elide: Text.ElideRight elide: Text.ElideRight
color: activeScriptButton.checked ? palette.highlightedText : palette.text color: activeScriptButton.checked ? palette.highlightedText : palette.text
} }
}
} }
Button Button
@ -142,22 +136,20 @@ UM.Dialog
anchors.rightMargin: base.textMargin anchors.rightMargin: base.textMargin
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
onClicked: manager.removeScriptByIndex(index) onClicked: manager.removeScriptByIndex(index)
style: ButtonStyle contentItem: Item
{
label: Item
{ {
UM.RecolorImage UM.RecolorImage
{ {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: Math.round(control.width / 2.7) width: Math.round(removeButton.width / 2.7)
height: Math.round(control.height / 2.7) height: Math.round(removeButton.height / 2.7)
sourceSize.height: width sourceSize.height: width
color: palette.text color: palette.text
source: UM.Theme.getIcon("Cancel") source: UM.Theme.getIcon("Cancel")
} }
} }
}
} }
Button Button
{ {
@ -176,23 +168,20 @@ UM.Dialog
} }
return manager.moveScript(index, index + 1) return manager.moveScript(index, index + 1)
} }
style: ButtonStyle contentItem: Item
{
label: Item
{ {
UM.RecolorImage UM.RecolorImage
{ {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: Math.round(control.width / 2.5) width: Math.round(downButton.width / 2.5)
height: Math.round(control.height / 2.5) height: Math.round(downButton.height / 2.5)
sourceSize.height: width sourceSize.height: width
color: control.enabled ? palette.text : disabledPalette.text color: downButton.enabled ? palette.text : disabledPalette.text
source: UM.Theme.getIcon("ChevronSingleDown") source: UM.Theme.getIcon("ChevronSingleDown")
} }
} }
} }
}
Button Button
{ {
id: upButton id: upButton
@ -210,25 +199,22 @@ UM.Dialog
} }
return manager.moveScript(index, index - 1) return manager.moveScript(index, index - 1)
} }
style: ButtonStyle contentItem: Item
{
label: Item
{ {
UM.RecolorImage UM.RecolorImage
{ {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: Math.round(control.width / 2.5) width: Math.round(upButton.width / 2.5)
height: Math.round(control.height / 2.5) height: Math.round(upButton.height / 2.5)
sourceSize.height: width sourceSize.height: width
color: control.enabled ? palette.text : disabledPalette.text color: upButton.enabled ? palette.text : disabledPalette.text
source: UM.Theme.getIcon("ChevronSingleUp") source: UM.Theme.getIcon("ChevronSingleUp")
} }
} }
} }
} }
} }
}
Button Button
{ {
id: addButton id: addButton
@ -238,15 +224,8 @@ UM.Dialog
anchors.top: activeScriptsList.bottom anchors.top: activeScriptsList.bottom
anchors.topMargin: base.textMargin anchors.topMargin: base.textMargin
onClicked: scriptsMenu.open() onClicked: scriptsMenu.open()
style: ButtonStyle
{
label: Label
{
text: control.text
} }
} Menu
}
QQC2.Menu
{ {
id: scriptsMenu id: scriptsMenu
width: parent.width width: parent.width
@ -255,7 +234,7 @@ UM.Dialog
{ {
model: manager.loadedScriptList model: manager.loadedScriptList
QQC2.MenuItem MenuItem
{ {
text: manager.getScriptLabelByKey(modelData.toString()) text: manager.getScriptLabelByKey(modelData.toString())
onTriggered: manager.addScriptToList(modelData.toString()) onTriggered: manager.addScriptToList(modelData.toString())
@ -310,7 +289,6 @@ UM.Dialog
} }
visible: manager.selectedScriptDefinitionId != "" visible: manager.selectedScriptDefinitionId != ""
style: UM.Theme.styles.scrollview;
ListView ListView
{ {
@ -483,7 +461,6 @@ UM.Dialog
rightButtons: Button rightButtons: Button
{ {
text: catalog.i18nc("@action:button", "Close") text: catalog.i18nc("@action:button", "Close")
iconName: "dialog-close"
onClicked: dialog.accept() onClicked: dialog.accept()
} }