diff options
author | Dominik Kapusta <dominik.kapusta@teleca.com> | 2010-02-23 12:48:56 +0100 |
---|---|---|
committer | Daniel d'Andrada <daniel.dandrada@nokia.com> | 2010-03-24 14:19:43 +0200 |
commit | cb109ed58bc44c0637d68708220b210c6b8d08b1 (patch) | |
tree | b2104342f7ec38271ca9e7f4831ecc537eb5dc5d | |
parent | 781096044c6d7b87298c331fad9e1e181cf292fb (diff) |
Changes: Change orientation angle without animation, when window is hidden.
RevBy: Daniel d'Andrada
Details: Restore one-argument DuiWindow::setOrientationAngle() method by
removing orientation change mode parameter (immediate or animated). The
mode is now decided based on DuiWindow::isVisible(), which makes it
immediate when window was hidden or hasn't been shown yet. The correct
mode is passed to DuiSceneManager::setOrientationAngle(), which remains
a two-argument function.
Also move Dui::OrientationChangeMode enum to DuiSceneManager.
Includes compilation fix for ut_duilayout.
It doesn't break tests because the window is hidden when
they are run, so the rotation is immediate.
-rw-r--r-- | demos/widgetsgallery/staticpagebenchmark.cpp | 4 | ||||
-rw-r--r-- | doc/src/news.dox | 3 | ||||
-rw-r--r-- | src/core/duinamespace.h | 11 | ||||
-rw-r--r-- | src/scene/duiscenemanager.cpp | 4 | ||||
-rw-r--r-- | src/scene/duiscenemanager.h | 17 | ||||
-rw-r--r-- | src/widgets/duiwindow.cpp | 6 | ||||
-rw-r--r-- | src/widgets/duiwindow.h | 14 | ||||
-rw-r--r-- | tests/ut_duilayout/ut_duilayout.cpp | 36 | ||||
-rw-r--r-- | tests/ut_duiscenemanager/ut_duiscenemanager.cpp | 12 | ||||
-rw-r--r-- | tests/ut_duiwindow/ut_duiwindow.cpp | 7 |
10 files changed, 61 insertions, 53 deletions
diff --git a/demos/widgetsgallery/staticpagebenchmark.cpp b/demos/widgetsgallery/staticpagebenchmark.cpp index f59bd1b4..115961a3 100644 --- a/demos/widgetsgallery/staticpagebenchmark.cpp +++ b/demos/widgetsgallery/staticpagebenchmark.cpp @@ -40,7 +40,7 @@ void StaticPageBenchmark::waitPageDuration() { formerOrientationAngle = DuiApplication::activeWindow()->orientationAngle(); DuiApplication::activeWindow()->setOrientationAngleLocked(false); - DuiApplication::activeWindow()->setOrientationAngle(targetOrientationAngle, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(targetOrientationAngle); DuiApplication::activeWindow()->setOrientationAngleLocked(true); timedemo->startTiming(); @@ -52,7 +52,7 @@ void StaticPageBenchmark::terminateBenchmark() timedemo->stopTiming(); DuiApplication::activeWindow()->setOrientationAngleLocked(false); - DuiApplication::activeWindow()->setOrientationAngle(formerOrientationAngle, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(formerOrientationAngle); DuiApplication::activeWindow()->setOrientationAngleLocked(true); emit finished(); } diff --git a/doc/src/news.dox b/doc/src/news.dox index 2e7e445f..594eebbe 100644 --- a/doc/src/news.dox +++ b/doc/src/news.dox @@ -30,8 +30,9 @@ \subsection removed Removed or Renamed - escapeButtonMode() property was removed from DuiApplicationPage. Use escapeMode() instead. - DuiDialog::windowModal() was renamed to DuiDialog::systemModal(). - - DuiApplicationPage::pageTitleChanged(DuiApplicationPage *, const QString &title) signal was removed. +- restored one-argument DuiWindow::setOrientationAngle(Dui::OrientationAngle), the rotation animation + is enabled by default and it's disabled if the window is hidden (DuiWindow::isVisible() returns false). \section v0190 diff --git a/src/core/duinamespace.h b/src/core/duinamespace.h index 2e355adf..3209f082 100644 --- a/src/core/duinamespace.h +++ b/src/core/duinamespace.h @@ -69,17 +69,6 @@ namespace Dui NonRecursive }; - /*! - * This enum is used to describe whether the orientation change - * invoked manually should be animated or not. - * - * \sa DuiWindow::setOrientationAngle() - */ - enum OrientationChangeMode { - AnimatedOrientationChange, - ImmediateOrientationChange - }; - //! extensions for Qt::inputMethodQuery enum InputMethodQueryExtensions { InputEnabledQuery = 10000, // as workaround for qgraphicsview inputmethod shortcomings - DEPRECATED diff --git a/src/scene/duiscenemanager.cpp b/src/scene/duiscenemanager.cpp index 768e656c..f0435ba9 100644 --- a/src/scene/duiscenemanager.cpp +++ b/src/scene/duiscenemanager.cpp @@ -1287,14 +1287,14 @@ void DuiSceneManager::closeSoftwareInputPanel() } void DuiSceneManager::setOrientationAngle(Dui::OrientationAngle angle, - Dui::OrientationChangeMode mode) + OrientationChangeMode mode) { Q_D(DuiSceneManager); if (d->orientationAnimation->state() == QAbstractAnimation::Running) d->orientationAnimation->stop(); - if (mode == Dui::AnimatedOrientationChange) + if (mode == AnimatedOrientationChange) d->rotateToAngle(angle); else d->setOrientationAngleWithoutAnimation(angle); diff --git a/src/scene/duiscenemanager.h b/src/scene/duiscenemanager.h index c02a801a..80daee6c 100644 --- a/src/scene/duiscenemanager.h +++ b/src/scene/duiscenemanager.h @@ -61,6 +61,17 @@ class DUI_EXPORT DuiSceneManager : public QObject public: /*! + * This enum is used to describe whether the orientation change + * invoked manually should be animated or not. + * + * \sa setOrientationAngle() + */ + enum OrientationChangeMode { + AnimatedOrientationChange, + ImmediateOrientationChange + }; + + /*! * Constructor of the DuiSceneManager class, constructs the manager for the given \a scene. * * \note You normally don't have to create an instance of this class, @@ -133,11 +144,13 @@ public: public Q_SLOTS: /*! - * Sets the orientation to \a angle. The \a mode can be set to Dui::ImmediateOrientationChange + * Sets the orientation to \a angle. The \a mode can be set to ImmediateOrientationChange * to disable orientation animation. + * + * /sa OrientationChangeMode */ void setOrientationAngle(Dui::OrientationAngle angle, - Dui::OrientationChangeMode mode = Dui::AnimatedOrientationChange); + OrientationChangeMode mode = AnimatedOrientationChange); /*! * Sends a request to the application's input context to open a software input diff --git a/src/widgets/duiwindow.cpp b/src/widgets/duiwindow.cpp index 8e8942e4..906c568d 100644 --- a/src/widgets/duiwindow.cpp +++ b/src/widgets/duiwindow.cpp @@ -513,7 +513,7 @@ Dui::OrientationAngle DuiWindow::orientationAngle() const } } -void DuiWindow::setOrientationAngle(Dui::OrientationAngle angle, Dui::OrientationChangeMode mode) +void DuiWindow::setOrientationAngle(Dui::OrientationAngle angle) { Q_D(DuiWindow); @@ -522,6 +522,10 @@ void DuiWindow::setOrientationAngle(Dui::OrientationAngle angle, Dui::Orientatio d->angle = angle; if (d->sceneManager) { + DuiSceneManager::OrientationChangeMode mode = isVisible() ? + DuiSceneManager::AnimatedOrientationChange : + DuiSceneManager::ImmediateOrientationChange; + d->sceneManager->setOrientationAngle(angle, mode); } else { // first notify widgets, then emit the signal (in case someone diff --git a/src/widgets/duiwindow.h b/src/widgets/duiwindow.h index a7c2d835..23974b01 100644 --- a/src/widgets/duiwindow.h +++ b/src/widgets/duiwindow.h @@ -259,16 +259,16 @@ public: public Q_SLOTS: /*! - * Allows to set the orientation angle of the window. When reimplementing, you should emit - * orientationChanged() and orientationAngleChanged() signals when appropriate. + * Allows to set the orientation angle of the window. If the window is hidden or it hasn't been + * shown yet, the orientation angle change is immediate (i.e. without rotation animation). + * Otherwise a rotation animation is performed. * - * \param angle New orientation angle for the window - * \param mode Specifies whether the orientation change should be animated or not. + * When reimplementing, you should emit orientationChanged() and orientationAngleChanged() + * signals when appropriate. * - * \sa Dui::OrientationChangeMode + * \param angle New orientation angle for the window */ - virtual void setOrientationAngle(Dui::OrientationAngle angle, - Dui::OrientationChangeMode mode = Dui::AnimatedOrientationChange); + virtual void setOrientationAngle(Dui::OrientationAngle angle); /*! * Locks window's orientation angle changes. Equal to calling setOrientationAngleLocked(true). diff --git a/tests/ut_duilayout/ut_duilayout.cpp b/tests/ut_duilayout/ut_duilayout.cpp index 1e148b5a..feab9e8f 100644 --- a/tests/ut_duilayout/ut_duilayout.cpp +++ b/tests/ut_duilayout/ut_duilayout.cpp @@ -183,7 +183,7 @@ void Ut_DuiLayout::init() m_proxy = m_scene->addWidget(m_button); m_scene->addItem(m_form); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle0, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle0); Q_ASSERT(0 != m_button); Q_ASSERT(0 != m_scene); Q_ASSERT(0 != m_proxy); @@ -1913,7 +1913,7 @@ void Ut_DuiLayout::testLayoutPolicyStylingSimple() QCOMPARE(bottom, -1.0); //Now rotate - the values should be read in from the CSS file - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90); policy->getContentsMargins(&left, &top, &right, &bottom); QCOMPARE(left, 4.0); QCOMPARE(top, 5.0); @@ -1943,7 +1943,7 @@ void Ut_DuiLayout::testLayoutPolicyStylingSimpleWithSceneManager() QCOMPARE(bottom, -1.0); //Now rotate - the values should be read in from the CSS file - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90); policy->getContentsMargins(&left, &top, &right, &bottom); QCOMPARE(left, 4.0); QCOMPARE(top, 5.0); @@ -2104,20 +2104,20 @@ void Ut_DuiLayout::testLayoutPolicyStyling() checkPolicies(layout, policy, isCurrent, policyType, -1.0, -1.0, -1.0, -1.0, 6.0, 7.0); // Now rotate to portrait - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90); checkPolicies(layout, policy, isCurrent, policyType, 4.0, 5.0, 2.0, 6.0, 2.0, 3.0); policy->setObjectName("packed"); QCOMPARE(policy->objectName(), QString("packed")); checkPolicies(layout, policy, isCurrent, policyType, 1, 2.0, 3.0, 4.0, 5.0, 6.0); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle180, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle180); QCOMPARE(policy->objectName(), QString("packed")); checkPolicies(layout, policy, isCurrent, policyType, -1, 0.0, 0.0, 0.0, 0.0, 0.0); policy->setObjectName("spacing"); QCOMPARE(policy->objectName(), QString("spacing")); checkPolicies(layout, policy, isCurrent, policyType, -1, 0.0, 0.0, 0.0, 10.0, 11.0); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle270, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle270); QCOMPARE(policy->objectName(), QString("spacing")); checkPolicies(layout, policy, isCurrent, policyType, -1, 0.0, 0.0, 0.0, 10.0, 11.0); @@ -2125,7 +2125,7 @@ void Ut_DuiLayout::testLayoutPolicyStyling() QCOMPARE(policy->objectName(), QString("packed")); checkPolicies(layout, policy, isCurrent, policyType, 1, 2.0, 3.0, 4.0, 5.0, 6.0); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle0, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle0); policy->setObjectName(QString::null); QVERIFY(policy->objectName().isEmpty()); checkPolicies(layout, policy, isCurrent, policyType, -1.0, -1.0, -1.0, -1.0, 6.0, 7.0); @@ -2139,7 +2139,7 @@ void Ut_DuiLayout::testLayoutSwitchingWithOrientation() DuiLayoutTest *layout = new DuiLayoutTest(m_form); DuiAbstractLayoutPolicy *landscape_policy = new DuiLinearLayoutPolicy(layout, Qt::Horizontal); QVERIFY(layout->policy() == landscape_policy); //Only policy, so it must be this one - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90); QCOMPARE(DuiApplication::activeWindow()->orientationAngle(), Dui::Angle90); DuiAbstractLayoutPolicy *portrait_policy = new DuiGridLayoutPolicy(layout); QVERIFY(layout->policy() == landscape_policy); //Still only policy, so it must be this one @@ -2150,25 +2150,25 @@ void Ut_DuiLayout::testLayoutSwitchingWithOrientation() layout->setLandscapePolicy(landscape_policy); QVERIFY(layout->policy() == portrait_policy); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90, Dui::ImmediateOrientationChange); //Set it to 90, again + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90); //Set it to 90, again QCOMPARE(DuiApplication::activeWindow()->orientationAngle(), Dui::Angle90); QVERIFY(layout->policy() == portrait_policy); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle180, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle180); QCOMPARE(DuiApplication::activeWindow()->orientationAngle(), Dui::Angle180); QVERIFY(layout->policy() == landscape_policy); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle270, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle270); QCOMPARE(DuiApplication::activeWindow()->orientationAngle(), Dui::Angle270); QVERIFY(layout->policy() == portrait_policy); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90); QCOMPARE(DuiApplication::activeWindow()->orientationAngle(), Dui::Angle90); QVERIFY(layout->policy() == portrait_policy); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle0, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle0); QCOMPARE(DuiApplication::activeWindow()->orientationAngle(), Dui::Angle0); QVERIFY(layout->policy() == landscape_policy); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle0, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle0); QCOMPARE(DuiApplication::activeWindow()->orientationAngle(), Dui::Angle0); QVERIFY(layout->policy() == landscape_policy); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle180, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle180); QCOMPARE(DuiApplication::activeWindow()->orientationAngle(), Dui::Angle180); QVERIFY(layout->policy() == landscape_policy); @@ -3266,7 +3266,7 @@ void Ut_DuiLayout::testSwitchingPoliciesHidesItems() QCOMPARE(widgets[3]->isVisible(), false); //Rotate, to switch to policy2 - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90); qApp->processEvents(); while (layout->animation()->isAnimating()) @@ -3332,7 +3332,7 @@ void Ut_DuiLayout::testSwitchingPoliciesInsidePolicyHidesItems() QCOMPARE(widgets[2]->isVisible(), true); QCOMPARE(widgets[3]->isVisible(), true); - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle0, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle0); innerLayout->setLandscapePolicy(innerPolicy1); innerLayout->setPortraitPolicy(innerPolicy2); @@ -3347,7 +3347,7 @@ void Ut_DuiLayout::testSwitchingPoliciesInsidePolicyHidesItems() QCOMPARE(widgets[3]->isVisible(), false); //Rotate, to switch to innerPolicy2 - DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90, Dui::ImmediateOrientationChange); + DuiApplication::activeWindow()->setOrientationAngle(Dui::Angle90); qApp->processEvents(); while (layout->animation()->isAnimating() || innerLayout->animation()->isAnimating()) diff --git a/tests/ut_duiscenemanager/ut_duiscenemanager.cpp b/tests/ut_duiscenemanager/ut_duiscenemanager.cpp index 1dd3482b..2abae3eb 100644 --- a/tests/ut_duiscenemanager/ut_duiscenemanager.cpp +++ b/tests/ut_duiscenemanager/ut_duiscenemanager.cpp @@ -263,7 +263,7 @@ void Ut_DuiSceneManager::testOrientationChangedSignal() newAngle %= 360; sm->setOrientationAngle((Dui::OrientationAngle) newAngle, - Dui::ImmediateOrientationChange); + DuiSceneManager::ImmediateOrientationChange); Dui::Orientation newOrientation = (newAngle == Dui::Angle0 || newAngle == Dui::Angle180) ? Dui::Landscape : Dui::Portrait; @@ -280,7 +280,7 @@ void Ut_DuiSceneManager::testNoOrientationChangedSignalWhenRotatingBy180Degrees( newAngle %= 360; sm->setOrientationAngle((Dui::OrientationAngle) newAngle, - Dui::ImmediateOrientationChange); + DuiSceneManager::ImmediateOrientationChange); QCOMPARE(spy.count(), 0); } @@ -318,12 +318,12 @@ void Ut_DuiSceneManager::testAngleBoundaryCases() int newAngle = sm->orientationAngle() + Dui::Angle270; newAngle %= 360; sm->setOrientationAngle((Dui::OrientationAngle) newAngle, - Dui::ImmediateOrientationChange); + DuiSceneManager::ImmediateOrientationChange); newAngle = sm->orientationAngle() + Dui::Angle90; newAngle %= 360; sm->setOrientationAngle((Dui::OrientationAngle) newAngle, - Dui::ImmediateOrientationChange); + DuiSceneManager::ImmediateOrientationChange); QCOMPARE(spyChanged.count(), 2); @@ -337,7 +337,7 @@ void Ut_DuiSceneManager::testSceneSizes() QVERIFY(vSR.width() > 0); QVERIFY(vSR.height() > 0); - sm->setOrientationAngle(Dui::Angle90, Dui::ImmediateOrientationChange); + sm->setOrientationAngle(Dui::Angle90, DuiSceneManager::ImmediateOrientationChange); // check scenerects are in correct orientation // what about square? @@ -350,7 +350,7 @@ void Ut_DuiSceneManager::testSceneSizes() vSR = sm->visibleSceneSize(Dui::Landscape); QVERIFY(vSR.width() > vSR.height()); - sm->setOrientationAngle(Dui::Angle180, Dui::ImmediateOrientationChange); + sm->setOrientationAngle(Dui::Angle180, DuiSceneManager::ImmediateOrientationChange); QCOMPARE(sm->orientation(), Dui::Landscape); QCOMPARE(sm->visibleSceneSize(), sm->visibleSceneSize(Dui::Landscape)); diff --git a/tests/ut_duiwindow/ut_duiwindow.cpp b/tests/ut_duiwindow/ut_duiwindow.cpp index cd5792e1..ec522b37 100644 --- a/tests/ut_duiwindow/ut_duiwindow.cpp +++ b/tests/ut_duiwindow/ut_duiwindow.cpp @@ -132,9 +132,10 @@ Dui::Orientation DuiSceneManager::orientation() const return (gOrientationAngle == Dui::Angle90 || gOrientationAngle == Dui::Angle270) ? Dui::Portrait : Dui::Landscape; } -void DuiSceneManager::setOrientationAngle(Dui::OrientationAngle angle, Dui::OrientationChangeMode mode) +void DuiSceneManager::setOrientationAngle(Dui::OrientationAngle angle, DuiSceneManager::OrientationChangeMode mode) { Q_UNUSED(mode); + Dui::Orientation newOrientation = (angle == Dui::Angle90 || angle == Dui::Angle270) ? Dui::Portrait : Dui::Landscape; @@ -280,7 +281,7 @@ void Ut_DuiWindow::testOrientationChangedSignalPropagationFromSceneManager() win->sceneManager(); Dui::OrientationAngle newAngle = (Dui::OrientationAngle)(win->orientationAngle() + 90); - win->sceneManager()->setOrientationAngle(newAngle, Dui::ImmediateOrientationChange); + win->sceneManager()->setOrientationAngle(newAngle, DuiSceneManager::ImmediateOrientationChange); QCOMPARE(orientationSpy.count(), 1); QCOMPARE(angleSpy.count(), 1); @@ -295,7 +296,7 @@ void Ut_DuiWindow::testNoOrientationChangedSignalWhenRotatingBy180Degrees() win->sceneManager(); Dui::OrientationAngle newAngle = (Dui::OrientationAngle)(win->orientationAngle() + 180); - win->setOrientationAngle(newAngle, Dui::ImmediateOrientationChange); + win->setOrientationAngle(newAngle); QCOMPARE(orientationSpy.count(), 0); QCOMPARE(angleSpy.count(), 1); |