Ejemplo n.º 1
0
void CMainWindow::startingAnimation()
{
    setWindowFlags(Qt::Window | Qt::FramelessWindowHint); //FramelessWindowHint wymagane do przezroczystego t³a
    setAttribute(Qt::WA_TranslucentBackground, true);
    QRect screenRect = QApplication::desktop()->screenGeometry();
    QSequentialAnimationGroup *group = new QSequentialAnimationGroup(this);
    QPropertyAnimation* fadeIn = new QPropertyAnimation(this, "windowOpacity", this);
    fadeIn->setDuration(2000);
    fadeIn->setStartValue(0.0);
    fadeIn->setEndValue(1.0);
    group->addAnimation(fadeIn);
    QParallelAnimationGroup *moveGroup = new QParallelAnimationGroup(this);
    QPropertyAnimation* imageRight = new QPropertyAnimation(pandemicImage, "geometry", this);
    imageRight->setStartValue(pandemicImage->geometry());
    imageRight->setEndValue(pandemicImage->geometry().translated(screenRect.width() - pandemicImage->geometry().right(), 0));
    imageRight->setDuration(1000);
    imageRight->setEasingCurve(QEasingCurve::InOutCubic);
    moveGroup->addAnimation(imageRight);
    QPropertyAnimation* menuLeft = new QPropertyAnimation(menu, "geometry", this);
    menuLeft->setStartValue(menu->geometry());
    menuLeft->setEndValue(QRect(0,0, screenRect.width()-pandemicImage->width()+1, menu->height()));
    menuLeft->setDuration(1000);
    menuLeft->setEasingCurve(QEasingCurve::InOutCubic);
    moveGroup->addAnimation(menuLeft);
    group->addAnimation(moveGroup);
    group->start();
    connect(group, &QSequentialAnimationGroup::finished, [this]() {
        content->setObjectName("body");
    });
}
Ejemplo n.º 2
0
Tank::Tank(QObject *parent)
    : QGLSceneNode(parent)
    , m_texture(0)
{
    QSequentialAnimationGroup *seq = new QSequentialAnimationGroup(this);
    QGraphicsScale3D *scale = new QGraphicsScale3D(this);
    addTransform(scale);
    QPropertyAnimation *anim = new QPropertyAnimation(scale, "scale");
    anim->setDuration(10000);
    anim->setStartValue(QVector3D(1.0f, 0.1f, 1.0f));
    anim->setEndValue(QVector3D(1.0f, 1.2f, 1.0f));
    anim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad));
    seq->addAnimation(anim);
    seq->addPause(2000);
    anim = new QPropertyAnimation(scale, "scale");
    anim->setDuration(10000);
    anim->setStartValue(QVector3D(1.0f, 1.2f, 1.0f));
    anim->setEndValue(QVector3D(1.0f, 0.1f, 1.0f));
    anim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad));
    seq->addAnimation(anim);
    seq->setLoopCount(-1);
    seq->start();

    addNode(tankObject());

    QGLMaterial *mat = qCreateFluid();
    m_texture = mat->texture();
    setMaterial(mat);
}
Ejemplo n.º 3
0
void DockModeWindow::setPrepareAddedToWindowManager() {
	m_prepareAddedToWm = true;
	if (G_LIKELY(s_dockGlow == 0)) {
		QString path(Settings::LunaSettings()->lunaSystemResourcesPath.c_str());
		path.append("/dockmode/dock-loading-glow.png");
		s_dockGlow = new QPixmap(path);
		if(s_dockGlow)
			s_dockGlowRefCount++;
		if (!s_dockGlow || s_dockGlow->isNull()) {
			g_critical("%s: Failed to load image '%s'", __PRETTY_FUNCTION__, qPrintable(path));
		}
	} else {
		s_dockGlowRefCount++;
	}

	ApplicationDescription* appDesc = static_cast<Window*>(this)->appDescription();
	int size = Settings::LunaSettings()->splashIconSize;
	m_icon.load(appDesc->splashIconName().c_str());
	if (!m_icon.isNull()) {
		// scale splash icon to fit the devices screen dimensions
		m_icon = m_icon.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
	}
	else {
		// just use the launcher icon
		m_icon = appDesc->getDefaultLaunchPoint()->icon();
		int newWidth = qMin((int)(m_icon.width()*1.5), size);
		int newHeight = qMin((int)(m_icon.height()*1.5), size);
		m_icon = m_icon.scaled(newWidth, newHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
	}
	

	// set up the pulsing animation
	QPropertyAnimation* pulseIn = new QPropertyAnimation(this, "pulseOpacity");
	pulseIn->setDuration(AS(cardLoadingPulseDuration));
	pulseIn->setEasingCurve(AS_CURVE(cardLoadingPulseCurve));
	pulseIn->setEndValue(1.0);

	QPropertyAnimation* pulseOut = new QPropertyAnimation(this, "pulseOpacity");
	pulseOut->setDuration(AS(cardLoadingPulseDuration));
	pulseOut->setEasingCurve(AS_CURVE(cardLoadingPulseCurve));
	pulseOut->setEndValue(0.0);

	QSequentialAnimationGroup* pulseGroup = new QSequentialAnimationGroup;
	pulseGroup->addAnimation(pulseIn);
	pulseGroup->addAnimation(pulseOut);
	pulseGroup->setLoopCount(-1);

	m_pulseAnimation.addPause(AS(cardLoadingTimeBeforeShowingPulsing));
	m_pulseAnimation.addAnimation(pulseGroup);

	m_loadingOverlayEnabled = true;
	m_pulseAnimation.start();

	update();
}
void MWidgetSlideAnimationPrivate::init()
{
    Q_Q(MWidgetSlideAnimation);

    direction = MWidgetSlideAnimation::In;

    QSequentialAnimationGroup *delayedAnimation = new QSequentialAnimationGroup;
    delay = new QPauseAnimation;
    positionAnimation = new QPropertyAnimation;
    positionAnimation->setPropertyName("pos");
    delayedAnimation->addAnimation(delay);
    delayedAnimation->addAnimation(positionAnimation);
    q->addAnimation(delayedAnimation);
    q->connect(delay, SIGNAL(finished()), SLOT(_q_onDelayFinished()));
}
Ejemplo n.º 5
0
void Unite::animationDeplacement(vector<Case *> chemin ) {
    this->setSelected(false);
     float decalageX,decalageY;
     Case* caseActu=chemin[0];
     QSequentialAnimationGroup *group = new QSequentialAnimationGroup();
     QSequentialAnimationGroup *animPm = new QSequentialAnimationGroup();
     QParallelAnimationGroup *groupPara = new QParallelAnimationGroup();

     QPointF OS = offset();
     int anim;
     int j=1;

     for (unsigned int i=1;i<chemin.size(); i++) {
         QPropertyAnimation *animation = new QPropertyAnimation(this, "offset");
         animation->setDuration(200);

         decalageX = (chemin[i]->getX()-caseActu->getX())*SIZE;
         decalageY = (chemin[i]->getY()-caseActu->getY())*SIZE;

         if (decalageX>0)
             anim=30;
         else if (decalageX<0)
             anim=20;
         else if (decalageY<0)
             anim=10;
         else if (decalageY>0)
             anim=0;

         QPropertyAnimation *animPix = new QPropertyAnimation(this, "pixmap");
         animPix->setDuration(200);
         animPix->setStartValue(anim);
         animPix->setEndValue(anim+7);
         animPm->addAnimation(animPix);

         animation->setStartValue(OS);
         OS=QPointF(OS.x()+decalageX,OS.y()+decalageY);
         animation->setEndValue(OS);
         group->addAnimation(animation);

         j++;
         caseActu=chemin[i];
     }

     groupPara->addAnimation(group);
     groupPara->addAnimation(animPm);
     groupPara->start();
     this->setSelected(true);
}
Ejemplo n.º 6
0
void QocViewWidget::rebuildChart()
{
	QPushButton *pb = qobject_cast<QPushButton *>(sender());
//	QParallelAnimationGroup *group = new QParallelAnimationGroup();
	QSequentialAnimationGroup *group = new QSequentialAnimationGroup();

	if (pb)
	{
		pb->setEnabled(false);
		connect(group, SIGNAL(finished()), this, SLOT(animationFinished()));
		connect(this, SIGNAL(animationEnded(bool)), pb, SLOT(setEnabled(bool)));
	}
	QList<QocAbstractChartItem *> items = m_chart->items(QocAbstractChart::ChartLayer);
	foreach(QocAbstractChartItem *item, items)
	{
		QocAbstractValueItem *i = qobject_cast<QocAbstractValueItem *>(item);
		if ( i )
		{
			QPropertyAnimation *anim = new QPropertyAnimation(i, "value", group);
			anim->setStartValue(0);
			anim->setEndValue(i->value());
			anim->setDuration(2000/items.size());
			group->addAnimation(anim);

//			i->blockSignals(true);
			i->setValue(0);
//			i->blockSignals(false);
		}
	}
Ejemplo n.º 7
0
void DiscountPage::setupItemAnimations()
{
    QState *smallState = new QState();
    QState *bigState = new QState();

    for (int i = 0; i < this->m_itemList.size(); i++) {
        smallState->assignProperty(this->m_itemList[i],"scale", 0);
        bigState->assignProperty(this->m_itemList[i],"scale",1);
    }

    QSequentialAnimationGroup *showItemGroup = new QSequentialAnimationGroup(this);
    for (int i = 0; i < this->m_itemList.size(); i++) {
        QPropertyAnimation *anim = new QPropertyAnimation(this->m_itemList[i], "scale", this);
        anim->setDuration(300);
        anim->setEasingCurve(QEasingCurve::OutBack);
        showItemGroup->addAnimation(anim);
    }

    QSignalTransition *trans = smallState->addTransition(this, SIGNAL(start()), bigState);
    trans->addAnimation(showItemGroup);
    connect(showItemGroup,SIGNAL(finished()),this,SLOT(startSelect()));

    trans = bigState->addTransition(this,SIGNAL(quitPage()),smallState);
    connect(smallState,SIGNAL(entered()),this,SLOT(closeSelect()));

    QStateMachine *states = new QStateMachine(this);
    states->addState(smallState);
    states->addState(bigState);
    states->setInitialState(smallState);

    states->start();
}
Ejemplo n.º 8
0
void Sprite::start(int loops)
{
    if(loops<0)loops=0;
    QMapIterator<QString, AnimationLine*> i(lines);
    QParallelAnimationGroup *pgroup = new QParallelAnimationGroup;

    while (i.hasNext())  {
        i.next();
        AnimationLine * line = i.value();
        const QByteArray &name = i.key().toLocal8Bit();
        QSequentialAnimationGroup *sgroup = new QSequentialAnimationGroup;

        QMapIterator<int,qreal> j(line->frames);

        while(j.hasNext())
        {
            j.next();

            QPropertyAnimation *trans = new QPropertyAnimation(this,name);
            trans->setStartValue(j.value());
            trans->setEasingCurve(line->easings[j.key()]);
            if(j.hasNext())
            {
                trans->setEndValue(j.peekNext().value());
                trans->setDuration(j.peekNext().key()-j.key());
            }
            else
            {
                trans->setEndValue(j.value());
                trans->setDuration(total_time - j.key());
            }
            sgroup->addAnimation(trans);
        }
        QPropertyAnimation *trans = new QPropertyAnimation(this,name);
        trans->setEndValue(line->frames[0]);
        trans->setDuration(resetTime);
        sgroup->addAnimation(trans);

        pgroup->addAnimation(sgroup);
    }

    if(--loops)connect(pgroup,SIGNAL(finished()),this,SLOT(start(int)));
    else connect(pgroup,SIGNAL(finished()),this,SLOT(deleteLater()));
Ejemplo n.º 9
0
void TFutureProgressPrivate::_q_FadeAway()
   {
      Q_Q(TFutureProgress);
      FaderWidget->raise();
      QSequentialAnimationGroup *Group = new QSequentialAnimationGroup(q);
      QPropertyAnimation *Animation = new QPropertyAnimation(FaderWidget, "Opacity");
      Animation->setDuration(600);
      Animation->setEndValue(1.0);
      Group->addAnimation(Animation);

      Animation = new QPropertyAnimation(q, "maximumHeight");
      Animation->setDuration(120);
      Animation->setEasingCurve(QEasingCurve::InCurve);
      Animation->setStartValue(q->sizeHint().height());
      Animation->setEndValue(0.0);
      Group->addAnimation(Animation);
      Group->start(QAbstractAnimation::DeleteWhenStopped);

      QObject::connect(Group, SIGNAL(finished()), q, SIGNAL(RemoveMe()));
   }
Ejemplo n.º 10
0
void IndicatorItem::doAnimation() {
    QSequentialAnimationGroup *group = new QSequentialAnimationGroup(this);

    QPropertyAnimation *animation = new QPropertyAnimation(this, "finish");
    animation->setEndValue(real_finish);
    animation->setEasingCurve(QEasingCurve::OutCubic);
    animation->setDuration(500);

    QPropertyAnimation *pause = new QPropertyAnimation(this, "opacity");
    pause->setEndValue(0);
    pause->setEasingCurve(QEasingCurve::InQuart);
    pause->setDuration(600);

    group->addAnimation(animation);
    group->addAnimation(pause);

    group->start(QAbstractAnimation::DeleteWhenStopped);

    connect(group, &QSequentialAnimationGroup::finished, this, &IndicatorItem::deleteLater);
}
Ejemplo n.º 11
0
void Creator::LogInToTest(QString user_name)
{
    testwidget->SetUserName(user_name);
    testwidget->upDateScores();

    TestWindow->show();

    QParallelAnimationGroup* parallelWindow = WindowAnimation(LogInWindow , TestWindow , LogState , TestState);
    QParallelAnimationGroup* parallelButton = ButtonAnimation(testwidget->but, 10);

    QParallelAnimationGroup* parallel = new QParallelAnimationGroup;
    parallel->addAnimation(parallelWindow);

    QSequentialAnimationGroup* sequential = new QSequentialAnimationGroup;
    sequential->addAnimation(parallel);
    sequential->addPause(0);
    sequential->addAnimation(parallelButton);

    sequential->start();
    sleep(1000);

    LogInWindow->close();
}
Ejemplo n.º 12
0
void ContactsViewDelegate::startAlertAnimation()
{
    if (!m_alertAnimation)
    {
        QSequentialAnimationGroup *ag = new QSequentialAnimationGroup(this);
        m_alertAnimation = ag;

        QPropertyAnimation *aIn = new QPropertyAnimation(this, "alertOpacity");
        aIn->setEndValue(qreal(1));
        aIn->setEasingCurve(QEasingCurve::OutQuad);
        aIn->setDuration(750);

        QPropertyAnimation *aOut = new QPropertyAnimation(this, "alertOpacity");
        aOut->setEndValue(qreal(0.2));
        aOut->setEasingCurve(QEasingCurve::InQuad);
        aOut->setDuration(750);

        ag->addAnimation(aIn);
        ag->addPause(150);
        ag->addAnimation(aOut);
        ag->setLoopCount(-1);
        ag->start();
    }
}
Ejemplo n.º 13
0
void FutureProgressPrivate::fadeAway()
{
    m_isFading = true;

    QGraphicsOpacityEffect *opacityEffect = new QGraphicsOpacityEffect;
    opacityEffect->setOpacity(1.);
    m_q->setGraphicsEffect(opacityEffect);

    QSequentialAnimationGroup *group = new QSequentialAnimationGroup(this);
    QPropertyAnimation *animation = new QPropertyAnimation(opacityEffect, "opacity");
    animation->setDuration(StyleHelper::progressFadeAnimationDuration);
    animation->setEndValue(0.);
    group->addAnimation(animation);
    animation = new QPropertyAnimation(m_q, "maximumHeight");
    animation->setDuration(120);
    animation->setEasingCurve(QEasingCurve::InCurve);
    animation->setStartValue(m_q->sizeHint().height());
    animation->setEndValue(0.0);
    group->addAnimation(animation);

    connect(group, &QAbstractAnimation::finished, m_q, &FutureProgress::removeMe);
    group->start(QAbstractAnimation::DeleteWhenStopped);
    emit m_q->fadeStarted();
}
Ejemplo n.º 14
0
void AVLTree::LevelOrder()
{
    QSequentialAnimationGroup *group = new QSequentialAnimationGroup;
    QQueue<TreeNode*> q;
    q.push_back(root);
    while (!q.empty())
    {
        TreeNode *node = q.front();
        q.pop_front();
        if (node == NULL) continue;
        group->addAnimation(node->getPopAnim());
        q.push_back(node->Lson);
        q.push_back(node->Rson);
    }
    group->start(QAbstractAnimation::DeleteWhenStopped);
}
Ejemplo n.º 15
0
void Creator::TestToLogIn()
{
    singleWindow->show();

    QParallelAnimationGroup* parallelWindow = WindowToMenuAnimation(TestWindow , singleWindow , TestState , SingleState );

    QParallelAnimationGroup* parallel = new QParallelAnimationGroup;
    parallel->addAnimation(parallelWindow);

    QSequentialAnimationGroup* sequential = new QSequentialAnimationGroup;
    sequential->addAnimation(parallel);

    sequential->start();
    sleep(1000);
    for ( int i = 0 ; i < 10 ; i++ ){
        testwidget->but[i]->setProperty("pos",QPointF(testwidget->but[9]->x(),testwidget->but[9]->y()));
    }

    TestWindow->close();
}
Ejemplo n.º 16
0
	void GlanceShower::Start ()
	{
		if (!TabWidget_)
		{
			qWarning () << Q_FUNC_INFO
				<< "no tab widget set";
			return;
		}

		int count = TabWidget_->count ();
		if (count < 2)
			return;

		QSequentialAnimationGroup *animGroup = new QSequentialAnimationGroup;

		int sqr = std::sqrt ((double)count);
		int rows = sqr;
		int cols = sqr;
		if (rows * cols < count)
			++cols;
		if (rows * cols < count)
			++rows;

		QRect screenGeom = QApplication::desktop ()->
				screenGeometry (Core::Instance ().GetReallyMainWindow ());
		int width = screenGeom.width ();
		int height = screenGeom.height ();

		int singleW = width / cols;
		int singleH = height / rows;

		int wW = singleW * 4 / 5;
		int wH = singleH * 4 / 5;

		qreal scaleFactor = 0;
		QSize sSize;

		int animLength = 500 / (sqr);

		QProgressDialog pg;
		pg.setMinimumDuration (1000);
		pg.setRange (0, count);

		for (int row = 0; row < rows; ++row)
			for (int column = 0;
					column < cols && column + row * cols < count;
					++column)
			{
				int idx = column + row * cols;
				pg.setValue (idx);
				QWidget *w = TabWidget_->widget (idx);

				if (!sSize.isValid ())
					sSize = w->size () / 2;
				if (sSize != w->size ())
					w->resize (sSize * 2);

				if (!scaleFactor)
					scaleFactor = std::min (static_cast<qreal> (wW) / sSize.width (),
							static_cast<qreal> (wH) / sSize.height ());

				QPixmap pixmap (sSize * 2);
				w->render (&pixmap);
				pixmap = pixmap.scaled (sSize,
						Qt::IgnoreAspectRatio, Qt::SmoothTransformation);

				{
					QPainter p (&pixmap);
					QPen pen (Qt::black);
					pen.setWidth (2 / scaleFactor + 1);
					p.setPen (pen);
					p.drawRect (QRect (QPoint (0, 0), sSize));
				}

				GlanceItem *item = new GlanceItem (pixmap);
				item->SetIndex (idx);
				connect (item,
						SIGNAL (clicked (int)),
						this,
						SLOT (handleClicked (int)));

				Scene_->addItem (item);
				item->setTransformOriginPoint (sSize.width () / 2, sSize.height () / 2);
				item->setScale (scaleFactor);
				item->SetIdealScale (scaleFactor);
				item->setOpacity (0);
				item->moveBy (column * singleW, row * singleH);

				QParallelAnimationGroup *pair = new QParallelAnimationGroup;

				QPropertyAnimation *posAnim = new QPropertyAnimation (item, "Pos");
				posAnim->setDuration (animLength);
				posAnim->setStartValue (QPointF (0, 0));
				posAnim->setEndValue (QPointF (column * singleW, row * singleH));
				posAnim->setEasingCurve (QEasingCurve::OutSine);
				pair->addAnimation (posAnim);

				QPropertyAnimation *opacityAnim = new QPropertyAnimation (item, "Opacity");
				opacityAnim->setDuration (animLength);
				opacityAnim->setStartValue (0.);
				opacityAnim->setEndValue (1.);
				pair->addAnimation (opacityAnim);

				animGroup->addAnimation (pair);
			}

		setScene (Scene_);

		setGeometry (screenGeom);
		animGroup->start ();
		show ();
	}
Ejemplo n.º 17
0
//! [0]
PadNavigator::PadNavigator(const QSize &size, QWidget *parent)
    : QGraphicsView(parent)
{
//! [0]
//! [1]
    // Splash item
    SplashItem *splash = new SplashItem;
    splash->setZValue(1);
//! [1]

//! [2]
    // Pad item
    FlippablePad *pad = new FlippablePad(size);
    QGraphicsRotation *flipRotation = new QGraphicsRotation(pad);
    QGraphicsRotation *xRotation = new QGraphicsRotation(pad);
    QGraphicsRotation *yRotation = new QGraphicsRotation(pad);
    flipRotation->setAxis(Qt::YAxis);
    xRotation->setAxis(Qt::YAxis);
    yRotation->setAxis(Qt::XAxis);
    pad->setTransformations(QList<QGraphicsTransform *>()
                            << flipRotation
                            << xRotation << yRotation);
//! [2]

//! [3]
    // Back (proxy widget) item
    QGraphicsProxyWidget *backItem = new QGraphicsProxyWidget(pad);
    QWidget *widget = new QWidget;
    form.setupUi(widget);
    form.hostName->setFocus();
    backItem->setWidget(widget);
    backItem->setVisible(false);
    backItem->setFocus();
    backItem->setCacheMode(QGraphicsItem::ItemCoordinateCache);
    const QRectF r = backItem->rect();
    backItem->setTransform(QTransform()
                           .rotate(180, Qt::YAxis)
                           .translate(-r.width()/2, -r.height()/2));
//! [3]

//! [4]
    // Selection item
    RoundRectItem *selectionItem = new RoundRectItem(QRectF(-60, -60, 120, 120), Qt::gray, pad);
    selectionItem->setZValue(0.5);
//! [4]

//! [5]
    // Splash animations
    QPropertyAnimation *smoothSplashMove = new QPropertyAnimation(splash, "y");
    QPropertyAnimation *smoothSplashOpacity = new QPropertyAnimation(splash, "opacity");
    smoothSplashMove->setEasingCurve(QEasingCurve::InQuad);
    smoothSplashMove->setDuration(250);
    smoothSplashOpacity->setDuration(250);
//! [5]

//! [6]
    // Selection animation
    QPropertyAnimation *smoothXSelection = new QPropertyAnimation(selectionItem, "x");
    QPropertyAnimation *smoothYSelection = new QPropertyAnimation(selectionItem, "y");
    QPropertyAnimation *smoothXRotation = new QPropertyAnimation(xRotation, "angle");
    QPropertyAnimation *smoothYRotation = new QPropertyAnimation(yRotation, "angle");
    smoothXSelection->setDuration(125);
    smoothYSelection->setDuration(125);
    smoothXRotation->setDuration(125);
    smoothYRotation->setDuration(125);
    smoothXSelection->setEasingCurve(QEasingCurve::InOutQuad);
    smoothYSelection->setEasingCurve(QEasingCurve::InOutQuad);
    smoothXRotation->setEasingCurve(QEasingCurve::InOutQuad);
    smoothYRotation->setEasingCurve(QEasingCurve::InOutQuad);
//! [6]

//! [7]
    // Flip animation setup
    QPropertyAnimation *smoothFlipRotation = new QPropertyAnimation(flipRotation, "angle");
    QPropertyAnimation *smoothFlipScale = new QPropertyAnimation(pad, "scale");
    QPropertyAnimation *smoothFlipXRotation = new QPropertyAnimation(xRotation, "angle");
    QPropertyAnimation *smoothFlipYRotation = new QPropertyAnimation(yRotation, "angle");
    QParallelAnimationGroup *flipAnimation = new QParallelAnimationGroup(this);
    smoothFlipScale->setDuration(500);
    smoothFlipRotation->setDuration(500);
    smoothFlipXRotation->setDuration(500);
    smoothFlipYRotation->setDuration(500);
    smoothFlipScale->setEasingCurve(QEasingCurve::InOutQuad);
    smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad);
    smoothFlipXRotation->setEasingCurve(QEasingCurve::InOutQuad);
    smoothFlipYRotation->setEasingCurve(QEasingCurve::InOutQuad);
    smoothFlipScale->setKeyValueAt(0, qvariant_cast<qreal>(1.0));
    smoothFlipScale->setKeyValueAt(0.5, qvariant_cast<qreal>(0.7));
    smoothFlipScale->setKeyValueAt(1, qvariant_cast<qreal>(1.0));
    flipAnimation->addAnimation(smoothFlipRotation);
    flipAnimation->addAnimation(smoothFlipScale);
    flipAnimation->addAnimation(smoothFlipXRotation);
    flipAnimation->addAnimation(smoothFlipYRotation);
//! [7]

//! [8]
    // Flip animation delayed property assignment
    QSequentialAnimationGroup *setVariablesSequence = new QSequentialAnimationGroup;
    QPropertyAnimation *setFillAnimation = new QPropertyAnimation(pad, "fill");
    QPropertyAnimation *setBackItemVisibleAnimation = new QPropertyAnimation(backItem, "visible");
    QPropertyAnimation *setSelectionItemVisibleAnimation = new QPropertyAnimation(selectionItem, "visible");
    setFillAnimation->setDuration(0);
    setBackItemVisibleAnimation->setDuration(0);
    setSelectionItemVisibleAnimation->setDuration(0);
    setVariablesSequence->addPause(250);
    setVariablesSequence->addAnimation(setBackItemVisibleAnimation);
    setVariablesSequence->addAnimation(setSelectionItemVisibleAnimation);
    setVariablesSequence->addAnimation(setFillAnimation);
    flipAnimation->addAnimation(setVariablesSequence);
//! [8]

//! [9]
    // Build the state machine
    QStateMachine *stateMachine = new QStateMachine(this);
    QState *splashState = new QState(stateMachine);
    QState *frontState = new QState(stateMachine);
    QHistoryState *historyState = new QHistoryState(frontState);
    QState *backState = new QState(stateMachine);
//! [9]
//! [10]
    frontState->assignProperty(pad, "fill", false);
    frontState->assignProperty(splash, "opacity", 0.0);
    frontState->assignProperty(backItem, "visible", false);
    frontState->assignProperty(flipRotation, "angle", qvariant_cast<qreal>(0.0));
    frontState->assignProperty(selectionItem, "visible", true);
    backState->assignProperty(pad, "fill", true);
    backState->assignProperty(backItem, "visible", true);
    backState->assignProperty(xRotation, "angle", qvariant_cast<qreal>(0.0));
    backState->assignProperty(yRotation, "angle", qvariant_cast<qreal>(0.0));
    backState->assignProperty(flipRotation, "angle", qvariant_cast<qreal>(180.0));
    backState->assignProperty(selectionItem, "visible", false);
    stateMachine->addDefaultAnimation(smoothXRotation);
    stateMachine->addDefaultAnimation(smoothYRotation);
    stateMachine->addDefaultAnimation(smoothXSelection);
    stateMachine->addDefaultAnimation(smoothYSelection);
    stateMachine->setInitialState(splashState);
//! [10]

//! [11]
    // Transitions
    QEventTransition *anyKeyTransition = new QEventTransition(this, QEvent::KeyPress, splashState);
    anyKeyTransition->setTargetState(frontState);
    anyKeyTransition->addAnimation(smoothSplashMove);
    anyKeyTransition->addAnimation(smoothSplashOpacity);
//! [11]

//! [12]
    QKeyEventTransition *enterTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                   Qt::Key_Enter, backState);
    QKeyEventTransition *returnTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                    Qt::Key_Return, backState);
    QKeyEventTransition *backEnterTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                       Qt::Key_Enter, frontState);
    QKeyEventTransition *backReturnTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                        Qt::Key_Return, frontState);
    enterTransition->setTargetState(historyState);
    returnTransition->setTargetState(historyState);
    backEnterTransition->setTargetState(backState);
    backReturnTransition->setTargetState(backState);
    enterTransition->addAnimation(flipAnimation);
    returnTransition->addAnimation(flipAnimation);
    backEnterTransition->addAnimation(flipAnimation);
    backReturnTransition->addAnimation(flipAnimation);
