Exemple #1
0
void Highlight::setItem(QQuickItem *item)
{
    if (m_item)
        m_item->disconnect(this);

    if (item) {
        connect(item, SIGNAL(xChanged()), SLOT(adjust()));
        connect(item, SIGNAL(yChanged()), SLOT(adjust()));
        connect(item, SIGNAL(widthChanged()), SLOT(adjust()));
        connect(item, SIGNAL(heightChanged()), SLOT(adjust()));
        connect(item, SIGNAL(rotationChanged()), SLOT(adjust()));
        connect(item, SIGNAL(transformOriginChanged(TransformOrigin)),
                SLOT(adjust()));
    }
    QQuickWindow *view = item->window();
    QQuickItem * contentItem = view->contentItem();
    if (contentItem) {
        connect(contentItem, SIGNAL(xChanged()), SLOT(adjust()));
        connect(contentItem, SIGNAL(yChanged()), SLOT(adjust()));
        connect(contentItem, SIGNAL(widthChanged()), SLOT(adjust()));
        connect(contentItem, SIGNAL(heightChanged()), SLOT(adjust()));
        connect(contentItem, SIGNAL(rotationChanged()), SLOT(adjust()));
        connect(contentItem, SIGNAL(transformOriginChanged(TransformOrigin)),
                SLOT(adjust()));
    }
    m_item = item;
    setContentsSize(view->size());
    adjust();
}
void QQuickMenuPopupWindow::setItemAt(QQuickItem *menuItem)
{
    if (m_itemAt) {
        disconnect(m_itemAt, SIGNAL(xChanged()), this, SLOT(updatePosition()));
        disconnect(m_itemAt, SIGNAL(yChanged()), this, SLOT(updatePosition()));
    }

    m_itemAt = menuItem;
    if (menuItem) {
        m_oldItemPos = menuItem->position().toPoint();
        connect(menuItem, SIGNAL(xChanged()), this, SLOT(updatePosition()));
        connect(menuItem, SIGNAL(yChanged()), this, SLOT(updatePosition()));
    }
}
Exemple #3
0
void ShapeSideBar::updateForCurrentPropertyChange()
{
	d->rectGroup->setVisible((bool)d->rectLayer);
	d->textGroup->setVisible((bool)d->textLayer);
	
	if (d->rectLayer)
	{
		emit xChanged(d->rectLayer->rect().x());
		emit yChanged(d->rectLayer->rect().y());
		emit widthChanged(d->rectLayer->rect().width());
		emit heightChanged(d->rectLayer->rect().height());
	}
	
	if (d->textLayer)
	{
		if (d->textEdit->toPlainText() != d->textLayer->text())
			d->textEdit->setText(d->textLayer->text());
		
		QFont font = d->textLayer->font();
		QString fontText = font.family() + " / " + font.styleName() + " / " + QString::number(font.pointSize()) + "pt";
		d->fontButton->setText(fontText);
		
		emit fontItalicChanged(font.italic());
		
		auto alignment = d->textLayer->alignment();
		
		for (Qt::Alignment alignElem : { Qt::AlignLeft, Qt::AlignHCenter, Qt::AlignRight, Qt::AlignTop, Qt::AlignVCenter, Qt::AlignBottom })
		{
			if (alignment & alignElem)
				d->alignButtons[alignElem]->setChecked(true);
		}
	}
}
void tst_QGraphicsObject::pos()
{
    MyGraphicsObject object;
    QSignalSpy xSpy(&object, SIGNAL(xChanged()));
    QSignalSpy ySpy(&object, SIGNAL(yChanged()));
    QVERIFY(object.pos() == QPointF(0, 0));
    object.setPos(10, 10);
    QCOMPARE(xSpy.count(), 1);
    QCOMPARE(ySpy.count(), 1);

    QVERIFY(object.pos() == QPointF(10,10));

    object.setPos(10, 10);
    QCOMPARE(xSpy.count(), 1);
    QCOMPARE(ySpy.count(), 1);

    object.setProperty("pos", QPointF(0, 0));
    QCOMPARE(xSpy.count(), 2);
    QCOMPARE(ySpy.count(), 2);
    QVERIFY(object.property("pos") == QPointF(0,0));

    object.setProperty("pos", QPointF(10, 0));
    QCOMPARE(xSpy.count(), 3);
    QCOMPARE(ySpy.count(), 2);
    QVERIFY(object.property("pos") == QPointF(10,0));

    object.setProperty("pos", QPointF(10, 10));
    QCOMPARE(xSpy.count(), 3);
    QCOMPARE(ySpy.count(), 3);
    QVERIFY(object.property("pos") == QPointF(10, 10));
}
void QQuickPathInterpolator::_q_pathUpdated()
{
    if (! _path)
        return;

    qreal angle = 0;
    const QPointF pt = _path->sequentialPointAt(_progress, &angle);

    if (_x != pt.x()) {
        _x = pt.x();
        emit xChanged();
    }

    if (_y != pt.y()) {
        _y = pt.y();
        emit yChanged();
    }

    //convert to clockwise
    angle = qreal(360) - angle;
    if (qFuzzyCompare(angle, qreal(360)))
        angle = qreal(0);

    if (angle != _angle) {
        _angle = angle;
        emit angleChanged();
    }
}
Exemple #6
0
void QQuickTouchPoint::setX(qreal x)
{
    if (_x == x)
        return;
    _x = x;
    emit xChanged();
}
/*!
    Sets the wrap mode of the x dimension to \a x.
 */
