SyncState.qml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import QtQuick 2.10
  2. import QtQuick.Controls 2.3
  3. import UM 1.5 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. UM.Label
  71. {
  72. id: stateLabel
  73. // text is determined by State
  74. font: UM.Theme.getFont("medium")
  75. width: contentWidth + UM.Theme.getSize("default_margin").height
  76. height: contentHeight
  77. visible: !Cura.API.account.manualSyncEnabled && !Cura.API.account.updatePackagesEnabled
  78. }
  79. UM.Label
  80. {
  81. id: updatePackagesButton
  82. text: catalog.i18nc("@button", "Install pending updates")
  83. color: UM.Theme.getColor("text_link")
  84. font: UM.Theme.getFont("medium")
  85. height: contentHeight
  86. width: contentWidth + UM.Theme.getSize("default_margin").height
  87. visible: Cura.API.account.updatePackagesEnabled
  88. MouseArea
  89. {
  90. anchors.fill: parent
  91. onClicked: Cura.API.account.onUpdatePackagesClicked()
  92. hoverEnabled: true
  93. onEntered: updatePackagesButton.font.underline = true
  94. onExited: updatePackagesButton.font.underline = false
  95. }
  96. }
  97. UM.Label
  98. {
  99. id: accountSyncButton
  100. text: catalog.i18nc("@button", "Check for account updates")
  101. color: UM.Theme.getColor("text_link")
  102. font: UM.Theme.getFont("medium")
  103. height: contentHeight
  104. width: contentWidth + UM.Theme.getSize("default_margin").height
  105. visible: Cura.API.account.manualSyncEnabled
  106. MouseArea
  107. {
  108. anchors.fill: parent
  109. onClicked: Cura.API.account.sync(true)
  110. hoverEnabled: true
  111. onEntered: accountSyncButton.font.underline = true
  112. onExited: accountSyncButton.font.underline = false
  113. }
  114. }
  115. }
  116. }