emailuis/nmailui/src/nmuieffects.cpp
changeset 54 997a02608b3a
parent 30 759dc5235cdb
equal deleted inserted replaced
53:bf7eb7911fc5 54:997a02608b3a
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "nmuiheaders.h"
    18 #include "nmuiheaders.h"
    19 
    19 
    20 static const char *SendAnimation = ":/effects/mail_send.fxml";
    20 static const char *NmSendAnimation = ":/effects/mail_send.fxml";
    21 
    21 
    22 /*!
    22 /*!
    23     \class NmEffects
    23     \class NmEffects
    24     \brief This class is for launching the effects
    24     \brief This class is for launching the effects
    25 */
    25 */
    53 void NmUiEffects::prepareEffect(NmUiEffectType effect)
    53 void NmUiEffects::prepareEffect(NmUiEffectType effect)
    54 {
    54 {
    55     NM_FUNCTION;
    55     NM_FUNCTION;
    56     
    56     
    57     switch (effect) {
    57     switch (effect) {
    58     case NmEditorSendMessageAnimation:
    58         case NmEditorSendMessageAnimation: {
    59         // delete any existing stuff
    59             // delete any existing stuff
    60         resetSendAnimation();
    60             resetSendAnimation();
       
    61             
       
    62             // This effect is for editor send message. Get the screen capture of
       
    63             // editor view for animation which will be lauched soon.
       
    64             mDoSendAnimation = true;
       
    65     
       
    66             // take screen shot
       
    67             mSendAnimationScreenShot = screenShot();
       
    68             
       
    69             if (mSendAnimationScreenShot){
       
    70                 // Create graphics item based pixmap image but don't show it yet.
       
    71                 mSendAnimationScreenShot->hide();
       
    72                 mSendAnimationScreenShot->setPos(0,0);
       
    73                 mSendAnimationScreenShot->setZValue(0);
    61         
    74         
    62         // This effect is for editor send message. Get the screen capture of
    75                 // Adds or moves the item and all its childen to this scene.
    63         // editor view for animation which will be lauched soon.
    76                 // This scene takes ownership of the item.
    64         mDoSendAnimation = true;
    77                 mMainWindow.scene()->addItem(mSendAnimationScreenShot);
    65 
       
    66         // take screen shot
       
    67         mSendAnimationScreenShot = screenShot();
       
    68         
    78         
    69         // Create graphics item based pixmap image but don't show it yet.
    79                 // Set editor screen capture visible before old view is popped.
    70         mSendAnimationScreenShot->hide();
    80                 // New view is drawn under this image.
    71         mSendAnimationScreenShot->setPos(0,0);
    81                 mSendAnimationScreenShot->show();
    72         mSendAnimationScreenShot->setZValue(0);
    82         
    73 
    83                 HbEffect::add(mSendAnimationScreenShot, NmSendAnimation, "mail_send");        
    74         // Adds or moves the item and all its childen to this scene.
    84             }
    75         // This scene takes ownership of the item.
    85             break;
    76         mMainWindow.scene()->addItem(mSendAnimationScreenShot);
    86         }
    77 
       
    78         // Set editor screen capture visible before old view is popped.
       
    79         // New view is drawn under this image.
       
    80         mSendAnimationScreenShot->show();
       
    81 
       
    82         HbEffect::add(mSendAnimationScreenShot, SendAnimation, "mail_send");
       
    83         break;
       
    84     }
    87     }
    85 }
    88 }
    86 
    89 
    87 /*!
    90 /*!
    88     Function will start the selected effect.
    91     Function will start the selected effect.
    90 void NmUiEffects::startEffect(NmUiEffectType effect)
    93 void NmUiEffects::startEffect(NmUiEffectType effect)
    91 {
    94 {
    92     NM_FUNCTION;
    95     NM_FUNCTION;
    93     
    96     
    94     switch (effect) {
    97     switch (effect) {
    95     case NmEditorSendMessageAnimation:
    98         case NmEditorSendMessageAnimation: {
    96         // Send message animation for editor view.
    99             // Send message animation for editor view.
    97         if (mDoSendAnimation && mSendAnimationScreenShot) {
   100             if (mDoSendAnimation && mSendAnimationScreenShot) {
    98             mDoSendAnimation = false;
   101                 mDoSendAnimation = false;
    99             // Start animation and connect completion signal to sendAnimationComplete slot.
   102                 // Start animation and connect completion signal to sendAnimationComplete slot.
   100             HbEffect::start(mSendAnimationScreenShot, "mail_send", this, "sendAnimationComplete");
   103                 HbEffect::start(mSendAnimationScreenShot, "mail_send", this, "sendAnimationComplete");
       
   104             }
       
   105             break;
   101         }
   106         }
   102         break;
       
   103     }
   107     }
   104 }
   108 }
   105 
   109 
   106 /*!
   110 /*!
   107    Generates a screenshot of the current screen. Picture is rotated
   111    Generates a screenshot of the current screen. Picture is rotated
   111 {
   115 {
   112     NM_FUNCTION;
   116     NM_FUNCTION;
   113     
   117     
   114     // Grab whole view into pixmap image (also chrome is included)
   118     // Grab whole view into pixmap image (also chrome is included)
   115     QPixmap screenCapture = QPixmap::grabWindow(mMainWindow.internalWinId());
   119     QPixmap screenCapture = QPixmap::grabWindow(mMainWindow.internalWinId());
   116 
   120     QGraphicsPixmapItem *ret(NULL);
   117     QGraphicsPixmapItem *ret = NULL;
       
   118     
   121     
   119     // for landscape, the screenshot must be rotated
   122     // for landscape, the screenshot must be rotated
   120     if(mMainWindow.orientation() == Qt::Horizontal) {
   123     if(mMainWindow.orientation() == Qt::Horizontal) {
   121         QMatrix mat;
   124         QMatrix mat;
   122         mat.rotate(-90); // rotate 90 degrees counter-clockwise
   125         mat.rotate(-90); // rotate 90 degrees counter-clockwise
   136 {
   139 {
   137     NM_FUNCTION;
   140     NM_FUNCTION;
   138     
   141     
   139     if (mSendAnimationScreenShot) {
   142     if (mSendAnimationScreenShot) {
   140         // Clean send animation
   143         // Clean send animation
   141         HbEffect::remove(mSendAnimationScreenShot, SendAnimation, "mail_send");
   144         HbEffect::remove(mSendAnimationScreenShot, NmSendAnimation, "mail_send");
   142         // Ownership of QGraphicsPixmapItem is tranferred to GraphicsScene when it has been added
   145         // Ownership of QGraphicsPixmapItem is tranferred to GraphicsScene when it has been added
   143         // to it GraphicsScene.
   146         // to it GraphicsScene.
   144         // GraphicsPixmapItem needs to be removed from the GraphicsScene before deleting
   147         // GraphicsPixmapItem needs to be removed from the GraphicsScene before deleting
   145         // it to prevent double deletion.
   148         // it to prevent double deletion.
   146         mMainWindow.scene()->removeItem(mSendAnimationScreenShot);
   149         mMainWindow.scene()->removeItem(mSendAnimationScreenShot);