void QTextureWrapMode::setX(WrapMode x)
{
    Q_D(QTextureWrapMode);
    if (d->m_x != x) {
        d->m_x = x;
        emit xChanged();
    }
}
void GyroState::setx(float value)
{
   mutex->lock();
   bool changed = data.x != value;
   data.x = value;
   mutex->unlock();
   if (changed) emit xChanged(value);
}
void MagSensor::setx(float value)
{
   mutex->lock();
   bool changed = data.x != value;
   data.x = value;
   mutex->unlock();
   if (changed) emit xChanged(value);
}
void QQuickTranslate::setX(qreal x)
{
    Q_D(QQuickTranslate);
    if (d->x == x)
        return;
    d->x = x;
    update();
    emit xChanged();
}
void InputRegion::setX(qreal x)
{
    Q_D(InputRegion);
    if (d->x != x) {
        d->x = x;
        d->scheduleUpdate();
        emit xChanged();
    }
}
void GyroState::emitNotifications()
{
            //if (data.x != oldData.x)
            emit xChanged(data.x);
        //if (data.y != oldData.y)
            emit yChanged(data.y);
        //if (data.z != oldData.z)
            emit zChanged(data.z);

}
void MagSensor::emitNotifications()
{
            //if (data.x != oldData.x)
            emit xChanged(data.x);
        //if (data.y != oldData.y)
            emit yChanged(data.y);
        //if (data.z != oldData.z)
            emit zChanged(data.z);

}
Exemple #14
0
ZArrow::ZArrow(QGraphicsItem* pFrom, QGraphicsItem* pTo, QGraphicsItem* pParent)
	:QObject(NULL), QGraphicsLineItem(pParent), m_pFrom(pFrom), m_pTo(pTo)
{
#if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
	QGraphicsObject* pObjFrom = dynamic_cast<QGraphicsObject*>(m_pFrom);
	if (pObjFrom)
	{
		connect(pObjFrom, SIGNAL(xChanged()), SLOT(updatePosition()));
		connect(pObjFrom, SIGNAL(yChanged()), SLOT(updatePosition()));
	}

	QGraphicsObject* pObjTo = dynamic_cast<QGraphicsObject*>(m_pTo);
	if (pObjTo)
	{
		connect(pObjTo, SIGNAL(xChanged()), SLOT(updatePosition()));
		connect(pObjTo, SIGNAL(yChanged()), SLOT(updatePosition()));
	}
	updatePosition();
#endif
/*!
    \qmlproperty list<string> QtQuick.Particles2::ParticlePainter::particles
    Which logical particle groups will be painted.

    If empty, it will paint the default particle ("").
*/
QSGParticlePainter::QSGParticlePainter(QSGItem *parent) :
    QSGItem(parent),
    m_system(0), m_count(0), m_sentinel(new QSGParticleData(0))
{
    connect(this, SIGNAL(parentChanged(QSGItem*)),
            this, SLOT(calcSystemOffset()));
    connect(this, SIGNAL(xChanged()),
            this, SLOT(calcSystemOffset()));
    connect(this, SIGNAL(yChanged()),
            this, SLOT(calcSystemOffset()));
}
// x offset in image pixels
void ffmpegWidget::setX(int x) {
    x = x < 0 ? 0 : (x > _maxX) ? _maxX : x;
    // xvideo only accepts multiple of 2 offsets    
    if (this->xv_format >= 0) x = x - x % 2;    
    if (_x != x) {
        _x = x;
        emit xChanged(x);
        if (!disableUpdates) {
            update();
        }
    }
}
Exemple #17
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    //    If you want to use an engine, this shows how to get an UI Element!:

    //    QQmlApplicationEngine engine;
    //    engine.load(QUrl(QStringLiteral("qrc:/game.qml")));

    //    QObject root = engine.rootObjects().first();
    //    QObject element = root.findChild("element");
    //    element.setProperty("color","red");


    //Creating Objects from Qml in C++ with QQuickView
    //http://stackoverflow.com/questions/14092319/create-qml-element-in-c


    QQuickView view;
    //Background
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource(QUrl("qrc:///game.qml"));

    //Spaceshuttle
    QQmlComponent component(view.engine(), QUrl("qrc:///shuttle.qml"));
    QObject *shuttle = component.create();
    //Components are only drawn if parent is somehow related to the root view
    QQmlProperty::write(shuttle, "parent", QVariant::fromValue<QObject*>(view.rootObject()));

    //some sample "Astroids" - ( wrong Image ;) )
    QVector<QObject*> astroids(0);

    for(int i = 0; i < 5; i++){
        QQmlComponent fireballComponent(view.engine(), QUrl("qrc:///fireball.qml"));
        astroids.append(fireballComponent.create());
        QQmlProperty::write(astroids[i], "parent", QVariant::fromValue<QObject*>(view.rootObject()));
        QQmlProperty::write(astroids[i], "x", i*50);
        QQmlProperty::write(astroids[i], "y", i*50);
    }

    //QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);

    qDebug() << shuttle->property("id").toString();

    Logger logger;
    logger.setQObject(shuttle);
    QObject::connect(shuttle, SIGNAL(xChanged()), &logger, SLOT(showCoordinates()));

    view.show();

    return app.exec();
}
void SquareBinding::setX(QString xStr)
{
    qDebug() << "HELLO" << x() << ", " << xStr;
    if (x() == QString::number(xStr.toDouble(), 'f', 2))
    {
        return;
    }

    qDebug() << __FUNCTION__ << xStr;

    position_.setX(xStr.toDouble());

    emit xChanged();
}
Exemple #19
0
bool ExtendWidget::eventFilter(QObject *o, QEvent *e)
{
    Q_D(ExtendWidget);

    if (o == d->target) {
        if (e->type() == QEvent::Resize) {
            QResizeEvent *event = static_cast<QResizeEvent *>(e);
            if (event) {
                QSize size = event->size();

                if (size.width() != d->old_size.width()) {
                    emit widthChanged(size.width());
                }

                if (size.height() != d->old_size.height()) {
                    emit heightChanged(size.height());
                }

                if (size != d->old_size) {
                    emit sizeChanged(size);
                }

                d->old_size = size;
            }
        } else if (e->type() == QEvent::Move) {
            QMoveEvent *event = static_cast<QMoveEvent *>(e);

            if (event) {
                QPoint pos = event->pos();

                if (pos.x() != d->old_pos.x()) {
                    emit xChanged(pos.x());
                }

                if (pos.y() != d->old_pos.y()) {
                    emit yChanged(pos.y());
                }

                if (pos != d->old_pos) {
                    emit positionChanged(pos);
                }

                d->old_pos = pos;
            }
        }
    }

    return false;
}
void QSGParticlePainter::setSystem(QSGParticleSystem *arg)
{
    if (m_system != arg) {
        m_system = arg;
        if (m_system){
            m_system->registerParticlePainter(this);
            connect(m_system, SIGNAL(xChanged()),
                    this, SLOT(calcSystemOffset()));
            connect(m_system, SIGNAL(yChanged()),
                    this, SLOT(calcSystemOffset()));
            calcSystemOffset();
        }
        emit systemChanged(arg);
    }
}
Exemple #21
0
StateNode::StateNode(DiagramScene *scene, FiniteAutomata *_FA, QString uniqueName)
{
    FA = _FA;
    myscene = scene;
    node_name = uniqueName;
    firstInit();

    connect(this,SIGNAL(sendStatusBarMessage(QString)),scene,SIGNAL(sendStatusBarMessage(QString)));
    connect(this,SIGNAL(FA_changed(FiniteAutomata*)),scene,SIGNAL(FA_changed(FiniteAutomata*)));
    connect(this,SIGNAL(xChanged()),this,SLOT(positionChanged()));
    connect(this,SIGNAL(yChanged()),this,SLOT(positionChanged()));

    FA->addState(node_name);
    emit FA_changed(FA);


}
void QmlGyroscopeReading::readingUpdate()
{
    qreal gx = m_sensor->reading()->x();
    if (m_x != gx) {
        m_x = gx;
        Q_EMIT xChanged();
    }
    qreal gy = m_sensor->reading()->y();
    if (m_y != gy) {
        m_y = gy;
        Q_EMIT yChanged();
    }
    qreal gz = m_sensor->reading()->z();
    if (m_z != gz) {
        m_z = gz;
        Q_EMIT zChanged();
    }
}
void QmlRotationSensorReading::readingUpdate()
{
    qreal rX = m_sensor->reading()->x();
    if (m_x != rX) {
        m_x = rX;
        Q_EMIT xChanged();
    }
    qreal rY = m_sensor->reading()->y();
    if (m_y != rY) {
        m_y = rY;
        Q_EMIT yChanged();
    }
    qreal rZ = m_sensor->reading()->z();
    if (m_z != rZ) {
        m_z = rZ;
        Q_EMIT zChanged();
    }
}
Exemple #24
0
void Box2DBody::setTarget(QQuickItem *target)
{
    if (mTarget == target)
        return;

    if (mTarget)
        mTarget->disconnect(this);

    mTarget = target;
    mTransformDirty = target != 0;

    if (target) {
        connect(target, SIGNAL(xChanged()), this, SLOT(markTransformDirty()));
        connect(target, SIGNAL(yChanged()), this, SLOT(markTransformDirty()));
        connect(target, SIGNAL(rotationChanged()), this, SLOT(markTransformDirty()));
    }

    emit targetChanged();
}
Exemple #25
0
void Cursor::dispatchEvents()
{
    if (m_new_position != m_position|| m_content_height_changed) {
        bool emit_x_changed = m_new_position.x() != m_position.x();
        bool emit_y_changed = m_new_position.y() != m_position.y();
        m_position = m_new_position;
        if (emit_x_changed)
            emit xChanged();
        if (emit_y_changed || m_content_height_changed)
            emit yChanged();
    }

    if (m_new_visibillity != m_visible) {
        m_visible = m_new_visibillity;
        emit visibilityChanged();
    }

    if (m_new_blinking != m_blinking) {
        m_blinking = m_new_blinking;
        emit blinkingChanged();
    }
}
void QmlMagnetometerReading::readingUpdate()
{
    qreal magX = m_sensor->reading()->x();
    if (m_x != magX) {
        m_x = magX;
        Q_EMIT xChanged();
    }
    qreal magY = m_sensor->reading()->y();
    if (m_y != magY) {
        m_y = magY;
        Q_EMIT yChanged();
    }
    qreal magZ = m_sensor->reading()->z();
    if (m_z != magZ) {
        m_z = magZ;
        Q_EMIT zChanged();
    }
    qreal calLevel = m_sensor->reading()->calibrationLevel();
    if (m_calibrationLevel != calLevel) {
        m_calibrationLevel = calLevel;
        Q_EMIT calibrationLevelChanged();
    }
}
Exemple #27
0
 void Rotation::updateX() {
   emit xChanged();
   emit rotationChanged();
 }
