summaryrefslogtreecommitdiffstats
path: root/WebKitTools/QtLauncher
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/QtLauncher')
-rw-r--r--WebKitTools/QtLauncher/main.cpp30
-rw-r--r--WebKitTools/QtLauncher/webview.cpp47
-rw-r--r--WebKitTools/QtLauncher/webview.h23
3 files changed, 96 insertions, 4 deletions
diff --git a/WebKitTools/QtLauncher/main.cpp b/WebKitTools/QtLauncher/main.cpp
index c725c2f..1203ce7 100644
--- a/WebKitTools/QtLauncher/main.cpp
+++ b/WebKitTools/QtLauncher/main.cpp
@@ -133,6 +133,8 @@ private:
WebInspector* inspector;
QAction* formatMenuAction;
+ QAction* flipAnimated;
+ QAction* flipYAnimated;
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
QList<QTouchEvent::TouchPoint> touchPoints;
@@ -461,6 +463,13 @@ void LauncherWindow::initializeView(bool useGraphicsView)
if (gShowFrameRate)
view->enableFrameRateMeasurement();
page()->settings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, gUseCompositing);
+
+ if (flipAnimated)
+ connect(flipAnimated, SIGNAL(triggered()), view, SLOT(animatedFlip()));
+
+ if (flipYAnimated)
+ connect(flipYAnimated, SIGNAL(triggered()), view, SLOT(animatedYFlip()));
+
m_view = view;
}
@@ -540,13 +549,26 @@ void LauncherWindow::setupUI()
touchMockAction->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_T));
#endif
- QAction* toggleAcceleratedCompositing = toolsMenu->addAction("Toggle Accelerated Compositing", this, SLOT(toggleAcceleratedCompositing(bool)));
+ QMenu* graphicsViewMenu = toolsMenu->addMenu("QGraphicsView");
+ QAction* toggleGraphicsView = graphicsViewMenu->addAction("Toggle use of QGraphicsView", this, SLOT(initializeView(bool)));
+ toggleGraphicsView->setCheckable(true);
+ toggleGraphicsView->setChecked(false);
+
+ QAction* toggleAcceleratedCompositing = graphicsViewMenu->addAction("Toggle Accelerated Compositing", this, SLOT(toggleAcceleratedCompositing(bool)));
toggleAcceleratedCompositing->setCheckable(true);
toggleAcceleratedCompositing->setChecked(false);
+ toggleAcceleratedCompositing->setEnabled(false);
+ toggleAcceleratedCompositing->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool)));
- QAction* toggleGraphicsView = toolsMenu->addAction("Toggle use of QGraphicsView", this, SLOT(initializeView(bool)));
- toggleGraphicsView->setCheckable(true);
- toggleGraphicsView->setChecked(false);
+ graphicsViewMenu->addSeparator();
+
+ flipAnimated = graphicsViewMenu->addAction("Animated Flip");
+ flipAnimated->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool)));
+ flipAnimated->setEnabled(false);
+
+ flipYAnimated = graphicsViewMenu->addAction("Animated Y-Flip");
+ flipYAnimated->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool)));
+ flipYAnimated->setEnabled(false);
}
QWebPage* WebPage::createWindow(QWebPage::WebWindowType type)
diff --git a/WebKitTools/QtLauncher/webview.cpp b/WebKitTools/QtLauncher/webview.cpp
index 443fc3e..311d79b 100644
--- a/WebKitTools/QtLauncher/webview.cpp
+++ b/WebKitTools/QtLauncher/webview.cpp
@@ -48,6 +48,29 @@ WebViewGraphicsBased::WebViewGraphicsBased(QWidget* parent)
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ QStateMachine* machine = new QStateMachine(this);
+ QState* s0 = new QState(machine);
+ s0->assignProperty(this, "yRotation", 0);
+
+ QState* s1 = new QState(machine);
+ s1->assignProperty(this, "yRotation", 90);
+
+ QAbstractTransition* t1 = s0->addTransition(this, SIGNAL(yFlipRequest()), s1);
+ QPropertyAnimation* yRotationAnim = new QPropertyAnimation(this, "yRotation", this);
+ yRotationAnim->setDuration(1000);
+ t1->addAnimation(yRotationAnim);
+
+ QState* s2 = new QState(machine);
+ s2->assignProperty(this, "yRotation", -90);
+ s1->addTransition(s1, SIGNAL(propertiesAssigned()), s2);
+
+ QAbstractTransition* t2 = s2->addTransition(s0);
+ t2->addAnimation(yRotationAnim);
+
+ machine->setInitialState(s0);
+ machine->start();
+#endif
}
void WebViewGraphicsBased::resizeEvent(QResizeEvent* event)
@@ -83,6 +106,30 @@ void WebViewGraphicsBased::updateFrameRate()
m_numPaintsSinceLastMeasure = 0;
}
+void WebViewGraphicsBased::animatedFlip()
+{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ QSizeF center = m_item->boundingRect().size() / 2;
+ QPointF centerPoint = QPointF(center.width(), center.height());
+ m_item->setTransformOriginPoint(centerPoint);
+
+ QPropertyAnimation* animation = new QPropertyAnimation(m_item, "rotation", this);
+ animation->setDuration(1000);
+
+ int rotation = int(m_item->rotation());
+
+ animation->setStartValue(rotation);
+ animation->setEndValue(rotation + 180 - (rotation % 180));
+
+ animation->start(QAbstractAnimation::DeleteWhenStopped);
+#endif
+}
+
+void WebViewGraphicsBased::animatedYFlip()
+{
+ emit yFlipRequest();
+}
+
void WebViewGraphicsBased::paintEvent(QPaintEvent* event)
{
QGraphicsView::paintEvent(event);
diff --git a/WebKitTools/QtLauncher/webview.h b/WebKitTools/QtLauncher/webview.h
index 83bd801..297d975 100644
--- a/WebKitTools/QtLauncher/webview.h
+++ b/WebKitTools/QtLauncher/webview.h
@@ -66,6 +66,7 @@ protected:
class WebViewGraphicsBased : public QGraphicsView {
Q_OBJECT
+ Q_PROPERTY(qreal yRotation READ yRotation WRITE setYRotation)
public:
WebViewGraphicsBased(QWidget* parent);
@@ -76,8 +77,29 @@ public:
void enableFrameRateMeasurement();
virtual void paintEvent(QPaintEvent* event);
+ void setYRotation(qreal angle)
+ {
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ QRectF r = m_item->boundingRect();
+ m_item->setTransform(QTransform()
+ .translate(r.width() / 2, r.height() / 2)
+ .rotate(angle, Qt::YAxis)
+ .translate(-r.width() / 2, -r.height() / 2));
+#endif
+ m_yRotation = angle;
+ }
+ qreal yRotation() const
+ {
+ return m_yRotation;
+ }
+
public slots:
void updateFrameRate();
+ void animatedFlip();
+ void animatedYFlip();
+
+signals:
+ void yFlipRequest();
private:
GraphicsWebView* m_item;
@@ -86,6 +108,7 @@ private:
QTime m_startTime;
QTime m_lastConsultTime;
bool m_measureFps;
+ qreal m_yRotation;
};
#endif