WhatsNewContent.qml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 QtQuick.Layouts 1.3
  6. import Qt5Compat.GraphicalEffects // For the DropShadow
  7. import UM 1.3 as UM
  8. import Cura 1.1 as Cura
  9. //
  10. // This component contains the content for the "What's new in Ultimaker Cura" page of the welcome on-boarding process.
  11. // Previously this was just the changelog, but now it will just have the larger stories, the changelog has its own page.
  12. //
  13. Item
  14. {
  15. property var manager: CuraApplication.getWhatsNewPagesModel()
  16. UM.I18nCatalog { id: catalog; name: "cura" }
  17. Label
  18. {
  19. id: titleLabel
  20. anchors.top: parent.top
  21. anchors.horizontalCenter: parent.horizontalCenter
  22. horizontalAlignment: Text.AlignHCenter
  23. text: catalog.i18nc("@label", "What's New")
  24. color: UM.Theme.getColor("primary_button")
  25. font: UM.Theme.getFont("huge")
  26. renderType: Text.NativeRendering
  27. }
  28. Rectangle
  29. {
  30. anchors
  31. {
  32. top: titleLabel.bottom
  33. topMargin: UM.Theme.getSize("default_margin").width
  34. bottom: whatsNewDots.top
  35. bottomMargin: UM.Theme.getSize("narrow_margin").width
  36. left: parent.left
  37. right: parent.right
  38. }
  39. color: UM.Theme.getColor("viewport_overlay")
  40. StackLayout
  41. {
  42. id: whatsNewViewport
  43. anchors
  44. {
  45. top: parent.top
  46. horizontalCenter: parent.horizontalCenter
  47. }
  48. height: parent.height
  49. width: parent.width
  50. currentIndex: whatsNewDots.currentIndex
  51. Repeater
  52. {
  53. model: manager.subpageCount
  54. Rectangle
  55. {
  56. Layout.alignment: Qt.AlignmentFlag.AlignHCenter
  57. color: UM.Theme.getColor("viewport_overlay")
  58. width: whatsNewViewport.width
  59. height: whatsNewViewport.height
  60. AnimatedImage
  61. {
  62. id: subpageImage
  63. anchors
  64. {
  65. top: parent.top
  66. topMargin: UM.Theme.getSize("thick_margin").width
  67. left: parent.left
  68. leftMargin: UM.Theme.getSize("thick_margin").width
  69. right: parent.right
  70. rightMargin: UM.Theme.getSize("thick_margin").width
  71. }
  72. width: Math.round(parent.width - (UM.Theme.getSize("thick_margin").height * 2))
  73. fillMode: Image.PreserveAspectFit
  74. onStatusChanged: playing = (status == AnimatedImage.Ready)
  75. source: manager.getSubpageImageSource(index)
  76. }
  77. DropShadow {
  78. anchors.fill: subpageImage
  79. radius: UM.Theme.getSize("monitor_shadow_radius").width
  80. color: UM.Theme.getColor("first_run_shadow")
  81. source: subpageImage
  82. }
  83. Cura.ScrollableTextArea
  84. {
  85. id: subpageText
  86. anchors
  87. {
  88. top: subpageImage.bottom
  89. topMargin: UM.Theme.getSize("default_margin").height
  90. bottom: parent.bottom
  91. bottomMargin: UM.Theme.getSize("thin_margin").height
  92. left: subpageImage.left
  93. right: subpageImage.right
  94. }
  95. back_color: UM.Theme.getColor("viewport_overlay")
  96. do_borders: false
  97. textArea.wrapMode: TextEdit.Wrap
  98. textArea.text: "<style>a:link { color: " + UM.Theme.getColor("text_link") + "; text-decoration: underline; }</style>" + manager.getSubpageText(index)
  99. textArea.textFormat: Text.RichText
  100. textArea.readOnly: true
  101. textArea.font: UM.Theme.getFont("default")
  102. textArea.onLinkActivated: Qt.openUrlExternally(link)
  103. textArea.leftPadding: 0
  104. textArea.rightPadding: 0
  105. }
  106. }
  107. }
  108. }
  109. }
  110. PageIndicator
  111. {
  112. id: whatsNewDots
  113. currentIndex: whatsNewViewport.currentIndex
  114. count: whatsNewViewport.count
  115. interactive: true
  116. anchors
  117. {
  118. bottom: whatsNewNextButton.top
  119. bottomMargin: UM.Theme.getSize("wide_margin").height
  120. horizontalCenter: parent.horizontalCenter
  121. }
  122. delegate:
  123. Rectangle
  124. {
  125. width: UM.Theme.getSize("thin_margin").width
  126. height: UM.Theme.getSize("thin_margin").height
  127. radius: width / 2
  128. color:
  129. index === whatsNewViewport.currentIndex ?
  130. UM.Theme.getColor("primary") :
  131. UM.Theme.getColor("secondary_button_shadow")
  132. }
  133. }
  134. Item
  135. {
  136. id: bottomSpacer
  137. anchors.bottom: whatsNewNextButton.top
  138. height: UM.Theme.getSize("default_margin").height / 2
  139. width: UM.Theme.getSize("default_margin").width / 2
  140. }
  141. Cura.TertiaryButton
  142. {
  143. id: whatsNewNextButton
  144. anchors.left: parent.left
  145. anchors.bottom: parent.bottom
  146. text: base.currentItem.next_page_button_text
  147. onClicked: base.showNextPage()
  148. }
  149. Cura.PrimaryButton
  150. {
  151. id: whatsNewSubpageButton
  152. anchors.right: parent.right
  153. anchors.bottom: parent.bottom
  154. text: catalog.i18nc("@button", "Next")
  155. onClicked:
  156. whatsNewDots.currentIndex === (whatsNewDots.count - 1) ?
  157. base.showNextPage() :
  158. ++whatsNewDots.currentIndex
  159. }
  160. }