@@ -372,17 +372,24 @@ FocusScope
372372 moduleStore .downloadInProgress = true
373373 moduleStore .downloadTotal = request .totalBytes
374374 moduleStore .downloadProgress = Qt .binding (function () { return request .receivedBytes ; })
375+ moduleStore .currentDownloadRequest = request
375376 request .accept ()
376377 }
377378 else
378379 request .cancel ()
379380 }
380381
381382 onDownloadFinished : function (request ) {
383+ moduleStore .downloadInProgress = false
384+ moduleStore .currentDownloadRequest = null
385+ if (request .state !== WebEngineDownloadRequest .DownloadCompleted ) {
386+ console .log (" Download interrupted:" , request .interruptReasonString )
387+ return
388+ }
382389 console .log (" Download finished:" , request .downloadFileName )
383390 let path = request .downloadDirectory + ' /' + request .downloadFileName
391+ moduleLibrary .startInstalling ()
384392 dynamicModules .installJASPModule (path)
385- moduleStore .downloadInProgress = false
386393 }
387394 }
388395
@@ -401,6 +408,7 @@ FocusScope
401408 property bool installInProgress: false ;
402409 property int downloadProgress;
403410 property int downloadTotal;
411+ property var currentDownloadRequest: null ;
404412
405413 webChannel .registeredObjects : [ moduleStoreWebChannel ]
406414
@@ -441,6 +449,89 @@ FocusScope
441449
442450 focus: true
443451
452+ // Progress bar overlay for download and installation
453+ Rectangle
454+ {
455+ id: progressOverlay
456+ anchors .fill : parent
457+ color: jaspTheme .grayDarker
458+ visible: moduleStore .downloadInProgress || moduleLibrary .isInstalling
459+ z: 10
460+
461+ Column
462+ {
463+ anchors .centerIn : parent
464+ spacing: 10 * preferencesModel .uiScale
465+ width: 300 * preferencesModel .uiScale
466+
467+ Text
468+ {
469+ id: progressText
470+ text: moduleStore .downloadInProgress ? qsTr (" Downloading module..." ) : qsTr (" Installing module..." )
471+ color: " white"
472+ font .pixelSize : 16 * preferencesModel .uiScale
473+ anchors .horizontalCenter : parent .horizontalCenter
474+ }
475+
476+ // TODO show progress of installation
477+ Rectangle
478+ {
479+ id: progressBarBackground
480+ width: parent .width
481+ height: 30 * preferencesModel .uiScale
482+ color: jaspTheme .grayDarker
483+ border .color : jaspTheme .uiBorder
484+ border .width : 1
485+ radius: 3
486+ visible: moduleStore .downloadInProgress
487+
488+ Rectangle
489+ {
490+ id: progressBarFill
491+ width: moduleStore .downloadTotal > 0 ? (parent .width * moduleStore .downloadProgress / moduleStore .downloadTotal ) : 0
492+ height: parent .height
493+ color: jaspTheme .blue
494+ radius: parent .radius
495+
496+ Behavior on width
497+ {
498+ enabled: preferencesModel .animationsOn
499+ PropertyAnimation { duration: 100 }
500+ }
501+ }
502+
503+ Text
504+ {
505+ anchors .centerIn : parent
506+ text: moduleStore .downloadTotal > 0 ? Math .round ((moduleStore .downloadProgress / moduleStore .downloadTotal ) * 100 ) + " %" : " 0%"
507+ color: " white"
508+ font .pixelSize : 12 * preferencesModel .uiScale
509+ }
510+ }
511+
512+ RoundedButton
513+ {
514+ id: cancelButton
515+ text: qsTr (" Cancel" )
516+ width: 120 * preferencesModel .uiScale
517+ height: 30 * preferencesModel .uiScale
518+ anchors .horizontalCenter : parent .horizontalCenter
519+ // TODO also allow to cancel installation
520+ visible: moduleStore .downloadInProgress
521+
522+ onClicked:
523+ {
524+ if (moduleStore .currentDownloadRequest !== null ) {
525+ moduleStore .currentDownloadRequest .cancel ()
526+ }
527+ moduleStore .downloadInProgress = false
528+ moduleStore .currentDownloadRequest = null
529+ }
530+ toolTip: qsTr (" Cancel download" )
531+ }
532+ }
533+ }
534+
444535 Item
445536 {
446537 id: dropShadow
0 commit comments