DiscardOrKeepProfileChangesDialog.qml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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: 800 * screenScaleFactor
  14. height: 400 * screenScaleFactor
  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. color: UM.Theme.getColor("setting_control_disabled_text")
  94. }
  95. }
  96. TableViewColumn
  97. {
  98. role: "label"
  99. title: catalog.i18nc("@title:column", "Profile settings")
  100. delegate: labelDelegate
  101. width: (tableView.width * 0.4) | 0
  102. }
  103. TableViewColumn
  104. {
  105. role: "original_value"
  106. title: catalog.i18nc("@title:column", "Default")
  107. width: (tableView.width * 0.3) | 0
  108. delegate: defaultDelegate
  109. }
  110. TableViewColumn
  111. {
  112. role: "user_value"
  113. title: catalog.i18nc("@title:column", "Customized")
  114. width: (tableView.width * 0.3) | 0
  115. }
  116. section.property: "category"
  117. section.delegate: Label
  118. {
  119. text: section
  120. font.bold: true
  121. }
  122. model: base.changesModel
  123. }
  124. }
  125. Item
  126. {
  127. id: optionRow
  128. anchors.bottom: buttonsRow.top
  129. anchors.right: parent.right
  130. anchors.left: parent.left
  131. anchors.margins: UM.Theme.getSize("default_margin").width
  132. height: childrenRect.height
  133. ComboBox
  134. {
  135. id: discardOrKeepProfileChangesDropDownButton
  136. width: 300
  137. model: ListModel
  138. {
  139. id: discardOrKeepProfileListModel
  140. Component.onCompleted: {
  141. append({ text: catalog.i18nc("@option:discardOrKeep", "Always ask me this"), code: "always_ask" })
  142. append({ text: catalog.i18nc("@option:discardOrKeep", "Discard and never ask again"), code: "always_discard" })
  143. append({ text: catalog.i18nc("@option:discardOrKeep", "Keep and never ask again"), code: "always_keep" })
  144. }
  145. }
  146. onActivated:
  147. {
  148. var code = model.get(index).code;
  149. UM.Preferences.setValue("cura/choice_on_profile_override", code);
  150. if (code == "always_keep") {
  151. keepButton.enabled = true;
  152. discardButton.enabled = false;
  153. }
  154. else if (code == "always_discard") {
  155. keepButton.enabled = false;
  156. discardButton.enabled = true;
  157. }
  158. else {
  159. keepButton.enabled = true;
  160. discardButton.enabled = true;
  161. }
  162. }
  163. }
  164. }
  165. Item
  166. {
  167. id: buttonsRow
  168. anchors.bottom: parent.bottom
  169. anchors.right: parent.right
  170. anchors.left: parent.left
  171. anchors.margins: UM.Theme.getSize("default_margin").width
  172. height: childrenRect.height
  173. Button
  174. {
  175. id: discardButton
  176. text: catalog.i18nc("@action:button", "Discard");
  177. anchors.right: parent.right
  178. onClicked:
  179. {
  180. CuraApplication.discardOrKeepProfileChangesClosed("discard")
  181. base.hide()
  182. }
  183. isDefault: true
  184. }
  185. Button
  186. {
  187. id: keepButton
  188. text: catalog.i18nc("@action:button", "Keep");
  189. anchors.right: discardButton.left
  190. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  191. onClicked:
  192. {
  193. CuraApplication.discardOrKeepProfileChangesClosed("keep")
  194. base.hide()
  195. }
  196. }
  197. Button
  198. {
  199. id: createNewProfileButton
  200. text: catalog.i18nc("@action:button", "Create New Profile");
  201. anchors.left: parent.left
  202. action: Cura.Actions.addProfile
  203. onClicked: base.hide()
  204. }
  205. }
  206. }