Browse Source

Add state for when it's loading

This has a slight bug in that the icon will immediately change to an arrow once loading has completed, but will slowly rotate back to angle 0. You don't see this, since the new plug-ins will come in between. The new plug-ins will always be a full page, or otherwise the icon disappears altogether and it's not visible anyway. But if you hold down the scrollbar while loading and quickly scroll down when loading completed, you can see this happen. I don't think anyone will really mind though.

Contributes to issue CURA-8556.
Ghostkeeper 3 years ago
parent
commit
1ab677f5dd
1 changed files with 26 additions and 3 deletions
  1. 26 3
      plugins/Marketplace/resources/qml/Plugins.qml

+ 26 - 3
plugins/Marketplace/resources/qml/Plugins.qml

@@ -67,18 +67,41 @@ ScrollView
 
                 UM.RecolorImage
                 {
+                    id: loadMoreIcon
                     width: visible ? UM.Theme.getSize("small_button_icon").width : 0
                     height: UM.Theme.getSize("small_button_icon").height
                     anchors.verticalCenter: loadMoreLabel.verticalCenter
 
-                    visible: pluginList.hasMore
-                    source: UM.Theme.getIcon("ArrowDown")
+                    visible: pluginList.hasMore || pluginList.isLoading
+                    source: UM.Theme.getIcon(pluginList.isLoading ? "ArrowDoubleCircleRight" : "ArrowDown")
                     color: UM.Theme.getColor(loadMoreButton.enabled ? "secondary_button_text" : "action_button_disabled_text")
+
+                    RotationAnimator
+                    {
+                        target: loadMoreIcon
+                        from: 0
+                        to: 360
+                        duration: 1000
+                        loops: Animation.Infinite
+                        running: pluginList.isLoading
+                        alwaysRunToEnd: true
+                    }
                 }
                 Label
                 {
                     id: loadMoreLabel
-                    text: pluginList.hasMore ? catalog.i18nc("@button", "Load More") : catalog.i18nc("@button", "No more results to load")
+                    text:
+                    {
+                        if(pluginList.isLoading)
+                        {
+                            return catalog.i18nc("@button", "Loading");
+                        }
+                        if(pluginList.hasMore)
+                        {
+                            return catalog.i18nc("@button", "Load more");
+                        }
+                        return catalog.i18nc("@button", "No more results to load");
+                    }
                     font: UM.Theme.getFont("medium_bold")
                     color: UM.Theme.getColor(loadMoreButton.enabled ? "secondary_button_text" : "action_button_disabled_text")
                 }