void DynamicObjectModel::setSliderEditor(Node& node, float min, float max, float step)
{
	auto value = node.m_getter().toFloat();
	node.onCreateEditor = [&node, value, min, max, step](QWidget* parent, const QStyleOptionViewItem&) -> QWidget* {
		QWidget* widget = new QWidget(parent);
		QHBoxLayout* layout = new QHBoxLayout(widget);
		layout->setContentsMargins(0, 0, 0, 0);
		auto slider = new QSlider(Qt::Orientation::Horizontal, widget);
		slider->setRange(min * 100, max * 100);
		slider->setSingleStep(step * 100);
		slider->setPageStep(step * 100);
		slider->setValue(value * 100);
		slider->setTracking(true);
		auto input = new QDoubleSpinBox(widget);
		input->setRange(min, max);
		input->setValue(value);
		input->setDecimals(2);
		input->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
		connect(slider, &QSlider::valueChanged, [&node, input](int value){
			node.m_setter(value * 0.01f);
			input->setValue(value * 0.01f);
		});
		connect(input, (void (QDoubleSpinBox::*)(double))&QDoubleSpinBox::valueChanged, [slider, node](double value){
			node.m_setter(value);
			slider->setValue((int)(value * 100));
		});
		layout->addWidget(input);
		layout->addWidget(slider);
		return widget;
	};
}
SPSlider::SPSlider(QWidget *parent) :
    QSlider(parent)
{
    //关闭分段移动
    setSingleStep(0);
    setPageStep(0);
}
void Slider::reloadSlider()
{
    slider->hide();
    if (orientation == 0) {
      slider->setOrientation(Qt::Horizontal);
      slider->setGeometry(x()+10, height()/2-10, width()-20, 20);
    }
      else if (orientation == 1) {
             slider->setOrientation(Qt::Vertical);
             slider->setGeometry(width()/2-10, 10, 20, height()-20);
           }
    slider->setMinValue(-32768);
    slider->show();

    setTickmarks (tickmarks);
    setTickInterval (tickInterval);
    setTracking (tracking);
    setPageStep(pageStep);
    setMainColor(mainColor);
    setTickmarksColor(tickmarksColor);

    setMinValue(minValue);
    setMaxValue(maxValue);
    if (direction == 0) slider->setValue((int)(-32768 + (value-minValue)/lineStep));
      else if (direction == 1) slider->setValue((int)(-32768 + (maxValue-value)/lineStep));

    setNewMask();
}
Beispiel #4
0
VolumeSlider::VolumeSlider(QWidget *p)
    : QSlider(p)
    , lineWidth(0)
    , shown(false)
    , down(false)
    , fadingStop(false)
    , muteAction(0)
    , menu(0)
{
    widthStep=Utils::touchFriendly() ? 5 : 4;
    setRange(0, 100);
    setPageStep(Settings::self()->volumeStep());
    lineWidth=Utils::scaleForDpi(1);

    int w=lineWidth*widthStep*19;
    int h=lineWidth*constHeightStep*10;
    setFixedHeight(h+1);
    setFixedWidth(w);
    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    setOrientation(Qt::Horizontal);
    setFocusPolicy(Qt::NoFocus);
    setStyle(new VolumeSliderProxyStyle());
    setStyleSheet(QString("QSlider::groove:horizontal {border: 0px;} "
                          "QSlider::sub-page:horizontal {border: 0px;} "
                          "QSlider::handle:horizontal {width: 0px; height:0px; margin:0;}"));
    textCol=clampColor(palette().color(QPalette::Active, QPalette::Text));
    generatePixmaps();
}
Slider::Slider(int minval, int maxval, int pageStep, Qt::Orientation o, QWidget* parent)
    : QSlider(o, parent),
      mReadOnly(false)
{ 
    setRange(minval, maxval);
    setPageStep(pageStep);
}
Beispiel #6
0
void ScrollBar::moveSlider(double min, double max)
{
    const int sliderTicks = qRound((max - min) / 
        (d_maxBase - d_minBase) * d_baseTicks);

    // setRange initiates a valueChanged of the scrollbars
    // in some situations. So we block
    // and unblock the signals.

    blockSignals(true);

    setRange(sliderTicks / 2, d_baseTicks - sliderTicks / 2);
    int steps = sliderTicks / 200;
    if ( steps <= 0 )
        steps = 1;

    setSingleStep(steps);
    setPageStep(sliderTicks);

    int tick = mapToTick(min + (max - min) / 2);
    if ( isInverted() )
        tick = d_baseTicks - tick;

    setSliderPosition(tick);
    blockSignals(false);
}
Beispiel #7
0
MidiPanKnob::MidiPanKnob(QWidget* parent)
   : Knob(parent)
      {
      setCenter(true);
      setRange(-64.0f, 63.0f);
      setLineStep(1.0f);
      setPageStep(10.0f);
      }
