aboutsummaryrefslogtreecommitdiff
path: root/src/drone_controller.cc
diff options
context:
space:
mode:
authorccolin2020-12-22 13:30:32 +0100
committerccolin2020-12-22 13:30:32 +0100
commite7065796753dd6bf37f166a3da4dcf37d2893bb6 (patch)
treed2195205b2dd44f10398c91acdbe6716f235c0bf /src/drone_controller.cc
parent7fbe0814d52ba861a02b0560d4e6872845ef241e (diff)
synchronize playing status to play/pause button
Diffstat (limited to 'src/drone_controller.cc')
-rw-r--r--src/drone_controller.cc25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/drone_controller.cc b/src/drone_controller.cc
index 46acc7e..2f1364e 100644
--- a/src/drone_controller.cc
+++ b/src/drone_controller.cc
@@ -62,36 +62,47 @@ int DroneController::getDuration() const {
void DroneController::step() {
- qDebug() << "frame " << frame << "/" << duration
- << " (" << (double) frame / duration * 100 << "%)";
+ qDebug("frame %d (%d%%)", frame, (int) ((double) frame / duration * 100));
emit frameChanged(frame);
- frame++;
+ if (frame == duration) {
+ pause();
+ } else {
+ frame++;
+ }
}
void DroneController::play() {
+ if (!paused) return;
paused = false;
timer.start(1000. / framerate);
qDebug() << "playing";
+ emit playing();
}
void DroneController::pause() {
+ if (paused) return;
paused = true;
timer.stop();
qDebug() << "pausing";
+ emit pausing();
}
void DroneController::suspend() {
- bool old_paused = paused;
- pause();
- paused = old_paused;
+ if (!paused) {
+ pause();
+ paused = false;
+ }
}
void DroneController::resume() {
- if (!paused) play();
+ if (!paused) {
+ paused = true;
+ play();
+ }
}