41 #include "videosortfilterproxymodel.h" |
41 #include "videosortfilterproxymodel.h" |
42 #include "videoservices.h" |
42 #include "videoservices.h" |
43 #include "videodetailslabel.h" |
43 #include "videodetailslabel.h" |
44 |
44 |
45 const char* const VIDEO_DETAILS_DOCML = ":/xml/videofiledetails.docml"; |
45 const char* const VIDEO_DETAILS_DOCML = ":/xml/videofiledetails.docml"; |
46 const char* const VIDEO_DETAILS_GFX_PLAY = ":/gfx/play.png"; |
46 const char* const VIDEO_DETAILS_PORTRAIT = "portrait"; |
|
47 const char* const VIDEO_DETAILS_LANDSCAPE = "landscape"; |
47 const char* const VIDEO_DETAILS_GFX_DEFAULT = ":/gfx/pri_large_video.svg"; |
48 const char* const VIDEO_DETAILS_GFX_DEFAULT = ":/gfx/pri_large_video.svg"; |
48 const char* const VIDEO_DETAILS_VIEW = "videofiledetailsview"; |
49 const char* const VIDEO_DETAILS_VIEW = "videofiledetailsview"; |
49 const char* const VIDEO_DETAILS_TITLE = "mLblTitle"; |
50 const char* const VIDEO_DETAILS_TITLE = "mLblTitle"; |
50 const char* const VIDEO_DETAILS_THUMBNAIL = "mDetailsLabel"; |
51 const char* const VIDEO_DETAILS_THUMBNAIL = "mDetailsLabel"; |
51 const char* const VIDEO_DETAILS_BUTTON = "mButton"; |
52 const char* const VIDEO_DETAILS_BUTTON = "mButton"; |
92 // Create view |
93 // Create view |
93 // --------------------------------------------------------------------------- |
94 // --------------------------------------------------------------------------- |
94 // |
95 // |
95 void VideoFileDetailsViewPlugin::createView() |
96 void VideoFileDetailsViewPlugin::createView() |
96 { |
97 { |
97 if (VideoFileDetailsViewPlugin::EPreCreated == mCreated) |
98 mLoader.reset(); |
98 { |
99 |
99 finalizeCreateView(); |
|
100 } |
|
101 else if (VideoFileDetailsViewPlugin::ENotCreated == mCreated) |
|
102 { |
|
103 preCreateView(); |
|
104 } |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // preCreateView |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 void VideoFileDetailsViewPlugin::preCreateView() |
|
112 { |
|
113 mActivated = false; |
100 mActivated = false; |
114 mCreated = VideoFileDetailsViewPlugin::EPreCreated; |
101 |
115 |
102 bool ok = false; |
116 if (!mThumbnailManager) |
103 |
|
104 //Load the details view docml first |
|
105 mLoader.load(VIDEO_DETAILS_DOCML, &ok); |
|
106 |
|
107 if(!ok) |
117 { |
108 { |
118 mThumbnailManager = new ThumbnailManager(); |
109 return; |
119 } |
110 } |
120 } |
111 |
121 // --------------------------------------------------------------------------- |
112 //Load portrait section by default as only vertical orientation is currently supported by videoplayer |
122 // finalizeCreateView |
113 mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT, &ok); |
123 // --------------------------------------------------------------------------- |
114 |
124 // |
115 if(!ok) |
125 void VideoFileDetailsViewPlugin::finalizeCreateView() |
116 { |
126 { |
117 return; |
127 mView.reset(); |
118 } |
128 mActivated = false; |
|
129 mCreated = VideoFileDetailsViewPlugin::EFinalized; |
|
130 bool ok = false; |
|
131 mView.load(VIDEO_DETAILS_DOCML, &ok); |
|
132 |
119 |
133 mModel = mCollectionWrapper.getModel(VideoCollectionWrapper::EAllVideos); |
120 mModel = mCollectionWrapper.getModel(VideoCollectionWrapper::EAllVideos); |
134 |
121 |
135 if (!mModel) |
122 if (!mModel) |
136 { |
123 { |
151 |
138 |
152 connect(mModel->sourceModel(), |
139 connect(mModel->sourceModel(), |
153 SIGNAL(shortDetailsReady(TMPXItemId)), |
140 SIGNAL(shortDetailsReady(TMPXItemId)), |
154 this, SLOT(shortDetailsReadySlot(TMPXItemId))); |
141 this, SLOT(shortDetailsReadySlot(TMPXItemId))); |
155 |
142 |
156 connect(mModel, |
143 connect(mModel->sourceModel(), |
157 SIGNAL(fullDetailsReady(TMPXItemId)), |
144 SIGNAL(fullVideoDetailsReady(TMPXItemId)), |
158 this, SLOT(fullDetailsReadySlot(TMPXItemId))); |
145 this, SLOT(fullDetailsReadySlot(TMPXItemId))); |
159 |
146 |
160 connect(mModel, |
147 connect(mModel, |
161 SIGNAL(rowsRemoved(const QModelIndex&, int, int)), |
148 SIGNAL(rowsRemoved(const QModelIndex&, int, int)), |
162 this, SLOT(rowsRemovedSlot(const QModelIndex&, int, int))); |
149 this, SLOT(rowsRemovedSlot(const QModelIndex&, int, int))); |
184 } |
171 } |
185 else |
172 else |
186 { |
173 { |
187 connect(deleteAction, SIGNAL(triggered(bool)), this, SLOT(deleteVideoSlot())); |
174 connect(deleteAction, SIGNAL(triggered(bool)), this, SLOT(deleteVideoSlot())); |
188 } |
175 } |
189 |
176 |
190 // Create navigation keys. |
177 // Create navigation keys. |
191 mNavKeyBackAction = new HbAction(Hb::BackNaviAction); |
178 mNavKeyBackAction = new HbAction(Hb::BackNaviAction); |
192 |
179 |
|
180 if (!mThumbnailManager) |
|
181 { |
|
182 mThumbnailManager = new ThumbnailManager(); |
|
183 } |
|
184 |
193 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap,void*,int,int)), |
185 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap,void*,int,int)), |
194 this, SLOT(thumbnailReadySlot(QPixmap,void*,int,int))); |
186 this, SLOT(thumbnailReadySlot(QPixmap,void*,int,int))); |
195 } |
187 } |
196 |
188 |
197 // --------------------------------------------------------------------------- |
189 // --------------------------------------------------------------------------- |
212 } |
204 } |
213 |
205 |
214 delete mNavKeyBackAction; mNavKeyBackAction = 0; |
206 delete mNavKeyBackAction; mNavKeyBackAction = 0; |
215 delete mThumbnailManager; mThumbnailManager = 0; |
207 delete mThumbnailManager; mThumbnailManager = 0; |
216 disconnect(); |
208 disconnect(); |
217 mView.reset(); |
209 mLoader.reset(); |
218 } |
210 } |
219 |
211 |
220 // --------------------------------------------------------------------------- |
212 // --------------------------------------------------------------------------- |
221 // Activate view |
213 // Activate view |
222 // --------------------------------------------------------------------------- |
214 // --------------------------------------------------------------------------- |
223 // |
215 // |
224 void VideoFileDetailsViewPlugin::activateView() |
216 void VideoFileDetailsViewPlugin::activateView() |
225 { |
217 { |
226 if ( !mActivated && (VideoFileDetailsViewPlugin::EFinalized == mCreated)) |
218 if (!mActivated) |
227 { |
219 { |
228 HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0); |
220 HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0); |
229 |
221 |
230 HbView *currentView = mainWnd->currentView(); |
222 HbView *currentView = mainWnd->currentView(); |
231 if(currentView && mNavKeyBackAction) |
223 if(currentView && mNavKeyBackAction) |
237 else |
229 else |
238 { |
230 { |
239 return; |
231 return; |
240 } |
232 } |
241 } |
233 } |
242 |
234 |
243 mainWnd->setOrientation(Qt::Vertical, false); |
235 mainWnd->setOrientation(Qt::Vertical, false); |
244 |
236 |
245 // following if is for the future implementations where we should support |
237 // following if is for the future implementations where we should support |
246 // also landscape configuration. |
238 // also landscape configuration. |
247 Qt::Orientation orientation = mainWnd->orientation(); |
239 Qt::Orientation orientation = mainWnd->orientation(); |
248 if ( orientation == Qt::Vertical ) |
240 if ( (orientation == Qt::Vertical) && (orientation != mPreviousOrietation) ) |
249 { |
241 { |
250 mView.load(VIDEO_DETAILS_DOCML, "portrait"); |
242 mPreviousOrietation = orientation; |
|
243 mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT); |
251 } |
244 } |
252 else if ( orientation == Qt::Horizontal ) |
245 else if ( (orientation == Qt::Horizontal) && (orientation != mPreviousOrietation) ) |
253 { |
246 { |
254 mView.load(VIDEO_DETAILS_DOCML, "landscape"); |
247 mPreviousOrietation = orientation; |
|
248 mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_LANDSCAPE); |
255 } |
249 } |
256 |
250 |
257 if (mIsService && !mVideoServices) |
251 if (mIsService && !mVideoServices) |
258 { |
252 { |
259 mVideoServices = VideoServices::instance(); |
253 mVideoServices = VideoServices::instance(); |
261 if (!mVideoServices) |
255 if (!mVideoServices) |
262 { |
256 { |
263 return; |
257 return; |
264 } |
258 } |
265 } |
259 } |
266 if (mIsService && mVideoServices) |
260 |
|
261 HbPushButton* button = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON); |
|
262 |
|
263 if (mIsService && mVideoServices) |
267 { |
264 { |
268 HbPushButton* attachBtn = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON); |
265 button->setText(tr("Attach")); //localisation |
269 attachBtn->setText(tr("Attach")); //TODO: Localisation |
266 |
270 |
267 connect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri())); |
271 connect(attachBtn, SIGNAL(clicked(bool)), this, SLOT(getFileUri())); |
|
272 connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&))); |
268 connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&))); |
273 |
269 |
274 HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0); |
270 HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0); |
275 |
271 |
276 mainWnd->currentView()->setTitle(mVideoServices->contextTitle()); |
272 mainWnd->currentView()->setTitle(mVideoServices->contextTitle()); |
277 } |
273 } |
278 else if(!mIsService) |
274 else if(!mIsService) |
279 { |
275 { |
280 HbPushButton* shareBtn = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON); |
276 connect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot())); |
281 connect(shareBtn, SIGNAL(triggered(bool)), this, SLOT(sendVideoSlot())); |
277 button->setText(hbTrId("txt_videos_opt_share")); |
282 shareBtn->setText(hbTrId("txt_videos_opt_share")); |
|
283 } |
278 } |
284 |
279 |
285 connect(mainWnd, |
280 connect(mainWnd, |
286 SIGNAL(orientationChanged(Qt::Orientation)), |
281 SIGNAL(orientationChanged(Qt::Orientation)), |
287 this, SLOT(orientationChange(Qt::Orientation))); |
282 this, SLOT(orientationChange(Qt::Orientation))); |
343 disconnect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri())); |
338 disconnect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri())); |
344 disconnect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&))); |
339 disconnect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&))); |
345 } |
340 } |
346 else |
341 else |
347 { |
342 { |
348 disconnect(button, SIGNAL(triggered(bool)), this, SLOT(sendVideoSlot())); |
343 disconnect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot())); |
349 } |
344 } |
350 |
345 |
351 } |
346 } |
352 } |
347 } |
353 |
348 |
355 // Get view |
350 // Get view |
356 // --------------------------------------------------------------------------- |
351 // --------------------------------------------------------------------------- |
357 // |
352 // |
358 QGraphicsWidget* VideoFileDetailsViewPlugin::getView() |
353 QGraphicsWidget* VideoFileDetailsViewPlugin::getView() |
359 { |
354 { |
360 return mView.findWidget(VIDEO_DETAILS_VIEW); |
355 return mLoader.findWidget(VIDEO_DETAILS_VIEW); |
361 } |
356 } |
362 |
357 |
363 // --------------------------------------------------------------------------- |
358 // --------------------------------------------------------------------------- |
364 // Slot: Orientation change |
359 // Slot: Orientation change |
365 // --------------------------------------------------------------------------- |
360 // --------------------------------------------------------------------------- |
366 // |
361 // |
367 void VideoFileDetailsViewPlugin::orientationChange( Qt::Orientation orientation ) |
362 void VideoFileDetailsViewPlugin::orientationChange( Qt::Orientation orientation ) |
368 { |
363 { |
369 if ( orientation == Qt::Vertical ) |
364 if ( orientation == Qt::Vertical ) |
370 { |
365 { |
371 mView.load(VIDEO_DETAILS_DOCML, "portrait"); |
366 mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT); |
372 } |
367 } |
373 |
368 |
374 else if ( orientation == Qt::Horizontal ) |
369 else if ( orientation == Qt::Horizontal ) |
375 { |
370 { |
376 mView.load(VIDEO_DETAILS_DOCML, "landscape"); |
371 mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_LANDSCAPE); |
377 } |
372 } |
378 mTitleAnim->adjustSize(); |
373 mTitleAnim->adjustSize(); |
379 mTitleAnim->startAnimation(); |
374 mTitleAnim->startAnimation(); |
380 } |
375 } |
381 |
376 |
506 QModelIndex modelIndex = mModel->indexOfId(mVideoId); |
501 QModelIndex modelIndex = mModel->indexOfId(mVideoId); |
507 QVariant variant = mModel->data(modelIndex, Qt::DisplayRole); |
502 QVariant variant = mModel->data(modelIndex, Qt::DisplayRole); |
508 |
503 |
509 if (variant.isValid()) |
504 if (variant.isValid()) |
510 { |
505 { |
511 QString text = tr("Do you want to delete \"%1\"?").arg(variant.toStringList().first()); //TODO: Localisation: txt_common_menu_delete |
506 QString text = hbTrId("txt_videos_info_do_you_want_to_delete_1").arg( |
|
507 variant.toStringList().first()); |
512 |
508 |
513 if (HbMessageBox::question(text)) |
509 if (HbMessageBox::question(text)) |
514 { |
510 { |
515 deleteItem(modelIndex); |
511 deleteItem(modelIndex); |
516 } |
512 } |
619 |
614 |
620 sourceImage = sourceImage.copy(rect); |
615 sourceImage = sourceImage.copy(rect); |
621 QImage resultImage = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied); |
616 QImage resultImage = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied); |
622 |
617 |
623 QPainter painter(&resultImage); |
618 QPainter painter(&resultImage); |
624 painter.setCompositionMode(QPainter::CompositionMode_Source); |
619 painter.setCompositionMode(QPainter::CompositionMode_Source); |
625 painter.fillRect(resultImage.rect(), Qt::transparent); |
620 painter.fillRect(resultImage.rect(), Qt::transparent); |
626 painter.setCompositionMode(QPainter::CompositionMode_SourceOver); |
621 painter.setCompositionMode(QPainter::CompositionMode_SourceOver); |
627 painter.drawImage( (int)(sourceImage.width() - play.width())/2, |
622 painter.drawPixmap( (int)(sourceImage.width() - playIcon().width())/2, |
628 (int)(sourceImage.height() - play.height())/2, |
623 (int)(sourceImage.height() - playIcon().height())/2, |
629 play ); |
624 playIcon() ); |
630 painter.setCompositionMode(QPainter::CompositionMode_Screen); |
625 painter.setCompositionMode(QPainter::CompositionMode_Screen); |
631 painter.drawImage(0, 0, sourceImage); |
626 painter.drawImage(0, 0, sourceImage); |
632 painter.end(); |
627 painter.end(); |
633 |
628 |
634 HbIcon compsedIcon(QPixmap::fromImage(resultImage)); |
629 HbIcon compsedIcon(QPixmap::fromImage(resultImage)); |
635 mThumbLabel->setIcon(compsedIcon); |
630 mThumbLabel->setIcon(compsedIcon); |
636 } |
631 } |
668 mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT)); |
663 mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT)); |
669 } |
664 } |
670 } |
665 } |
671 |
666 |
672 // --------------------------------------------------------------------------- |
667 // --------------------------------------------------------------------------- |
|
668 // playIcon |
|
669 // --------------------------------------------------------------------------- |
|
670 // |
|
671 const QPixmap &VideoFileDetailsViewPlugin::playIcon() |
|
672 { |
|
673 // Check if we have already the icon. |
|
674 if(!mPlayIcon.isNull()) |
|
675 { |
|
676 return mPlayIcon; |
|
677 } |
|
678 |
|
679 // Compose the icon. |
|
680 HbIcon play = HbIcon("qtg_mono_play"); |
|
681 HbIcon topLeft = HbIcon("qtg_fr_popup_trans_tl"); |
|
682 HbIcon top = HbIcon("qtg_fr_popup_trans_t"); |
|
683 HbIcon topRight = HbIcon("qtg_fr_popup_trans_tr"); |
|
684 HbIcon left = HbIcon("qtg_fr_popup_trans_l"); |
|
685 HbIcon center = HbIcon("qtg_fr_popup_trans_c"); |
|
686 HbIcon right = HbIcon("qtg_fr_popup_trans_r"); |
|
687 HbIcon bottomLeft = HbIcon("qtg_fr_popup_trans_bl"); |
|
688 HbIcon bottom = HbIcon("qtg_fr_popup_trans_b"); |
|
689 HbIcon bottomRight = HbIcon("qtg_fr_popup_trans_br"); |
|
690 |
|
691 int width = topLeft.width() + top.width() + topRight.width(); |
|
692 int height = topLeft.height() + center.height() + bottomLeft.height(); |
|
693 |
|
694 mPlayIcon = QPixmap(width, height); |
|
695 |
|
696 QPainter painter(&mPlayIcon); |
|
697 painter.fillRect(mPlayIcon.rect(), Qt::white); |
|
698 |
|
699 painter.setCompositionMode(QPainter::CompositionMode_SourceOver); |
|
700 |
|
701 int x = 0; |
|
702 int y = 0; |
|
703 |
|
704 // Draw top |
|
705 painter.drawPixmap(QPoint(x, y), topLeft.pixmap()); |
|
706 x += left.width(); |
|
707 |
|
708 painter.drawPixmap(QPoint(x, y), top.pixmap()); |
|
709 x += top.width(); |
|
710 |
|
711 painter.drawPixmap(QPoint(x, y), topRight.pixmap()); |
|
712 y += top.height(); |
|
713 |
|
714 // Draw center |
|
715 x = 0; |
|
716 painter.drawPixmap(QPoint(x, y), left.pixmap()); |
|
717 x += left.width(); |
|
718 |
|
719 painter.drawPixmap(QPoint(x, y), center.pixmap()); |
|
720 x += center.width(); |
|
721 |
|
722 painter.drawPixmap(QPoint(x, y), right.pixmap()); |
|
723 y += center.height(); |
|
724 |
|
725 // Draw bottom |
|
726 x = 0; |
|
727 painter.drawPixmap(QPoint(x, y), bottomLeft.pixmap()); |
|
728 x += left.width(); |
|
729 |
|
730 painter.drawPixmap(QPoint(x, y), bottom.pixmap()); |
|
731 x += top.width(); |
|
732 |
|
733 painter.drawPixmap(QPoint(x, y), bottomRight.pixmap()); |
|
734 |
|
735 // Draw play icon |
|
736 play.setSize(mPlayIcon.size()); |
|
737 play.setColor(Qt::white); |
|
738 painter.drawPixmap(mPlayIcon.rect(), play.pixmap()); |
|
739 painter.end(); |
|
740 |
|
741 return mPlayIcon; |
|
742 } |
|
743 |
|
744 // --------------------------------------------------------------------------- |
673 // findWidget |
745 // findWidget |
674 // --------------------------------------------------------------------------- |
746 // --------------------------------------------------------------------------- |
675 // |
747 // |
676 template<class T> |
748 template<class T> |
677 T* VideoFileDetailsViewPlugin::findWidget(QString name) |
749 T* VideoFileDetailsViewPlugin::findWidget(QString name) |
678 { |
750 { |
679 return qobject_cast<T *>(mView.findWidget(name)); |
751 return qobject_cast<T *>(mLoader.findWidget(name)); |
680 } |
752 } |
681 |
753 |
682 // --------------------------------------------------------------------------- |
754 // --------------------------------------------------------------------------- |
683 // findObject |
755 // findObject |
684 // --------------------------------------------------------------------------- |
756 // --------------------------------------------------------------------------- |
685 // |
757 // |
686 template<class T> |
758 template<class T> |
687 T* VideoFileDetailsViewPlugin::findObject(QString name) |
759 T* VideoFileDetailsViewPlugin::findObject(QString name) |
688 { |
760 { |
689 return qobject_cast<T *>(mView.findObject(name)); |
761 return qobject_cast<T *>(mLoader.findObject(name)); |
690 } |
762 } |
691 |
763 |
692 XQ_EXPORT_PLUGIN2( videofiledetailsview, VideoFileDetailsViewPlugin ); |
764 XQ_EXPORT_PLUGIN2( videofiledetailsview, VideoFileDetailsViewPlugin ); |
693 |
765 |
694 // end of file |
766 // end of file |