SyncState.qml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  76. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  77. wrapMode: Text.NoWrap
  78. height: contentHeight
  79. visible: !Cura.API.account.manualSyncEnabled && !Cura.API.account.updatePackagesEnabled
  80. }
  81. UM.Label
  82. {
  83. id: updatePackagesButton
  84. text: catalog.i18nc("@button", "Install pending updates")
  85. color: UM.Theme.getColor("text_link")
  86. font: UM.Theme.getFont("medium")
  87. height: contentHeight
  88. wrapMode: Text.NoWrap
  89. width: contentWidth + UM.Theme.getSize("default_margin").height
  90. visible: Cura.API.account.updatePackagesEnabled
  91. MouseArea
  92. {
  93. anchors.fill: parent
  94. onClicked: Cura.API.account.onUpdatePackagesClicked()
  95. hoverEnabled: true
  96. onEntered: updatePackagesButton.font.underline = true
  97. onExited: updatePackagesButton.font.underline = false
  98. }
  99. }
  100. UM.Label
  101. {
  102. id: accountSyncButton
  103. text: catalog.i18nc("@button", "Check for account updates")
  104. color: UM.Theme.getColor("text_link")
  105. font: UM.Theme.getFont("medium")
  106. wrapMode: Text.NoWrap
  107. height: contentHeight
  108. width: contentWidth + UM.Theme.getSize("default_margin").height
  109. visible: Cura.API.account.manualSyncEnabled
  110. MouseArea
  111. {
  112. anchors.fill: parent
  113. onClicked: Cura.API.account.sync(true)
  114. hoverEnabled: true
  115. onEntered: accountSyncButton.font.underline = true
  116. onExited: accountSyncButton.font.underline = false
  117. }
  118. }
  119. }
  120. }