PluginBrowser.qml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. import UM 1.1 as UM
  2. import QtQuick 2.2
  3. import QtQuick.Dialogs 1.1
  4. import QtQuick.Window 2.2
  5. import QtQuick.Controls 1.1
  6. UM.Dialog
  7. {
  8. id: base
  9. title: catalog.i18nc("@title:window", "Find & Update plugins")
  10. width: 600
  11. height: 450
  12. Item
  13. {
  14. anchors.fill: parent
  15. Item
  16. {
  17. id: topBar
  18. height: childrenRect.height;
  19. width: parent.width
  20. Label
  21. {
  22. id: introText
  23. text: catalog.i18nc("@label", "Here you can find a list of Third Party plugins.")
  24. width: parent.width
  25. height: 30
  26. }
  27. Button
  28. {
  29. id: refresh
  30. text: catalog.i18nc("@action:button", "Refresh")
  31. onClicked: manager.requestPluginList()
  32. anchors.right: parent.right
  33. enabled: !manager.isDownloading
  34. }
  35. }
  36. ScrollView
  37. {
  38. width: parent.width
  39. anchors.top: topBar.bottom
  40. anchors.bottom: bottomBar.top
  41. anchors.bottomMargin: UM.Theme.getSize("default_margin").height
  42. frameVisible: true
  43. ListView
  44. {
  45. id: pluginList
  46. model: manager.pluginsModel
  47. anchors.fill: parent
  48. property var activePlugin
  49. delegate: pluginDelegate
  50. }
  51. }
  52. Item
  53. {
  54. id: bottomBar
  55. width: parent.width
  56. height: closeButton.height
  57. anchors.bottom:parent.bottom
  58. anchors.left: parent.left
  59. ProgressBar
  60. {
  61. id: progressbar
  62. anchors.bottom: parent.bottom
  63. minimumValue: 0;
  64. maximumValue: 100
  65. anchors.left:parent.left
  66. anchors.right: closeButton.left
  67. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  68. value: manager.isDownloading ? manager.downloadProgress : 0
  69. }
  70. Button
  71. {
  72. id: closeButton
  73. text: catalog.i18nc("@action:button", "Close")
  74. iconName: "dialog-close"
  75. onClicked:
  76. {
  77. if (manager.isDownloading)
  78. {
  79. manager.cancelDownload()
  80. }
  81. base.close();
  82. }
  83. anchors.bottom: parent.bottom
  84. anchors.right: parent.right
  85. }
  86. }
  87. Item
  88. {
  89. SystemPalette { id: palette }
  90. Component
  91. {
  92. id: pluginDelegate
  93. Rectangle
  94. {
  95. width: pluginList.width;
  96. height: texts.height;
  97. color: index % 2 ? palette.base : palette.alternateBase
  98. Column
  99. {
  100. id: texts
  101. width: parent.width
  102. height: childrenRect.height
  103. anchors.left: parent.left
  104. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  105. anchors.right: downloadButton.left
  106. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  107. Label
  108. {
  109. text: "<b>" + model.name + "</b> - " + model.author
  110. width: contentWidth
  111. height: contentHeight + UM.Theme.getSize("default_margin").height
  112. verticalAlignment: Text.AlignVCenter
  113. }
  114. Label
  115. {
  116. text: model.short_description
  117. width: parent.width
  118. height: contentHeight + UM.Theme.getSize("default_margin").height
  119. wrapMode: Text.WordWrap
  120. verticalAlignment: Text.AlignVCenter
  121. }
  122. }
  123. Button
  124. {
  125. id: downloadButton
  126. text:
  127. {
  128. if (manager.isDownloading && pluginList.activePlugin == model)
  129. {
  130. return catalog.i18nc("@action:button", "Cancel");
  131. }
  132. else if (model.already_installed)
  133. {
  134. if (model.can_upgrade)
  135. {
  136. return catalog.i18nc("@action:button", "Upgrade");
  137. }
  138. return catalog.i18nc("@action:button", "Installed");
  139. }
  140. return catalog.i18nc("@action:button", "Download");
  141. }
  142. onClicked:
  143. {
  144. if(!manager.isDownloading)
  145. {
  146. pluginList.activePlugin = model;
  147. manager.downloadAndInstallPlugin(model.file_location);
  148. }
  149. else
  150. {
  151. manager.cancelDownload();
  152. }
  153. }
  154. anchors.right: parent.right
  155. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  156. anchors.verticalCenter: parent.verticalCenter
  157. enabled:
  158. {
  159. if (manager.isDownloading)
  160. {
  161. return (pluginList.activePlugin == model);
  162. }
  163. else
  164. {
  165. return (!model.already_installed || model.can_upgrade);
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. UM.I18nCatalog { id: catalog; name:"cura" }
  173. }
  174. }