CompatibilityDialog.qml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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/logobot.svg"
  62. height: lineHeight
  63. width: height
  64. mipmap: true
  65. fillMode: Image.PreserveAspectFit
  66. }
  67. Label
  68. {
  69. text: model.display_name
  70. font: UM.Theme.getFont("medium_bold")
  71. anchors.left: packageIcon.right
  72. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  73. anchors.verticalCenter: packageIcon.verticalCenter
  74. color: UM.Theme.getColor("text")
  75. elide: Text.ElideRight
  76. }
  77. }
  78. }
  79. }
  80. // Incompatible packages
  81. Label
  82. {
  83. font: UM.Theme.getFont("default")
  84. text: catalog.i18nc("@label", "The following packages can not be installed because of an incompatible Cura version:")
  85. visible: subscribedPackagesModel.hasIncompatiblePackages
  86. color: UM.Theme.getColor("text")
  87. height: contentHeight + UM.Theme.getSize("default_margin").height
  88. }
  89. Repeater
  90. {
  91. model: subscribedPackagesModel
  92. Component
  93. {
  94. Item
  95. {
  96. width: parent.width
  97. property int lineHeight: 60
  98. visible: !model.is_compatible && !model.is_dismissed
  99. height: visible ? (lineHeight + UM.Theme.getSize("default_margin").height) : 0 // We only show the incompatible packages here
  100. Image
  101. {
  102. id: packageIcon
  103. source: model.icon_url || "../../images/logobot.svg"
  104. height: lineHeight
  105. width: height
  106. mipmap: true
  107. fillMode: Image.PreserveAspectFit
  108. }
  109. 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. color: UM.Theme.getColor("text")
  117. elide: Text.ElideRight
  118. }
  119. }
  120. }
  121. }
  122. }
  123. } // End of ScrollView
  124. Cura.PrimaryButton
  125. {
  126. id: nextButton
  127. anchors.bottom: parent.bottom
  128. anchors.right: parent.right
  129. anchors.margins: UM.Theme.getSize("default_margin").height
  130. text: actionButtonText
  131. onClicked: accept()
  132. leftPadding: UM.Theme.getSize("dialog_primary_button_padding").width
  133. rightPadding: UM.Theme.getSize("dialog_primary_button_padding").width
  134. }
  135. }
  136. }