SyncState.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import QtQuick 2.10
  2. import QtQuick.Controls 2.3
  3. import UM 1.4 as UM
  4. import Cura 1.1 as Cura
  5. Row // Sync state icon + message
  6. {
  7. property var syncState: Cura.API.account.syncState
  8. id: syncRow
  9. width: childrenRect.width
  10. height: childrenRect.height
  11. spacing: UM.Theme.getSize("narrow_margin").height
  12. states: [
  13. State
  14. {
  15. name: "idle"
  16. when: syncState == Cura.AccountSyncState.IDLE
  17. PropertyChanges { target: icon; source: UM.Theme.getIcon("update")}
  18. },
  19. State
  20. {
  21. name: "syncing"
  22. when: syncState == Cura.AccountSyncState.SYNCING
  23. PropertyChanges { target: icon; source: UM.Theme.getIcon("update") }
  24. PropertyChanges { target: stateLabel; text: catalog.i18nc("@label", "Checking...")}
  25. },
  26. State
  27. {
  28. name: "up_to_date"
  29. when: syncState == Cura.AccountSyncState.SUCCESS
  30. PropertyChanges { target: icon; source: UM.Theme.getIcon("checked") }
  31. PropertyChanges { target: stateLabel; text: catalog.i18nc("@label", "You are in sync with your account")}
  32. },
  33. State
  34. {
  35. name: "error"
  36. when: syncState == Cura.AccountSyncState.ERROR
  37. PropertyChanges { target: icon; source: UM.Theme.getIcon("warning_light") }
  38. PropertyChanges { target: stateLabel; text: catalog.i18nc("@label", "Something went wrong...")}
  39. }
  40. ]
  41. SystemPalette
  42. {
  43. id: palette
  44. }
  45. UM.RecolorImage
  46. {
  47. id: icon
  48. width: 20 * screenScaleFactor
  49. height: width
  50. source: Cura.API.account.manualSyncEnabled ? UM.Theme.getIcon("update") : UM.Theme.getIcon("checked")
  51. color: palette.text
  52. RotationAnimator
  53. {
  54. id: updateAnimator
  55. target: icon
  56. from: 0
  57. to: 360
  58. duration: 1000
  59. loops: Animation.Infinite
  60. running: syncState == Cura.AccountSyncState.SYNCING
  61. // reset rotation when stopped
  62. onRunningChanged: {
  63. if(!running)
  64. {
  65. icon.rotation = 0
  66. }
  67. }
  68. }
  69. }
  70. Column
  71. {
  72. width: childrenRect.width
  73. height: childrenRect.height
  74. Label
  75. {
  76. id: stateLabel
  77. text: catalog.i18nc("@state", catalog.i18nc("@label", "You are in sync with your account"))
  78. color: UM.Theme.getColor("text")
  79. font: UM.Theme.getFont("medium")
  80. renderType: Text.NativeRendering
  81. width: contentWidth + UM.Theme.getSize("default_margin").height
  82. height: contentHeight
  83. verticalAlignment: Text.AlignVCenter
  84. visible: !Cura.API.account.manualSyncEnabled
  85. }
  86. Label
  87. {
  88. id: accountSyncButton
  89. text: catalog.i18nc("@button", "Check for account updates")
  90. color: UM.Theme.getColor("secondary_button_text")
  91. font: UM.Theme.getFont("medium")
  92. renderType: Text.NativeRendering
  93. verticalAlignment: Text.AlignVCenter
  94. height: contentHeight
  95. width: contentWidth + UM.Theme.getSize("default_margin").height
  96. visible: Cura.API.account.manualSyncEnabled
  97. MouseArea
  98. {
  99. anchors.fill: parent
  100. onClicked: Cura.API.account.sync(true)
  101. hoverEnabled: true
  102. onEntered: accountSyncButton.font.underline = true
  103. onExited: accountSyncButton.font.underline = false
  104. }
  105. }
  106. }
  107. }