Beispiel #8
0
ConfigSlider::ConfigSlider(const QString &section, const QString &item, const QString &widgetCaption, const QString &toolTip,
		int minValue, int maxValue, int pageStep, ConfigGroupBox *parentConfigGroupBox, ConfigurationWindowDataManager *dataManager)
	: QSlider(Qt::Horizontal, parentConfigGroupBox->widget()),
		ConfigWidgetValue(section, item, widgetCaption, toolTip, parentConfigGroupBox, dataManager), label(0)
{
	setMinimum(minValue);
	setMaximum(maxValue);
	setPageStep(pageStep);
}
Beispiel #9
0
VolSlider::VolSlider(QWidget* parent)
   : Slider(parent)
      {
      setLog(true);
      setRange(-60.0f, 10.0f);
      setScaleWidth(7);
      setLineStep(.8f);
      setPageStep(3.0f);
      }
Beispiel #10
0
void RichHScrollBar::changePageStep(int p)
{
    p = qMax(p, MinVisible);
    p = qMin(p, maximum() - value() + pageStep());
    if(p != pageStep())
    {
        setMaximum(maximum() + pageStep() - p);
        setPageStep(p);
    }
}
Beispiel #11
0
KRuler::KRuler(QWidget *parent)
    : QAbstractSlider(parent)
    , d(new KRulerPrivate)
{
    setRange(INIT_MIN_VALUE, INIT_MAX_VALUE);
    setPageStep(10);
    setValue(INIT_VALUE);
    initWidget(Qt::Horizontal);
    setFixedHeight(FIX_WIDTH);
}
Beispiel #12
0
Drawbar::Drawbar(QWidget* parent)
   : Slider(parent)
      {
      _sliderColor = Qt::darkGray;
      setOrientation(Qt::Vertical);
      setInvertedAppearance(true);
      setRange(0.0, 8.0);
      setLineStep(1.0);
      setPageStep(1.0);
      setInteger(true);
      }
