WhatsNewContent.qml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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.AlignmentFlag.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. back_color: UM.Theme.getColor("viewport_overlay")
  89. do_borders: false
  90. textArea.wrapMode: TextEdit.Wrap
  91. textArea.text: "<style>a:link { color: " + UM.Theme.getColor("text_link") + "; text-decoration: underline; }</style>" + manager.getSubpageText(index)
  92. textArea.textFormat: Text.RichText
  93. textArea.readOnly: true
  94. textArea.font: UM.Theme.getFont("default")
  95. textArea.onLinkActivated: Qt.openUrlExternally(link)
  96. textArea.leftPadding: 0
  97. textArea.rightPadding: 0
  98. }
  99. }
  100. }
  101. }
  102. }
  103. PageIndicator
  104. {
  105. id: whatsNewDots
  106. currentIndex: whatsNewViewport.currentIndex
  107. count: whatsNewViewport.count
  108. interactive: true
  109. anchors
  110. {
  111. bottom: whatsNewNextButton.top
  112. bottomMargin: UM.Theme.getSize("wide_margin").height
  113. horizontalCenter: parent.horizontalCenter
  114. }
  115. delegate:
  116. Rectangle
  117. {
  118. width: UM.Theme.getSize("thin_margin").width
  119. height: UM.Theme.getSize("thin_margin").height
  120. radius: width / 2
  121. color:
  122. index === whatsNewViewport.currentIndex ?
  123. UM.Theme.getColor("primary") :
  124. UM.Theme.getColor("secondary_button_shadow")
  125. }
  126. }
  127. Item
  128. {
  129. id: bottomSpacer
  130. anchors.bottom: whatsNewNextButton.top
  131. height: UM.Theme.getSize("default_margin").height / 2
  132. width: UM.Theme.getSize("default_margin").width / 2
  133. }
  134. Cura.TertiaryButton
  135. {
  136. id: whatsNewNextButton
  137. anchors.left: parent.left
  138. anchors.bottom: parent.bottom
  139. text: base.currentItem.next_page_button_text
  140. onClicked: base.showNextPage()
  141. }
  142. Cura.PrimaryButton
  143. {
  144. id: whatsNewSubpageButton
  145. anchors.right: parent.right
  146. anchors.bottom: parent.bottom
  147. text: catalog.i18nc("@button", "Next")
  148. onClicked:
  149. whatsNewDots.currentIndex === (whatsNewDots.count - 1) ?
  150. base.showNextPage() :
  151. ++whatsNewDots.currentIndex
  152. }
  153. }