CompatibilityDialog.qml 5.7 KB

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