taskswitcher/server/src/tsenv.cpp
changeset 119 50e220be30d1
equal deleted inserted replaced
116:305818acdca4 119:50e220be30d1
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #include "tsenv.h"
       
    18 
       
    19 const int thumbnailWidth(128);
       
    20 const int thumbnailHeight(128);
       
    21 
       
    22 void TsEnv::createThumbnail(const QPixmap& source, 
       
    23                             int angle, 
       
    24                             const void* userData)
       
    25 {
       
    26     try {
       
    27     QPixmap thumbnailSource;
       
    28     const Qt::Axis rotationAxis(Qt::ZAxis); 
       
    29     if ( 270 <= angle ) {
       
    30         thumbnailSource = source.transformed(QTransform().rotate(270.0f, 
       
    31                                                                  rotationAxis),
       
    32                                              Qt::SmoothTransformation);
       
    33     } else if( 180 <= angle ) {
       
    34         thumbnailSource = source.transformed(QTransform().rotate(180.0f, 
       
    35                                                                  rotationAxis),
       
    36                                              Qt::SmoothTransformation);
       
    37     } else if( 90 <= angle ) {
       
    38         thumbnailSource = source.transformed(QTransform().rotate(90.0f, 
       
    39                                                                  rotationAxis),
       
    40                                              Qt::SmoothTransformation);
       
    41     } else {
       
    42         thumbnailSource = source;
       
    43     }
       
    44     const QRect expectedRect(0, 0, thumbnailWidth, thumbnailHeight);
       
    45     const QPixmap thumbanail(thumbnailSource.scaled(expectedRect.size(), 
       
    46                                                     Qt::KeepAspectRatioByExpanding,
       
    47                                                     Qt::SmoothTransformation));
       
    48     emit thumbnailCreated(thumbanail.copy(expectedRect), userData);
       
    49     } catch (...) {
       
    50     }
       
    51 }