Ejemplo n.º 1
0
void KSelector::wheelEvent( QWheelEvent *e )
{
    int val = value() + e->delta()/120;
    setSliderDown(true);
    setValue( val );
    setSliderDown(false);
}
Ejemplo n.º 2
0
void ClickAndGoSlider::mousePressEvent(QMouseEvent *e)
{
    if (e->modifiers() == Qt::ControlModifier)
    {
        emit controlClicked();
        return;
    }

    QStyleOptionSlider opt;
    initStyleOption(&opt);
    QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);

    if (e->button() == Qt::LeftButton && // react only to left button press
        sr.contains(e->pos()) == false) // check if the click is not over the slider's handle
    {
        int newVal = 0;
        if (orientation() == Qt::Vertical)
            newVal = minimum() + ((maximum() - minimum()) * (height() - e->y())) / height();
        else
            newVal = minimum() + ((maximum() - minimum()) * e->x()) / width();

        setSliderDown(true);
        if (invertedAppearance() == true)
            setValue( maximum() - newVal );
        else
            setValue(newVal);
        setSliderDown(false);

        e->accept();
    }
    QSlider::mousePressEvent(e);
}
Ejemplo n.º 3
0
void ClickAndGoSlider::keyPressEvent(QKeyEvent *e)
{
    if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)
        setSliderDown(true);
    QSlider::keyPressEvent(e);
    if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)
        setSliderDown(false);
}
Ejemplo n.º 4
0
void ControlSlider::mousePressEvent(QMouseEvent *event)
{
	setSliderDown(true);
	if(handleRect().contains(event->pos()))
	{
		handlePressed = true;
		setSliderDown(true);
		int sliderValue = style()->sliderValueFromPosition(minimum(),maximum(),event->pos().x()-6,width()-12);
		setValue(sliderValue);
	}
}
Ejemplo n.º 5
0
/*!
    \reimp
*/
void QScrollBar::mousePressEvent(QMouseEvent *e)
{
    Q_D(QScrollBar);

    if (d->repeatActionTimer.isActive())
        d->stopRepeatAction();

    bool midButtonAbsPos = style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition,
                                             0, this);
    QStyleOptionSlider opt;
    initStyleOption(&opt);

    if (d->maximum == d->minimum // no range
        || (e->buttons() & (~e->button())) // another button was clicked before
        || !(e->button() == Qt::LeftButton || (midButtonAbsPos && e->button() == Qt::MidButton)))
        return;

    d->pressedControl = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->pos(), this);
    d->pointerOutsidePressedControl = false;

    QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
                                       QStyle::SC_ScrollBarSlider, this);
    QPoint click = e->pos();
    QPoint pressValue = click - sr.center() + sr.topLeft();
    d->pressValue = d->orientation == Qt::Horizontal ? d->pixelPosToRangeValue(pressValue.x()) :
        d->pixelPosToRangeValue(pressValue.y());
    if (d->pressedControl == QStyle::SC_ScrollBarSlider) {
        d->clickOffset = HORIZONTAL ? (click.x()-sr.x()) : (click.y()-sr.y());
        d->snapBackPosition = d->position;
    }

    if ((d->pressedControl == QStyle::SC_ScrollBarAddPage
          || d->pressedControl == QStyle::SC_ScrollBarSubPage)
        && ((midButtonAbsPos && e->button() == Qt::MidButton)
            || (style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition, &opt, this)
                && e->button() == Qt::LeftButton))) {
        int sliderLength = HORIZONTAL ? sr.width() : sr.height();
        setSliderPosition(d->pixelPosToRangeValue((HORIZONTAL ? e->pos().x()
                                                              : e->pos().y()) - sliderLength / 2));
        d->pressedControl = QStyle::SC_ScrollBarSlider;
        d->clickOffset = sliderLength / 2;
    }
    const int initialDelay = 500; // default threshold
    QElapsedTimer time;
    time.start();
    d->activateControl(d->pressedControl, initialDelay);
    repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this));
    if (time.elapsed() >= initialDelay && d->repeatActionTimer.isActive()) {
        // It took more than 500ms (the initial timer delay) to process
        // the control activation and repaint(), we therefore need
        // to restart the timer in case we have a pending mouse release event;
        // otherwise we'll get a timer event right before the release event,
        // causing the repeat action to be invoked twice on a single mouse click.
        // 50ms is the default repeat time (see activateControl/setRepeatAction).
        d->repeatActionTimer.start(50, this);
    }
    if (d->pressedControl == QStyle::SC_ScrollBarSlider)
        setSliderDown(true);
}
Ejemplo n.º 6
0
/*!
    \reimp
 */
