|
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 is used to display audio content in univiewer. |
|
15 * |
|
16 */ |
|
17 #include "univieweraudiowidget.h" |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include <QFileInfo> |
|
21 #include <QTimer> |
|
22 #include <HbMenu> |
|
23 |
|
24 // USER INCLUDES |
|
25 #include "msgmediautil.h" |
|
26 #include "univiewerutils.h" |
|
27 |
|
28 // LOCAL CONSTANTS |
|
29 #define LOC_OPEN hbTrId("txt_common_menu_open") |
|
30 #define LOC_SAVE hbTrId("txt_common_menu_save") |
|
31 |
|
32 const QString AUDIO_ICON("qtg_mono_audio"); |
|
33 |
|
34 //---------------------------------------------------------------------------- |
|
35 // UniViewerAudioWidget::UniViewerAudioWidget |
|
36 // @see header file |
|
37 //---------------------------------------------------------------------------- |
|
38 UniViewerAudioWidget::UniViewerAudioWidget(QGraphicsItem *parent) : |
|
39 HbPushButton(parent), mViewerUtils(0) |
|
40 { |
|
41 connect(this, SIGNAL(clicked()), this, SLOT(handleShortTap())); |
|
42 connect(this, SIGNAL(longPress(QPointF)), this, SLOT(handleLongTap(QPointF))); |
|
43 } |
|
44 |
|
45 //---------------------------------------------------------------------------- |
|
46 // UniViewerAudioWidget::~UniViewerAudioWidget |
|
47 // @see header file |
|
48 //---------------------------------------------------------------------------- |
|
49 UniViewerAudioWidget::~UniViewerAudioWidget() |
|
50 { |
|
51 } |
|
52 |
|
53 //---------------------------------------------------------------------------- |
|
54 // UniViewerAudioWidget::~UniViewerAudioWidget |
|
55 // @see header file |
|
56 //---------------------------------------------------------------------------- |
|
57 void UniViewerAudioWidget::populate(const QString &mimeType, const QString &filePath) |
|
58 { |
|
59 mMimeType = mimeType; |
|
60 mMediaPath = filePath; |
|
61 |
|
62 this->setIcon(HbIcon(AUDIO_ICON)); |
|
63 QFileInfo fileInfo(mMediaPath); |
|
64 this->setText(fileInfo.baseName()); |
|
65 this->setTextAlignment(Qt::AlignLeft); |
|
66 MsgMediaUtil mediaUtil; |
|
67 this->setAdditionalText(mediaUtil.mediaDuration(mMediaPath)); |
|
68 } |
|
69 |
|
70 //---------------------------------------------------------------------------- |
|
71 // UniViewerAudioWidget::handleShortTap |
|
72 // @see header file |
|
73 //---------------------------------------------------------------------------- |
|
74 void UniViewerAudioWidget::handleShortTap() |
|
75 { |
|
76 emit shortTap(mMediaPath); |
|
77 |
|
78 // Open the media. |
|
79 handleOpen(); |
|
80 } |
|
81 |
|
82 //---------------------------------------------------------------------------- |
|
83 // UniViewerAudioWidget::handleLongTap |
|
84 // @see header file |
|
85 //---------------------------------------------------------------------------- |
|
86 void UniViewerAudioWidget::handleLongTap(const QPointF &position) |
|
87 { |
|
88 emit longTap(position); |
|
89 |
|
90 // Display context sensitive menu. |
|
91 HbMenu* menu = new HbMenu; |
|
92 menu->setAttribute(Qt::WA_DeleteOnClose); |
|
93 menu->addAction(LOC_OPEN, this, SLOT(handleOpen())); |
|
94 menu->addAction(LOC_SAVE, this, SLOT(handleSave())); |
|
95 menu->setPreferredPos(position); |
|
96 menu->show(); |
|
97 } |
|
98 |
|
99 //---------------------------------------------------------------------------- |
|
100 // UniViewerAudioWidget::handleOpen |
|
101 // @see header file |
|
102 //---------------------------------------------------------------------------- |
|
103 void UniViewerAudioWidget::handleOpen() |
|
104 { |
|
105 this->ungrabGesture(Qt::TapGesture); |
|
106 |
|
107 if (!mViewerUtils) { |
|
108 mViewerUtils = new UniViewerUtils(this); |
|
109 } |
|
110 mViewerUtils->launchContentViewer(mMimeType, mMediaPath); |
|
111 |
|
112 //fire timer to regrab gesture after some delay. |
|
113 QTimer::singleShot(300,this,SLOT(regrabGesture())); |
|
114 } |
|
115 |
|
116 //---------------------------------------------------------------------------- |
|
117 // UniViewerAudioWidget::handleSave |
|
118 // @see header file |
|
119 //---------------------------------------------------------------------------- |
|
120 void UniViewerAudioWidget::handleSave() |
|
121 { |
|
122 |
|
123 } |
|
124 |
|
125 //--------------------------------------------------------------- |
|
126 // UniViewerAudioWidget::regrabGesture |
|
127 // @see header file |
|
128 //--------------------------------------------------------------- |
|
129 void UniViewerAudioWidget::regrabGesture() |
|
130 { |
|
131 this->grabGesture(Qt::TapGesture); |
|
132 } |
|
133 // EOF |