[app] Show progress indicator when copying the book

This commit is contained in:
Slava Monich 2015-12-03 01:00:45 +02:00
parent 272a45279c
commit 84b9b77523
3 changed files with 25 additions and 5 deletions

View file

@ -46,6 +46,7 @@ Item {
property alias book: cover.book property alias book: cover.book
property alias synchronous: cover.synchronous property alias synchronous: cover.synchronous
property alias remorseTimeout: deleteAnimation.duration property alias remorseTimeout: deleteAnimation.duration
property alias copyProgress: progressIndicator.value
property real margins: Theme.paddingMedium property real margins: Theme.paddingMedium
property real deleteAllOpacity: 1 property real deleteAllOpacity: 1
property bool editMode property bool editMode
@ -62,8 +63,9 @@ Item {
readonly property bool scaling: scaleUpAnimation.running || scaleDownAnimation.running || deleteAnimation.running readonly property bool scaling: scaleUpAnimation.running || scaleDownAnimation.running || deleteAnimation.running
readonly property bool moving: moveAnimationX.running || moveAnimationY.running readonly property bool moving: moveAnimationX.running || moveAnimationY.running
readonly property bool animating: scaling || moving readonly property bool animating: scaling || moving
readonly property bool copying: copyingIn || copyingOut
property bool _deleting: deleting && !deletingAll readonly property bool _deleting: deleting && !deletingAll
readonly property real _borderRadius: Theme.paddingSmall readonly property real _borderRadius: Theme.paddingSmall
readonly property color _borderColor: Theme.primaryColor readonly property color _borderColor: Theme.primaryColor
readonly property real _borderWidth: 2 readonly property real _borderWidth: 2
@ -134,11 +136,14 @@ Item {
onClicked: root.deleteRequested() onClicked: root.deleteRequested()
} }
BusyIndicator { ProgressCircle {
id: busyIndicator id: progressIndicator
width: parent.width/2
height: width
anchors.centerIn: parent anchors.centerIn: parent
size: BusyIndicatorSize.Medium opacity: (copying && !longCopyTimer.running && value > 0 && value < 1) ? 1 : 0
running: copyingIn || copyingOut visible: opacity > 0
Behavior on opacity { FadeAnimation {} }
} }
function withinDeleteButton(x, y) { function withinDeleteButton(x, y) {
@ -181,6 +186,19 @@ Item {
} }
} }
onCopyingChanged: {
if (copying) {
longCopyTimer.restart()
} else {
longCopyTimer.stop()
}
}
Timer {
id: longCopyTimer
interval: 500
}
NumberAnimation { NumberAnimation {
id: scaleUpAnimation id: scaleUpAnimation
target: root target: root

View file

@ -212,6 +212,7 @@ Item {
name: model.name name: model.name
copyingIn: model.copyingIn copyingIn: model.copyingIn
copyingOut: model.copyingOut copyingOut: model.copyingOut
copyProgress: model.copyProgress
remorseTimeout: _remorseTimeout remorseTimeout: _remorseTimeout
onScalingChanged: updateLastPressedItemScalingIndex() onScalingChanged: updateLastPressedItemScalingIndex()
onPressedChanged: updateLastPressedItemScalingIndex() onPressedChanged: updateLastPressedItemScalingIndex()

View file

@ -614,6 +614,7 @@ bool BooksBook::copyTo(QDir aDestDir, CopyOperation* aOperation)
} }
} }
} }
aOperation->copyProgressChanged(PROGRESS_PRECISION);
delete [] buf; delete [] buf;
dest.close(); dest.close();
if (copied == total) { if (copied == total) {