Exemple #28
0
void WWindowPrivate::init()
{
    Q_Q(WWindow);

    icon = sk->icon();

    visible = true;

    hoverItem = NULL;

    q->setAcceptHoverEvents(true);

#ifdef QT_LATEST
    q->setFlag(QQuickItem::ItemAcceptsDrops);
#endif

    //---------------------------------------------------------------------------------------------
    // View

#if defined(SK_WIN_NATIVE)
    view = new WView(q, NULL);
#elif defined(Q_OS_WIN)
    view = new WView(q, NULL, Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
#else
    view = new WView(q, NULL, Qt::FramelessWindowHint);
#endif

#ifdef QT_4
    view->setWindowTitle(sk->name());
#else
    view->setTitle(sk->name());
#endif

    if (icon.isEmpty() == false)
    {
#ifdef QT_4
        view->setWindowIcon(QIcon(icon));
#else
        view->setIcon(QIcon(icon));
#endif
    }

    view->setVisible(true);

    //---------------------------------------------------------------------------------------------
    // Signals

    QObject::connect(view, SIGNAL(messageReceived(const QString &)),
                     q,    SIGNAL(messageReceived(const QString &)));

    QObject::connect(view, SIGNAL(stateChanged(Qt::WindowState)),
                     q,    SIGNAL(stateChanged(Qt::WindowState)));

    QObject::connect(view, SIGNAL(fadeIn ()), q, SIGNAL(fadeIn ()));
    QObject::connect(view, SIGNAL(fadeOut()), q, SIGNAL(fadeOut()));

    QObject::connect(view, SIGNAL(dragEnded()), q, SIGNAL(dragEnded()));

    QObject::connect(view, SIGNAL(beforeClose()), q, SIGNAL(beforeClose()));

    //---------------------------------------------------------------------------------------------

    QObject::connect(view, SIGNAL(itemWidthChanged ()), q, SIGNAL(itemWidthChanged ()));
    QObject::connect(view, SIGNAL(itemHeightChanged()), q, SIGNAL(itemHeightChanged()));

    QObject::connect(view, SIGNAL(xChanged()), q, SIGNAL(viewXChanged()));
    QObject::connect(view, SIGNAL(yChanged()), q, SIGNAL(viewYChanged()));

    QObject::connect(view, SIGNAL(widthChanged ()), q, SIGNAL(viewWidthChanged ()));
    QObject::connect(view, SIGNAL(heightChanged()), q, SIGNAL(viewHeightChanged()));

    QObject::connect(view, SIGNAL(centerXChanged()), q, SIGNAL(centerXChanged()));
    QObject::connect(view, SIGNAL(centerYChanged()), q, SIGNAL(centerYChanged()));

    QObject::connect(view, SIGNAL(originXChanged()), q, SIGNAL(originXChanged()));
    QObject::connect(view, SIGNAL(originYChanged()), q, SIGNAL(originYChanged()));

    QObject::connect(view, SIGNAL(ratioChanged()), q, SIGNAL(ratioChanged()));

    QObject::connect(view, SIGNAL(zoomChanged()), q, SIGNAL(zoomChanged()));

    QObject::connect(view, SIGNAL(minimumWidthChanged ()), q, SIGNAL(minimumWidthChanged ()));
    QObject::connect(view, SIGNAL(minimumHeightChanged()), q, SIGNAL(minimumHeightChanged()));

    QObject::connect(view, SIGNAL(maximumWidthChanged ()), q, SIGNAL(maximumWidthChanged ()));
    QObject::connect(view, SIGNAL(maximumHeightChanged()), q, SIGNAL(maximumHeightChanged()));

    QObject::connect(view, SIGNAL(geometryNormalChanged()), q, SIGNAL(geometryNormalChanged()));

    QObject::connect(view, SIGNAL(minimizedChanged ()), q, SIGNAL(minimizedChanged ()));
    QObject::connect(view, SIGNAL(maximizedChanged ()), q, SIGNAL(maximizedChanged ()));
    QObject::connect(view, SIGNAL(fullScreenChanged()), q, SIGNAL(fullScreenChanged()));
    QObject::connect(view, SIGNAL(lockedChanged    ()), q, SIGNAL(lockedChanged    ()));
    QObject::connect(view, SIGNAL(scalingChanged   ()), q, SIGNAL(scalingChanged   ()));

    QObject::connect(view, SIGNAL(activeChanged  ()), q, SIGNAL(activeChanged  ()));
    QObject::connect(view, SIGNAL(enteredChanged ()), q, SIGNAL(enteredChanged ()));
    QObject::connect(view, SIGNAL(draggingChanged()), q, SIGNAL(draggingChanged()));
    QObject::connect(view, SIGNAL(draggedChanged ()), q, SIGNAL(draggedChanged ()));
    QObject::connect(view, SIGNAL(resizingChanged()), q, SIGNAL(resizingChanged()));
    QObject::connect(view, SIGNAL(touchingChanged()), q, SIGNAL(touchingChanged()));

    QObject::connect(view, SIGNAL(mousePosChanged   ()), q, SIGNAL(mousePosChanged   ()));
    QObject::connect(view, SIGNAL(mouseCursorChanged()), q, SIGNAL(mouseCursorChanged()));

#ifdef QT_4
    QObject::connect(view, SIGNAL(openglChanged()), q, SIGNAL(openglChanged()));
#endif

    QObject::connect(view, SIGNAL(antialiasChanged()), q, SIGNAL(antialiasChanged()));
    QObject::connect(view, SIGNAL(vsyncChanged    ()), q, SIGNAL(vsyncChanged    ()));

    QObject::connect(view, SIGNAL(hoverEnabledChanged()), q, SIGNAL(hoverEnabledChanged()));

    QObject::connect(view, SIGNAL(fadeEnabledChanged ()), q, SIGNAL(fadeEnabledChanged ()));
    QObject::connect(view, SIGNAL(fadeDurationChanged()), q, SIGNAL(fadeDurationChanged()));

    //---------------------------------------------------------------------------------------------

    QObject::connect(view, SIGNAL(idleCheckChanged()), q, SIGNAL(idleCheckChanged()));
    QObject::connect(view, SIGNAL(idleChanged     ()), q, SIGNAL(idleChanged     ()));
    QObject::connect(view, SIGNAL(idleDelayChanged()), q, SIGNAL(idleDelayChanged()));

    //---------------------------------------------------------------------------------------------

    QObject::connect(view, SIGNAL(mousePressed(WDeclarativeMouseEvent *)),
                     q,    SIGNAL(mousePressed(WDeclarativeMouseEvent *)));

    QObject::connect(view, SIGNAL(mouseReleased(WDeclarativeMouseEvent *)),
                     q,    SIGNAL(mouseReleased(WDeclarativeMouseEvent *)));

    QObject::connect(view, SIGNAL(mouseDoubleClicked(WDeclarativeMouseEvent *)),
                     q,    SIGNAL(mouseDoubleClicked(WDeclarativeMouseEvent *)));

    QObject::connect(view, SIGNAL(keyPressed(WDeclarativeKeyEvent *)),
                     q,    SIGNAL(keyPressed(WDeclarativeKeyEvent *)));

    QObject::connect(view, SIGNAL(keyReleased(WDeclarativeKeyEvent *)),
                     q,    SIGNAL(keyReleased(WDeclarativeKeyEvent *)));

    //---------------------------------------------------------------------------------------------

    QObject::connect(view, SIGNAL(keyShiftPressedChanged()),
                     q,    SIGNAL(keyShiftPressedChanged()));

    QObject::connect(view, SIGNAL(keyControlPressedChanged()),
                     q,    SIGNAL(keyControlPressedChanged()));

    QObject::connect(view, SIGNAL(keyAltPressedChanged()),
                     q,    SIGNAL(keyAltPressedChanged()));

    //---------------------------------------------------------------------------------------------

    QObject::connect(view, SIGNAL(availableGeometryChanged()),
                     q,    SIGNAL(availableGeometryChanged()));
}
void THREEQuaternion::setX(float x) {
    if (m_x != x) {
        m_x = x;
        emit xChanged(x);
    }
}
void SquareBinding::updatePosition()
{
    emit xChanged();
    emit yChanged();
}