--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmailui/src/nmuieffects.cpp Fri May 14 15:41:10 2010 +0300
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Graphical effects/animations for nmail ui.
+*
+*/
+
+#include "nmuiheaders.h"
+
+static const char *SendAnimation = ":/effects/mail_send.fxml";
+
+/*!
+ \class NmEffects
+ \brief This class is for launching the effects
+*/
+
+/*!
+ Constructor
+*/
+NmUiEffects::NmUiEffects(HbMainWindow &mainWindow) :
+ mMainWindow(mainWindow),
+ mSendAnimationScreenShot(NULL),
+ mDoSendAnimation(false)
+{
+}
+
+/*!
+ Destructor
+*/
+NmUiEffects::~NmUiEffects()
+{
+ // Clean send animation if sendAnimationComplete slot is not called for some reason.
+ // E.g. red key pressed.
+ resetSendAnimation();
+}
+
+/*!
+ Function will perform needed initializations for selected effect.
+*/
+void NmUiEffects::prepareEffect(NmUiEffectType effect)
+{
+ switch (effect) {
+ case NmEditorSendMessageAnimation:
+ // delete any existing stuff
+ resetSendAnimation();
+
+ // This effect is for editor send message. Get the screen capture of
+ // editor view for animation which will be lauched soon.
+ mDoSendAnimation = true;
+
+ // take screen shot
+ mSendAnimationScreenShot = screenShot();
+
+ // Create graphics item based pixmap image but don't show it yet.
+ mSendAnimationScreenShot->hide();
+ mSendAnimationScreenShot->setPos(0,0);
+ mSendAnimationScreenShot->setZValue(0);
+ mMainWindow.scene()->addItem(mSendAnimationScreenShot);
+
+ // Set editor screen capture visible before old view is popped.
+ // New view is drawn under this image.
+ mSendAnimationScreenShot->show();
+
+ HbEffect::add(mSendAnimationScreenShot, SendAnimation, "mail_send");
+ break;
+ }
+}
+
+/*!
+ Function will start the selected effect.
+*/
+void NmUiEffects::startEffect(NmUiEffectType effect)
+{
+ switch (effect) {
+ case NmEditorSendMessageAnimation:
+ // Send message animation for editor view.
+ if (mDoSendAnimation && mSendAnimationScreenShot) {
+ mDoSendAnimation = false;
+ // Start animation and connect completion signal to sendAnimationComplete slot.
+ HbEffect::start(mSendAnimationScreenShot, "mail_send", this, "sendAnimationComplete");
+ }
+ break;
+ }
+}
+
+/*!
+ Generates a screenshot of the current screen. Picture is rotated
+ according to the main window orientation.
+ */
+QGraphicsPixmapItem *NmUiEffects::screenShot()
+{
+ // Grab whole view into pixmap image (also chrome is included)
+ QPixmap screenCapture = QPixmap::grabWindow(mMainWindow.internalWinId());
+
+ QGraphicsPixmapItem *ret = NULL;
+
+ // for landscape, the screenshot must be rotated
+ if(mMainWindow.orientation() == Qt::Horizontal) {
+ QMatrix mat;
+ mat.rotate(-90); // rotate 90 degrees counter-clockwise
+ ret = new QGraphicsPixmapItem(screenCapture.transformed(mat));
+ }
+ else {
+ ret = new QGraphicsPixmapItem(screenCapture);
+ }
+
+ return ret;
+}
+
+/*!
+ Clean up for send animation
+ */
+void NmUiEffects::resetSendAnimation()
+{
+ if (mSendAnimationScreenShot) {
+ // Clean send animation
+ HbEffect::remove(mSendAnimationScreenShot, SendAnimation, "mail_send");
+ delete mSendAnimationScreenShot;
+ mSendAnimationScreenShot = NULL;
+ mDoSendAnimation = false;
+ }
+}
+
+/*!
+ Slot is called when send message animation for editor view has been completed.
+*/
+void NmUiEffects::sendAnimationComplete(HbEffect::EffectStatus status)
+{
+ Q_UNUSED(status);
+ resetSendAnimation();
+}