summaryrefslogtreecommitdiffstats
path: root/tools/qmlviewer
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-11-30 09:14:05 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-11-30 09:14:05 (GMT)
commit126ab609611d188322eeaeca38ecc9ae13e9574b (patch)
tree4e33b6e222062498298bc203a35a3f19ec259af8 /tools/qmlviewer
parentc8cb256644c143f9d85eed0a8d295ffd05a2017d (diff)
downloadQt-126ab609611d188322eeaeca38ecc9ae13e9574b.zip
Qt-126ab609611d188322eeaeca38ecc9ae13e9574b.tar.gz
Qt-126ab609611d188322eeaeca38ecc9ae13e9574b.tar.bz2
Add orientation property to qmlviewer.
Diffstat (limited to 'tools/qmlviewer')
-rw-r--r--tools/qmlviewer/qmlviewer.cpp46
-rw-r--r--tools/qmlviewer/qmlviewer.h5
2 files changed, 48 insertions, 3 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index ea0936b..13f0009 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -301,8 +301,9 @@ QString QmlViewer::getVideoFileName()
QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
- : QWidget(parent, flags), frame_stream(0), scaleSkin(true), mb(0), m_scriptOptions(0),
- tester(0)
+ : QWidget(parent, flags), frame_stream(0), scaleSkin(true), mb(0)
+ , portraitOrientation(0), landscapeOrientation(0)
+ , m_scriptOptions(0), tester(0)
{
devicemode = false;
skin = 0;
@@ -341,8 +342,10 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
QObject::connect(canvas, SIGNAL(initialSize(QSize)), this, SLOT(adjustSizeSlot()));
QObject::connect(canvas, SIGNAL(errors(QList<QmlError>)), this, SLOT(executeErrors()));
- if (!(flags & Qt::FramelessWindowHint))
+ if (!(flags & Qt::FramelessWindowHint)) {
createMenu(menuBar(),0);
+ setPortrait();
+ }
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
@@ -476,6 +479,23 @@ void QmlViewer::createMenu(QMenuBar *menu, QMenu *flatmenu)
if (!flatmenu)
settingsMenu->addAction(recordOptions);
+ QMenu *propertiesMenu = new QMenu(tr("Properties"));
+ QActionGroup *orientation = new QActionGroup(parent);
+ orientation->setExclusive(true);
+ portraitOrientation = new QAction(tr("orientation: Portrait"), parent);
+ portraitOrientation->setCheckable(true);
+ connect(portraitOrientation, SIGNAL(triggered()), this, SLOT(setPortrait()));
+ orientation->addAction(portraitOrientation);
+ propertiesMenu->addAction(portraitOrientation);
+
+ landscapeOrientation = new QAction(tr("orientation: Landscape"), parent);
+ landscapeOrientation->setCheckable(true);
+ connect(landscapeOrientation, SIGNAL(triggered()), this, SLOT(setLandscape()));
+ orientation->addAction(landscapeOrientation);
+ propertiesMenu->addAction(landscapeOrientation);
+
+ settingsMenu->addMenu(propertiesMenu);
+
if (flatmenu) flatmenu->addSeparator();
QMenu *helpMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Help"));
@@ -509,6 +529,18 @@ void QmlViewer::proxySettingsChanged()
reload ();
}
+void QmlViewer::setPortrait()
+{
+ canvas->rootContext()->setContextProperty("orientation", "Portrait");
+ portraitOrientation->setChecked(true);
+}
+
+void QmlViewer::setLandscape()
+{
+ canvas->rootContext()->setContextProperty("orientation", "Landscape");
+ landscapeOrientation->setChecked(true);
+}
+
void QmlViewer::setScaleSkin()
{
if (scaleSkin)
@@ -870,6 +902,7 @@ void QmlViewer::keyPressEvent(QKeyEvent *event)
<< "F7 - show timing\n"
<< "F8 - show performance (if available)\n"
<< "F9 - toggle video recording\n"
+ << "F10 - toggle orientation\n"
<< "device keys: 0=quit, 1..8=F1..F8"
;
} else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) {
@@ -884,6 +917,13 @@ void QmlViewer::keyPressEvent(QKeyEvent *event)
QPerformanceLog::clear();
} else if (event->key() == Qt::Key_F9 || (event->key() == Qt::Key_9 && devicemode)) {
toggleRecording();
+ } else if (event->key() == Qt::Key_F10) {
+ if (portraitOrientation) {
+ if (portraitOrientation->isChecked())
+ setLandscape();
+ else
+ setPortrait();
+ }
}
QWidget::keyPressEvent(event);
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
index 78512a9..6e31db54 100644
--- a/tools/qmlviewer/qmlviewer.h
+++ b/tools/qmlviewer/qmlviewer.h
@@ -119,6 +119,8 @@ private slots:
void pickRecordingFile();
void setScaleSkin();
void adjustSizeSlot();
+ void setPortrait();
+ void setLandscape();
private:
void setupProxy();
@@ -154,6 +156,9 @@ private:
bool ffmpegAvailable;
bool convertAvailable;
+ QAction *portraitOrientation;
+ QAction *landscapeOrientation;
+
QString m_script;
ScriptOptions m_scriptOptions;
QmlGraphicsTester *tester;