Add support for loading a custom QML panel to tools and PrinterToolbar

This allows us to provide custom actions dependant on the active tool,
like reset rotation or scale to max.
This commit is contained in:
Arjen Hiemstra 2015-04-17 18:32:28 +02:00
parent a751a137d9
commit da0d71fd94

View file

@ -5,30 +5,53 @@ import QtQuick.Layouts 1.1
import UM 1.0 as UM
RowLayout {
Item {
id: base;
spacing: UM.Theme.sizes.default_margin.width * 2;
width: buttons.width;
height: buttons.height + panel.height;
Repeater {
id: repeat
RowLayout {
id: buttons;
model: UM.Models.toolModel
anchors.bottom: parent.bottom;
anchors.left: parent.left;
PrinterButton {
text: model.name;
iconSource: UM.Theme.icons[model.icon];
tooltip: model.description;
spacing: UM.Theme.sizes.default_margin.width * 2;
checkable: true;
checked: model.active;
Repeater {
id: repeat
//Workaround since using ToolButton's onClicked would break the binding of the checked property, instead
//just catch the click so we do not trigger that behaviour.
MouseArea {
anchors.fill: parent;
onClicked: parent.checked ? UM.Controller.setActiveTool(null) : UM.Controller.setActiveTool(model.id);
model: UM.Models.toolModel
PrinterButton {
text: model.name;
iconSource: UM.Theme.icons[model.icon];
tooltip: model.description;
checkable: true;
checked: model.active;
//Workaround since using ToolButton's onClicked would break the binding of the checked property, instead
//just catch the click so we do not trigger that behaviour.
MouseArea {
anchors.fill: parent;
onClicked: parent.checked ? UM.Controller.setActiveTool(null) : UM.Controller.setActiveTool(model.id);
}
}
}
}
Loader {
id: panel
anchors.left: parent.left;
anchors.right: parent.right;
anchors.bottom: buttons.top;
anchors.bottomMargin: UM.Theme.sizes.default_margin.height;
height: childrenRect.height;
source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : "";
}
}