Skip to content

Commit

Permalink
some improvement suggested by @rodlie
Browse files Browse the repository at this point in the history
  • Loading branch information
pgilfernandez committed Nov 11, 2024
1 parent c723a2c commit 63c8ddd
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/ui/dialogs/scenesettingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>::of(&QComboBox::currentIndexChanged),this, [this]() { updateDuration(); });
connect(mTypeTime, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &SceneSettingsDialog::updateDuration);

validate();

Expand Down Expand Up @@ -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);
}
}

0 comments on commit 63c8ddd

Please sign in to comment.