WhatsNewContent.qml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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.5 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. UM.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. }
  26. Rectangle
  27. {
  28. anchors
  29. {
  30. top: titleLabel.bottom
  31. topMargin: UM.Theme.getSize("default_margin").width
  32. bottom: whatsNewDots.top
  33. bottomMargin: UM.Theme.getSize("narrow_margin").width
  34. left: parent.left
  35. right: parent.right
  36. }
  37. color: UM.Theme.getColor("viewport_overlay")
  38. StackLayout
  39. {
  40. id: whatsNewViewport
  41. anchors
  42. {
  43. top: parent.top
  44. horizontalCenter: parent.horizontalCenter
  45. }
  46. height: parent.height
  47. width: parent.width
  48. currentIndex: whatsNewDots.currentIndex
  49. Repeater
  50. {
  51. model: manager.subpageCount
  52. Rectangle
  53. {
  54. Layout.alignment: Qt.AlignHCenter
  55. color: UM.Theme.getColor("viewport_overlay")
  56. width: whatsNewViewport.width
  57. height: whatsNewViewport.height
  58. AnimatedImage
  59. {
  60. id: subpageImage
  61. anchors
  62. {
  63. top: parent.top
  64. topMargin: UM.Theme.getSize("thick_margin").width
  65. left: parent.left
  66. leftMargin: UM.Theme.getSize("thick_margin").width
  67. right: parent.right
  68. rightMargin: UM.Theme.getSize("thick_margin").width
  69. }
  70. width: Math.round(parent.width - (UM.Theme.getSize("thick_margin").height * 2))
  71. fillMode: Image.PreserveAspectFit
  72. onStatusChanged: playing = (status == AnimatedImage.Ready)
  73. source: manager.getSubpageImageSource(index)
  74. }
  75. Cura.ScrollableTextArea
  76. {
  77. id: subpageText
  78. anchors
  79. {
  80. top: subpageImage.bottom
  81. topMargin: UM.Theme.getSize("default_margin").height
  82. bottom: parent.bottom
  83. bottomMargin: UM.Theme.getSize("thin_margin").height
  84. left: subpageImage.left
  85. right: subpageImage.right
  86. }
  87. back_color: UM.Theme.getColor("viewport_overlay")
  88. do_borders: false
  89. textArea.wrapMode: TextEdit.Wrap
  90. textArea.text: "<style>a:link { color: " + UM.Theme.getColor("text_link") + "; text-decoration: underline; }</style>" + manager.getSubpageText(index)
  91. textArea.textFormat: Text.RichText
  92. textArea.readOnly: true
  93. textArea.font: UM.Theme.getFont("default")
  94. textArea.onLinkActivated: Qt.openUrlExternally(link)
  95. textArea.leftPadding: 0
  96. textArea.rightPadding: 0
  97. }
  98. }
  99. }
  100. }
  101. }
  102. PageIndicator
  103. {
  104. id: whatsNewDots
  105. currentIndex: whatsNewViewport.currentIndex
  106. count: whatsNewViewport.count
  107. interactive: true
  108. anchors
  109. {
  110. bottom: whatsNewNextButton.top
  111. bottomMargin: UM.Theme.getSize("wide_margin").height
  112. horizontalCenter: parent.horizontalCenter
  113. }
  114. delegate:
  115. Rectangle
  116. {
  117. width: UM.Theme.getSize("thin_margin").width
  118. height: UM.Theme.getSize("thin_margin").height
  119. radius: width / 2
  120. color:
  121. index === whatsNewViewport.currentIndex ?
  122. UM.Theme.getColor("primary") :
  123. UM.Theme.getColor("secondary_button_shadow")
  124. }
  125. }
  126. Item
  127. {
  128. id: bottomSpacer
  129. anchors.bottom: whatsNewNextButton.top
  130. height: UM.Theme.getSize("default_margin").height / 2
  131. width: UM.Theme.getSize("default_margin").width / 2
  132. }
  133. Cura.TertiaryButton
  134. {
  135. id: whatsNewNextButton
  136. anchors.left: parent.left
  137. anchors.bottom: parent.bottom
  138. text: base.currentItem.next_page_button_text
  139. onClicked: base.showNextPage()
  140. }
  141. Cura.PrimaryButton
  142. {
  143. id: whatsNewSubpageButton
  144. anchors.right: parent.right
  145. anchors.bottom: parent.bottom
  146. text: catalog.i18nc("@button", "Next")
  147. onClicked:
  148. whatsNewDots.currentIndex === (whatsNewDots.count - 1) ?
  149. base.showNextPage() :
  150. ++whatsNewDots.currentIndex
  151. }
  152. }