Exemplo n.º 1
0
/*!
    \reimp
 */
void HbScrollBar::timerEvent( QTimerEvent *event )
{
    Q_D(HbScrollBar);
    if (event->timerId() == d->repeatActionTimer.timerId()) {
        if (value() > d->mPressedTargetValue) {
            HbWidgetFeedback::triggered(this, Hb::InstantKeyRepeated, Hb::ModifierSliderHandle);
            emit valueChangeRequested(value() - qMin(pageSize(), value() - d->mPressedTargetValue), orientation());
        } else if (value() < d->mPressedTargetValue){
            HbWidgetFeedback::triggered(this, Hb::InstantKeyRepeated, Hb::ModifierSliderHandle);
            emit valueChangeRequested(value() + qMin(pageSize(), d->mPressedTargetValue - value()), orientation());
        }
        if (value() != d->mPressedTargetValue) {
            d->repeatActionTimer.start(REPEATION_TIME, this);
        } else {
            d->repeatActionTimer.stop();
        }
    }
}
Exemplo n.º 2
0
void Parametertuner::handleJoystickInput(const sensor_msgs::JoyConstPtr& joy)
{
	if(!m_useJoystick)
		return;

	if(joy->buttons.size() < 8)
		return;

	int buttonUp = 4;
	int buttonDown = 5;
	int buttonLeft = 6;
	int buttonRight = 7;

	bool collapse = false;
	bool pressedUpLeft = joy->buttons[buttonUp] && joy->buttons[buttonLeft];
	if(m_buttonUpLeft && !pressedUpLeft)
	{
		expansionRequested(COLLAPSE);
		collapse = true;
	}
	m_buttonUpLeft = pressedUpLeft;

	if(m_buttonUp && !joy->buttons[buttonUp] && !collapse)
		moveSelectionRequested(UP);
	m_buttonUp = joy->buttons[buttonUp];

	if(m_buttonDown && !joy->buttons[buttonDown])
		moveSelectionRequested(DOWN);
	m_buttonDown = joy->buttons[buttonDown];

	if(m_buttonDec && !joy->buttons[buttonLeft] && !collapse)
		valueChangeRequested(LEFT);
	m_buttonDec = joy->buttons[buttonLeft];

	if(m_buttonInc && !joy->buttons[buttonRight])
		valueChangeRequested(RIGHT);
	m_buttonInc = joy->buttons[buttonRight];

}
Exemplo n.º 3
0
/*!
    \reimp
 */
void HbScrollBar::mousePressEvent( QGraphicsSceneMouseEvent *event )
{
    Q_D(HbScrollBar);
    QGraphicsWidget::mousePressEvent(event);

    if ( !d->mInteractive ) {
        return;
    }

    HbStyleOptionScrollBar opt;

    QRectF handleBounds = d->handleItem->boundingRect();

    d->mPressPosition = mapToItem(d->handleItem, event->pos());

    switch (orientation()) {
    case Qt::Horizontal:
        d->mThumbPressed = (event->pos().x() >= d->handleItem->pos().x() &&
                            event->pos().x() <= d->handleItem->pos().x() + handleBounds.width());
        if (!d->mThumbPressed) {
            d->mGroovePressed = true;
            HbWidgetFeedback::triggered(this, Hb::InstantPressed);

            if (d->handleItem->pos().x() < event->pos().x()) {
                emit valueChangeRequested(qMin(value() + pageSize(), qreal(1.0)), orientation());
            } else {
                emit valueChangeRequested(qMax(value() - pageSize(), qreal(0.0)), orientation());
            }
            d->mPressedTargetValue = qBound(qreal(0.0),
                                            qreal((event->pos().x() - (handleBounds.width() / 2.0)) / (boundingRect().width() - handleBounds.width())),
                                            qreal(1.0));

            d->repeatActionTimer.start(REPEATION_TIME, this);
        } else {
            HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierSliderHandle);
            initStyleOption(&opt);
            style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt );
            emit d->core.handlePressed();
        }

        break;
    case Qt::Vertical:
        d->mThumbPressed = (event->pos().y() >= d->handleItem->pos().y() &&
                            event->pos().y() <= d->handleItem->pos().y() + handleBounds.height());
        if (!d->mThumbPressed) {
            d->mGroovePressed = true;
            HbWidgetFeedback::triggered(this, Hb::InstantPressed);

            if (d->handleItem->pos().y() < event->pos().y()) {
                emit valueChangeRequested(qMin(value() + pageSize(), qreal(1.0)), orientation());
            } else {
                emit valueChangeRequested(qMax(value() - pageSize(), qreal(0.0)), orientation());
            }

            d->mPressedTargetValue = qBound(qreal(0.0),
                                            qreal((event->pos().y() - (handleBounds.height() / 2.0)) / (boundingRect().height() - handleBounds.height())),
                                            qreal(1.0));

            d->repeatActionTimer.start(REPEATION_TIME, this);
        } else {
            HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierSliderHandle);
            initStyleOption(&opt);
            style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt );
            emit d->core.handlePressed();
        }

        break;
    }
    event->accept();
}