ProfileWarningReset.qml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. // Copyright (C) 2022 UltiMaker
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import UM 1.6 as UM
  5. import Cura 1.6 as Cura
  6. import "../Dialogs"
  7. Item
  8. {
  9. property bool fullWarning: true // <- Can you see the warning icon and the text, or is it just the buttons?
  10. property var simpleModeSettingsManager :CuraApplication.getSimpleModeSettingsManager()
  11. height: visible ? UM.Theme.getSize("action_button_icon").height : 0
  12. width: visible ? childrenRect.width: 0
  13. visible: Cura.MachineManager.hasUserSettings || (fullWarning && Cura.MachineManager.hasCustomQuality)
  14. Rectangle
  15. {
  16. id: warningIcon
  17. visible: fullWarning
  18. color: UM.Theme.getColor("warning")
  19. height: UM.Theme.getSize("action_button_icon").height
  20. width: visible ? height : 0
  21. radius: width
  22. anchors
  23. {
  24. left: parent.left
  25. verticalCenter: parent.verticalCenter
  26. }
  27. UM.ColorImage
  28. {
  29. id: warningIconImage
  30. height: UM.Theme.getSize("action_button_icon").height
  31. width: height
  32. source: UM.Theme.getIcon("Warning", "low")
  33. }
  34. }
  35. UM.Label
  36. {
  37. id: warning
  38. visible: fullWarning
  39. width: visible ? parent.width - warningIcon.width - (compareAndSaveButton.width + resetToDefaultQualityButton.width) : 0
  40. anchors
  41. {
  42. left: warningIcon.right
  43. verticalCenter: parent.verticalCenter
  44. leftMargin: visible ? UM.Theme.getSize("thin_margin").width : 0
  45. }
  46. wrapMode: Text.WordWrap
  47. states: [
  48. State
  49. {
  50. name: "settings changed and custom quality"
  51. when: Cura.MachineManager.hasUserSettings && Cura.MachineManager.hasCustomQuality
  52. PropertyChanges
  53. {
  54. target: warning
  55. text: {
  56. var profile_name = Cura.MachineManager.activeQualityChangesGroup.name
  57. return catalog.i18nc("@info, %1 is the name of the custom profile", "<b>%1</b> custom profile is active and you overwrote some settings.").arg(profile_name)
  58. }
  59. }
  60. },
  61. State
  62. {
  63. name: "custom quality"
  64. when: Cura.MachineManager.hasCustomQuality
  65. PropertyChanges
  66. {
  67. target: warning
  68. text: {
  69. var profile_name = Cura.MachineManager.activeQualityChangesGroup.name
  70. return catalog.i18nc("@info, %1 is the name of the custom profile", "<b>%1</b> custom profile is overriding some settings.").arg(profile_name)
  71. }
  72. }
  73. },
  74. State
  75. {
  76. name: "recommended settings changed"
  77. when: Cura.MachineManager.hasUserSettings
  78. PropertyChanges
  79. {
  80. target: warning
  81. text:
  82. {
  83. var profile_name = Cura.MachineManager.activeQualityOrQualityChangesName;
  84. return catalog.i18nc("@info %1 is the name of a profile", "Recommended settings (for <b>%1</b>) were altered.").arg(profile_name);
  85. }
  86. }
  87. },
  88. State
  89. {
  90. name: "custom settings changed"
  91. when: simpleModeSettingsManager.isProfileCustomized
  92. PropertyChanges
  93. {
  94. target: warning
  95. text:
  96. {
  97. var profile_name = Cura.MachineManager.activeQualityOrQualityChangesName;
  98. return catalog.i18nc("@info %1 is the name of a profile", "Some setting-values defined in <b>%1</b> were overridden.").arg(profile_name);
  99. }
  100. }
  101. }
  102. ]
  103. }
  104. UM.SimpleButton
  105. {
  106. id: resetToDefaultQualityButton
  107. height: UM.Theme.getSize("action_button_icon").height
  108. width: visible ? height : 0
  109. iconSource: UM.Theme.getIcon("ArrowReset")
  110. anchors
  111. {
  112. right: buttonsSpacer.left
  113. verticalCenter: parent.verticalCenter
  114. }
  115. visible: enabled
  116. color: enabled ? UM.Theme.getColor("accent_1") : UM.Theme.getColor("disabled")
  117. hoverColor: UM.Theme.getColor("primary_hover")
  118. enabled: (fullWarning && Cura.MachineManager.hasCustomQuality) || Cura.MachineManager.hasUserSettings
  119. onClicked: Cura.MachineManager.resetToUseDefaultQuality()
  120. UM.ToolTip
  121. {
  122. visible: parent.hovered
  123. y: parent.y + parent.height + UM.Theme.getSize("default_margin").height
  124. targetPoint: Qt.point(parent.x, Math.round(parent.y + parent.height / 2))
  125. tooltipText: catalog.i18nc("@info", "Reset to defaults.")
  126. }
  127. }
  128. // Spacer
  129. Item
  130. {
  131. id: buttonsSpacer
  132. width: compareAndSaveButton.visible ? UM.Theme.getSize("default_margin").width : 0
  133. anchors.right: compareAndSaveButton.left
  134. }
  135. UM.SimpleButton
  136. {
  137. id: compareAndSaveButton
  138. height: UM.Theme.getSize("action_button_icon").height
  139. width: visible ? height : 0
  140. iconSource: UM.Theme.getIcon("Save")
  141. anchors
  142. {
  143. right: parent.right
  144. verticalCenter: parent.verticalCenter
  145. }
  146. visible: enabled
  147. color: enabled ? UM.Theme.getColor("accent_1") : UM.Theme.getColor("disabled")
  148. hoverColor: UM.Theme.getColor("primary_hover")
  149. enabled: Cura.MachineManager.hasUserSettings
  150. onClicked: CuraApplication.showCompareAndSaveProfileChanges
  151. (
  152. Cura.MachineManager.hasCustomQuality ?
  153. DiscardOrKeepProfileChangesDialog.ButtonsType.SaveFromCustom :
  154. DiscardOrKeepProfileChangesDialog.ButtonsType.SaveFromBuiltIn
  155. )
  156. UM.ToolTip
  157. {
  158. visible: parent.hovered
  159. y: parent.y + parent.height + UM.Theme.getSize("default_margin").height
  160. targetPoint: Qt.point(parent.x, Math.round(parent.y + parent.height / 2))
  161. tooltipText: catalog.i18nc("@info", "Compare and save.")
  162. }
  163. }
  164. }