DiscardOrKeepProfileChangesDialog.qml 6.6 KB

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