Exemplo n.º 1
0
int QSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractSlider::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 2)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< TickPosition*>(_v) = tickPosition(); break;
        case 1: *reinterpret_cast< int*>(_v) = tickInterval(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setTickPosition(*reinterpret_cast< TickPosition*>(_v)); break;
        case 1: setTickInterval(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
/*!
    Initialises slider according to SliderParams data
*/
void CxuiSettingSlider::init(CxUiSettings::SliderParams *data)
{
    CX_DEBUG_ENTER_FUNCTION();

    // initialise engine side settings
    if (mEngine) {
        mSettings = &mEngine->settings();
        CX_ASSERT_ALWAYS(mSettings);
    }

    // initialise data
    if (data) {

        // scale value is needed because slider doesn't show all ticks and
        // labels correctly if step is something else than 1
        int step = 1;
        mSliderScaleValue = 1;
        if (data->mMinorStep != 0) {
            mSliderScaleValue = step / data->mMinorStep;
        }

        // scale min and max values as step has been set to 1
        int minvalue = data->mRange.first * mSliderScaleValue;
        int maxvalue = data->mRange.second * mSliderScaleValue;
        CX_DEBUG(("Setting slider range [%d..%d]", minvalue, maxvalue));
        setRange(minvalue,maxvalue);
        setSingleStep(step);
         
        setSnappingMode(HbSlider::MinorTickSnapping);

        setMajorTickLabels(data->mSettingStrings);
        setMajorTickInterval(mSliderScaleValue * data->mMajorStep);
        setMinorTickInterval(mSliderScaleValue * data->mMinorStep);
        setTickPosition(Hb::SliderTicksAbove);

        setSettingId(data->mSettingId);

    }
    CX_DEBUG_EXIT_FUNCTION();
}
Exemplo n.º 3
0
void KexiSlider::init(Qt::Orientation orientation)
{
    d->layout=new QBoxLayout(QBoxLayout::LeftToRight, this);
    d->layout->setSpacing(2);
    d->layout->setMargin(0);
    d->slider = new Slider(this);
    d->spinBox = new QSpinBox(this);
    d->spinBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    d->layout->addWidget(d->spinBox,0, Qt::AlignVCenter);
    d->layout->addWidget(d->slider,0, Qt::AlignVCenter);

    connect(d->slider, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));
    connect(d->slider, SIGNAL(sliderPressed()), this, SIGNAL(sliderPressed()));
    connect(d->slider, SIGNAL(sliderReleased()), this, SIGNAL(sliderReleased()));
    connect(d->slider, SIGNAL(valueChanged(int)), d->spinBox, SLOT(setValue(int)));
    connect(d->spinBox, SIGNAL(valueChanged(int)), d->slider, SLOT(setValue(int)));

    setMaximum(100);
    setOrientation(orientation);
    setTickPosition(QSlider::TicksAbove);
}