CompatibilityDialog.qml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // Copyright (c) 2020 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Window 2.2
  5. import QtQuick.Controls 2.3
  6. import UM 1.1 as UM
  7. import Cura 1.6 as Cura
  8. UM.Dialog{
  9. visible: true
  10. title: catalog.i18nc("@title", "Changes from your account")
  11. width: UM.Theme.getSize("popup_dialog").width
  12. height: UM.Theme.getSize("popup_dialog").height
  13. minimumWidth: width
  14. maximumWidth: minimumWidth
  15. minimumHeight: height
  16. maximumHeight: minimumHeight
  17. margin: 0
  18. property string actionButtonText: subscribedPackagesModel.hasIncompatiblePackages && !subscribedPackagesModel.hasCompatiblePackages ? catalog.i18nc("@button", "Dismiss") : catalog.i18nc("@button", "Next")
  19. Rectangle
  20. {
  21. id: root
  22. anchors.fill: parent
  23. color: UM.Theme.getColor("main_background")
  24. UM.I18nCatalog
  25. {
  26. id: catalog
  27. name: "cura"
  28. }
  29. ScrollView
  30. {
  31. width: parent.width
  32. height: parent.height - nextButton.height - nextButton.anchors.margins * 2 // We want some leftover space for the button at the bottom
  33. clip: true
  34. Column
  35. {
  36. anchors.fill: parent
  37. anchors.margins: UM.Theme.getSize("default_margin").width
  38. // Compatible packages
  39. Label
  40. {
  41. font: UM.Theme.getFont("default")
  42. text: catalog.i18nc("@label", "The following packages will be added:")
  43. visible: subscribedPackagesModel.hasCompatiblePackages
  44. color: UM.Theme.getColor("text")
  45. height: contentHeight + UM.Theme.getSize("default_margin").height
  46. }
  47. Repeater
  48. {
  49. model: subscribedPackagesModel
  50. Component
  51. {
  52. Item
  53. {
  54. width: parent.width
  55. property int lineHeight: 60
  56. visible: model.is_compatible
  57. height: visible ? (lineHeight + UM.Theme.getSize("default_margin").height) : 0 // We only show the compatible packages here
  58. Image
  59. {
  60. id: packageIcon
  61. source: model.icon_url || "../../images/placeholder.svg"
  62. height: lineHeight
  63. width: height
  64. sourceSize.height: height
  65. sourceSize.width: width
  66. mipmap: true
  67. fillMode: Image.PreserveAspectFit
  68. }
  69. Label
  70. {
  71. text: model.display_name
  72. font: UM.Theme.getFont("medium_bold")
  73. anchors.left: packageIcon.right
  74. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  75. anchors.verticalCenter: packageIcon.verticalCenter
  76. color: UM.Theme.getColor("text")
  77. elide: Text.ElideRight
  78. }
  79. }
  80. }
  81. }
  82. // Incompatible packages
  83. Label
  84. {
  85. font: UM.Theme.getFont("default")
  86. text: catalog.i18nc("@label", "The following packages can not be installed because of an incompatible Cura version:")
  87. visible: subscribedPackagesModel.hasIncompatiblePackages
  88. color: UM.Theme.getColor("text")
  89. height: contentHeight + UM.Theme.getSize("default_margin").height
  90. }
  91. Repeater
  92. {
  93. model: subscribedPackagesModel
  94. Component
  95. {
  96. Item
  97. {
  98. width: parent.width
  99. property int lineHeight: 60
  100. visible: !model.is_compatible && !model.is_dismissed
  101. height: visible ? (lineHeight + UM.Theme.getSize("default_margin").height) : 0 // We only show the incompatible packages here
  102. Image
  103. {
  104. id: packageIcon
  105. source: model.icon_url || "../../images/placeholder.svg"
  106. height: lineHeight
  107. width: height
  108. sourceSize.height: height
  109. sourceSize.width: width
  110. mipmap: true
  111. fillMode: Image.PreserveAspectFit
  112. }
  113. Label
  114. {
  115. text: model.display_name
  116. font: UM.Theme.getFont("medium_bold")
  117. anchors.left: packageIcon.right
  118. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  119. anchors.verticalCenter: packageIcon.verticalCenter
  120. color: UM.Theme.getColor("text")
  121. elide: Text.ElideRight
  122. }
  123. }
  124. }
  125. }
  126. }
  127. } // End of ScrollView
  128. Cura.PrimaryButton
  129. {
  130. id: nextButton
  131. anchors.bottom: parent.bottom
  132. anchors.right: parent.right
  133. anchors.margins: UM.Theme.getSize("default_margin").height
  134. text: actionButtonText
  135. onClicked: accept()
  136. leftPadding: UM.Theme.getSize("dialog_primary_button_padding").width
  137. rightPadding: UM.Theme.getSize("dialog_primary_button_padding").width
  138. }
  139. }
  140. }