fix inconsistencies when loading a file if another is already loaded
This commit is contained in:
parent
e87f0b5256
commit
c6ca25b110
@ -126,7 +126,6 @@ DroneController::DroneController(const QJsonObject &json)
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(&timer, &QTimer::timeout, this, &DroneController::step);
|
connect(&timer, &QTimer::timeout, this, &DroneController::step);
|
||||||
pause();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,7 +135,6 @@ int DroneController::getDuration() const {
|
|||||||
|
|
||||||
|
|
||||||
void DroneController::step() {
|
void DroneController::step() {
|
||||||
// qDebug("frame %d (%d%%)", frame, (int) ((double) frame / duration * 100));
|
|
||||||
for (Drone d : drones) {
|
for (Drone d : drones) {
|
||||||
d.setTo(frame);
|
d.setTo(frame);
|
||||||
}
|
}
|
||||||
@ -154,7 +152,6 @@ void DroneController::play() {
|
|||||||
if (!paused) return;
|
if (!paused) return;
|
||||||
paused = false;
|
paused = false;
|
||||||
timer.start(1000. / framerate);
|
timer.start(1000. / framerate);
|
||||||
qDebug() << "playing";
|
|
||||||
emit playing();
|
emit playing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +160,6 @@ void DroneController::pause() {
|
|||||||
if (paused) return;
|
if (paused) return;
|
||||||
paused = true;
|
paused = true;
|
||||||
timer.stop();
|
timer.stop();
|
||||||
qDebug() << "pausing";
|
|
||||||
emit pausing();
|
emit pausing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,16 +53,19 @@ void MainWindow::open(const QString &path) {
|
|||||||
QByteArray data = file.readAll();
|
QByteArray data = file.readAll();
|
||||||
QJsonDocument json_doc = QJsonDocument::fromJson(data);
|
QJsonDocument json_doc = QJsonDocument::fromJson(data);
|
||||||
if (dc) delete dc;
|
if (dc) delete dc;
|
||||||
|
glw.meshes.clear();
|
||||||
dc = new DroneController(json_doc.object());
|
dc = new DroneController(json_doc.object());
|
||||||
playpause_action->setEnabled(true);
|
playpause_action->setEnabled(true);
|
||||||
connect(dc, &DroneController::playing, this, &MainWindow::play);
|
connect(dc, &DroneController::playing, this, &MainWindow::play);
|
||||||
connect(dc, &DroneController::pausing, this, &MainWindow::pause);
|
connect(dc, &DroneController::pausing, this, &MainWindow::pause);
|
||||||
slider->setMinimum(0);
|
slider->setMinimum(0);
|
||||||
slider->setMaximum(dc->getDuration());
|
slider->setMaximum(dc->getDuration());
|
||||||
|
slider->setValue(0);
|
||||||
connect(slider, &QSlider::sliderPressed, dc, &DroneController::suspend);
|
connect(slider, &QSlider::sliderPressed, dc, &DroneController::suspend);
|
||||||
connect(slider, &QSlider::sliderReleased, dc, &DroneController::resume);
|
connect(slider, &QSlider::sliderReleased, dc, &DroneController::resume);
|
||||||
connect(slider, &QSlider::valueChanged, dc, &DroneController::seek);
|
connect(slider, &QSlider::valueChanged, dc, &DroneController::seek);
|
||||||
connect(dc, &DroneController::frameChanged, slider, &QSlider::setValue);
|
connect(dc, &DroneController::frameChanged, slider, &QSlider::setValue);
|
||||||
|
pause();
|
||||||
slider->setEnabled(true);
|
slider->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user