diff options
Diffstat (limited to 'tools/qml')
-rw-r--r-- | tools/qml/content/Browser.qml | 2 | ||||
-rw-r--r-- | tools/qml/deviceorientation.h | 9 | ||||
-rw-r--r-- | tools/qml/deviceorientation_maemo.cpp | 4 | ||||
-rw-r--r-- | tools/qml/qmlruntime.cpp | 94 | ||||
-rw-r--r-- | tools/qml/qmlruntime.h | 9 |
5 files changed, 68 insertions, 50 deletions
diff --git a/tools/qml/content/Browser.qml b/tools/qml/content/Browser.qml index 838a848..ff2bb47 100644 --- a/tools/qml/content/Browser.qml +++ b/tools/qml/content/Browser.qml @@ -134,7 +134,7 @@ Rectangle { MouseArea { id: mouseRegion anchors.fill: parent - onClicked: { launch() } + onClicked: { if (folders == wrapper.ListView.view.model) launch() } } states: [ State { diff --git a/tools/qml/deviceorientation.h b/tools/qml/deviceorientation.h index d209005..817bfc8 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, + Portrait, + Landscape, + PortraitInverted, + LandscapeInverted + }; + 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..7948e2a 100644 --- a/tools/qml/deviceorientation_maemo.cpp +++ b/tools/qml/deviceorientation_maemo.cpp @@ -102,8 +102,12 @@ private: o = UnknownOrientation; } else if (ax < -750) { o = Portrait; + } else if (ax > 750) { + o = PortraitInverted; } else if (ay < -750) { o = Landscape; + } else if (ay > 750) { + o = LandscapeInverted; } return o; diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index fe323c1..676881d 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -281,7 +281,12 @@ public: ret << httpProxy; return ret; } +#ifdef Q_OS_WIN + // systemProxyForQuery can take insanely long on Windows (QTBUG-10106) + return QNetworkProxyFactory::proxyForQuery(query); +#else return QNetworkProxyFactory::systemProxyForQuery(query); +#endif } void setHttpProxy (QNetworkProxy proxy) { @@ -367,7 +372,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 +423,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 +576,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: Portrait")); + orientation->addAction(tr("orientation: Landscape")); + orientation->addAction(tr("orientation: Portrait (Inverted)")); + orientation->addAction(tr("orientation: Landscape (Inverted)")); + 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 +628,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() @@ -805,11 +804,11 @@ void QDeclarativeViewer::statusChanged() tester->executefailure(); if (canvas->status() == QDeclarativeView::Ready) { - initialSize = canvas->sizeHint(); + initialSize = canvas->initialSize(); if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { - updateSizeHints(); if (!isFullScreen() && !isMaximized()) { resize(QSize(initialSize.width(), initialSize.height()+menuBarHeight())); + updateSizeHints(); } } } @@ -942,7 +941,7 @@ void QDeclarativeViewer::sceneResized(QSize size) if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) { updateSizeHints(); } - } + } } void QDeclarativeViewer::keyPressEvent(QKeyEvent *event) @@ -971,12 +970,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 +1175,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("Portrait")) + DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait); + else if (o == QLatin1String("Landscape")) + DeviceOrientation::instance()->setOrientation(DeviceOrientation::Landscape); + else if (o == QLatin1String("Portrait (Inverted)")) + DeviceOrientation::instance()->setOrientation(DeviceOrientation::PortraitInverted); + else if (o == QLatin1String("Landscape (Inverted)")) + DeviceOrientation::instance()->setOrientation(DeviceOrientation::LandscapeInverted); +} + void QDeclarativeViewer::orientationChanged() { if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { @@ -1253,7 +1264,6 @@ void QDeclarativeViewer::updateSizeHints() setMinimumSize(QSize(0,0)); setMaximumSize(QSize(16777215,16777215)); } - updateGeometry(); } void QDeclarativeViewer::registerTypes() 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; |