ApplicationButton.qml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Copyright (c) 2021 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import UM 1.5 as UM
  6. import Cura 1.1 as Cura
  7. Button
  8. {
  9. id: base
  10. property alias iconSource: applicationIcon.source
  11. property alias displayName: applicationDisplayName.text
  12. property alias tooltipText: tooltip.text
  13. property bool isExternalLink: false
  14. property color borderColor: hovered ? UM.Theme.getColor("primary") : "transparent"
  15. property color backgroundColor: hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button")
  16. Behavior on backgroundColor { ColorAnimation { duration: 200; } }
  17. Behavior on borderColor { ColorAnimation { duration: 200; } }
  18. hoverEnabled: true
  19. width: UM.Theme.getSize("application_switcher_item").width
  20. height: UM.Theme.getSize("application_switcher_item").height
  21. background: Rectangle
  22. {
  23. color:backgroundColor
  24. border.color: borderColor
  25. border.width: UM.Theme.getSize("default_lining").width
  26. }
  27. UM.ToolTip
  28. {
  29. id: tooltip
  30. tooltipText: base.text
  31. visible: base.hovered
  32. }
  33. Column
  34. {
  35. id: applicationButtonContent
  36. anchors.left: parent.left
  37. anchors.right: parent.right
  38. anchors.verticalCenter: parent.verticalCenter
  39. UM.ColorImage
  40. {
  41. id: applicationIcon
  42. anchors.horizontalCenter: parent.horizontalCenter
  43. color: UM.Theme.getColor("icon")
  44. width: UM.Theme.getSize("application_switcher_icon").width
  45. height: width
  46. UM.ColorImage
  47. {
  48. id: externalLinkIndicatorIcon
  49. visible: base.isExternalLink
  50. anchors
  51. {
  52. bottom: parent.bottom
  53. bottomMargin: - Math.round(height * 1 / 6)
  54. right: parent.right
  55. rightMargin: - Math.round(width * 5 / 6)
  56. }
  57. width: UM.Theme.getSize("icon_indicator").width
  58. height: width
  59. color: UM.Theme.getColor("icon")
  60. source: UM.Theme.getIcon("LinkExternal")
  61. }
  62. }
  63. UM.Label
  64. {
  65. id: applicationDisplayName
  66. anchors.left: parent.left
  67. anchors.right: parent.right
  68. height: base.height - applicationIcon.height - 2 * UM.Theme.getSize("default_margin").width // Account for the top and bottom margins
  69. horizontalAlignment: Text.AlignHCenter
  70. wrapMode: Text.Wrap
  71. elide: Text.ElideRight
  72. }
  73. }
  74. }