emailuis/nmailui/src/nmuieffects.cpp
changeset 43 99bcbff212ad
parent 23 2dc6caa42ec3
child 47 f83bd4ae1fe3
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    30 NmUiEffects::NmUiEffects(HbMainWindow &mainWindow) :
    30 NmUiEffects::NmUiEffects(HbMainWindow &mainWindow) :
    31     mMainWindow(mainWindow),
    31     mMainWindow(mainWindow),
    32     mSendAnimationScreenShot(NULL),
    32     mSendAnimationScreenShot(NULL),
    33     mDoSendAnimation(false)
    33     mDoSendAnimation(false)
    34 {
    34 {
       
    35     NM_FUNCTION;
    35 }
    36 }
    36 
    37 
    37 /*!
    38 /*!
    38     Destructor
    39     Destructor
    39 */
    40 */
    40 NmUiEffects::~NmUiEffects()
    41 NmUiEffects::~NmUiEffects()
    41 {
    42 {
       
    43     NM_FUNCTION;
       
    44     
    42     // Clean send animation if sendAnimationComplete slot is not called for some reason.
    45     // Clean send animation if sendAnimationComplete slot is not called for some reason.
    43     // E.g. red key pressed.
    46     // E.g. red key pressed.
    44     resetSendAnimation();
    47     resetSendAnimation();
    45 }
    48 }
    46 
    49 
    47 /*!
    50 /*!
    48     Function will perform needed initializations for selected effect.
    51     Function will perform needed initializations for selected effect.
    49 */
    52 */
    50 void NmUiEffects::prepareEffect(NmUiEffectType effect)
    53 void NmUiEffects::prepareEffect(NmUiEffectType effect)
    51 {
    54 {
       
    55     NM_FUNCTION;
       
    56     
    52     switch (effect) {
    57     switch (effect) {
    53     case NmEditorSendMessageAnimation:
    58     case NmEditorSendMessageAnimation:
    54         // delete any existing stuff
    59         // delete any existing stuff
    55         resetSendAnimation();
    60         resetSendAnimation();
    56         
    61         
    63         
    68         
    64         // Create graphics item based pixmap image but don't show it yet.
    69         // Create graphics item based pixmap image but don't show it yet.
    65         mSendAnimationScreenShot->hide();
    70         mSendAnimationScreenShot->hide();
    66         mSendAnimationScreenShot->setPos(0,0);
    71         mSendAnimationScreenShot->setPos(0,0);
    67         mSendAnimationScreenShot->setZValue(0);
    72         mSendAnimationScreenShot->setZValue(0);
       
    73 
       
    74         // Adds or moves the item and all its childen to this scene.
       
    75         // This scene takes ownership of the item.
    68         mMainWindow.scene()->addItem(mSendAnimationScreenShot);
    76         mMainWindow.scene()->addItem(mSendAnimationScreenShot);
    69 
    77 
    70         // Set editor screen capture visible before old view is popped.
    78         // Set editor screen capture visible before old view is popped.
    71         // New view is drawn under this image.
    79         // New view is drawn under this image.
    72         mSendAnimationScreenShot->show();
    80         mSendAnimationScreenShot->show();
    79 /*!
    87 /*!
    80     Function will start the selected effect.
    88     Function will start the selected effect.
    81 */
    89 */
    82 void NmUiEffects::startEffect(NmUiEffectType effect)
    90 void NmUiEffects::startEffect(NmUiEffectType effect)
    83 {
    91 {
       
    92     NM_FUNCTION;
       
    93     
    84     switch (effect) {
    94     switch (effect) {
    85     case NmEditorSendMessageAnimation:
    95     case NmEditorSendMessageAnimation:
    86         // Send message animation for editor view.
    96         // Send message animation for editor view.
    87         if (mDoSendAnimation && mSendAnimationScreenShot) {
    97         if (mDoSendAnimation && mSendAnimationScreenShot) {
    88             mDoSendAnimation = false;
    98             mDoSendAnimation = false;
    97    Generates a screenshot of the current screen. Picture is rotated
   107    Generates a screenshot of the current screen. Picture is rotated
    98    according to the main window orientation.
   108    according to the main window orientation.
    99  */
   109  */
   100 QGraphicsPixmapItem *NmUiEffects::screenShot()
   110 QGraphicsPixmapItem *NmUiEffects::screenShot()
   101 {
   111 {
       
   112     NM_FUNCTION;
       
   113     
   102     // Grab whole view into pixmap image (also chrome is included)
   114     // Grab whole view into pixmap image (also chrome is included)
   103     QPixmap screenCapture = QPixmap::grabWindow(mMainWindow.internalWinId());
   115     QPixmap screenCapture = QPixmap::grabWindow(mMainWindow.internalWinId());
   104 
   116 
   105     QGraphicsPixmapItem *ret = NULL;
   117     QGraphicsPixmapItem *ret = NULL;
   106     
   118     
   120 /*!
   132 /*!
   121    Clean up for send animation
   133    Clean up for send animation
   122  */
   134  */
   123 void NmUiEffects::resetSendAnimation()
   135 void NmUiEffects::resetSendAnimation()
   124 {
   136 {
       
   137     NM_FUNCTION;
       
   138     
   125     if (mSendAnimationScreenShot) {
   139     if (mSendAnimationScreenShot) {
   126         // Clean send animation
   140         // Clean send animation
   127         HbEffect::remove(mSendAnimationScreenShot, SendAnimation, "mail_send");
   141         HbEffect::remove(mSendAnimationScreenShot, SendAnimation, "mail_send");
       
   142         // Ownership of QGraphicsPixmapItem is tranferred to GraphicsScene when it has been added
       
   143         // to it GraphicsScene.
       
   144         // GraphicsPixmapItem needs to be removed from the GraphicsScene before deleting
       
   145         // it to prevent double deletion.
       
   146         mMainWindow.scene()->removeItem(mSendAnimationScreenShot);
   128         delete mSendAnimationScreenShot;
   147         delete mSendAnimationScreenShot;
   129         mSendAnimationScreenShot = NULL;
   148         mSendAnimationScreenShot = NULL;
   130         mDoSendAnimation = false;
   149         mDoSendAnimation = false;
   131     }
   150     }
   132 }
   151 }
   134 /*!
   153 /*!
   135     Slot is called when send message animation for editor view has been completed.
   154     Slot is called when send message animation for editor view has been completed.
   136 */
   155 */
   137 void NmUiEffects::sendAnimationComplete(HbEffect::EffectStatus status)
   156 void NmUiEffects::sendAnimationComplete(HbEffect::EffectStatus status)
   138 {
   157 {
       
   158     NM_FUNCTION;
       
   159     
   139     Q_UNUSED(status);
   160     Q_UNUSED(status);
   140     resetSendAnimation();
   161     resetSendAnimation();
   141 }
   162 }