ApplicationButton.qml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.4 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 backgroundColor: hovered ? UM.Theme.getColor("primary") : "transparent"
  15. Behavior on backgroundColor { ColorAnimation { duration: 200; } }
  16. width: UM.Theme.getSize("application_switcher_item").width
  17. height: UM.Theme.getSize("application_switcher_item").height
  18. background: Rectangle
  19. {
  20. color: backgroundColor
  21. border.color: backgroundColor
  22. border.width: UM.Theme.getSize("default_lining").width
  23. }
  24. UM.TooltipArea
  25. {
  26. id: tooltip
  27. anchors.fill: parent
  28. }
  29. Column
  30. {
  31. id: applicationButtonContent
  32. anchors.left: parent.left
  33. anchors.right: parent.right
  34. anchors.verticalCenter: parent.verticalCenter
  35. UM.RecolorImage
  36. {
  37. id: applicationIcon
  38. anchors.horizontalCenter: parent.horizontalCenter
  39. color: UM.Theme.getColor("icon")
  40. width: UM.Theme.getSize("application_switcher_icon").width
  41. height: width
  42. Item
  43. {
  44. id: externalLinkIndicator
  45. visible: base.isExternalLink
  46. anchors
  47. {
  48. bottom: parent.bottom
  49. bottomMargin: - Math.round(height * 1 / 6)
  50. right: parent.right
  51. rightMargin: - Math.round(width * 5 / 6)
  52. }
  53. UM.RecolorImage
  54. {
  55. id: externalLinkIndicatorIcon
  56. anchors.centerIn: parent
  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. }
  64. Label
  65. {
  66. id: applicationDisplayName
  67. anchors.left: parent.left
  68. anchors.right: parent.right
  69. height: base.height - applicationIcon.height - 2 * UM.Theme.getSize("default_margin").width // Account for the top and bottom margins
  70. horizontalAlignment: Text.AlignHCenter
  71. verticalAlignment: Text.AlignVCenter
  72. wrapMode: Text.Wrap
  73. elide: Text.ElideRight
  74. color: UM.Theme.getColor("text")
  75. }
  76. }
  77. }