DiscardOrKeepProfileChangesDialog.qml 6.4 KB

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