LoadMoreProjectsCard.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // Copyright (C) 2021 Ultimaker B.V.
  2. import QtQuick 2.10
  3. import QtQuick.Controls 2.3
  4. import UM 1.2 as UM
  5. import Cura 1.6 as Cura
  6. Cura.RoundedRectangle
  7. {
  8. id: base
  9. cornerSide: Cura.RoundedRectangle.Direction.All
  10. border.color: UM.Theme.getColor("lining")
  11. border.width: UM.Theme.getSize("default_lining").width
  12. radius: UM.Theme.getSize("default_radius").width
  13. signal clicked()
  14. property var hasMoreProjectsToLoad
  15. enabled: hasMoreProjectsToLoad
  16. color: UM.Theme.getColor("main_background")
  17. MouseArea
  18. {
  19. id: cardMouseArea
  20. anchors.fill: parent
  21. hoverEnabled: true
  22. }
  23. Row
  24. {
  25. id: projectInformationRow
  26. anchors.horizontalCenter: parent.horizontalCenter
  27. anchors.verticalCenter: parent.verticalCenter
  28. UM.ColorImage
  29. {
  30. id: projectImage
  31. anchors.verticalCenter: parent.verticalCenter
  32. width: UM.Theme.getSize("section").height
  33. height: width
  34. color: UM.Theme.getColor("text_link")
  35. source: Qt.resolvedUrl("../images/arrow_down.svg")
  36. }
  37. Label
  38. {
  39. id: displayNameLabel
  40. anchors.verticalCenter: parent.verticalCenter
  41. text: "Load more projects"
  42. color: UM.Theme.getColor("text_link")
  43. font: UM.Theme.getFont("medium_bold")
  44. }
  45. }
  46. Component.onCompleted:
  47. {
  48. cardMouseArea.clicked.connect(base.clicked)
  49. }
  50. states:
  51. [
  52. State
  53. {
  54. name: "canLoadMoreProjectsAndHovered";
  55. when: base.hasMoreProjectsToLoad && cardMouseArea.containsMouse
  56. PropertyChanges
  57. {
  58. target: projectImage
  59. color: UM.Theme.getColor("text_link")
  60. source: Qt.resolvedUrl("../images/arrow_down.svg")
  61. }
  62. PropertyChanges
  63. {
  64. target: displayNameLabel
  65. color: UM.Theme.getColor("text_link")
  66. text: "Load more projects"
  67. }
  68. PropertyChanges
  69. {
  70. target: base
  71. color: UM.Theme.getColor("action_button_hovered")
  72. }
  73. },
  74. State
  75. {
  76. name: "canLoadMoreProjectsAndNotHovered";
  77. when: base.hasMoreProjectsToLoad && !cardMouseArea.containsMouse
  78. PropertyChanges
  79. {
  80. target: projectImage
  81. color: UM.Theme.getColor("text_link")
  82. source: Qt.resolvedUrl("../images/arrow_down.svg")
  83. }
  84. PropertyChanges
  85. {
  86. target: displayNameLabel
  87. color: UM.Theme.getColor("text_link")
  88. text: "Load more projects"
  89. }
  90. PropertyChanges
  91. {
  92. target: base
  93. color: UM.Theme.getColor("main_background")
  94. }
  95. },
  96. State
  97. {
  98. name: "noMoreProjectsToLoad"
  99. when: !base.hasMoreProjectsToLoad
  100. PropertyChanges
  101. {
  102. target: projectImage
  103. color: UM.Theme.getColor("action_button_disabled_text")
  104. source: Qt.resolvedUrl("../images/update.svg")
  105. }
  106. PropertyChanges
  107. {
  108. target: displayNameLabel
  109. color: UM.Theme.getColor("action_button_disabled_text")
  110. text: "No more projects to load"
  111. }
  112. PropertyChanges
  113. {
  114. target: base
  115. color: UM.Theme.getColor("action_button_disabled")
  116. }
  117. }
  118. ]
  119. }