diff options
Diffstat (limited to 'apps/com.pelagicore.downloads')
5 files changed, 49 insertions, 1 deletions
diff --git a/apps/com.pelagicore.downloads/controls/DownloadsToolsColumn.qml b/apps/com.pelagicore.downloads/controls/DownloadsToolsColumn.qml index 95dea832..65ab16c3 100644 --- a/apps/com.pelagicore.downloads/controls/DownloadsToolsColumn.qml +++ b/apps/com.pelagicore.downloads/controls/DownloadsToolsColumn.qml @@ -44,14 +44,52 @@ Item { property string serverUrl signal toolClicked(int index) + signal refresh() + + BusyIndicator { + id: busyIndicator + + running: false + anchors.horizontalCenter: root.horizontalCenter + opacity: 0.0; + visible: opacity > 0.0 + width: Sizes.dp(100); height: width + } ToolsColumn { id: toolsColumn + property bool refreshRequired: false + + interactive: true width: Sizes.dp(264) anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: Sizes.dp(53) onClicked: root.toolClicked(currentIndex) + onContentYChanged: { + if (atYBeginning) { + var d = Math.abs(contentY); + busyIndicator.opacity = d / busyIndicator.height; + if (d > busyIndicator.height) { + if (!busyIndicator.running) { + busyIndicator.running = true; + refreshRequired = true; + } + } else { + busyIndicator.running = false; + // if we drag back - no refresh + if (dragging) + refreshRequired = false; + } + } + } + onMovementEnded: { + busyIndicator.opacity = 0.0; + if (refreshRequired) { + refreshRequired = false; + refresh(); + } + } } } diff --git a/apps/com.pelagicore.downloads/stores/DownloadsStates.qml b/apps/com.pelagicore.downloads/stores/DownloadsStates.qml index 69db4c7c..7c9d96ae 100644 --- a/apps/com.pelagicore.downloads/stores/DownloadsStates.qml +++ b/apps/com.pelagicore.downloads/stores/DownloadsStates.qml @@ -304,6 +304,12 @@ DSM.StateMachine { signal: jsonAppModel.onStatusChanged guard: jsonAppModel.status === "loading" } + + DSM.SignalTransition { + targetState: fetchingCategoriesState + signal: jsonCategoryModel.onStatusChanged + guard: jsonCategoryModel.status === "loading" + } } } } diff --git a/apps/com.pelagicore.downloads/stores/DownloadsStore.qml b/apps/com.pelagicore.downloads/stores/DownloadsStore.qml index 98728495..ee9ab822 100644 --- a/apps/com.pelagicore.downloads/stores/DownloadsStore.qml +++ b/apps/com.pelagicore.downloads/stores/DownloadsStore.qml @@ -298,6 +298,9 @@ Item { ListModel { id: categoryListModel + function refresh() { + jsonCategoryModel.refresh(); + } } JSONModel { diff --git a/apps/com.pelagicore.downloads/stores/JSONModel.qml b/apps/com.pelagicore.downloads/stores/JSONModel.qml index e18cf4ef..76d2beea 100644 --- a/apps/com.pelagicore.downloads/stores/JSONModel.qml +++ b/apps/com.pelagicore.downloads/stores/JSONModel.qml @@ -43,8 +43,8 @@ ListModel { function refresh() { status = "loading" - clear(); JSONBackend.serverCall(url, data, function(data) { + clear(); if (data === 0) { status = "error"; diff --git a/apps/com.pelagicore.downloads/views/DownloadsView.qml b/apps/com.pelagicore.downloads/views/DownloadsView.qml index ca7fa916..212ecf48 100644 --- a/apps/com.pelagicore.downloads/views/DownloadsView.qml +++ b/apps/com.pelagicore.downloads/views/DownloadsView.qml @@ -183,6 +183,7 @@ Item { model: root.store.categoryModel serverUrl: root.store.appServerUrl onToolClicked: root.store.selectCategory(index) + onRefresh: root.store.categoryModel.refresh() } DownloadAppList { |