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