SyncState.qml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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("ArrowDoubleCircleRight")}
  18. },
  19. State
  20. {
  21. name: "syncing"
  22. when: syncState == Cura.AccountSyncState.SYNCING
  23. PropertyChanges { target: icon; source: UM.Theme.getIcon("ArrowDoubleCircleRight") }
  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("CheckCircle") }
  31. PropertyChanges { target: stateLabel; text: catalog.i18nc("@label", "Account synced")}
  32. },
  33. State
  34. {
  35. name: "error"
  36. when: syncState == Cura.AccountSyncState.ERROR
  37. PropertyChanges { target: icon; source: UM.Theme.getIcon("Warning") }
  38. PropertyChanges { target: stateLabel; text: catalog.i18nc("@label", "Something went wrong...")}
  39. }
  40. ]
  41. UM.RecolorImage
  42. {
  43. id: icon
  44. width: 20 * screenScaleFactor
  45. height: width
  46. // source is determined by State
  47. color: UM.Theme.getColor("account_sync_state_icon")
  48. RotationAnimator
  49. {
  50. id: updateAnimator
  51. target: icon
  52. from: 0
  53. to: 360
  54. duration: 1000
  55. loops: Animation.Infinite
  56. running: syncState == Cura.AccountSyncState.SYNCING
  57. // reset rotation when stopped
  58. onRunningChanged: {
  59. if(!running)
  60. {
  61. icon.rotation = 0
  62. }
  63. }
  64. }
  65. }
  66. Column
  67. {
  68. width: childrenRect.width
  69. height: childrenRect.height
  70. Label
  71. {
  72. id: stateLabel
  73. // text is determined by State
  74. color: UM.Theme.getColor("text")
  75. font: UM.Theme.getFont("medium")
  76. renderType: Text.NativeRendering
  77. width: contentWidth + UM.Theme.getSize("default_margin").height
  78. height: contentHeight
  79. verticalAlignment: Text.AlignVCenter
  80. visible: !Cura.API.account.manualSyncEnabled && !Cura.API.account.updatePackagesEnabled
  81. }
  82. Label
  83. {
  84. id: updatePackagesButton
  85. text: catalog.i18nc("@button", "Install pending updates")
  86. color: UM.Theme.getColor("text_link")
  87. font: UM.Theme.getFont("medium")
  88. renderType: Text.NativeRendering
  89. verticalAlignment: Text.AlignVCenter
  90. height: contentHeight
  91. width: contentWidth + UM.Theme.getSize("default_margin").height
  92. visible: Cura.API.account.updatePackagesEnabled
  93. MouseArea
  94. {
  95. anchors.fill: parent
  96. onClicked: Cura.API.account.onUpdatePackagesClicked()
  97. hoverEnabled: true
  98. onEntered: updatePackagesButton.font.underline = true
  99. onExited: updatePackagesButton.font.underline = false
  100. }
  101. }
  102. Label
  103. {
  104. id: accountSyncButton
  105. text: catalog.i18nc("@button", "Check for account updates")
  106. color: UM.Theme.getColor("text_link")
  107. font: UM.Theme.getFont("medium")
  108. renderType: Text.NativeRendering
  109. verticalAlignment: Text.AlignVCenter
  110. height: contentHeight
  111. width: contentWidth + UM.Theme.getSize("default_margin").height
  112. visible: Cura.API.account.manualSyncEnabled
  113. MouseArea
  114. {
  115. anchors.fill: parent
  116. onClicked: Cura.API.account.sync(true)
  117. hoverEnabled: true
  118. onEntered: accountSyncButton.font.underline = true
  119. onExited: accountSyncButton.font.underline = false
  120. }
  121. }
  122. }
  123. }