ApplicationButton.qml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. spacing: UM.Theme.getSize("default_margin").width
  32. UM.RecolorImage
  33. {
  34. id: applicationIcon
  35. anchors.horizontalCenter: parent.horizontalCenter
  36. color: UM.Theme.getColor("monitor_icon_primary")
  37. width: UM.Theme.getSize("application_switcher_icon").width
  38. height: width
  39. Item
  40. {
  41. id: externalLinkIndicator
  42. visible: base.isExternalLink
  43. anchors
  44. {
  45. bottom: parent.bottom
  46. bottomMargin: - Math.round(height * 1 / 6)
  47. right: parent.right
  48. rightMargin: - Math.round(width * 5 / 6)
  49. }
  50. Rectangle
  51. {
  52. anchors.centerIn: parent
  53. width: UM.Theme.getSize("small_button_icon").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: externalLinkIcon
  61. anchors.centerIn: parent
  62. width: UM.Theme.getSize("printer_status_icon").width
  63. height: width
  64. color: UM.Theme.getColor("monitor_icon_primary")
  65. source: UM.Theme.getIcon("LinkExternal")
  66. }
  67. }
  68. }
  69. Label
  70. {
  71. id: applicationDisplayName
  72. anchors.horizontalCenter: parent.horizontalCenter
  73. }
  74. }
  75. }