58 mLayout = new HbStackedLayout(this); |
58 mLayout = new HbStackedLayout(this); |
59 mLayout->setContentsMargins( 0.0, 0.0, 0.0, 0.0 ); |
59 mLayout->setContentsMargins( 0.0, 0.0, 0.0, 0.0 ); |
60 mLayout->setMinimumSize( 0.0, 0.0 ); |
60 mLayout->setMinimumSize( 0.0, 0.0 ); |
61 setLayout( mLayout ); |
61 setLayout( mLayout ); |
62 bool widgetsOk = false; |
62 bool widgetsOk = false; |
63 bool layoutOk = false; |
|
64 mDocumentLoader = new HbDocumentLoader(); |
63 mDocumentLoader = new HbDocumentLoader(); |
65 HbMainWindow *mainWindow = hbInstance->allMainWindows()[0]; |
64 HbMainWindow *mainWindow = hbInstance->allMainWindows()[0]; |
66 |
65 |
67 if ( mDocumentLoader ) { |
66 if ( mDocumentLoader ) { |
68 mDocumentLoader->load( QString(":/playbackviewdocml/playbackwidget.docml"), &widgetsOk); |
67 mDocumentLoader->load( QString(":/playbackviewdocml/playbackwidget.docml"), &widgetsOk); |
69 layoutOk = loadLayout( mainWindow->orientation() ); |
68 } |
70 } |
69 if ( widgetsOk ) { |
71 if ( widgetsOk && layoutOk ) { |
|
72 QGraphicsWidget *tmpWidgetPtr; |
70 QGraphicsWidget *tmpWidgetPtr; |
73 tmpWidgetPtr = mDocumentLoader->findWidget(QString("playbackWidgetContainer")); |
71 tmpWidgetPtr = mDocumentLoader->findWidget(QString("playbackWidgetContainer")); |
74 tmpWidgetPtr->setParentItem(this); |
72 tmpWidgetPtr->setParentItem(this); |
75 mLayout->addItem( qobject_cast<HbWidget*>( tmpWidgetPtr ) ); |
73 mLayout->addItem( qobject_cast<HbWidget*>( tmpWidgetPtr ) ); |
76 tmpWidgetPtr = mDocumentLoader->findWidget(QString("albumText")); |
74 tmpWidgetPtr = mDocumentLoader->findWidget(QString("albumText")); |
88 mProgressBar->setMinMaxTextVisible(true); |
86 mProgressBar->setMinMaxTextVisible(true); |
89 } |
87 } |
90 else { |
88 else { |
91 TX_LOG_ARGS("Error: invalid xml file."); |
89 TX_LOG_ARGS("Error: invalid xml file."); |
92 Q_ASSERT_X(widgetsOk, "MpPlaybackWidget", "invalid xml file - widget"); |
90 Q_ASSERT_X(widgetsOk, "MpPlaybackWidget", "invalid xml file - widget"); |
93 Q_ASSERT_X(layoutOk, "MpPlaybackWidget", "invalid xml file - layout"); |
91 } |
94 } |
|
95 |
|
96 connect( mainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
|
97 this, SLOT(loadLayout(Qt::Orientation)) ); |
|
98 |
92 |
99 connect( mProgressBar, SIGNAL(sliderPressed()), this, SLOT(handleSliderPressed()) ); |
93 connect( mProgressBar, SIGNAL(sliderPressed()), this, SLOT(handleSliderPressed()) ); |
100 connect( mProgressBar, SIGNAL(sliderReleased()), this, SLOT(handleSliderReleased()) ); |
94 connect( mProgressBar, SIGNAL(sliderReleased()), this, SLOT(handleSliderReleased()) ); |
101 connect( mProgressBar, SIGNAL(sliderMoved(int)), this, SLOT(handleSliderMoved(int)) ); |
95 connect( mProgressBar, SIGNAL(sliderMoved(int)), this, SLOT(handleSliderMoved(int)) ); |
102 |
96 |
103 connect( mPlaybackData, SIGNAL(playbackInfoChanged()), this, SLOT(playbackInfoChanged()) ); |
97 connect( mPlaybackData, SIGNAL(playbackInfoChanged()), this, SLOT(playbackInfoChanged()) ); |
104 connect( mPlaybackData, SIGNAL(durationChanged()), this, SLOT(durationChanged()) ); |
98 connect( mPlaybackData, SIGNAL(durationChanged()), this, SLOT(durationChanged()) ); |
105 connect( mPlaybackData, SIGNAL(positionChanged()), this, SLOT(positionChanged()) ); |
99 connect( mPlaybackData, SIGNAL(positionChanged()), this, SLOT(positionChanged()) ); |
106 connect( mPlaybackData, SIGNAL(albumArtReady()), this, SLOT(albumArtChanged()) ); |
100 connect( mPlaybackData, SIGNAL(albumArtReady()), this, SLOT(albumArtChanged()) ); |
107 |
101 |
108 mCompositePixmap = QPixmap( 360, 360 ); |
102 |
109 mCompositePixmap.fill( Qt::transparent ); |
|
110 |
103 |
111 TX_EXIT |
104 TX_EXIT |
112 } |
105 } |
113 |
106 |
114 /*! |
107 /*! |
171 Slot to handle Album art changed. |
164 Slot to handle Album art changed. |
172 */ |
165 */ |
173 void MpPlaybackWidget::albumArtChanged( ) |
166 void MpPlaybackWidget::albumArtChanged( ) |
174 { |
167 { |
175 TX_ENTRY |
168 TX_ENTRY |
176 QPixmap pixmap; |
169 HbIcon icon; |
177 mPlaybackData->albumArt( pixmap ); |
170 mPlaybackData->albumArt( icon ); |
178 composeAlbumCover( pixmap ); |
171 |
179 |
172 |
180 QIcon qicon; |
|
181 if ( !mCompositePixmap.isNull() ) { |
|
182 qicon = QIcon( mCompositePixmap ); |
|
183 } |
|
184 else { |
|
185 qicon = QIcon( pixmap ); |
|
186 } |
|
187 HbIcon icon( qicon ); |
|
188 mAlbumArt->setIcon( icon ); |
173 mAlbumArt->setIcon( icon ); |
189 TX_EXIT |
174 TX_EXIT |
190 } |
175 } |
191 |
176 |
192 /*! |
|
193 Orientation change. Load layout based on the \a orientation. |
|
194 */ |
|
195 bool MpPlaybackWidget::loadLayout( Qt::Orientation orientation ) |
|
196 { |
|
197 bool ret(false); |
|
198 if ( orientation == Qt::Vertical ) { |
|
199 mDocumentLoader->load(QString(":/playbackviewdocml/playbackwidget.docml"), "portrait", &ret); |
|
200 } |
|
201 else { |
|
202 mDocumentLoader->load(QString(":/playbackviewdocml/playbackwidget.docml"), "landscape", & ret); |
|
203 } |
|
204 return ret; |
|
205 } |
|
206 |
177 |
207 /*! |
178 /*! |
208 Slot to handle slider pressed. |
179 Slot to handle slider pressed. |
209 */ |
180 */ |
210 void MpPlaybackWidget::handleSliderPressed() |
181 void MpPlaybackWidget::handleSliderPressed() |
260 TX_EXIT |
231 TX_EXIT |
261 return duration.toString( "hh:mm:ss" ); |
232 return duration.toString( "hh:mm:ss" ); |
262 } |
233 } |
263 } |
234 } |
264 |
235 |
265 /*! |
236 |
266 Compose the album art. |
|
267 */ |
|
268 void MpPlaybackWidget::composeAlbumCover( QPixmap& albumart ) |
|
269 { |
|
270 TX_ENTRY |
|
271 mCompositePixmap.fill( Qt::transparent ); |
|
272 QPainter painter(&mCompositePixmap); |
|
273 painter.setCompositionMode(QPainter::CompositionMode_Clear); |
|
274 painter.setCompositionMode(QPainter::CompositionMode_SourceOver); |
|
275 painter.fillRect(mCompositePixmap.rect(), Qt::transparent); |
|
276 painter.drawPixmap(QRect(0, 0,360,360), albumart); |
|
277 TX_EXIT |
|
278 } |
|