//! [12]

//! [13]
    // Create substates for each icon; store in temporary grid.
    int columns = size.width();
    int rows = size.height();
    QVector< QVector< QState * > > stateGrid;
    stateGrid.resize(rows);
    for (int y = 0; y < rows; ++y) {
        stateGrid[y].resize(columns);
        for (int x = 0; x < columns; ++x)
            stateGrid[y][x] = new QState(frontState);
    }
    frontState->setInitialState(stateGrid[0][0]);
    selectionItem->setPos(pad->iconAt(0, 0)->pos());
//! [13]

//! [14]
    // Enable key navigation using state transitions
    for (int y = 0; y < rows; ++y) {
        for (int x = 0; x < columns; ++x) {
            QState *state = stateGrid[y][x];
            QKeyEventTransition *rightTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                           Qt::Key_Right, state);
            QKeyEventTransition *leftTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                          Qt::Key_Left, state);
            QKeyEventTransition *downTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                          Qt::Key_Down, state);
            QKeyEventTransition *upTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                        Qt::Key_Up, state);
            rightTransition->setTargetState(stateGrid[y][(x + 1) % columns]);
            leftTransition->setTargetState(stateGrid[y][((x - 1) + columns) % columns]);
            downTransition->setTargetState(stateGrid[(y + 1) % rows][x]);
            upTransition->setTargetState(stateGrid[((y - 1) + rows) % rows][x]);
