PluginBrowser.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. // Copyright (c) 2017 Ultimaker B.V.
  2. // PluginBrowser is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Dialogs 1.1
  5. import QtQuick.Window 2.2
  6. import QtQuick.Controls 1.4
  7. import QtQuick.Controls.Styles 1.4
  8. // TODO: Switch to QtQuick.Controls 2.x and remove QtQuick.Controls.Styles
  9. import UM 1.1 as UM
  10. Window {
  11. id: base
  12. title: catalog.i18nc("@title:tab", "Plugins");
  13. width: 800 * screenScaleFactor
  14. height: 640 * screenScaleFactor
  15. minimumWidth: 350 * screenScaleFactor
  16. minimumHeight: 350 * screenScaleFactor
  17. color: UM.Theme.getColor("sidebar")
  18. Item {
  19. id: view
  20. anchors {
  21. fill: parent
  22. leftMargin: UM.Theme.getSize("default_margin").width
  23. rightMargin: UM.Theme.getSize("default_margin").width
  24. topMargin: UM.Theme.getSize("default_margin").height
  25. bottomMargin: UM.Theme.getSize("default_margin").height
  26. }
  27. Rectangle {
  28. id: topBar
  29. width: parent.width
  30. color: "transparent"
  31. height: childrenRect.height
  32. Row {
  33. spacing: 12
  34. height: childrenRect.height
  35. width: childrenRect.width
  36. anchors.horizontalCenter: parent.horizontalCenter
  37. Button {
  38. text: "Install"
  39. style: ButtonStyle {
  40. background: Rectangle {
  41. color: "transparent"
  42. implicitWidth: 96
  43. implicitHeight: 48
  44. Rectangle {
  45. visible: manager.viewing == "available" ? true : false
  46. color: UM.Theme.getColor("primary")
  47. anchors.bottom: parent.bottom
  48. width: parent.width
  49. height: 3
  50. }
  51. }
  52. label: Text {
  53. text: control.text
  54. color: UM.Theme.getColor("text")
  55. font {
  56. pixelSize: 15
  57. }
  58. verticalAlignment: Text.AlignVCenter
  59. horizontalAlignment: Text.AlignHCenter
  60. }
  61. }
  62. onClicked: manager.setView("available")
  63. }
  64. Button {
  65. text: "Manage"
  66. style: ButtonStyle {
  67. background: Rectangle {
  68. color: "transparent"
  69. implicitWidth: 96
  70. implicitHeight: 48
  71. Rectangle {
  72. visible: manager.viewing == "installed" ? true : false
  73. color: UM.Theme.getColor("primary")
  74. anchors.bottom: parent.bottom
  75. width: parent.width
  76. height: 3
  77. }
  78. }
  79. label: Text {
  80. text: control.text
  81. color: UM.Theme.getColor("text")
  82. font {
  83. pixelSize: 15
  84. }
  85. verticalAlignment: Text.AlignVCenter
  86. horizontalAlignment: Text.AlignHCenter
  87. }
  88. }
  89. onClicked: manager.setView("installed")
  90. }
  91. }
  92. }
  93. // Scroll view breaks in QtQuick.Controls 2.x
  94. ScrollView {
  95. id: installedPluginList
  96. width: parent.width
  97. height: 400
  98. anchors {
  99. top: topBar.bottom
  100. topMargin: UM.Theme.getSize("default_margin").height
  101. bottom: bottomBar.top
  102. bottomMargin: UM.Theme.getSize("default_margin").height
  103. }
  104. frameVisible: true
  105. ListView {
  106. id: pluginList
  107. property var activePlugin
  108. property var filter: "installed"
  109. anchors.fill: parent
  110. model: manager.pluginsModel
  111. delegate: PluginEntry {}
  112. }
  113. }
  114. Rectangle {
  115. id: bottomBar
  116. width: parent.width
  117. height: childrenRect.height
  118. color: "transparent"
  119. anchors.bottom: parent.bottom
  120. Label {
  121. visible: manager.restartRequired
  122. text: "You will need to restart Cura before changes in plugins have effect."
  123. height: 30
  124. verticalAlignment: Text.AlignVCenter
  125. }
  126. Button {
  127. id: restartChangedButton
  128. text: "Quit Cura"
  129. anchors.right: closeButton.left
  130. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  131. visible: manager.restartRequired
  132. iconName: "dialog-restart"
  133. onClicked: manager.restart()
  134. style: ButtonStyle {
  135. background: Rectangle {
  136. implicitWidth: 96
  137. implicitHeight: 30
  138. color: UM.Theme.getColor("primary")
  139. }
  140. label: Text {
  141. verticalAlignment: Text.AlignVCenter
  142. color: UM.Theme.getColor("button_text")
  143. font {
  144. pixelSize: 13
  145. bold: true
  146. }
  147. text: control.text
  148. horizontalAlignment: Text.AlignHCenter
  149. }
  150. }
  151. }
  152. Button {
  153. id: closeButton
  154. text: catalog.i18nc("@action:button", "Close")
  155. iconName: "dialog-close"
  156. onClicked: {
  157. if ( manager.isDownloading ) {
  158. manager.cancelDownload()
  159. }
  160. base.close();
  161. }
  162. anchors.right: parent.right
  163. style: ButtonStyle {
  164. background: Rectangle {
  165. color: "transparent"
  166. implicitWidth: 96
  167. implicitHeight: 30
  168. border {
  169. width: 1
  170. color: UM.Theme.getColor("lining")
  171. }
  172. }
  173. label: Text {
  174. verticalAlignment: Text.AlignVCenter
  175. color: UM.Theme.getColor("text")
  176. text: control.text
  177. horizontalAlignment: Text.AlignHCenter
  178. }
  179. }
  180. }
  181. }
  182. UM.I18nCatalog { id: catalog; name: "cura" }
  183. Connections {
  184. target: manager
  185. onShowLicenseDialog: {
  186. licenseDialog.pluginName = manager.getLicenseDialogPluginName();
  187. licenseDialog.licenseContent = manager.getLicenseDialogLicenseContent();
  188. licenseDialog.pluginFileLocation = manager.getLicenseDialogPluginFileLocation();
  189. licenseDialog.show();
  190. }
  191. }
  192. UM.Dialog {
  193. id: licenseDialog
  194. title: catalog.i18nc("@title:window", "Plugin License Agreement")
  195. minimumWidth: UM.Theme.getSize("license_window_minimum").width
  196. minimumHeight: UM.Theme.getSize("license_window_minimum").height
  197. width: minimumWidth
  198. height: minimumHeight
  199. property var pluginName;
  200. property var licenseContent;
  201. property var pluginFileLocation;
  202. Item
  203. {
  204. anchors.fill: parent
  205. Label
  206. {
  207. id: licenseTitle
  208. anchors.top: parent.top
  209. anchors.left: parent.left
  210. anchors.right: parent.right
  211. text: licenseDialog.pluginName + catalog.i18nc("@label", "This plugin contains a license.\nYou need to accept this license to install this plugin.\nDo you agree with the terms below?")
  212. wrapMode: Text.Wrap
  213. }
  214. TextArea
  215. {
  216. id: licenseText
  217. anchors.top: licenseTitle.bottom
  218. anchors.bottom: parent.bottom
  219. anchors.left: parent.left
  220. anchors.right: parent.right
  221. anchors.topMargin: UM.Theme.getSize("default_margin").height
  222. readOnly: true
  223. text: licenseDialog.licenseContent != null ? licenseDialog.licenseContent : ""
  224. }
  225. }
  226. rightButtons: [
  227. Button
  228. {
  229. id: acceptButton
  230. anchors.margins: UM.Theme.getSize("default_margin").width
  231. text: catalog.i18nc("@action:button", "Accept")
  232. onClicked:
  233. {
  234. licenseDialog.close();
  235. manager.installPlugin(licenseDialog.pluginFileLocation);
  236. }
  237. },
  238. Button
  239. {
  240. id: declineButton
  241. anchors.margins: UM.Theme.getSize("default_margin").width
  242. text: catalog.i18nc("@action:button", "Decline")
  243. onClicked:
  244. {
  245. licenseDialog.close();
  246. }
  247. }
  248. ]
  249. }
  250. Connections {
  251. target: manager
  252. onShowRestartDialog: {
  253. restartDialog.message = manager.getRestartDialogMessage();
  254. restartDialog.show();
  255. }
  256. }
  257. Window {
  258. id: restartDialog
  259. // title: catalog.i18nc("@title:tab", "Plugins");
  260. width: 360 * screenScaleFactor
  261. height: 120 * screenScaleFactor
  262. minimumWidth: 360 * screenScaleFactor
  263. minimumHeight: 120 * screenScaleFactor
  264. color: UM.Theme.getColor("sidebar")
  265. property var message;
  266. Text {
  267. id: message
  268. anchors {
  269. left: parent.left
  270. leftMargin: UM.Theme.getSize("default_margin").width
  271. top: parent.top
  272. topMargin: UM.Theme.getSize("default_margin").height
  273. }
  274. text: restartDialog.message != null ? restartDialog.message : ""
  275. }
  276. Button {
  277. id: laterButton
  278. text: "Later"
  279. onClicked: restartDialog.close();
  280. anchors {
  281. left: parent.left
  282. leftMargin: UM.Theme.getSize("default_margin").width
  283. bottom: parent.bottom
  284. bottomMargin: UM.Theme.getSize("default_margin").height
  285. }
  286. style: ButtonStyle {
  287. background: Rectangle {
  288. color: "transparent"
  289. implicitWidth: 96
  290. implicitHeight: 30
  291. border {
  292. width: 1
  293. color: UM.Theme.getColor("lining")
  294. }
  295. }
  296. label: Text {
  297. verticalAlignment: Text.AlignVCenter
  298. color: UM.Theme.getColor("text")
  299. text: control.text
  300. horizontalAlignment: Text.AlignHCenter
  301. }
  302. }
  303. }
  304. Button {
  305. id: restartButton
  306. text: "Quit Cura"
  307. anchors {
  308. right: parent.right
  309. rightMargin: UM.Theme.getSize("default_margin").width
  310. bottom: parent.bottom
  311. bottomMargin: UM.Theme.getSize("default_margin").height
  312. }
  313. onClicked: manager.restart()
  314. style: ButtonStyle {
  315. background: Rectangle {
  316. implicitWidth: 96
  317. implicitHeight: 30
  318. color: UM.Theme.getColor("primary")
  319. }
  320. label: Text {
  321. verticalAlignment: Text.AlignVCenter
  322. color: UM.Theme.getColor("button_text")
  323. font {
  324. pixelSize: 13
  325. bold: true
  326. }
  327. text: control.text
  328. horizontalAlignment: Text.AlignHCenter
  329. }
  330. }
  331. }
  332. }
  333. }
  334. }