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