WhatsNewContent.qml 5.7 KB

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