void QxtSpanSlider::mouseReleaseEvent(QMouseEvent* event)
{
    QSlider::mouseReleaseEvent(event);
    setSliderDown(false);
    qxt_d().lowerPressed = QStyle::SC_None;
    qxt_d().upperPressed = QStyle::SC_None;
    update();
}
Ejemplo n.º 7
0
void NavigationSlider::leaveEvent( QEvent * )
{
    setSliderDown( false );
    if ( m_handleImagePath != "marble/navigation/navigational_slider_handle" ) {
        m_handleImagePath = "marble/navigation/navigational_slider_handle";
        repaint();
    }
}
Ejemplo n.º 8
0
void NavigationSlider::mouseReleaseEvent( QMouseEvent * )
{
    setSliderDown( false );
    if ( m_handleImagePath != "marble/navigation/navigational_slider_handle_hover" ) {
        m_handleImagePath = "marble/navigation/navigational_slider_handle_hover";
        repaint();
    }
}
Ejemplo n.º 9
0
void NavigationSlider::mousePressEvent( QMouseEvent * )
{
    setSliderDown( true );
    if ( m_handleImagePath != "marble/navigation/navigational_slider_handle_press" ) {
        m_handleImagePath = "marble/navigation/navigational_slider_handle_press";
        repaint();
    }
}
Ejemplo n.º 10
0
/*!
    \reimp
*/
void QSlider::mousePressEvent(QMouseEvent *ev)
{
    Q_D(QSlider);
    if (d->maximum == d->minimum || (ev->buttons() ^ ev->button())) {
        ev->ignore();
        return;
    }
#ifdef QT_KEYPAD_NAVIGATION
    if (QApplication::keypadNavigationEnabled())
        setEditFocus(true);
#endif
    ev->accept();
    if ((ev->button() & style()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons)) == ev->button()) {
        QStyleOptionSlider opt;
        initStyleOption(&opt);
        const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
        const QPoint center = sliderRect.center() - sliderRect.topLeft();
        // to take half of the slider off for the setSliderPosition call we use the center - topLeft

        setSliderPosition(d->pixelPosToRangeValue(d->pick(ev->pos() - center)));
        triggerAction(SliderMove);
        setRepeatAction(SliderNoAction);
        d->pressedControl = QStyle::SC_SliderHandle;
        update();
    } else if ((ev->button() & style()->styleHint(QStyle::SH_Slider_PageSetButtons)) == ev->button()) {
        QStyleOptionSlider opt;
        initStyleOption(&opt);
        d->pressedControl = style()->hitTestComplexControl(QStyle::CC_Slider,
                                                           &opt, ev->pos(), this);
        SliderAction action = SliderNoAction;
        if (d->pressedControl == QStyle::SC_SliderGroove) {
            const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
            int pressValue = d->pixelPosToRangeValue(d->pick(ev->pos() - sliderRect.center() + sliderRect.topLeft()));
            d->pressValue = pressValue;
            if (pressValue > d->value)
                action = SliderPageStepAdd;
            else if (pressValue < d->value)
                action = SliderPageStepSub;
            if (action) {
                triggerAction(action);
                setRepeatAction(action);
            }
        }
    } else {
        ev->ignore();
        return;
    }

    if (d->pressedControl == QStyle::SC_SliderHandle) {
        QStyleOptionSlider opt;
        initStyleOption(&opt);
        setRepeatAction(SliderNoAction);
        QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
        d->clickOffset = d->pick(ev->pos() - sr.topLeft());
        update(sr);
        setSliderDown(true);
    }
}
Ejemplo n.º 11
0
void ControlSlider::mouseReleaseEvent(QMouseEvent *event)
{
	if(!handlePressed)
	{
		int sliderValue = style()->sliderValueFromPosition(minimum(),maximum(),event->pos().x()-6,width()-12);
		setValue(sliderValue);
	}
	handlePressed = false;
	setSliderDown(false);
}
Ejemplo n.º 12
0
void QDial::mouseReleaseEvent(QMouseEvent * e)
{
    Q_D(QDial);
    if (e->buttons() & (~e->button())) {
        e->ignore();
        return;
    }
    e->accept();
    setValue(d->valueFromPoint(e->pos()));
    setSliderDown(false);
}
Ejemplo n.º 13
0
void NavigationSlider::mouseMoveEvent( QMouseEvent *mouseEvent )
{
    if ( !isSliderDown() && mouseEvent->buttons() & Qt::LeftButton ) {
        setSliderDown( true );
    }
    if ( isSliderDown() ) {
        qreal const fraction = ( mouseEvent->pos().y() - handleImageHeight/2 ) / qreal ( height() - handleImageHeight );
        int v = ( int ) minimum() + ( ( maximum() - minimum() ) ) * ( 1 - fraction );
        setValue( v );
        repaint();
    }
}
Ejemplo n.º 14
0
void CSliderMultiPos::mouseReleaseEvent(QMouseEvent* event){

    QSlider::mouseReleaseEvent( event );
    previousMousePos = QPoint(0,0);
    setSliderDown( false );
    if( lastPressedIndex!=INVALID_INDEX ){
        setValue( lastPressedIndex,handles.at(lastPressedIndex).getPosition() );
        handles[lastPressedIndex].setPressed(QStyle::SC_None);
        lastPressedIndex = INVALID_INDEX;
    }

    update();
}
Ejemplo n.º 15
0
/*!
    \reimp
*/
void QAbstractSlider::changeEvent(QEvent *ev)
{
    Q_D(QAbstractSlider);
    switch (ev->type()) {
    case QEvent::EnabledChange:
        if (!isEnabled()) {
            d->repeatActionTimer.stop();
            setSliderDown(false);
        }
        // fall through...
    default:
        QWidget::changeEvent(ev);
    }
}
Ejemplo n.º 16
0
void QDial::mousePressEvent(QMouseEvent *e)
{
    Q_D(QDial);
    if (d->maximum == d->minimum ||
        (e->button() != Qt::LeftButton)  ||
        (e->buttons() ^ e->button())) {
        e->ignore();
        return;
    }
    e->accept();
    setSliderPosition(d->valueFromPoint(e->pos()));
    // ### This isn't quite right,
    // we should be doing a hit test and only setting this if it's
    // the actual dial thingie (similar to what QSlider does), but we have no
    // subControls for QDial.
    setSliderDown(true);
}
Ejemplo n.º 17
0
/*!
    \reimp
*/
void QSlider::mouseReleaseEvent(QMouseEvent *ev)
{
    Q_D(QSlider);
    if (d->pressedControl == QStyle::SC_None || ev->buttons()) {
        ev->ignore();
        return;
    }
    ev->accept();
    QStyle::SubControl oldPressed = QStyle::SubControl(d->pressedControl);
    d->pressedControl = QStyle::SC_None;
    setRepeatAction(SliderNoAction);
    if (oldPressed == QStyle::SC_SliderHandle)
        setSliderDown(false);
    QStyleOptionSlider opt;
    initStyleOption(&opt);
    opt.subControls = oldPressed;
    update(style()->subControlRect(QStyle::CC_Slider, &opt, oldPressed, this));
}
Ejemplo n.º 18
0
void KSelector::mouseReleaseEvent( QMouseEvent *e )
{
    moveArrow( e->pos() );
    setSliderDown(false);
}
Ejemplo n.º 19
0
void KSelector::mousePressEvent( QMouseEvent *e )
{
    setSliderDown(true);
    moveArrow( e->pos() );
}
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;
}
Ejemplo n.º 21
0
void ClickAndGoSlider::wheelEvent(QWheelEvent *e)
{
    setSliderDown(true);
    QSlider::wheelEvent(e);
    setSliderDown(false);
}