ApplicationButton.qml 3.0 KB

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