//! [14]
//! [15]
            RoundRectItem *icon = pad->iconAt(x, y);
            state->assignProperty(xRotation, "angle", -icon->x() / 6.0);
            state->assignProperty(yRotation, "angle", icon->y() / 6.0);
            state->assignProperty(selectionItem, "x", icon->x());
            state->assignProperty(selectionItem, "y", icon->y());
            frontState->assignProperty(icon, "visible", true);
            backState->assignProperty(icon, "visible", false);

            QPropertyAnimation *setIconVisibleAnimation = new QPropertyAnimation(icon, "visible");
            setIconVisibleAnimation->setDuration(0);
            setVariablesSequence->addAnimation(setIconVisibleAnimation);
        }
    }
//! [15]

//! [16]
    // Scene
    QGraphicsScene *scene = new QGraphicsScene(this);
    scene->setBackgroundBrush(QPixmap(":/images/blue_angle_swirl.jpg"));
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    scene->addItem(pad);
    scene->setSceneRect(scene->itemsBoundingRect());
    setScene(scene);
//! [16]

//! [17]
    // Adjust splash item to scene contents
    const QRectF sbr = splash->boundingRect();
    splash->setPos(-sbr.width() / 2, scene->sceneRect().top() - 2);
    frontState->assignProperty(splash, "y", splash->y() - 100.0);
    scene->addItem(splash);
