ProfileWarningReset.qml 6.0 KB

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