diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-30 09:43:30 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-30 09:43:30 (GMT) |
commit | ac79a86a2ac154492025e803045316a01d69470e (patch) | |
tree | adc795ded9d1f2998b341bf78f1d4ef64036b03e | |
parent | 1003860c370308fae46ae00d9acdf5787ebc0007 (diff) | |
parent | 81542982a9b7f4d55707ec6abfd26f5046871f88 (diff) | |
download | Qt-ac79a86a2ac154492025e803045316a01d69470e.zip Qt-ac79a86a2ac154492025e803045316a01d69470e.tar.gz Qt-ac79a86a2ac154492025e803045316a01d69470e.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 46 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.h | 5 |
2 files changed, 48 insertions, 3 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 6130ade..a354653 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; @@ -342,8 +343,10 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) QObject::connect(canvas, SIGNAL(errors(QList<QmlError>)), this, SLOT(executeErrors())); QObject::connect(canvas, SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); - if (!(flags & Qt::FramelessWindowHint)) + if (!(flags & Qt::FramelessWindowHint)) { createMenu(menuBar(),0); + setPortrait(); + } QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); @@ -477,6 +480,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")); @@ -510,6 +530,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) @@ -871,6 +903,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)) { @@ -885,6 +918,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; |