Beispiel #13
0
VolumeSlider::VolumeSlider(QWidget *parent)
    : QSlider(parent)
{
    setOrientation(Qt::Horizontal);

    connect(this, SIGNAL(valueChanged(int)), this, SLOT(volume(int)));

    const int step = qMax(1.0,(qreal)100/50);
    setSingleStep(step);
    setPageStep(step);
}
Beispiel #14
0
QvisOpacitySlider::QvisOpacitySlider(int minValue, int maxValue, int step,
    int val, QWidget *parent, const void *data) :
    QAbstractSlider(parent)
{
    init();
    setMinimum(minValue);
    setMaximum(maxValue);
    setPageStep(step);
    setValue(val);

    userData = data;
}
Beispiel #15
0
KRuler::KRuler(Qt::Orientation orient, int widgetWidth,
               QWidget *parent, Qt::WindowFlags f)
    : QAbstractSlider(parent)
    , d(new KRulerPrivate)
{
    setRange(INIT_MIN_VALUE, INIT_MAX_VALUE);
    setPageStep(10);
    setValue(INIT_VALUE);
    setWindowFlags(f);
    initWidget(orient);
    if (orient == Qt::Horizontal) {
        setFixedHeight(widgetWidth);
    } else {
        setFixedWidth(widgetWidth);
    }
}
Beispiel #16
0
SBI_ZoomWidget::SBI_ZoomWidget(BrowserWindow* parent)
    : QSlider(parent)
    , m_window(parent)
{
    setOrientation(Qt::Horizontal);
    setFixedWidth(100);
    setMaximumHeight(20);

    setPageStep(2);
    setSingleStep(1);
    setRange(0, WebView::zoomLevels().count() - 1);

    connect(this, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int)));
    connect(m_window->tabWidget(), SIGNAL(currentChanged(int)), this, SLOT(currentViewChanged()));

    currentViewChanged();
}
Beispiel #17
0
void ScrollBar::moveSlider(double min, double max)
{
  if (mLogScale)
    {
      min = log(min);
      max = log(max);
    }

  int sliderTicks;
  sliderTicks = qRound((max - min) /
                       (d_maxBase - d_minBase) * d_baseTicks);

  // setRange initiates a valueChanged of the scrollbars
  // in some situations. So we block
  // and unblock the signals.

  blockSignals(true);

  setRange(sliderTicks / 2, d_baseTicks - sliderTicks / 2);
  int steps = sliderTicks / 200;

  if (steps <= 0)
    steps = 1;

#if QT_VERSION < 0x040000
  setSteps(steps, sliderTicks);
#else
  setSingleStep(steps);
  setPageStep(sliderTicks);
#endif

  int tick;
  tick = mapToTick(min + (max - min) / 2);

  if (isInverted())
    tick = d_baseTicks - tick;

#if QT_VERSION < 0x040000
  directSetValue(tick);
  rangeChange();
#else
  setSliderPosition(tick);
#endif
  blockSignals(false);
}
Slider::Slider( QWidget *parent, const char *name,Qt::WFlags flag)
       :VtlWidget( parent, name, flag)
{
    resize(100,40);

    slider = new QSlider(this);
    slider->setOrientation(Qt::Horizontal);
    slider->setGeometry(10,10,80,20);
    slider->setMinValue(-32768);
    slider->show();

    orientation = Qt::Horizontal;
    direction = LeftToRight;
    minValue = 0;
    maxValue = 100;
    value = 0;
    tracking = Disabled;
    tickmarks = 0;
    tickInterval = 10;
    lineStep = 10;
    pageStep = 10;
    mainColor = Qt::white;
    tickmarksColor = Qt::black;
    precision = 1;

    setTickmarks (tickmarks);
    setTickInterval (tickInterval);
    setTracking (tracking);
    setDirection(direction);
    setLineStep(lineStep);
    setPageStep(pageStep);
    setMainColor(mainColor);
    setTickmarksColor(tickmarksColor);

    setNewMask();

    MDIRef = NULL;

    connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
    connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(setNewMask()));
}
Beispiel #19
0
TimeSlider::TimeSlider(QWidget* parent) : QSlider(parent)
{
    setLength(100);
    setOrientation(Qt::Horizontal);
    setPageStep(0); // 0に設定するとwheelイベントはそのまま親へ伝搬される

    connect(this, SIGNAL(sliderPressed()),  this, SLOT(timeSliderPressed()));
    connect(this, SIGNAL(sliderReleased()), this, SLOT(timeSliderReleased()));
    connect(this, SIGNAL(sliderMoved(int)), this, SLOT(timeSliderMoved(int)));

    _movedPos = -1;
    _unableSetPosition = false;

    connect(&_timerRequestSeek, SIGNAL(timeout()),
            this,               SLOT(timerRequestSeekTimeout()));

    _timerUnableSetPosition.setSingleShot(true);
    connect(&_timerUnableSetPosition, SIGNAL(timeout()),
            this,                     SLOT(timerUnableSetPositionTimeout()));

    _reverseWheelSeek = false;
}
Beispiel #20
0
bool ConfigSlider::fromDomElement(QDomElement domElement)
{
	QString minValue = domElement.attribute("min-value");
	QString maxValue = domElement.attribute("max-value");
	QString pageStep = domElement.attribute("page-step");

	bool ok;

	setMinimum(minValue.toInt(&ok));
	if (!ok)
		return false;

	setMaximum(maxValue.toInt(&ok));
	if (!ok)
		return false;

	setPageStep(pageStep.toInt(&ok));
	if (!ok)
		return false;

	return ConfigWidgetValue::fromDomElement(domElement);
}
void VBoxGuestRAMSlider::init()
{
    ulong fullSize = vboxGlobal().host().GetMemorySize();
    CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties();
    mMinRAM = sys.GetMinGuestRAM();
    mMaxRAM = RT_MIN (RT_ALIGN (fullSize, _1G / _1M), sys.GetMaxGuestRAM());

    /* Come up with some nice round percent boundaries relative to
     * the system memory. A max of 75% on a 256GB config is ridiculous,
     * even on an 8GB rig reserving 2GB for the OS is way to conservative.
     * The max numbers can be estimated using the following program:
     *
     *      double calcMaxPct(uint64_t cbRam)
     *      {
     *          double cbRamOverhead = cbRam * 0.0390625; // 160 bytes per page.
     *          double cbRamForTheOS = RT_MAX(RT_MIN(_512M, cbRam * 0.25), _64M);
     *          double OSPct  = (cbRamOverhead + cbRamForTheOS) * 100.0 / cbRam;
     *          double MaxPct = 100 - OSPct;
     *          return MaxPct;
     *      }
     *
     *      int main()
     *      {
     *          uint64_t cbRam = _1G;
     *          for (; !(cbRam >> 33); cbRam += _1G)
     *              printf("%8lluGB %.1f%% %8lluKB\n", cbRam >> 30, calcMaxPct(cbRam),
     *                     (uint64_t)(cbRam * calcMaxPct(cbRam) / 100.0) >> 20);
     *          for (; !(cbRam >> 51); cbRam <<= 1)
     *              printf("%8lluGB %.1f%% %8lluKB\n", cbRam >> 30, calcMaxPct(cbRam),
     *                     (uint64_t)(cbRam * calcMaxPct(cbRam) / 100.0) >> 20);
     *          return 0;
     *      }
     *
     * Note. We might wanna put these calculations somewhere global later. */

    /* System RAM amount test */
    mMaxRAMAlw  = (uint)(0.75 * fullSize);
    mMaxRAMOpt  = (uint)(0.50 * fullSize);
    if (fullSize < 3072)
        /* done */;
    else if (fullSize < 4096)   /* 3GB */
        mMaxRAMAlw = (uint)(0.80 * fullSize);
    else if (fullSize < 6144)   /* 4-5GB */
    {
        mMaxRAMAlw = (uint)(0.84 * fullSize);
        mMaxRAMOpt = (uint)(0.60 * fullSize);
    }
    else if (fullSize < 8192)   /* 6-7GB */
    {
        mMaxRAMAlw = (uint)(0.88 * fullSize);
        mMaxRAMOpt = (uint)(0.65 * fullSize);
    }
    else if (fullSize < 16384)  /* 8-15GB */
    {
        mMaxRAMAlw = (uint)(0.90 * fullSize);
        mMaxRAMOpt = (uint)(0.70 * fullSize);
    }
    else if (fullSize < 32768)  /* 16-31GB */
    {
        mMaxRAMAlw = (uint)(0.93 * fullSize);
        mMaxRAMOpt = (uint)(0.75 * fullSize);
    }
    else if (fullSize < 65536)  /* 32-63GB */
    {
        mMaxRAMAlw = (uint)(0.94 * fullSize);
        mMaxRAMOpt = (uint)(0.80 * fullSize);
    }
    else if (fullSize < 131072) /* 64-127GB */
    {
        mMaxRAMAlw = (uint)(0.95 * fullSize);
        mMaxRAMOpt = (uint)(0.85 * fullSize);
    }
    else                        /* 128GB- */
    {
        mMaxRAMAlw = (uint)(0.96 * fullSize);
        mMaxRAMOpt = (uint)(0.90 * fullSize);
    }
    /* Now check the calculated maximums are out of the range for the guest
     * RAM. If so change it accordingly. */
    mMaxRAMAlw  = RT_MIN (mMaxRAMAlw, mMaxRAM);
    mMaxRAMOpt  = RT_MIN (mMaxRAMOpt, mMaxRAM);

    setPageStep (calcPageStep (mMaxRAM));
    setSingleStep (pageStep() / 4);
    setTickInterval (pageStep());
    /* Setup the scale so that ticks are at page step boundaries */
    setMinimum ((mMinRAM / pageStep()) * pageStep());
    setMaximum (mMaxRAM);
    setSnappingEnabled (true);
    setOptimalHint (mMinRAM, mMaxRAMOpt);
    setWarningHint (mMaxRAMOpt, mMaxRAMAlw);
    setErrorHint (mMaxRAMAlw, mMaxRAM);
}
int QAbstractSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: sliderPressed(); break;
        case 2: sliderMoved((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: sliderReleased(); break;
        case 4: rangeChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 5: actionTriggered((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 6: setValue((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 7: setOrientation((*reinterpret_cast< Qt::Orientation(*)>(_a[1]))); break;
        }
        _id -= 8;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = minimum(); break;
        case 1: *reinterpret_cast< int*>(_v) = maximum(); break;
        case 2: *reinterpret_cast< int*>(_v) = singleStep(); break;
        case 3: *reinterpret_cast< int*>(_v) = pageStep(); break;
        case 4: *reinterpret_cast< int*>(_v) = value(); break;
        case 5: *reinterpret_cast< int*>(_v) = sliderPosition(); break;
        case 6: *reinterpret_cast< bool*>(_v) = hasTracking(); break;
        case 7: *reinterpret_cast< Qt::Orientation*>(_v) = orientation(); break;
        case 8: *reinterpret_cast< bool*>(_v) = invertedAppearance(); break;
        case 9: *reinterpret_cast< bool*>(_v) = invertedControls(); break;
        case 10: *reinterpret_cast< bool*>(_v) = isSliderDown(); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setMinimum(*reinterpret_cast< int*>(_v)); break;
        case 1: setMaximum(*reinterpret_cast< int*>(_v)); break;
        case 2: setSingleStep(*reinterpret_cast< int*>(_v)); break;
        case 3: setPageStep(*reinterpret_cast< int*>(_v)); break;
        case 4: setValue(*reinterpret_cast< int*>(_v)); break;
        case 5: setSliderPosition(*reinterpret_cast< int*>(_v)); break;
        case 6: setTracking(*reinterpret_cast< bool*>(_v)); break;
        case 7: setOrientation(*reinterpret_cast< Qt::Orientation*>(_v)); break;
        case 8: setInvertedAppearance(*reinterpret_cast< bool*>(_v)); break;
        case 9: setInvertedControls(*reinterpret_cast< bool*>(_v)); break;
        case 10: setSliderDown(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 11;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
void TimeRangeScrollBar::setPrimaryTickSecs(int primaryTickSecs)
{
    setPageStep(primaryTickSecs);
    setSingleStep(primaryTickSecs);
}
bool Slider::onPropertyChanged(const QString& name, const QVariant& val)
{
    
    if ( VtlWidget::onPropertyChanged(name, val) )
      return TRUE;

    VtlActionHandler* actHandler = ((VtlWindow*)this->parentWidget())->actionHandler();  

    if (name == (QString) "PROCNAME") {
      processName = val.toString();
    }  
    else if (name == (QString) "ORIENTATION") {
           actHandler->setProperty(this, name, QVariant(orientation), val);
           setOrientation(val.toInt());
    }
    else if (name == (QString) "MINVALUE") {
           actHandler->setProperty(this, name, QVariant(minValue), val);
           setMinValue(val.toDouble());
    }
    else if (name == (QString) "MAXVALUE") {
           actHandler->setProperty(this, name, QVariant(maxValue), val);
           setMaxValue(val.toDouble());
    }
    else if (name == (QString) "DIRECTION") {
           actHandler->setProperty(this, name, QVariant(direction), val);
           setDirection(val.toInt());
    }
    else if (name == (QString )"SOURCER") {
      if ( val.toString() != "None" ) {
        _sourcer = SourcerConnector<VtlWidget>::change (this, _sourcer, val.toString() );
      }
      else 
        _sourcer = 0;
    }
    else if (name == (QString) "TRACKING") {
           actHandler->setProperty(this, name, QVariant(tracking), val);
           setTracking(val.toInt());
    }
    else if (name == (QString) "TICKMARKS") {
           actHandler->setProperty(this, name, QVariant(tickmarks), val);
           setTickmarks(val.toInt());
    }
    else if (name == (QString) "TICKINTERVAL") {
           actHandler->setProperty(this, name, QVariant(tickInterval), val);
           setTickInterval(val.toInt());
    }
    else if (name == (QString) "LINESTEP") {
           actHandler->setProperty(this, name, QVariant(lineStep), val);
           setLineStep(val.toDouble());
    }
    else if (name == (QString) "PAGESTEP") {
           actHandler->setProperty(this, name, QVariant(pageStep), val);
           setPageStep(val.toInt());
    }
    else if (name == (QString) "MAIN_COLOR") {
           actHandler->setProperty(this, name, QVariant(mainColor), val);
           setMainColor(val.toColor());
    }
    else if (name == (QString) "TICKMARKS_COLOR") {
           actHandler->setProperty(this, name, QVariant(tickmarksColor), val);
           setTickmarksColor(val.toColor());
    }
    else if (name == (QString) "PRECISION") {
           actHandler->setProperty(this, name, QVariant(precision), val);
           setPrecision(val.toInt());
    }

    repaint();
    return TRUE;
}
void DoubleAdaptedSlider::setAdaptedPageStep( double step )
{
    setPageStep( static_cast< int >( step * factor_ ) );
}
bool QDial::qt_property( int id, int f, QVariant* v)
{
    switch ( id - staticMetaObject()->propertyOffset() ) {
    case 0: switch( f ) {
	case 0: setTracking(v->asBool()); break;
	case 1: *v = QVariant( this->tracking(), 0 ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 1: switch( f ) {
	case 0: setWrapping(v->asBool()); break;
	case 1: *v = QVariant( this->wrapping(), 0 ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 2: switch( f ) {
	case 1: *v = QVariant( this->notchSize() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 3: switch( f ) {
	case 0: setNotchTarget(v->asDouble()); break;
	case 1: *v = QVariant( this->notchTarget() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 4: switch( f ) {
	case 0: setNotchesVisible(v->asBool()); break;
	case 1: *v = QVariant( this->notchesVisible(), 0 ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 5: switch( f ) {
	case 0: setMinValue(v->asInt()); break;
	case 1: *v = QVariant( this->minValue() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 6: switch( f ) {
	case 0: setMaxValue(v->asInt()); break;
	case 1: *v = QVariant( this->maxValue() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 7: switch( f ) {
	case 0: setLineStep(v->asInt()); break;
	case 1: *v = QVariant( this->lineStep() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 8: switch( f ) {
	case 0: setPageStep(v->asInt()); break;
	case 1: *v = QVariant( this->pageStep() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 9: switch( f ) {
	case 0: setValue(v->asInt()); break;
	case 1: *v = QVariant( this->value() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    default:
	return QWidget::qt_property( id, f, v );
    }
    return TRUE;
}
Beispiel #27
0
SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent, bool _static )
          : QSlider( q, _parent ), b_classic( _static )
{
    isSliding = false;
    f_buffering = 1.0;
    mHandleOpacity = 1.0;
    chapters = NULL;
    mHandleLength = -1;

    // prepare some static colors
    QPalette p = palette();
    QColor background = p.color( QPalette::Active, QPalette::Background );
    tickpointForeground = p.color( QPalette::Active, QPalette::WindowText );
    tickpointForeground.setHsv( tickpointForeground.hue(),
            ( background.saturation() + tickpointForeground.saturation() ) / 2,
            ( background.value() + tickpointForeground.value() ) / 2 );

    // set the background color and gradient
    QColor backgroundBase( p.window().color() );
    backgroundGradient.setColorAt( 0.0, backgroundBase.darker( 140 ) );
    backgroundGradient.setColorAt( 1.0, backgroundBase );

    // set the foreground color and gradient
    QColor foregroundBase( 50, 156, 255 );
    foregroundGradient.setColorAt( 0.0,  foregroundBase );
    foregroundGradient.setColorAt( 1.0,  foregroundBase.darker( 140 ) );

    // prepare the handle's gradient
    handleGradient.setColorAt( 0.0, p.window().color().lighter( 120 ) );
    handleGradient.setColorAt( 0.9, p.window().color().darker( 120 ) );

    // prepare the handle's shadow gradient
    QColor shadowBase = p.shadow().color();
    if( shadowBase.lightness() > 100 )
        shadowBase = QColor( 60, 60, 60 ); // Palette's shadow is too bright
    shadowDark = shadowBase.darker( 150 );
    shadowLight = shadowBase.lighter( 180 );
    shadowLight.setAlpha( 50 );

    /* Timer used to fire intermediate updatePos() when sliding */
    seekLimitTimer = new QTimer( this );
    seekLimitTimer->setSingleShot( true );

    /* Tooltip bubble */
    mTimeTooltip = new TimeTooltip( this );
    mTimeTooltip->setMouseTracking( true );

    /* Properties */
    setRange( MINIMUM, MAXIMUM );
    setSingleStep( 2 );
    setPageStep( 10 );
    setMouseTracking( true );
    setTracking( true );
    setFocusPolicy( Qt::NoFocus );

    /* Use the new/classic style */
    if( !b_classic )
        setStyle( new SeekStyle );

    /* Init to 0 */
    setPosition( -1.0, 0, 0 );
    secstotimestr( psz_length, 0 );

    animHandle = new QPropertyAnimation( this, "handleOpacity", this );
    animHandle->setDuration( FADEDURATION );
    animHandle->setStartValue( 0.0 );
    animHandle->setEndValue( 1.0 );

    hideHandleTimer = new QTimer( this );
    hideHandleTimer->setSingleShot( true );
    hideHandleTimer->setInterval( FADEOUTDELAY );

    CONNECT( this, sliderMoved( int ), this, startSeekTimer() );
    CONNECT( seekLimitTimer, timeout(), this, updatePos() );
    CONNECT( hideHandleTimer, timeout(), this, hideHandle() );
    mTimeTooltip->installEventFilter( this );
}
Beispiel #28
0
SeekBar::SeekBar(QWidget *parent) : QSlider(parent) {
    setPageStep(0);
    setOrientation(Qt::Horizontal);
    LoadStyleSheet();
}