From 63c8dddcdf11e0c17163670e58e4b4390baa2185 Mon Sep 17 00:00:00 2001 From: Pablo Gil Date: Mon, 11 Nov 2024 22:59:02 +0100 Subject: [PATCH] some improvement suggested by @rodlie --- src/ui/dialogs/scenesettingsdialog.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ui/dialogs/scenesettingsdialog.cpp b/src/ui/dialogs/scenesettingsdialog.cpp index 9261a70ae..4e8c657b0 100644 --- a/src/ui/dialogs/scenesettingsdialog.cpp +++ b/src/ui/dialogs/scenesettingsdialog.cpp @@ -186,7 +186,8 @@ SceneSettingsDialog::SceneSettingsDialog(const QString &name, connect(mCancelButton, &QPushButton::released, this, &SceneSettingsDialog::reject); connect(this, &QDialog::rejected, this, &QDialog::close); - connect(mTypeTime, QOverload::of(&QComboBox::currentIndexChanged),this, [this]() { updateDuration(); }); + connect(mTypeTime, QOverload::of(&QComboBox::currentIndexChanged), + this, &SceneSettingsDialog::updateDuration); validate(); @@ -314,14 +315,22 @@ void SceneSettingsDialog::updateDuration() { const QString typetime = mTypeTime->currentData().toString(); const qreal fps = mFPSSpinBox->value(); int duration = mMaxFrameSpin->value() - mMinFrameSpin->value(); + int index = mTypeTime->currentIndex(); - if (typetime == "Frames") { - // Convert seconds to frames - duration = qRound(duration * fps); - } else { - // Convert frames to seconds - duration = qRound(duration / fps); + if (mMinFrameSpin->value() >= mMaxFrameSpin->value()) { + return; + } + + switch(index) { + case 0: // Convert seconds to frames + duration = qRound(duration * fps); + break; + case 1: // Convert frames to seconds + duration = qRound(duration / fps); + break; + default: + return; } mMaxFrameSpin->setValue(mMinFrameSpin->value() + duration); -} \ No newline at end of file +}