Use logarithmic scale for speed slider (should allow better speed adjustments)

parent 3fd65c5d
Pipeline #14378 passed with stage
in 15 minutes and 19 seconds
#include "speeddialog.h"
#include "ui_clipspeed_ui.h"
#include <QPushButton>
#include <QDebug>
#include <QtMath>
SpeedDialog::SpeedDialog(QWidget *parent, double speed, double minSpeed, double maxSpeed, bool reversed)
: QDialog(parent)
......@@ -11,11 +13,9 @@ SpeedDialog::SpeedDialog(QWidget *parent, double speed, double minSpeed, double
ui->speedSpin->setDecimals(2);
ui->speedSpin->setMinimum(minSpeed);
ui->speedSpin->setMaximum(maxSpeed);
ui->speedSlider->setMinimum(100 * minSpeed);
ui->speedSlider->setMaximum(qMin(100 * minSpeed + 100000, 100 *maxSpeed));
ui->speedSpin->setValue(speed);
ui->speedSlider->setValue(100 * speed);
ui->speedSlider->setTickInterval((ui->speedSlider->maximum() - ui->speedSlider->minimum()) / 10);
ui->speedSlider->setMinimum(0);
ui->speedSlider->setMaximum(100);
ui->speedSlider->setTickInterval(10);
ui->speedSpin->selectAll();
ui->label_dest->setVisible(false);
ui->kurlrequester->setVisible(false);
......@@ -23,13 +23,18 @@ SpeedDialog::SpeedDialog(QWidget *parent, double speed, double minSpeed, double
if (reversed) {
ui->checkBox->setChecked(true);
}
ui->speedSpin->setValue(speed);
ui->speedSlider->setValue(qLn(speed) * 12);
connect(ui->speedSpin, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [&] (double value) {
ui->speedSlider->setValue(100 * value);
QSignalBlocker bk(ui->speedSlider);
ui->speedSlider->setValue(qLn(value) * 12);
ui->buttonBox->button((QDialogButtonBox::Ok))->setEnabled(!qFuzzyIsNull(value));
});
connect(ui->speedSlider, &QSlider::valueChanged, [&] (int value) {
ui->speedSpin->setValue(value / 100.);
ui->buttonBox->button((QDialogButtonBox::Ok))->setEnabled(value != 0);
double res = qExp(value / 12.);
QSignalBlocker bk(ui->speedSpin);
ui->speedSpin->setValue(res);
ui->buttonBox->button((QDialogButtonBox::Ok))->setEnabled(!qFuzzyIsNull(ui->speedSpin->value()));
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment