DiscardOrKeepProfileChangesDialog.qml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. // Copyright (c) 2017 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.1
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Dialogs 1.2
  6. import QtQuick.Window 2.1
  7. import UM 1.2 as UM
  8. import Cura 1.0 as Cura
  9. UM.Dialog
  10. {
  11. id: base
  12. title: catalog.i18nc("@title:window", "Discard or Keep changes")
  13. width: UM.Theme.getSize("popup_dialog").width
  14. height: UM.Theme.getSize("popup_dialog").height
  15. property var changesModel: Cura.UserChangesModel{ id: userChangesModel}
  16. onVisibilityChanged:
  17. {
  18. if(visible)
  19. {
  20. changesModel.forceUpdate()
  21. discardOrKeepProfileChangesDropDownButton.currentIndex = 0;
  22. for (var i = 0; i < discardOrKeepProfileChangesDropDownButton.model.count; ++i)
  23. {
  24. var code = discardOrKeepProfileChangesDropDownButton.model.get(i).code;
  25. if (code == UM.Preferences.getValue("cura/choice_on_profile_override"))
  26. {
  27. discardOrKeepProfileChangesDropDownButton.currentIndex = i;
  28. break;
  29. }
  30. }
  31. }
  32. }
  33. Row
  34. {
  35. id: infoTextRow
  36. height: childrenRect.height
  37. anchors.margins: UM.Theme.getSize("default_margin").width
  38. anchors.left: parent.left
  39. anchors.right: parent.right
  40. anchors.top: parent.top
  41. spacing: UM.Theme.getSize("default_margin").width
  42. UM.I18nCatalog
  43. {
  44. id: catalog;
  45. name: "cura"
  46. }
  47. Label
  48. {
  49. text: catalog.i18nc("@text:window", "You have customized some profile settings.\nWould you like to keep or discard those settings?")
  50. anchors.margins: UM.Theme.getSize("default_margin").width
  51. wrapMode: Text.WordWrap
  52. }
  53. }
  54. Item
  55. {
  56. anchors.margins: UM.Theme.getSize("default_margin").width
  57. anchors.top: infoTextRow.bottom
  58. anchors.bottom: optionRow.top
  59. anchors.left: parent.left
  60. anchors.right: parent.right
  61. TableView
  62. {
  63. anchors.fill: parent
  64. height: base.height - 150
  65. id: tableView
  66. Component
  67. {
  68. id: labelDelegate
  69. Label
  70. {
  71. property var extruder_name: userChangesModel.getItem(styleData.row).extruder
  72. anchors.left: parent.left
  73. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  74. font: UM.Theme.getFont("system")
  75. text:
  76. {
  77. var result = styleData.value
  78. if (extruder_name != "")
  79. {
  80. result += " (" + extruder_name + ")"
  81. }
  82. return result
  83. }
  84. }
  85. }
  86. Component
  87. {
  88. id: defaultDelegate
  89. Label
  90. {
  91. text: styleData.value
  92. font: UM.Theme.getFont("system")
  93. }
  94. }
  95. TableViewColumn
  96. {
  97. role: "label"
  98. title: catalog.i18nc("@title:column", "Profile settings")
  99. delegate: labelDelegate
  100. width: (tableView.width * 0.4) | 0
  101. }
  102. TableViewColumn
  103. {
  104. role: "original_value"
  105. title: catalog.i18nc("@title:column", "Default")
  106. width: (tableView.width * 0.3) | 0
  107. delegate: defaultDelegate
  108. }
  109. TableViewColumn
  110. {
  111. role: "user_value"
  112. title: catalog.i18nc("@title:column", "Customized")
  113. width: (tableView.width * 0.3) | 0
  114. }
  115. section.property: "category"
  116. section.delegate: Label
  117. {
  118. text: section
  119. font.bold: true
  120. }
  121. model: base.changesModel
  122. }
  123. }
  124. Item
  125. {
  126. id: optionRow
  127. anchors.bottom: buttonsRow.top
  128. anchors.right: parent.right
  129. anchors.left: parent.left
  130. anchors.margins: UM.Theme.getSize("default_margin").width
  131. height: childrenRect.height
  132. ComboBox
  133. {
  134. id: discardOrKeepProfileChangesDropDownButton
  135. width: 300
  136. model: ListModel
  137. {
  138. id: discardOrKeepProfileListModel
  139. Component.onCompleted: {
  140. append({ text: catalog.i18nc("@option:discardOrKeep", "Always ask me this"), code: "always_ask" })
  141. append({ text: catalog.i18nc("@option:discardOrKeep", "Discard and never ask again"), code: "always_discard" })
  142. append({ text: catalog.i18nc("@option:discardOrKeep", "Keep and never ask again"), code: "always_keep" })
  143. }
  144. }
  145. onActivated:
  146. {
  147. var code = model.get(index).code;
  148. UM.Preferences.setValue("cura/choice_on_profile_override", code);
  149. if (code == "always_keep") {
  150. keepButton.enabled = true;
  151. discardButton.enabled = false;
  152. }
  153. else if (code == "always_discard") {
  154. keepButton.enabled = false;
  155. discardButton.enabled = true;
  156. }
  157. else {
  158. keepButton.enabled = true;
  159. discardButton.enabled = true;
  160. }
  161. }
  162. }
  163. }
  164. Item
  165. {
  166. id: buttonsRow
  167. anchors.bottom: parent.bottom
  168. anchors.right: parent.right
  169. anchors.left: parent.left
  170. anchors.margins: UM.Theme.getSize("default_margin").width
  171. height: childrenRect.height
  172. Button
  173. {
  174. id: discardButton
  175. text: catalog.i18nc("@action:button", "Discard");
  176. anchors.right: parent.right
  177. onClicked:
  178. {
  179. CuraApplication.discardOrKeepProfileChangesClosed("discard")
  180. base.hide()
  181. }
  182. isDefault: true
  183. }
  184. Button
  185. {
  186. id: keepButton
  187. text: catalog.i18nc("@action:button", "Keep");
  188. anchors.right: discardButton.left
  189. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  190. onClicked:
  191. {
  192. CuraApplication.discardOrKeepProfileChangesClosed("keep")
  193. base.hide()
  194. }
  195. }
  196. Button
  197. {
  198. id: createNewProfileButton
  199. text: catalog.i18nc("@action:button", "Create New Profile");
  200. anchors.left: parent.left
  201. action: Cura.Actions.addProfile
  202. onClicked: base.hide()
  203. }
  204. }
  205. }