From 8e992590dbf39abdbdc55baf72cafd194aca9839 Mon Sep 17 00:00:00 2001 From: Pablo Gil Date: Tue, 12 Nov 2024 22:22:24 +0100 Subject: [PATCH] more simplification and more robust code --- src/ui/dialogs/scenesettingsdialog.cpp | 21 +++++++-------------- src/ui/dialogs/scenesettingsdialog.h | 2 +- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/ui/dialogs/scenesettingsdialog.cpp b/src/ui/dialogs/scenesettingsdialog.cpp index 2802ce73a..df9519963 100644 --- a/src/ui/dialogs/scenesettingsdialog.cpp +++ b/src/ui/dialogs/scenesettingsdialog.cpp @@ -311,25 +311,18 @@ void SceneSettingsDialog::sNewSceneDialog(Document& document, dialog->show(); } -void SceneSettingsDialog::updateDuration() { - const QString typetime = mTypeTime->currentData().toString(); +void SceneSettingsDialog::updateDuration(int index) +{ const qreal fps = mFPSSpinBox->value(); - int index = mTypeTime->currentIndex(); - - if (mMinFrameSpin->value() >= mMaxFrameSpin->value()) { - return; - } - switch(index) { case 0: // Convert seconds to frames - mMinFrameSpin->setValue(mMinFrameSpin->value() * fps); - mMaxFrameSpin->setValue(mMaxFrameSpin->value() * fps); + mMinFrameSpin->setValue(qRound(mMinFrameSpin->value() * fps)); + mMaxFrameSpin->setValue(qRound(mMaxFrameSpin->value() * fps)); break; case 1: // Convert frames to seconds - mMinFrameSpin->setValue(mMinFrameSpin->value() / fps); - mMaxFrameSpin->setValue(mMaxFrameSpin->value() / fps); + mMinFrameSpin->setValue(qRound(mMinFrameSpin->value() / fps)); + mMaxFrameSpin->setValue(qRound(mMaxFrameSpin->value() / fps)); break; - default: - return; + default:; } } diff --git a/src/ui/dialogs/scenesettingsdialog.h b/src/ui/dialogs/scenesettingsdialog.h index 65af0da0a..6deadcf8c 100644 --- a/src/ui/dialogs/scenesettingsdialog.h +++ b/src/ui/dialogs/scenesettingsdialog.h @@ -75,7 +75,7 @@ class UI_EXPORT SceneSettingsDialog : public QDialog private: bool validate(); - void updateDuration(); + void updateDuration(int index); Canvas * mTargetCanvas = nullptr;