messagingapp/msgui/unifiedviewer/src/univiewerpixmapwidget.cpp
changeset 41 25fe1fe642e3
parent 37 518b245aa84c
child 51 3507212d340e
equal deleted inserted replaced
40:224522e33db9 41:25fe1fe642e3
    36 
    36 
    37 const QString PIXMAP_ICON("qtg_small_image");
    37 const QString PIXMAP_ICON("qtg_small_image");
    38 const QString CORRUPTED_PIXMAP_ICON("qtg_large_corrupted");
    38 const QString CORRUPTED_PIXMAP_ICON("qtg_large_corrupted");
    39 const QString VIDEO_MIMETYPE("video");
    39 const QString VIDEO_MIMETYPE("video");
    40 const QString MSG_VIDEO_ICON("qtg_small_video");
    40 const QString MSG_VIDEO_ICON("qtg_small_video");
       
    41 const QString VIDEO_OVERLAY_ICON("qtg_large_video_player");
       
    42 
       
    43 const int WIDTH_RATIO = 4;
       
    44 const int HEIGHT_RATIO = 3;
    41 
    45 
    42 //---------------------------------------------------------------
    46 //---------------------------------------------------------------
    43 // UniViewerPixmapWidget::UniViewerPixmapWidget
    47 // UniViewerPixmapWidget::UniViewerPixmapWidget
    44 // @see header file
    48 // @see header file
    45 //---------------------------------------------------------------
    49 //---------------------------------------------------------------
    46 UniViewerPixmapWidget::UniViewerPixmapWidget(QGraphicsItem *parent) :
    50 UniViewerPixmapWidget::UniViewerPixmapWidget(QGraphicsItem *parent) :
    47     HbIconItem(parent), mViewerUtils(0), mThumbnailManager(0)
    51     HbIconItem(parent), mViewerUtils(0), mThumbnailManager(0)
    48 {
    52 {
    49     this->grabGesture(Qt::TapGesture);
    53     this->grabGesture(Qt::TapGesture);
    50     init();
    54     init();
    51 }
       
    52 
       
    53 //---------------------------------------------------------------
       
    54 // UniViewerPixmapWidget::init
       
    55 // @see header file
       
    56 //---------------------------------------------------------------
       
    57 void UniViewerPixmapWidget::init() 
       
    58 {
       
    59     mThumbnailManager = new ThumbnailManager(this);
       
    60     mThumbnailManager->setMode(ThumbnailManager::Default);
       
    61     mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality);
       
    62     mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
       
    63 
       
    64     connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), this,
       
    65     SLOT(thumbnailReady(QPixmap, void*, int, int)));
       
    66 
       
    67 }
    55 }
    68 
    56 
    69 //---------------------------------------------------------------
    57 //---------------------------------------------------------------
    70 // UniViewerPixmapWidget::~UniViewerPixmapWidget
    58 // UniViewerPixmapWidget::~UniViewerPixmapWidget
    71 // @see header file
    59 // @see header file
   166 //---------------------------------------------------------------
   154 //---------------------------------------------------------------
   167 void UniViewerPixmapWidget::handleSave()
   155 void UniViewerPixmapWidget::handleSave()
   168 {
   156 {
   169 }
   157 }
   170 
   158 
       
   159 //---------------------------------------------------------------
       
   160 // UniViewerPixmapWidget::regrabGesture
       
   161 // @see header file
       
   162 //---------------------------------------------------------------
       
   163 void UniViewerPixmapWidget::regrabGesture()
       
   164 {
       
   165     this->grabGesture(Qt::TapGesture);
       
   166 }
       
   167 
       
   168 //---------------------------------------------------------------
       
   169 // UniViewerPixmapWidget::thumbnailReady
       
   170 // @see header
       
   171 //---------------------------------------------------------------
       
   172 void UniViewerPixmapWidget::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error)
       
   173 {
       
   174     Q_UNUSED(data)
       
   175     Q_UNUSED(id)
       
   176     this->grabGesture(Qt::TapGesture);
       
   177     if (!error) {
       
   178         this->setIcon(HbIcon(pixmap));
       
   179         this->hide();
       
   180         emit setOverlayIcon(VIDEO_OVERLAY_ICON);
       
   181     }
       
   182 }
       
   183 
       
   184 //---------------------------------------------------------------
       
   185 // UniViewerPixmapWidget::init
       
   186 // @see header file
       
   187 //---------------------------------------------------------------
       
   188 void UniViewerPixmapWidget::init()
       
   189 {
       
   190     mThumbnailManager = new ThumbnailManager(this);
       
   191     mThumbnailManager->setMode(ThumbnailManager::CropToAspectRatio);
       
   192     mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality);
       
   193     mThumbnailManager->setThumbnailSize(getThumbnailSize());
       
   194 
       
   195     connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), this,
       
   196         SLOT(thumbnailReady(QPixmap, void*, int, int)));
       
   197 }
       
   198 
   171 //----------------------------------------------------------------------------
   199 //----------------------------------------------------------------------------
   172 // UniViewerPixmapWidget::handleShortTap
   200 // UniViewerPixmapWidget::handleShortTap
   173 // @see header file
   201 // @see header file
   174 //----------------------------------------------------------------------------
   202 //----------------------------------------------------------------------------
   175 void UniViewerPixmapWidget::handleShortTap()
   203 void UniViewerPixmapWidget::handleShortTap()
   195     menu->setPreferredPos(position);
   223     menu->setPreferredPos(position);
   196     menu->show();
   224     menu->show();
   197 }
   225 }
   198 
   226 
   199 //---------------------------------------------------------------
   227 //---------------------------------------------------------------
   200 // UniViewerPixmapWidget::regrabGesture
   228 // UniViewerPixmapWidget::getThumbnailSize
   201 // @see header file
   229 // @see header file
   202 //---------------------------------------------------------------
   230 //---------------------------------------------------------------
   203 void UniViewerPixmapWidget::regrabGesture()
   231 QSize UniViewerPixmapWidget::getThumbnailSize()
   204 {
   232 {
   205     this->grabGesture(Qt::TapGesture);
   233     QSize thumbnailSize(1, 1);
   206 }
   234     HbWidget *parent = qobject_cast<HbWidget *>(this->parentWidget());
   207 
   235 
   208 //---------------------------------------------------------------
   236     if (parent) {
   209 // UniViewerPixmapWidget::thumbnailReady
   237         qreal thumbnailWidth = 0.0;
   210 // @see header
   238         qreal thumbnailHeight = 0.0;
   211 //---------------------------------------------------------------
   239         parent->style()->parameter("hb-param-screen-short-edge", thumbnailWidth);
   212 void UniViewerPixmapWidget::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error)
   240         thumbnailHeight = (thumbnailWidth * HEIGHT_RATIO) / WIDTH_RATIO;
   213 {
   241         thumbnailSize.setHeight(qRound(thumbnailHeight));
   214     Q_UNUSED(data)
   242         thumbnailSize.setWidth(qRound(thumbnailWidth));
   215     Q_UNUSED(id)
   243     }
   216     this->grabGesture(Qt::TapGesture);
   244     return thumbnailSize;
   217     if (!error) {
   245 }
   218         this->setIcon(HbIcon(pixmap));
   246 
   219         this->hide();
       
   220         this->updateGeometry();
       
   221     }
       
   222 }
       
   223 // EOF
   247 // EOF