DiscardOrKeepProfileChangesDialog.qml 7.1 KB

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