//! [17]

//! [18]
    // View
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setMinimumSize(50, 50);
    setViewportUpdateMode(FullViewportUpdate);
    setCacheMode(CacheBackground);
    setRenderHints(QPainter::Antialiasing
                   | QPainter::SmoothPixmapTransform
                   | QPainter::TextAntialiasing);
#ifndef QT_NO_OPENGL
    setViewport(new QOpenGLWidget);
#endif

    stateMachine->start();
//! [18]
}
Ejemplo n.º 18
0
void Barbel::Scene::initScene()
{
    //Setup Framegraph
    if (m_frameGraph == Q_NULLPTR)
        m_frameGraph = new Qt3D::QFrameGraph();
    if (m_forwardRenderer == Q_NULLPTR)
        m_forwardRenderer = new Qt3D::QForwardRenderer();

    m_forwardRenderer->setClearColor(Qt::black);
    m_frameGraph->setActiveFrameGraph(m_forwardRenderer);
    m_rootEntity->addComponent(m_frameGraph);

    //Test Objects
    Barbel::Player *player = new Barbel::Player(m_rootEntity);
    player->setTranslation(QVector3D(0.0f, 0.0f, 0.0f));
    setActiveCamera(player->camera());
    activeCamera()->lens()->setAspectRatio(m_cameraAspectRatio);


    QVector3D startPostion(0.0f, 0.0f, 0.0f);
    QVector3D secondPosition(10.0f, 10.0f, 10.0f);
    QVector3D thirdPosition(-10.0f, 0.0f, 10.0f);

    QVector3D startAngles(0.0f, 0.0f, 0.0f);
    QVector3D secondAngles(45.0f, 150.0f, 0.0f);
    QVector3D thirdAngles(0.0f, 200.0f, 0.0f);
    QVector3D finalAngles(0.0f, 360.0f, 0.0f);


    QSequentialAnimationGroup *animationGroup = new QSequentialAnimationGroup(this);

    QParallelAnimationGroup *parallelAnimationGroup1 = new QParallelAnimationGroup(this);

    QPropertyAnimation *animation = new QPropertyAnimation(player, "translation", this);
    animation->setDuration(5000);
    animation->setStartValue(startPostion);
    animation->setEndValue(secondPosition);
    parallelAnimationGroup1->addAnimation(animation);

    QPropertyAnimation *rotationAnimation = new QPropertyAnimation(player, "rotation", this);
    rotationAnimation->setDuration(5000);
    rotationAnimation->setStartValue(startAngles);
    rotationAnimation->setEndValue(secondAngles);
    parallelAnimationGroup1->addAnimation(rotationAnimation);

    animationGroup->addAnimation(parallelAnimationGroup1);

    QParallelAnimationGroup *parallelAnimationGroup2 = new QParallelAnimationGroup(this);

    animation = new QPropertyAnimation(player, "translation", this);
    animation->setDuration(5000);
    animation->setStartValue(secondPosition);
    animation->setEndValue(thirdPosition);
    parallelAnimationGroup2->addAnimation(animation);

    rotationAnimation = new QPropertyAnimation(player, "rotation", this);
    rotationAnimation->setDuration(5000);
    rotationAnimation->setStartValue(secondAngles);
    rotationAnimation->setEndValue(thirdAngles);
    parallelAnimationGroup2->addAnimation(rotationAnimation);

    animationGroup->addAnimation(parallelAnimationGroup2);
    QParallelAnimationGroup *parallelAnimationGroup3 = new QParallelAnimationGroup(this);

    animation = new QPropertyAnimation(player, "translation", this);
    animation->setDuration(5000);
    animation->setStartValue(thirdPosition);
    animation->setEndValue(startPostion);
    parallelAnimationGroup3->addAnimation(animation);

    rotationAnimation = new QPropertyAnimation(player, "rotation", this);
    rotationAnimation->setDuration(5000);
    rotationAnimation->setStartValue(thirdAngles);
    rotationAnimation->setEndValue(finalAngles);
    parallelAnimationGroup3->addAnimation(rotationAnimation);

    animationGroup->addAnimation(parallelAnimationGroup3);
    animationGroup->setLoopCount(-1);
    animationGroup->start();

    //Test Cubes
    Qt3D::QPhongMaterial *phongMaterial1 = new Qt3D::QPhongMaterial();
    phongMaterial1->setDiffuse(QColor(94, 141, 25));
    phongMaterial1->setSpecular(Qt::white);
    Qt3D::QPhongMaterial *phongMaterial2 = new Qt3D::QPhongMaterial();
    phongMaterial2->setDiffuse(QColor(129, 23, 71));
    phongMaterial2->setSpecular(Qt::white);

    for (int z = -5; z < 5; z++) {
        for (int y = -5; y < 5; y++) {
            for (int x = -5; x < 5; x++) {
                float xSize = (rand() % 10000) / 10000.0;
                float ySize = (rand() % 10000) / 10000.0;
                float zSize = (rand() % 10000) / 10000.0;
                Barbel::TestCube *cube = new TestCube(QVector3D(x, y, z), QVector3D(xSize, ySize, zSize), m_rootEntity);
                if (y % 2)
                    cube->addComponent(phongMaterial1);
                else
                    cube->addComponent(phongMaterial2);
            }
        }
    }
}
void slideShowEngine::start()
{
int x,y;
QPixmap pix;
QModelIndex index;
QVariant val;
node itemNode;
QPropertyAnimation *enterAnimation,*displayAnimation,*exitAnimation;
Pixmap *item;
effect e;
QParallelAnimationGroup *parallelAnim;
QSequentialAnimationGroup *seqAnim;



    if(m_groupAnimation->state()==QAbstractAnimation::Paused)
        resume();

    if(m_groupAnimation->state()==QAbstractAnimation::Running)
        return;

    QList <QGraphicsView *> views=m_scene->views();
    m_size=views.at(0)->size();

    m_scene->clear();
    for(int i=0;i<m_sequence->rowCount();i++)
    {

        index=m_sequence->index(i);
        if(index.isValid())
        {
            m_scene->setSceneRect(0.0,0.0,qreal(m_size.width()),qreal(m_size.height())); // come fare per full screen size?
            qDebug() << "index valid";
            val=index.data(Qt::UserRole);
            itemNode=val.value<node>();
            qDebug() << "pix:" << itemNode.nodeName();
            pix=itemNode.nodePixmap();

            if(pix.width()>m_size.width() || pix.height()>m_size.height())
                pix=pix.scaled(m_size,Qt::KeepAspectRatio,Qt::SmoothTransformation);
            item = new Pixmap(pix);
            m_PixmapList.append(item); // serve questa lista?
            if(m_size.width()>pix.width())
            {
                x=(m_size.width()-pix.width())/2;
            }
            else
            {
                x=0;
            }


            if(m_size.height()>pix.height())
            {
                y=(m_size.height()-pix.height())/2;
            }
            else
            {
                y=0;
            }

            item->setPos(qreal(x), qreal(y));


            qDebug() <<qreal(m_sequence->rowCount()-i);
            item->setZValue(qreal(m_sequence->rowCount()-i));
            //m_scene->addItem(item);

            e=itemNode.enterEffect();
            enterAnimation = new QPropertyAnimation(item, e.effectType().toAscii());
            itemNode.setEnterAnimation(enterAnimation,item);
            connect(enterAnimation,SIGNAL(finished()),this,SLOT(animEnterFinished()));

            e=itemNode.displayEffect();
            displayAnimation = new QPropertyAnimation(item, e.effectType().toAscii());
            itemNode.setDisplayAnimation(displayAnimation,item);
            connect(displayAnimation,SIGNAL(finished()),this,SLOT(animDisplayFinished()));

            e=itemNode.exitEffect();
            exitAnimation = new QPropertyAnimation(item, e.effectType().toAscii());
            itemNode.setExitAnimation(exitAnimation,item);
            connect(exitAnimation,SIGNAL(finished()),this,SLOT(animExitFinished()));


            //parallelAnim= new QParallelAnimationGroup;

            //parallelAnim->addAnimation(exitAnimation);

            seqAnim = new QSequentialAnimationGroup;

            seqAnim->addAnimation(enterAnimation);
            seqAnim->addAnimation(displayAnimation);
            seqAnim->addAnimation(exitAnimation);


            qDebug() << "add all animation";

            m_groupAnimation->addAnimation(seqAnim);
            connect(m_groupAnimation,SIGNAL(finished()),this,SLOT(endOfSlideShow()));

            //group->addAnimation(animation4);

        } // end index is valid

    } // end for

    qDebug() << "start group";
    m_currentSlideIndex=0;
    m_scene->addItem(m_PixmapList.at(m_currentSlideIndex));
    m_groupAnimation->start();           
    //m_timerId=startTimer(2);
    //m_slideShowClock.restart();



    int width=640;
    int height=480;
    int bitrate=1000000;
    int gop = 20;


    // Create the encoder
    //QVideoEncoder encoder;
    //encoder.createFile("test.avi",width,height,bitrate,gop);




}
Ejemplo n.º 20
0
	void init()
	{
		Q_Q(KFlipWidget);
		flipRotation = new QGraphicsRotation(q);
		xRotation = new QGraphicsRotation(q);
		yRotation = new QGraphicsRotation(q);

		flipRotation->setAxis(Qt::YAxis);
		xRotation->setAxis(Qt::YAxis);
		yRotation->setAxis(Qt::XAxis);
		q->setTransformations(QList<QGraphicsTransform *>() << flipRotation << xRotation << yRotation);

		front = new KWidget(q);
		back = new KWidget(q);

		QSizeF s = q->size();
		back->setTransform(QTransform().rotate(180, Qt::YAxis).translate(-s.width(), 0));

		smoothFlipRotation = new QPropertyAnimation(flipRotation, "angle");
		smoothFlipScale = new QPropertyAnimation(q, "scale");
		smoothFlipXRotation = new QPropertyAnimation(xRotation, "angle");
		smoothFlipYRotation = new QPropertyAnimation(yRotation, "angle");
		flipAnimation = new QParallelAnimationGroup(q);

		smoothFlipScale->setDuration(500);
		smoothFlipRotation->setDuration(500);
		smoothFlipXRotation->setDuration(500);
		smoothFlipYRotation->setDuration(500);
		smoothFlipScale->setEasingCurve(QEasingCurve::InOutQuad);
		smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad);
		smoothFlipXRotation->setEasingCurve(QEasingCurve::InOutQuad);
		smoothFlipYRotation->setEasingCurve(QEasingCurve::InOutQuad);
		smoothFlipScale->setKeyValueAt(0, qVariantValue<qreal>(1.0));
		smoothFlipScale->setKeyValueAt(0.5, qVariantValue<qreal>(0.7));
		smoothFlipScale->setKeyValueAt(1, qVariantValue<qreal>(1.0));

		flipAnimation->addAnimation(smoothFlipRotation);
		flipAnimation->addAnimation(smoothFlipScale);
		flipAnimation->addAnimation(smoothFlipXRotation);
		flipAnimation->addAnimation(smoothFlipYRotation);


		// Flip animation delayed property assignment
		QSequentialAnimationGroup *setVariablesSequence = new QSequentialAnimationGroup;
		QPropertyAnimation *setBackItemVisibleAnimation = new QPropertyAnimation(back, "visible");
		QPropertyAnimation *setSelectionItemVisibleAnimation = new QPropertyAnimation(front, "visible");
		setBackItemVisibleAnimation->setDuration(0);
		setSelectionItemVisibleAnimation->setDuration(0);
		setVariablesSequence->addPause(250);
		setVariablesSequence->addAnimation(setBackItemVisibleAnimation);
		setVariablesSequence->addAnimation(setSelectionItemVisibleAnimation);
		flipAnimation->addAnimation(setVariablesSequence);

		// Build the state machine
		stateMachine = new QStateMachine(q);
		frontState = new QState(stateMachine);
		backState = new QState(stateMachine);

		frontState->assignProperty(back, "visible", false);
		frontState->assignProperty(flipRotation, "angle", qVariantValue<qreal>(0.0));
		frontState->assignProperty(front, "visible", true);

		backState->assignProperty(back, "visible", true);
		backState->assignProperty(xRotation, "angle", qVariantValue<qreal>(0.0));
		backState->assignProperty(yRotation, "angle", qVariantValue<qreal>(0.0));
		backState->assignProperty(flipRotation, "angle", qVariantValue<qreal>(180.0));
		backState->assignProperty(front, "visible", false);

		stateMachine->setInitialState(frontState);

		frontTransition = new QSignalTransition(q, SIGNAL(activeBack()), frontState);
		backTransition = new QSignalTransition(q, SIGNAL(activeFront()), backState);
		frontTransition->addAnimation(flipAnimation);
		backTransition->addAnimation(flipAnimation);
		frontTransition->setTargetState(backState);
		backTransition->setTargetState(frontState);

		bool bok = QObject::connect(flipAnimation, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)), q, SLOT(on_animation_stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
		bool bok1 = QObject::connect(flipAnimation, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)), q, SLOT(on_animation_stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));

		stateMachine->start();
	}