aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Miklas <marcin.miklas@teleca.com>2011-01-14 13:29:54 +0100
committerDaniel d'Andrada <daniel.dandrada@nokia.com>2011-01-17 10:55:48 +0200
commit4e2b6d3051aee796ab6d5a13917f9a43b6d90753 (patch)
tree1db93da2a7f1acd85a1f87ff618d487d1ed4c926
parent1ff29a6a4fedfd69ebd0f56d48d314eb3b8f3b7a (diff)
Fixes: NB#218550 - navigation bar animates to the wrong direction when drilling down
RevBy: Daniel d'Andrada ModifiedBy: Daniel d'Andrada. Changed how takeContentSnapshot() gets called. Details: Added support for tranitionDirection in MContentFadeAndSlideAnimation. NavigationBar animation moved to scenemanager because there we know if we are drilling down or going back. Animation now doesn't care of toolbar viewType so app developers must use sceneManager->appearSceneWindowNow(page) when they are using tabs.
-rw-r--r--src/corelib/animation/widget/mcontentfadeandslideanimation.cpp58
-rw-r--r--src/corelib/animation/widget/mcontentfadeandslideanimation.h2
-rw-r--r--src/corelib/animation/widget/mcontentfadeandslideanimation_p.h1
-rw-r--r--src/corelib/scene/mscenemanager.cpp24
-rw-r--r--src/corelib/scene/mscenemanager_p.h2
-rw-r--r--src/corelib/style/mcontentfadeandslideanimationstyle.h2
-rw-r--r--src/corelib/widgets/mapplicationwindow.cpp17
-rw-r--r--src/corelib/widgets/mapplicationwindow_p.h4
8 files changed, 67 insertions, 43 deletions
diff --git a/src/corelib/animation/widget/mcontentfadeandslideanimation.cpp b/src/corelib/animation/widget/mcontentfadeandslideanimation.cpp
index c594cb86..8f723a45 100644
--- a/src/corelib/animation/widget/mcontentfadeandslideanimation.cpp
+++ b/src/corelib/animation/widget/mcontentfadeandslideanimation.cpp
@@ -108,6 +108,26 @@ void MContentFadeAndSlideAnimationPrivate::init()
q->addAnimation(currentWithDelay);
}
+void MContentFadeAndSlideAnimationPrivate::findContentItem()
+{
+ Q_Q(MContentFadeAndSlideAnimation);
+
+ contentItem = 0;
+
+ if (!targetWidget || q->style()->contentObjectName().isEmpty())
+ return;
+
+ foreach(QGraphicsItem* item, targetWidget->childItems()) {
+ if (!item->isWidget())
+ continue;
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item);
+ if (widget->objectName() == q->style()->contentObjectName()) {
+ contentItem = widget;
+ break;
+ }
+ }
+}
+
MContentFadeAndSlideAnimation::MContentFadeAndSlideAnimation(QObject *parent) :
MAbstractWidgetAnimation(new MContentFadeAndSlideAnimationPrivate, parent)
@@ -127,8 +147,18 @@ MContentFadeAndSlideAnimation::~MContentFadeAndSlideAnimation()
void MContentFadeAndSlideAnimation::restoreTargetWidgetState()
{}
-void MContentFadeAndSlideAnimation::setTransitionDirection(MAbstractWidgetAnimation::TransitionDirection /*direction*/)
-{}
+void MContentFadeAndSlideAnimation::setTransitionDirection(MAbstractWidgetAnimation::TransitionDirection direction)
+{
+ Q_D(MContentFadeAndSlideAnimation);
+
+ if (direction == MAbstractWidgetAnimation::In)
+ style().setObjectName("In");
+ else
+ style().setObjectName("Out");
+
+ // contentObjectName might change so we must search for content again
+ d->findContentItem();
+}
void MContentFadeAndSlideAnimation::takeContentSnapshot()
{
@@ -140,25 +170,11 @@ void MContentFadeAndSlideAnimation::takeContentSnapshot()
void MContentFadeAndSlideAnimation::setTargetWidget(MWidgetController *targetWidget)
{
- MAbstractWidgetAnimation::setTargetWidget(targetWidget);
-
Q_D(MContentFadeAndSlideAnimation);
- d->contentItem = 0;
-
- if (!targetWidget)
- return;
-
- foreach(QGraphicsItem* item, targetWidget->childItems()) {
- if (!item->isWidget())
- continue;
- QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item);
- if (widget->objectName() == style()->contentObjectName()) {
- d->contentItem = widget;
- break;
- }
- }
+ MAbstractWidgetAnimation::setTargetWidget(targetWidget);
+ d->findContentItem();
}
void MContentFadeAndSlideAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
@@ -171,8 +187,8 @@ void MContentFadeAndSlideAnimation::updateState(QAbstractAnimation::State newSta
if (oldState == QAbstractAnimation::Stopped &&
newState == QAbstractAnimation::Running)
{
- d->fadeOut->setStartValue(d->contentItem->opacity());
- d->fadeOut->setEndValue(0.0);
+ d->fadeOut->setStartValue(1.0);
+ d->fadeOut->setEndValue(style()->fadeOutOpacity());
d->fadeOut->setDuration(style()->fadeOutDuration());
d->fadeOut->setEasingCurve(style()->fadeOutEasingCurve());
d->fadeOut->setTargetObject(d->snapshotItem);
@@ -188,7 +204,7 @@ void MContentFadeAndSlideAnimation::updateState(QAbstractAnimation::State newSta
d->delay->setDuration(style()->delay());
- d->fadeIn->setStartValue(0.0);
+ d->fadeIn->setStartValue(style()->fadeInOpacity());
d->fadeIn->setEndValue(d->contentItem->opacity());
d->fadeIn->setDuration(style()->fadeInDuration());
d->fadeIn->setEasingCurve(style()->fadeInEasingCurve());
diff --git a/src/corelib/animation/widget/mcontentfadeandslideanimation.h b/src/corelib/animation/widget/mcontentfadeandslideanimation.h
index f2d5dd16..0e2eeccd 100644
--- a/src/corelib/animation/widget/mcontentfadeandslideanimation.h
+++ b/src/corelib/animation/widget/mcontentfadeandslideanimation.h
@@ -37,6 +37,7 @@ public:
virtual ~MContentFadeAndSlideAnimation();
virtual void setTargetWidget(MWidgetController *widget);
+ virtual void setTransitionDirection(MAbstractWidgetAnimation::TransitionDirection direction);
public slots:
void takeContentSnapshot();
@@ -47,7 +48,6 @@ protected:
//! \reimp_end
virtual void restoreTargetWidgetState();
- virtual void setTransitionDirection(MAbstractWidgetAnimation::TransitionDirection direction);
};
//! \internal_end
diff --git a/src/corelib/animation/widget/mcontentfadeandslideanimation_p.h b/src/corelib/animation/widget/mcontentfadeandslideanimation_p.h
index a2d37a93..0fb14e50 100644
--- a/src/corelib/animation/widget/mcontentfadeandslideanimation_p.h
+++ b/src/corelib/animation/widget/mcontentfadeandslideanimation_p.h
@@ -46,6 +46,7 @@ public:
MContentFadeAndSlideAnimationPrivate();
void init();
+ void findContentItem();
QPointer<SnapshotItem> snapshotItem;
QGraphicsWidget* contentItem;
diff --git a/src/corelib/scene/mscenemanager.cpp b/src/corelib/scene/mscenemanager.cpp
index 95d1df38..764edc17 100644
--- a/src/corelib/scene/mscenemanager.cpp
+++ b/src/corelib/scene/mscenemanager.cpp
@@ -63,6 +63,7 @@
#include "mcrossfadedorientationanimation.h"
#include "mabstractwidgetanimation.h"
#include "mpageswitchanimation.h"
+#include "mcontentfadeandslideanimation.h"
#include "msceneeventeater.h"
#include <mwidgetslideanimation.h>
@@ -147,6 +148,9 @@ void MSceneManagerPrivate::init(MScene *scene)
q->connect(pageSwitchAnimation, SIGNAL(finished()),
SLOT(_q_onPageSwitchAnimationFinished()));
+ navigationBarAnimation = new MContentFadeAndSlideAnimation(q);
+ pageSwitchAnimation->addAnimation(navigationBarAnimation);
+
setOrientationAngleWithoutAnimation(newAngle);
q->connect(MTheme::instance(), SIGNAL(themeChangeCompleted()), q, SLOT(_q_updateRootElementsPositions()));
@@ -606,6 +610,9 @@ void MSceneManagerPrivate::addUnmanagedSceneWindow(MSceneWindow *sceneWindow)
sceneWindow->setZValue(zForWindowType(sceneWindow->windowType()));
sceneWindow->hide();
+
+ if (sceneWindow->windowType() == MSceneWindow::NavigationBar)
+ navigationBarAnimation->setTargetWidget(sceneWindow);
}
void MSceneManagerPrivate::addSceneWindow(MSceneWindow *sceneWindow)
@@ -1162,6 +1169,9 @@ void MSceneManagerPrivate::startPageSwitchAnimation(MSceneWindow *newPage,
{
Q_ASSERT(pageSwitchAnimation);
+ navigationBarAnimation->setTransitionDirection(direction == MPageSwitchAnimation::ToChildPage ?
+ MAbstractWidgetAnimation::In : MAbstractWidgetAnimation::Out);
+
pageSwitchAnimation->setNewPage(newPage);
pageSwitchAnimation->setOldPage(oldPage);
pageSwitchAnimation->setTransitionDirection(direction);
@@ -1175,6 +1185,13 @@ void MSceneManagerPrivate::pushPage(MSceneWindow *page, bool animatedTransition)
Q_Q(MSceneManager);
MSceneWindow *previousPage = 0;
+ // last chance to take a snapshot of navigationBar contents before it changes
+ // due to eiter a change in the escape button state or presence (triggered from a
+ // change in the page history, if the escape mode is in "auto") or finally due
+ // to a change in the current page, which will cause the nav bar to be repopulated.
+ if (navigationBarAnimation)
+ navigationBarAnimation->takeContentSnapshot();
+
if (currentPage && currentPage != page) {
previousPage = currentPage;
pageHistory.append(previousPage);
@@ -1204,6 +1221,13 @@ void MSceneManagerPrivate::popPage(bool animatedTransition)
MSceneWindow *previousPage = 0;
bool pageHistoryChanged = false;
+ // last chance to take a snapshot of navigationBar contents before it changes
+ // due to eiter a change in the escape button state or presence (triggered from a
+ // change in the page history, if the escape mode is in "auto") or finally due
+ // to a change in the current page, which will cause the nav bar to be repopulated.
+ if (navigationBarAnimation)
+ navigationBarAnimation->takeContentSnapshot();
+
// Pages in the history might have been deleted overtime.
while (previousPage == 0 && !pageHistory.isEmpty()) {
previousPage = pageHistory.takeLast();
diff --git a/src/corelib/scene/mscenemanager_p.h b/src/corelib/scene/mscenemanager_p.h
index 2e2163f8..d39ad837 100644
--- a/src/corelib/scene/mscenemanager_p.h
+++ b/src/corelib/scene/mscenemanager_p.h
@@ -38,6 +38,7 @@ class MSceneManager;
class MNavigationBar;
class MOrientationAnimation;
class MPageSwitchSlideAnimation;
+class MContentFadeAndSlideAnimation;
class MWindow;
class MSceneEventEater;
@@ -230,6 +231,7 @@ public:
MOrientationAnimation *orientationAnimation;
MPageSwitchAnimation *pageSwitchAnimation;
+ MContentFadeAndSlideAnimation* navigationBarAnimation;
QList<MSceneWindow *> windows;
QList<MSceneWindow *> blockingWindows;
diff --git a/src/corelib/style/mcontentfadeandslideanimationstyle.h b/src/corelib/style/mcontentfadeandslideanimationstyle.h
index 93841e37..9fd888a0 100644
--- a/src/corelib/style/mcontentfadeandslideanimationstyle.h
+++ b/src/corelib/style/mcontentfadeandslideanimationstyle.h
@@ -31,6 +31,7 @@ class MContentFadeAndSlideAnimationStyle : public MAbstractWidgetAnimationStyle
M_STYLE_ATTRIBUTE(QString, contentObjectName, ContentObjectName)
+ M_STYLE_ATTRIBUTE(qreal, fadeOutOpacity, FadeOutOpacity)
M_STYLE_ATTRIBUTE(int, fadeOutDuration, FadeOutDuration)
M_STYLE_ATTRIBUTE(QEasingCurve, fadeOutEasingCurve, FadeOutEasingCurve)
@@ -40,6 +41,7 @@ class MContentFadeAndSlideAnimationStyle : public MAbstractWidgetAnimationStyle
M_STYLE_ATTRIBUTE(int, delay, Delay)
+ M_STYLE_ATTRIBUTE(qreal, fadeInOpacity, FadeInOpacity)
M_STYLE_ATTRIBUTE(int, fadeInDuration, FadeInDuration)
M_STYLE_ATTRIBUTE(QEasingCurve, fadeInEasingCurve, FadeInEasingCurve)
diff --git a/src/corelib/widgets/mapplicationwindow.cpp b/src/corelib/widgets/mapplicationwindow.cpp
index 239674d5..20e93306 100644
--- a/src/corelib/widgets/mapplicationwindow.cpp
+++ b/src/corelib/widgets/mapplicationwindow.cpp
@@ -42,7 +42,6 @@
#include "mstatusbar.h"
#include "mdeviceprofile.h"
#include "mcomponentdata.h"
-#include "mcontentfadeandslideanimation.h"
#include <QList>
#include <QEvent>
@@ -99,7 +98,6 @@ MApplicationWindowPrivate::MApplicationWindowPrivate()
, showingDockWidget(false)
, animateNavigationBarTransitions(false)
, navigationBarPressed(false)
- , navigationBarAnimation(0)
, styleContainer(0)
{
if(MDeviceProfile::instance()->showStatusbar()) {
@@ -219,12 +217,6 @@ void MApplicationWindowPrivate::init()
sceneManager->appearSceneWindowNow(homeButtonPanel);
- navigationBarAnimation = new MContentFadeAndSlideAnimation(q);
- navigationBarAnimation->setTargetWidget(navigationBar);
- // when pageHistoryChange is emitted it's last chance to grab previous navigationBar contents
- q->connect(q->sceneManager(), SIGNAL(pageHistoryChanged()),
- navigationBarAnimation, SLOT(takeContentSnapshot()));
-
// Initialize escape button to close mode.
navigationBar->setEscapeButtonMode(MNavigationBarModel::EscapeButtonClose);
QObject::connect(navigationBar, SIGNAL(closeButtonClicked()), q, SLOT(close()));
@@ -888,13 +880,6 @@ void MApplicationWindowPrivate::applicationPageAppearEvent(MSceneWindowEvent *ev
connectPage(pageFromEvent);
_q_updatePageExposedContentRect();
- if (event->animatedTransition() &&
- (toolBar->viewType() == MToolBar::defaultType ||
- previousToolBarViewType == MToolBar::defaultType))
- {
- navigationBarAnimation->start();
- }
-
#ifdef Q_WS_X11
if (pageFromEvent && isChained && sceneManager) {
bool isFirstPage = sceneManager->pageHistory().isEmpty();
@@ -908,8 +893,6 @@ void MApplicationWindowPrivate::applicationPageAppearEvent(MSceneWindowEvent *ev
void MApplicationWindowPrivate::applicationPageDisappearEvent(MSceneWindowEvent *event)
{
- previousToolBarViewType = toolBar->viewType();
-
MApplicationPage *pageFromEvent = static_cast<MApplicationPage *>(event->sceneWindow());
// Page is going away. Let's disconnect it if it's the current page.
diff --git a/src/corelib/widgets/mapplicationwindow_p.h b/src/corelib/widgets/mapplicationwindow_p.h
index 46efc9bd..5395a448 100644
--- a/src/corelib/widgets/mapplicationwindow_p.h
+++ b/src/corelib/widgets/mapplicationwindow_p.h
@@ -46,7 +46,6 @@ class MApplicationPageInfo;
class MApplicationWindow;
class MSceneWindowEvent;
class QActionEvent;
-class MContentFadeAndSlideAnimation;
class MApplicationWindowPrivate : public MWindowPrivate
{
@@ -88,9 +87,6 @@ public:
bool navigationBarPressed;
- MContentFadeAndSlideAnimation* navigationBarAnimation;
- QString previousToolBarViewType;
-
void manageActions();
void distributeAction(QAction *action, QAction *before);
void refreshArrowIconVisibility();