New upstream version 0.16.2+dfsg1
This commit is contained in:
parent
67704ac59c
commit
6efda2859e
377 changed files with 7938 additions and 696 deletions
35
UI/double-slider.cpp
Normal file
35
UI/double-slider.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include "double-slider.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
DoubleSlider::DoubleSlider(QWidget *parent) : QSlider(parent)
|
||||
{
|
||||
connect(this, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(intValChanged(int)));
|
||||
}
|
||||
|
||||
void DoubleSlider::setDoubleConstraints(double newMin, double newMax,
|
||||
double newStep, double val)
|
||||
{
|
||||
minVal = newMin;
|
||||
maxVal = newMax;
|
||||
minStep = newStep;
|
||||
|
||||
double total = maxVal - minVal;
|
||||
int intMax = int(total / minStep);
|
||||
|
||||
setMinimum(0);
|
||||
setMaximum(intMax);
|
||||
setSingleStep(1);
|
||||
setDoubleVal(val);
|
||||
}
|
||||
|
||||
void DoubleSlider::intValChanged(int val)
|
||||
{
|
||||
emit doubleValChanged((minVal/minStep + val) * minStep);
|
||||
}
|
||||
|
||||
void DoubleSlider::setDoubleVal(double val)
|
||||
{
|
||||
setValue(lround((val - minVal) / minStep));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue