Implement error handling and showing error state

If an error occurs, the error message is stored in the list model, so that it can be shown with the list.

Contributes to issue CURA-8556.
This commit is contained in:
Ghostkeeper 2021-10-25 01:56:57 +02:00
parent bca2f36186
commit daf450142b
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A
2 changed files with 80 additions and 20 deletions

View file

@ -4,7 +4,7 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import Cura 1.7 as Cura
import UM 1.0 as UM
import UM 1.4 as UM
ScrollView
{
@ -49,7 +49,7 @@ ScrollView
width: parent.width
height: UM.Theme.getSize("card").height
enabled: pluginList.hasMore && !pluginList.isLoading
enabled: pluginList.hasMore && !pluginList.isLoading || pluginList.errorMessage != ""
onClicked: pluginList.request() //Load next page in plug-in list.
background: Rectangle
@ -67,6 +67,26 @@ ScrollView
states:
[
State
{
name: "Error"
when: pluginList.errorMessage != ""
PropertyChanges
{
target: errorIcon
visible: true
}
PropertyChanges
{
target: loadMoreIcon
visible: false
}
PropertyChanges
{
target: loadMoreLabel
text: catalog.i18nc("@button", "Failed to load plug-ins:") + " " + pluginList.errorMessage + "\n" + catalog.i18nc("@button", "Retry?")
}
},
State
{
name: "Loading"
@ -102,25 +122,38 @@ ScrollView
}
]
UM.RecolorImage
Item
{
id: loadMoreIcon
width: visible ? UM.Theme.getSize("small_button_icon").width : 0
width: (errorIcon.visible || loadMoreIcon.visible) ? UM.Theme.getSize("small_button_icon").width : 0
height: UM.Theme.getSize("small_button_icon").height
anchors.verticalCenter: loadMoreLabel.verticalCenter
source: UM.Theme.getIcon("ArrowDown")
color: UM.Theme.getColor("secondary_button_text")
RotationAnimator
UM.StatusIcon
{
target: loadMoreIcon
from: 0
to: 360
duration: 1000
loops: Animation.Infinite
running: pluginList.isLoading
alwaysRunToEnd: true
id: errorIcon
anchors.fill: parent
status: UM.StatusIcon.Status.ERROR
visible: false
}
UM.RecolorImage
{
id: loadMoreIcon
anchors.fill: parent
source: UM.Theme.getIcon("ArrowDown")
color: UM.Theme.getColor("secondary_button_text")
RotationAnimator
{
target: loadMoreIcon
from: 0
to: 360
duration: 1000
loops: Animation.Infinite
running: pluginList.isLoading
alwaysRunToEnd: true
}
}
}
Label