|         |      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: This widget displays the pixmap content in viewer. | 
|         |     15  * | 
|         |     16  */ | 
|         |     17  | 
|         |     18 #include "univiewerpixmapwidget.h" | 
|         |     19  | 
|         |     20 #include <HbTapGesture> | 
|         |     21 #include <HbWidget> | 
|         |     22 #include <HbInstantFeedback> | 
|         |     23 #include <QPixmap> | 
|         |     24  | 
|         |     25 //--------------------------------------------------------------- | 
|         |     26 // UniViewerPixmapWidget::UniViewerPixmapWidget | 
|         |     27 // @see header file | 
|         |     28 //--------------------------------------------------------------- | 
|         |     29 UniViewerPixmapWidget::UniViewerPixmapWidget(QGraphicsItem *parent) : | 
|         |     30     HbIconItem(parent) | 
|         |     31 { | 
|         |     32     mPixmapFile = QString(""); | 
|         |     33     this->grabGesture(Qt::TapGesture); | 
|         |     34 } | 
|         |     35  | 
|         |     36 //--------------------------------------------------------------- | 
|         |     37 // UniViewerPixmapWidget::~UniViewerPixmapWidget | 
|         |     38 // @see header file | 
|         |     39 //--------------------------------------------------------------- | 
|         |     40 UniViewerPixmapWidget::~UniViewerPixmapWidget() | 
|         |     41 { | 
|         |     42 } | 
|         |     43  | 
|         |     44 //--------------------------------------------------------------- | 
|         |     45 // UniViewerPixmapWidget::setPixmap | 
|         |     46 // @see header file | 
|         |     47 //--------------------------------------------------------------- | 
|         |     48 void UniViewerPixmapWidget::setPixmap(const QString &pixmapPath) | 
|         |     49 { | 
|         |     50     mPixmapFile = pixmapPath; | 
|         |     51     QPixmap pixmap(pixmapPath); | 
|         |     52     this->setIcon(HbIcon(pixmap)); | 
|         |     53 } | 
|         |     54  | 
|         |     55 //--------------------------------------------------------------- | 
|         |     56 // UniViewerPixmapWidget::gestureEvent | 
|         |     57 // @see header file | 
|         |     58 //--------------------------------------------------------------- | 
|         |     59 void UniViewerPixmapWidget::gestureEvent(QGestureEvent *event) | 
|         |     60 { | 
|         |     61     HbTapGesture *tapGesture = qobject_cast<HbTapGesture*> (event->gesture(Qt::TapGesture)); | 
|         |     62     if (tapGesture) { | 
|         |     63         switch (tapGesture->state()) { | 
|         |     64         case Qt::GestureStarted: | 
|         |     65         { | 
|         |     66             // Trigger haptic feedback. | 
|         |     67             HbInstantFeedback::play(HbFeedback::Basic); | 
|         |     68             break; | 
|         |     69         } | 
|         |     70         case Qt::GestureUpdated: | 
|         |     71         { | 
|         |     72             if (HbTapGesture::TapAndHold == tapGesture->tapStyleHint()) { | 
|         |     73                 // emit longtap | 
|         |     74             } | 
|         |     75             break; | 
|         |     76         } | 
|         |     77         case Qt::GestureFinished: | 
|         |     78         { | 
|         |     79             if (HbTapGesture::Tap == tapGesture->tapStyleHint()) { | 
|         |     80                 // Emit short tap | 
|         |     81                 emit shortTap(mPixmapFile); | 
|         |     82             } | 
|         |     83             break; | 
|         |     84         } | 
|         |     85         case Qt::GestureCanceled: | 
|         |     86         { | 
|         |     87             break; | 
|         |     88         } | 
|         |     89         } | 
|         |     90     } | 
|         |     91 } | 
|         |     92  | 
|         |     93 // EOF |