4 AppUI::AppUI(QGraphicsItem
*parent
): QGraphicsWidget( parent
),
7 mLayout( 0 ), mFlipLayout( 0 ),
11 setFlag(QGraphicsItem::ItemIsMovable
, true);
12 setAcceptTouchEvents(true);
13 setAcceptedMouseButtons( Qt::LeftButton
);
16 void AppUI:: buildWorld() {
18 mLayout
= new QGraphicsLinearLayout( Qt::Vertical
, this );
19 mGraphicsWidget
= new QGraphicsWidget(this);
20 mGraphicsWidget
->resize(300, 400);
21 mGraphicsWidget
->setAcceptedMouseButtons( Qt::LeftButton
);
22 mGraphicsWidget
->setAcceptTouchEvents(true);
24 mFlipLayout
= new QGraphicsLinearLayout(Qt::Vertical
, mGraphicsWidget
);
26 QWidget
*front
= new QWidget();
27 toBackButton
= new QPushButton("To Back");
28 //QObject::connect(toBackButton, SIGNAL(clicked()), this, SLOT(makeVisible()));
29 toBackButton
->setStyleSheet("background: pink");
31 QVBoxLayout
*vbox
= new QVBoxLayout(front
);
32 vbox
->addWidget(toBackButton
);
35 QGraphicsProxyWidget
*stackProxy1
= new QGraphicsProxyWidget();
36 stackProxy1
->setWidget( front
);
38 mFlipLayout
->addItem(stackProxy1
);
39 mLayout
->addItem( mGraphicsWidget
);
41 previousDim
= new QRectF( geometry() );
45 void AppUI::mousePressEvent ( QGraphicsSceneMouseEvent
* event
)
47 KineticScrolling::mousePressEvent( event
);
48 QGraphicsItem::mousePressEvent( event
);
51 void AppUI::mouseMoveEvent( QGraphicsSceneMouseEvent
*event
)
53 KineticScrolling::mouseMoveEvent( event
);
54 QGraphicsItem::mouseMoveEvent( event
);
57 void AppUI::mouseReleaseEvent( QGraphicsSceneMouseEvent
*event
)
59 KineticScrolling::mouseReleaseEvent( event
);
60 QGraphicsItem::mouseReleaseEvent( event
);
61 qDebug()<<"atual:"<<geometry().y()<<" new:"<<movement();
62 animation(duration(), geometry().y(), geometry().y() - movement());
65 void AppUI::animation(int duration
, qreal startValue
, qreal endValue
)
67 QPropertyAnimation
*anim1
= new QPropertyAnimation(this, "y");
68 anim1
->setEasingCurve(QEasingCurve::OutQuad
);
69 anim1
->setDuration(2*duration
);
70 anim1
->setStartValue(startValue
);
71 anim1
->setEndValue(endValue
);
73 qDebug()<<"duration:"<<duration
;