Toolbar.qml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.0 as UM
  8. Item {
  9. id: base;
  10. width: buttons.width;
  11. height: buttons.height + panel.height;
  12. RowLayout {
  13. id: buttons;
  14. anchors.bottom: parent.bottom;
  15. anchors.left: parent.left;
  16. spacing: UM.Theme.sizes.default_margin.width * 2;
  17. Repeater {
  18. id: repeat
  19. model: UM.Models.toolModel
  20. Button {
  21. text: model.name;
  22. iconSource: UM.Theme.icons[model.icon];
  23. tooltip: model.description;
  24. checkable: true;
  25. checked: model.active;
  26. style: UM.Theme.styles.tool_button;
  27. //Workaround since using ToolButton"s onClicked would break the binding of the checked property, instead
  28. //just catch the click so we do not trigger that behaviour.
  29. MouseArea {
  30. anchors.fill: parent;
  31. onClicked: parent.checked ? UM.Controller.setActiveTool(null) : UM.Controller.setActiveTool(model.id);
  32. }
  33. }
  34. }
  35. }
  36. Loader {
  37. id: panel
  38. anchors.left: parent.left;
  39. anchors.right: parent.right;
  40. anchors.bottom: buttons.top;
  41. anchors.bottomMargin: UM.Theme.sizes.default_margin.height;
  42. height: childrenRect.height;
  43. source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : "";
  44. }
  45. }