summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/qml/deviceorientation.cpp2
-rw-r--r--tools/qml/deviceorientation.h9
-rw-r--r--tools/qml/deviceorientation_maemo.cpp12
-rw-r--r--tools/qml/qmlruntime.cpp82
-rw-r--r--tools/qml/qmlruntime.h9
5 files changed, 64 insertions, 50 deletions
diff --git a/tools/qml/deviceorientation.cpp b/tools/qml/deviceorientation.cpp
index e7c70d5..a13b912 100644
--- a/tools/qml/deviceorientation.cpp
+++ b/tools/qml/deviceorientation.cpp
@@ -47,7 +47,7 @@ class DefaultDeviceOrientation : public DeviceOrientation
{
Q_OBJECT
public:
- DefaultDeviceOrientation() : DeviceOrientation(), m_orientation(DeviceOrientation::Portrait) {}
+ DefaultDeviceOrientation() : DeviceOrientation(), m_orientation(DeviceOrientation::TopUp) {}
Orientation orientation() const {
return m_orientation;
diff --git a/tools/qml/deviceorientation.h b/tools/qml/deviceorientation.h
index d209005..fe73868 100644
--- a/tools/qml/deviceorientation.h
+++ b/tools/qml/deviceorientation.h
@@ -52,7 +52,14 @@ class DeviceOrientation : public QObject
Q_OBJECT
Q_ENUMS(Orientation)
public:
- enum Orientation { UnknownOrientation, Portrait, Landscape };
+ enum Orientation {
+ UnknownOrientation,
+ TopUp,
+ TopDown,
+ LeftUp,
+ RightUp
+ };
+
virtual Orientation orientation() const = 0;
virtual void setOrientation(Orientation) = 0;
diff --git a/tools/qml/deviceorientation_maemo.cpp b/tools/qml/deviceorientation_maemo.cpp
index 9f12f3d..501ff79 100644
--- a/tools/qml/deviceorientation_maemo.cpp
+++ b/tools/qml/deviceorientation_maemo.cpp
@@ -48,11 +48,11 @@ class MaemoOrientation : public DeviceOrientation
Q_OBJECT
public:
MaemoOrientation()
- : DeviceOrientation(),m_current(Portrait), m_lastSeen(Portrait), m_lastSeenCount(0)
+ : DeviceOrientation(),m_current(TopUp), m_lastSeen(TopUp), m_lastSeenCount(0)
{
m_current = get();
if (m_current == UnknownOrientation)
- m_current = Portrait;
+ m_current = TopUp;
startTimer(100);
}
@@ -101,9 +101,13 @@ private:
if (abs(az) > 850) {
o = UnknownOrientation;
} else if (ax < -750) {
- o = Portrait;
+ o = LeftUp;
+ } else if (ax > 750) {
+ o = RightUp;
} else if (ay < -750) {
- o = Landscape;
+ o = TopUp;
+ } else if (ay > 750) {
+ o = TopDown;
}
return o;
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index fe323c1..f681303 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -367,7 +367,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
#endif
, loggerWindow(new LoggerWidget())
, frame_stream(0), mb(0)
- , portraitOrientation(0), landscapeOrientation(0)
+ , orientation(0)
, showWarningsWindow(0)
, m_scriptOptions(0)
, tester(0)
@@ -418,7 +418,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
if (!(flags & Qt::FramelessWindowHint)) {
createMenu(menuBar(),0);
- setPortrait();
+ changeOrientation(orientation->actions().value(0));
}
#if !defined(Q_OS_SYMBIAN)
@@ -571,26 +571,25 @@ void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu)
QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties"));
- QActionGroup *orientation = new QActionGroup(parent);
+ orientation = new QActionGroup(parent);
- QAction *toggleOrientation = new QAction(tr("&Toggle Orientation"), parent);
- toggleOrientation->setCheckable(true);
- toggleOrientation->setShortcut(QKeySequence("Ctrl+T"));
- settingsMenu->addAction(toggleOrientation);
- connect(toggleOrientation, SIGNAL(triggered()), this, SLOT(toggleOrientation()));
+ QAction *rotateOrientation = new QAction(tr("Rotate orientation"), parent);
+ rotateOrientation->setShortcut(QKeySequence("Ctrl+T"));
+ settingsMenu->addAction(rotateOrientation);
+ connect(rotateOrientation, SIGNAL(triggered()), this, SLOT(rotateOrientation()));
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);
+ connect(orientation, SIGNAL(triggered(QAction*)), this, SLOT(changeOrientation(QAction*)));
+
+ orientation->addAction(tr("orientation: TopUp"));
+ orientation->addAction(tr("orientation: LeftUp"));
+ orientation->addAction(tr("orientation: TopDown"));
+ orientation->addAction(tr("orientation: RightUp"));
+ QList<QAction *> actions = orientation->actions();
+ for (int i=0; i<actions.count(); i++) {
+ propertiesMenu->addAction(actions[i]);
+ actions[i]->setCheckable(true);
+ }
if (flatmenu) flatmenu->addSeparator();
@@ -624,21 +623,16 @@ void QDeclarativeViewer::proxySettingsChanged()
reload ();
}
-void QDeclarativeViewer::setPortrait()
-{
- DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait);
- portraitOrientation->setChecked(true);
-}
-
-void QDeclarativeViewer::setLandscape()
+void QDeclarativeViewer::rotateOrientation()
{
- DeviceOrientation::instance()->setOrientation(DeviceOrientation::Landscape);
- landscapeOrientation->setChecked(true);
-}
+ QAction *current = orientation->checkedAction();
+ QList<QAction *> actions = orientation->actions();
+ int index = actions.indexOf(current);
+ if (index < 0)
+ return;
-void QDeclarativeViewer::toggleOrientation()
-{
- DeviceOrientation::instance()->setOrientation(DeviceOrientation::instance()->orientation()==DeviceOrientation::Portrait?DeviceOrientation::Landscape:DeviceOrientation::Portrait);
+ QAction *newOrientation = actions[(index + 1) % actions.count()];
+ changeOrientation(newOrientation);
}
void QDeclarativeViewer::toggleFullScreen()
@@ -971,12 +965,7 @@ void QDeclarativeViewer::keyPressEvent(QKeyEvent *event)
} 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();
- }
+ rotateOrientation();
}
QWidget::keyPressEvent(event);
@@ -1181,6 +1170,23 @@ void QDeclarativeViewer::recordFrame()
}
}
+void QDeclarativeViewer::changeOrientation(QAction *action)
+{
+ if (!action)
+ return;
+ action->setChecked(true);
+
+ QString o = action->text().split(QLatin1Char(':')).value(1).trimmed();
+ if (o == QLatin1String("TopUp"))
+ DeviceOrientation::instance()->setOrientation(DeviceOrientation::TopUp);
+ else if (o == QLatin1String("TopDown"))
+ DeviceOrientation::instance()->setOrientation(DeviceOrientation::TopDown);
+ else if (o == QLatin1String("LeftUp"))
+ DeviceOrientation::instance()->setOrientation(DeviceOrientation::LeftUp);
+ else if (o == QLatin1String("RightUp"))
+ DeviceOrientation::instance()->setOrientation(DeviceOrientation::RightUp);
+}
+
void QDeclarativeViewer::orientationChanged()
{
if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) {
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
index 5086e02..27bd217 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -124,7 +124,7 @@ public slots:
void ffmpegFinished(int code);
void showProxySettings ();
void proxySettingsChanged ();
- void toggleOrientation();
+ void rotateOrientation();
void statusChanged();
void setSlowMode(bool);
void launch(const QString &);
@@ -140,9 +140,8 @@ private slots:
void recordFrame();
void chooseRecordingOptions();
void pickRecordingFile();
- void setPortrait();
- void setLandscape();
void toggleFullScreen();
+ void changeOrientation(QAction*);
void orientationChanged();
void showWarnings(bool show);
@@ -183,9 +182,7 @@ private:
bool ffmpegAvailable;
bool convertAvailable;
- QAction *portraitOrientation;
- QAction *landscapeOrientation;
-
+ QActionGroup *orientation;
QAction *showWarningsWindow;
QString m_script;