35
|
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: Music Player Settings view.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QParallelAnimationGroup>
|
|
19 |
#include <QPropertyAnimation>
|
|
20 |
|
|
21 |
#include <hbicon.h>
|
|
22 |
#include <hbaction.h>
|
|
23 |
#include <hbapplication.h>
|
|
24 |
#include <hbscrollbar.h>
|
|
25 |
#include <hblabel.h>
|
|
26 |
#include <hbtoolbutton.h>
|
37
|
27 |
#include <hblistview.h>
|
|
28 |
#include <hbstyleloader.h>
|
35
|
29 |
|
|
30 |
#include <hgmediawall.h>
|
|
31 |
|
|
32 |
#include "mpmediawallview.h"
|
|
33 |
#include "mpmediawalldocumentloader.h"
|
|
34 |
#include "mpcommondefs.h"
|
|
35 |
#include "mpmpxcollectiondata.h"
|
|
36 |
#include "mpcollectiondatamodel.h"
|
|
37 |
#include "mpenginefactory.h"
|
|
38 |
#include "mpplaybackdata.h"
|
|
39 |
#include "mpalbumcoverwidget.h"
|
|
40 |
#include "mptracklistwidget.h"
|
|
41 |
#include "mpcollectiontbonelistdatamodel.h"
|
|
42 |
#include "mptrace.h"
|
43
|
43 |
#include "mpreflectioneffect.h"
|
35
|
44 |
|
|
45 |
const char*MUSIC_MEDIAWALL_DOCML = ":/mediawallviewdocml/mediawall.docml";
|
|
46 |
|
|
47 |
/*!
|
|
48 |
\class MpMediaWallView
|
|
49 |
\brief Music Player Settings view.
|
|
50 |
|
|
51 |
Music player media wall view displays music players albums on an full screen view
|
|
52 |
*/
|
|
53 |
|
|
54 |
/*!
|
|
55 |
\fn void command( int command )
|
|
56 |
|
|
57 |
This signal is emitted when the view issues a \a command to the
|
|
58 |
application such as request to switch to a different view.
|
|
59 |
*/
|
|
60 |
|
|
61 |
|
|
62 |
/*!
|
|
63 |
Constructs the media wall view.
|
|
64 |
*/
|
|
65 |
MpMediaWallView::MpMediaWallView()
|
|
66 |
: mEngine( 0 ),
|
|
67 |
mCollectionData( 0 ),
|
|
68 |
mModel( 0 ),
|
|
69 |
mMediaWallWidget( 0 ),
|
|
70 |
mNoMusic( 0 ),
|
|
71 |
mDocumentLoader( 0 ),
|
|
72 |
mPlayPauseContainer( 0 ),
|
|
73 |
mPlayIcon( 0 ),
|
|
74 |
mPauseIcon( 0 ),
|
|
75 |
mPlayPauseAction( 0 ),
|
|
76 |
mLibraryUpdating( false ),
|
|
77 |
mPlaybackData( 0 ),
|
|
78 |
mActivated( false ),
|
|
79 |
mIconUpdateNedded( false ),
|
|
80 |
mListShowAnimationGroup( 0 ),
|
|
81 |
mListShowListAnimation( 0 ),
|
|
82 |
mCoverShowListAnimation( 0 ),
|
|
83 |
mShowingSongsList( false ),
|
|
84 |
mAlbumCover( 0 ),
|
|
85 |
mTrackList( 0 )
|
|
86 |
{
|
|
87 |
connect( MpEngineFactory::sharedEngine(), SIGNAL( libraryAboutToUpdate() ),
|
|
88 |
this, SLOT( libraryAboutToUpdate() ) );
|
|
89 |
connect( MpEngineFactory::sharedEngine(), SIGNAL( libraryUpdated() ),
|
|
90 |
this, SLOT( libraryUpdated() ) );
|
|
91 |
TX_LOG
|
|
92 |
}
|
|
93 |
|
|
94 |
/*!
|
|
95 |
Destructs the media wall view.
|
|
96 |
*/
|
|
97 |
MpMediaWallView::~MpMediaWallView()
|
|
98 |
{
|
|
99 |
TX_ENTRY
|
|
100 |
//delete not parented objects
|
|
101 |
delete mDocumentLoader;
|
|
102 |
delete mPlayIcon;
|
|
103 |
delete mPauseIcon;
|
|
104 |
TX_EXIT
|
|
105 |
}
|
|
106 |
|
|
107 |
/*!
|
|
108 |
Initializes the media wall view.
|
|
109 |
*/
|
|
110 |
void MpMediaWallView::initializeView()
|
|
111 |
{
|
|
112 |
TX_ENTRY
|
|
113 |
setTitleBarVisible( false );
|
|
114 |
setStatusBarVisible( false );
|
|
115 |
|
|
116 |
mDocumentLoader = new MpMediaWallDocumentLoader();
|
|
117 |
bool ok = false;
|
|
118 |
mDocumentLoader->load( MUSIC_MEDIAWALL_DOCML, &ok );
|
|
119 |
if ( ok ) {
|
|
120 |
QGraphicsWidget *widget;
|
|
121 |
|
|
122 |
//Setup fake softkey to hide the app
|
|
123 |
widget = mDocumentLoader->findWidget( QString( "navigationButton" ) );
|
|
124 |
HbAction *action;
|
|
125 |
action = new HbAction( Hb::BackNaviAction, this );
|
|
126 |
connect( action, SIGNAL( triggered( bool ) ), this, SLOT( sendToBackground() ) );
|
|
127 |
qobject_cast<HbToolButton*>( widget )->setAction( action );
|
|
128 |
|
|
129 |
//Setup the play/pause command button
|
|
130 |
widget = mDocumentLoader->findWidget( QString( "playPauseButton" ) );
|
|
131 |
mPauseIcon = new HbIcon( "qtg_mono_pause" );
|
|
132 |
mPlayIcon = new HbIcon( "qtg_mono_play" );
|
|
133 |
mPlayPauseAction = new HbAction( HbIcon() , QString(), this );
|
|
134 |
mPlaybackData = MpEngineFactory::sharedEngine()->playbackData();
|
|
135 |
qobject_cast<HbToolButton*>( widget )->setAction( mPlayPauseAction );
|
37
|
136 |
//we need this widget to hide the play pause button, for some reason it does not want to hide.
|
35
|
137 |
mPlayPauseContainer = mDocumentLoader->findWidget( QString( "playPauseButtonContainer" ) );
|
|
138 |
updatePlayPauseAction();
|
|
139 |
connect( mPlaybackData, SIGNAL( playbackStateChanged() ),
|
|
140 |
this, SLOT( updatePlayPauseAction() ) );
|
|
141 |
connect( mPlayPauseAction, SIGNAL( triggered( bool ) ),
|
|
142 |
MpEngineFactory::sharedEngine(), SLOT( playPause() ) );
|
|
143 |
|
|
144 |
|
|
145 |
//Get the main container and set as widget.
|
|
146 |
widget = mDocumentLoader->findWidget( QString( "container" ) );
|
|
147 |
setWidget( widget );
|
|
148 |
|
|
149 |
mEngine = MpEngineFactory::createIsolatedEngine( MpEngine::MediaBrowsing );
|
|
150 |
mCollectionData = mEngine->collectionData();
|
|
151 |
mModel = new MpCollectionDataModel( mCollectionData, this );
|
|
152 |
|
|
153 |
connect( mCollectionData, SIGNAL( contextChanged( TCollectionContext ) ),
|
|
154 |
this, SLOT( contextOpened( TCollectionContext ) ) );
|
|
155 |
connect( mEngine, SIGNAL( containerContentsChanged() ),
|
|
156 |
this, SLOT( containerContentsChanged() ) );
|
|
157 |
if ( !mLibraryUpdating ) {
|
|
158 |
mEngine->openCollection( ECollectionContextAlbumsMediaWall );
|
|
159 |
}
|
|
160 |
}
|
|
161 |
else {
|
|
162 |
TX_LOG_ARGS( "Error: invalid xml file." );
|
|
163 |
Q_ASSERT_X( ok, "MpCollectionView::initializeView", "invalid xml file" );
|
|
164 |
}
|
|
165 |
|
|
166 |
mAlbumCover = new MpAlbumCoverWidget( this );
|
43
|
167 |
mAlbumCover->setGraphicsEffect( new MpReflectionEffect(mAlbumCover) );
|
37
|
168 |
mAlbumCover->setDefaultIcon( HbIcon( "qtg_large_album_art" ) );
|
35
|
169 |
mAlbumCover->hide();
|
|
170 |
|
|
171 |
mTrackList = new MpTrackListWidget( this );
|
43
|
172 |
mTrackList->setGraphicsEffect( new MpReflectionEffect(mTrackList) );
|
36
|
173 |
mTrackList->list()->setModel( new MpCollectionTBoneListDataModel(mCollectionData, mPlaybackData, mTrackList ) );
|
35
|
174 |
mTrackList->hide();
|
|
175 |
|
|
176 |
connect(mAlbumCover,SIGNAL(clicked()),this, SLOT(hideTracksList()));
|
|
177 |
connect(mTrackList->list(), SIGNAL(activated(QModelIndex)), this, SLOT(listItemActivated(QModelIndex)));
|
37
|
178 |
connect(mTrackList,SIGNAL(closed()),this, SLOT(hideTracksList()));
|
35
|
179 |
|
37
|
180 |
HbStyleLoader::registerFilePath(":/css/mpcustommediawall.css");
|
43
|
181 |
HbStyleLoader::registerFilePath(":/css/mpcustommediawall_color.css");
|
37
|
182 |
HbStyleLoader::registerFilePath(":/css/mpcustommediawall.hgmediawall.widgetml");
|
35
|
183 |
|
|
184 |
TX_EXIT
|
|
185 |
}
|
|
186 |
|
|
187 |
/*!
|
|
188 |
Activates the media wall view.
|
|
189 |
*/
|
|
190 |
void MpMediaWallView::activateView()
|
|
191 |
{
|
|
192 |
TX_ENTRY
|
|
193 |
mActivated = true;
|
|
194 |
if ( mIconUpdateNedded ) {
|
|
195 |
updatePlayPauseAction();
|
|
196 |
mIconUpdateNedded = false;
|
|
197 |
}
|
|
198 |
scrollToNowPlaying();
|
|
199 |
TX_EXIT
|
|
200 |
}
|
|
201 |
|
|
202 |
/*!
|
|
203 |
Deactivates the media wall view.
|
|
204 |
*/
|
|
205 |
void MpMediaWallView::deactivateView()
|
|
206 |
{
|
|
207 |
TX_ENTRY
|
|
208 |
mActivated = false;
|
|
209 |
dismissListClosingAnimation();
|
|
210 |
TX_EXIT
|
|
211 |
}
|
|
212 |
|
|
213 |
/*!
|
|
214 |
Slot to be called when the context is opened.
|
|
215 |
*/
|
|
216 |
void MpMediaWallView::contextOpened( TCollectionContext context )
|
|
217 |
{
|
|
218 |
if ( context != ECollectionContextAlbumsMediaWall ) {
|
|
219 |
//Force the context to Albums Media Wall, this to get the model and
|
|
220 |
//data to provide the right funtionality to media wall.
|
|
221 |
mCollectionData->setContext( ECollectionContextAlbumsMediaWall );
|
|
222 |
return;
|
|
223 |
}
|
|
224 |
if ( mCollectionData->count() ) {
|
|
225 |
if (mNoMusic) {
|
|
226 |
delete mNoMusic;
|
|
227 |
mNoMusic = 0;
|
|
228 |
}
|
|
229 |
if ( mMediaWallWidget ) {
|
|
230 |
mModel->refreshModel();
|
43
|
231 |
scrollToDefault();
|
35
|
232 |
} else {
|
|
233 |
bool ok = false;
|
|
234 |
mDocumentLoader->load( MUSIC_MEDIAWALL_DOCML, "mediaWall", &ok);
|
|
235 |
if ( ok ) {
|
|
236 |
QGraphicsWidget *widget;
|
37
|
237 |
widget = mDocumentLoader->findWidget(QString("MPmediaWallWidget"));
|
35
|
238 |
mMediaWallWidget = qobject_cast<HgMediawall*>(widget);
|
37
|
239 |
//set these items as children of the media wall so they show behind the scrollbar.
|
|
240 |
mTrackList->setParentItem(mMediaWallWidget);
|
|
241 |
mAlbumCover->setParentItem(mMediaWallWidget);
|
35
|
242 |
mModel->refreshModel();
|
|
243 |
setUpMediaWallWidget();
|
|
244 |
}
|
|
245 |
else {
|
|
246 |
TX_LOG_ARGS("Error: invalid xml file.");
|
|
247 |
Q_ASSERT_X(ok, "MpMediaWallView::contextOpened", "invalid xml file");
|
|
248 |
|
|
249 |
}
|
|
250 |
}
|
|
251 |
}
|
|
252 |
else {
|
|
253 |
if ( mMediaWallWidget ) {
|
37
|
254 |
//Take ownership of these items to prevent delete from media wall widget.
|
|
255 |
mTrackList->setParentItem( this );
|
|
256 |
mAlbumCover->setParentItem( this );
|
35
|
257 |
delete mMediaWallWidget;
|
|
258 |
mMediaWallWidget = 0;
|
|
259 |
|
|
260 |
}
|
|
261 |
if ( !mNoMusic ) {
|
|
262 |
bool ok = false;
|
|
263 |
mDocumentLoader->load( MUSIC_MEDIAWALL_DOCML, "empty", &ok);
|
|
264 |
if ( ok ) {
|
|
265 |
QGraphicsWidget *widget;
|
|
266 |
widget = mDocumentLoader->findWidget(QString("noMusic"));
|
|
267 |
mNoMusic = qobject_cast<HbLabel*>(widget);
|
|
268 |
}
|
|
269 |
else {
|
|
270 |
TX_LOG_ARGS("Error: invalid xml file.");
|
|
271 |
Q_ASSERT_X(ok, "MpMediaWallView::contextOpened", "invalid xml file");
|
|
272 |
|
|
273 |
}
|
|
274 |
}
|
|
275 |
}
|
|
276 |
}
|
|
277 |
|
|
278 |
/*!
|
|
279 |
Slot to be called when the container contents changed.
|
|
280 |
*/
|
|
281 |
void MpMediaWallView::containerContentsChanged()
|
|
282 |
{
|
|
283 |
if ( !mLibraryUpdating && mEngine ) {
|
43
|
284 |
dismissListClosingAnimation();
|
35
|
285 |
mEngine->openCollection( ECollectionContextAlbumsMediaWall );
|
|
286 |
}
|
|
287 |
}
|
|
288 |
|
|
289 |
/*!
|
|
290 |
Slot to be called when the container contents changed.
|
|
291 |
*/
|
|
292 |
void MpMediaWallView::libraryAboutToUpdate()
|
|
293 |
{
|
|
294 |
mLibraryUpdating = true;
|
|
295 |
}
|
|
296 |
|
|
297 |
/*!
|
|
298 |
Slot to be called when the container contents changed.
|
|
299 |
*/
|
|
300 |
void MpMediaWallView::libraryUpdated()
|
|
301 |
{
|
|
302 |
mLibraryUpdating = false;
|
|
303 |
if ( mEngine ) {
|
|
304 |
mEngine->openCollection( ECollectionContextAlbumsMediaWall );
|
|
305 |
}
|
|
306 |
}
|
|
307 |
|
|
308 |
/*!
|
|
309 |
Slot to be called to send to background.
|
|
310 |
*/
|
|
311 |
void MpMediaWallView::sendToBackground()
|
|
312 |
{
|
|
313 |
TX_ENTRY
|
|
314 |
emit command( MpCommon::SendToBackground );
|
|
315 |
TX_EXIT
|
|
316 |
}
|
|
317 |
|
|
318 |
/*!
|
|
319 |
Slot to update teh play pause action icon.
|
|
320 |
*/
|
|
321 |
void MpMediaWallView::updatePlayPauseAction()
|
|
322 |
{
|
|
323 |
if ( !mActivated ) {
|
|
324 |
mIconUpdateNedded = true;
|
|
325 |
return;
|
|
326 |
}
|
|
327 |
TX_ENTRY
|
|
328 |
switch ( mPlaybackData->playbackState() ) {
|
|
329 |
case MpPlaybackData::Playing:
|
|
330 |
TX_LOG_ARGS( "MpPlaybackData::Playing" )
|
|
331 |
mPlayPauseAction->setIcon( *mPauseIcon );
|
|
332 |
mPlayPauseContainer->show();
|
|
333 |
break;
|
|
334 |
case MpPlaybackData::Paused:
|
|
335 |
case MpPlaybackData::Stopped:
|
|
336 |
TX_LOG_ARGS( "MpPlaybackData::Paused" )
|
|
337 |
mPlayPauseAction->setIcon( *mPlayIcon );
|
|
338 |
mPlayPauseContainer->show();
|
|
339 |
break;
|
|
340 |
case MpPlaybackData::NotPlaying:
|
|
341 |
mPlayPauseContainer->hide();
|
|
342 |
break;
|
|
343 |
default:
|
|
344 |
break;
|
|
345 |
}
|
|
346 |
TX_EXIT
|
|
347 |
}
|
|
348 |
|
|
349 |
/*!
|
|
350 |
Slot called to start the album and list opening animation.
|
|
351 |
*/
|
|
352 |
void MpMediaWallView::showTrackList()
|
|
353 |
{
|
|
354 |
if( mShowingSongsList ) {
|
|
355 |
return;
|
|
356 |
}
|
|
357 |
mShowingSongsList = true;
|
|
358 |
setUpListAnimation();
|
|
359 |
mListShowAnimationGroup->setDirection(QAbstractAnimation::Forward);
|
|
360 |
mListShowAnimationGroup->start();
|
37
|
361 |
mModel->setItemVisibility( mMediaWallWidget->currentIndex(), false );
|
35
|
362 |
}
|
|
363 |
|
|
364 |
/*!
|
|
365 |
Slot to be called to starts the album and list closing animation.
|
|
366 |
*/
|
|
367 |
void MpMediaWallView::hideTracksList()
|
|
368 |
{
|
|
369 |
mListShowAnimationGroup->setDirection(QAbstractAnimation::Backward);
|
|
370 |
connect(mListShowAnimationGroup, SIGNAL(finished()), this, SLOT(dismissListClosingAnimation()));
|
|
371 |
mListShowAnimationGroup->start();
|
|
372 |
}
|
|
373 |
|
|
374 |
/*!
|
|
375 |
Slot to be called when list closing animation is done or when we want to cancel the animation.
|
|
376 |
*/
|
|
377 |
void MpMediaWallView::dismissListClosingAnimation()
|
|
378 |
{
|
|
379 |
if ( !mShowingSongsList ) {
|
|
380 |
return;
|
|
381 |
}
|
|
382 |
mShowingSongsList = false;
|
|
383 |
mAlbumCover->hide();
|
|
384 |
mTrackList->hide();
|
37
|
385 |
mModel->setItemVisibility( mMediaWallWidget->currentIndex(), true );
|
35
|
386 |
mListShowAnimationGroup->stop();
|
|
387 |
disconnect(mListShowAnimationGroup, SIGNAL(finished()), this, SLOT(dismissListClosingAnimation()));
|
|
388 |
}
|
|
389 |
|
|
390 |
/*!
|
|
391 |
Slot to be called when a list item is selected by the user.
|
|
392 |
*/
|
|
393 |
void MpMediaWallView::listItemActivated( const QModelIndex &index )
|
|
394 |
{
|
|
395 |
int albumIndex = mMediaWallWidget->currentIndex().row();
|
|
396 |
//We are playing on the shared engine, but we pass the collection data that
|
|
397 |
//points to albums on media wall, this is used to construct the playlist.
|
|
398 |
MpEngineFactory::sharedEngine()->playAlbumSongs( albumIndex, index.row(), mCollectionData );
|
|
399 |
}
|
|
400 |
|
|
401 |
/*!
|
37
|
402 |
Slot to be called to fetch the songs for an album.
|
|
403 |
*/
|
|
404 |
void MpMediaWallView::fetchAlbumSongs(QModelIndex index)
|
|
405 |
{
|
|
406 |
if ( !mCollectionData->setCurrentAlbum( index.row() ) ) {
|
|
407 |
mEngine->findAlbumSongs( index.row() );
|
|
408 |
}
|
|
409 |
}
|
|
410 |
|
|
411 |
/*!
|
35
|
412 |
Loads the media wall widget.
|
|
413 |
*/
|
|
414 |
void MpMediaWallView::setUpMediaWallWidget()
|
|
415 |
{
|
37
|
416 |
HbIcon defaultIcon( "qtg_large_album_art" );
|
35
|
417 |
defaultIcon.setSize(mMediaWallWidget->itemSize());
|
|
418 |
mMediaWallWidget->setDefaultImage( defaultIcon.pixmap().toImage() );
|
37
|
419 |
mMediaWallWidget->enableReflections( true );
|
35
|
420 |
mMediaWallWidget->setModel( mModel );
|
43
|
421 |
scrollToDefault();
|
|
422 |
mMediaWallWidget->setTitleFontSpec( HbFontSpec( HbFontSpec::Primary ) );
|
|
423 |
mMediaWallWidget->setDescriptionFontSpec( HbFontSpec( HbFontSpec::Secondary ) );
|
|
424 |
mMediaWallWidget->setScrollBarPolicy( HgWidget::ScrollBarAlwaysOn ); //HgWidget::ScrollBarAutoHide
|
|
425 |
mMediaWallWidget->scrollBar()->setInteractive( true );
|
|
426 |
mMediaWallWidget->setIndexFeedbackPolicy( HgWidget::IndexFeedbackSingleCharacter );
|
|
427 |
connect(mMediaWallWidget, SIGNAL(animationAboutToEnd(QModelIndex)), SLOT(fetchAlbumSongs(QModelIndex)));
|
|
428 |
connect(mMediaWallWidget, SIGNAL(activated(QModelIndex)), SLOT(showTrackList()));
|
|
429 |
connect(mMediaWallWidget, SIGNAL(scrollingStarted()), SLOT(dismissListClosingAnimation()));
|
|
430 |
}
|
|
431 |
/*!
|
|
432 |
Scrolls the media wall to a default position.
|
|
433 |
*/
|
|
434 |
void MpMediaWallView::scrollToDefault()
|
|
435 |
{
|
|
436 |
//if something is playing go there, if not go to a balanced position.
|
35
|
437 |
if ( mPlaybackData->playbackState() != MpPlaybackData::NotPlaying ) {
|
|
438 |
scrollToNowPlaying();
|
|
439 |
}
|
43
|
440 |
else if ( mModel->rowCount() >= 5 ) {
|
35
|
441 |
/* 5 and more
|
|
442 |
[0] [1] [X] [3] [4]...
|
|
443 |
*/
|
|
444 |
QModelIndex index;
|
|
445 |
index = mModel->index( 2 );
|
|
446 |
mMediaWallWidget->scrollTo( index );
|
43
|
447 |
fetchAlbumSongs( index );
|
|
448 |
|
35
|
449 |
}
|
|
450 |
else if ( mModel->rowCount() >=3 ) {
|
|
451 |
/* 4 and 3
|
|
452 |
__ [0] [X] [2] [3]
|
|
453 |
__ [0] [X] [2] __
|
|
454 |
*/
|
|
455 |
QModelIndex index;
|
|
456 |
index = mModel->index( 1 );
|
|
457 |
mMediaWallWidget->scrollTo( index );
|
43
|
458 |
fetchAlbumSongs( index );
|
35
|
459 |
}
|
|
460 |
else {
|
|
461 |
/* 2 and 1
|
|
462 |
__ __ [X] [1] __
|
|
463 |
__ __ [X] __ __
|
|
464 |
*/
|
|
465 |
QModelIndex index;
|
|
466 |
index = mModel->index( 0 );
|
|
467 |
mMediaWallWidget->scrollTo( index );
|
43
|
468 |
fetchAlbumSongs( index );
|
35
|
469 |
}
|
|
470 |
}
|
|
471 |
|
|
472 |
/*!
|
|
473 |
Scrolls the media wall to now playing position.
|
|
474 |
*/
|
|
475 |
void MpMediaWallView::scrollToNowPlaying()
|
|
476 |
{
|
|
477 |
if ( mMediaWallWidget && mPlaybackData->playbackState() != MpPlaybackData::NotPlaying ) {
|
|
478 |
int albumId = mPlaybackData->albumId();
|
|
479 |
QModelIndex index;
|
|
480 |
index = mModel->index( mCollectionData->itemIndex( albumId ) );
|
|
481 |
mMediaWallWidget->scrollTo( index );
|
43
|
482 |
fetchAlbumSongs( index );
|
35
|
483 |
}
|
|
484 |
}
|
|
485 |
|
|
486 |
/*!
|
|
487 |
Sets up the album and list animation.
|
|
488 |
*/
|
|
489 |
void MpMediaWallView::setUpListAnimation()
|
|
490 |
{
|
|
491 |
if ( !mListShowAnimationGroup ) {
|
|
492 |
mListShowAnimationGroup = new QParallelAnimationGroup( this );
|
|
493 |
mCoverShowListAnimation = new QPropertyAnimation(mAlbumCover, "geometry", this );
|
|
494 |
mCoverShowListAnimation->setDuration( 400 );
|
|
495 |
mCoverShowListAnimation->setEasingCurve(QEasingCurve::InOutCubic);
|
|
496 |
mListShowAnimationGroup->addAnimation(mCoverShowListAnimation);
|
|
497 |
mListShowListAnimation = new QPropertyAnimation( mTrackList, "geometry", this );
|
|
498 |
mListShowListAnimation->setDuration( 400 );
|
|
499 |
mListShowListAnimation->setEasingCurve(QEasingCurve::InOutCubic);
|
37
|
500 |
mListShowAnimationGroup->addAnimation(mListShowListAnimation);
|
35
|
501 |
}
|
|
502 |
|
|
503 |
//Get the current album cover geometry.
|
|
504 |
QPolygonF poly;
|
|
505 |
QModelIndex index = mMediaWallWidget->currentIndex();
|
|
506 |
if ( !mMediaWallWidget->getItemOutline( index, poly ) ) {
|
|
507 |
return;
|
|
508 |
}
|
|
509 |
QRectF itemRect = poly.boundingRect();
|
|
510 |
|
|
511 |
//Get the album cover icon.
|
|
512 |
QVariant image = mModel->data(index, Qt::DecorationRole);
|
|
513 |
if ( image.canConvert<HbIcon>() ) {
|
|
514 |
mAlbumCover->setIcon(image.value<HbIcon>());
|
|
515 |
}
|
|
516 |
else {
|
|
517 |
mAlbumCover->setIcon(HbIcon());
|
|
518 |
}
|
|
519 |
|
|
520 |
//Mapping form local media wall coords to window coors.
|
|
521 |
itemRect.moveTo( mMediaWallWidget->geometry().topLeft() + itemRect.topLeft());
|
|
522 |
//Calculate start and end position of items for the animation.
|
|
523 |
QRectF endRect = itemRect;
|
|
524 |
endRect.moveTo( endRect.topLeft().x() - endRect.size().width() / 2.0, endRect.topLeft().y() );
|
|
525 |
mCoverShowListAnimation->setStartValue(itemRect);
|
|
526 |
mCoverShowListAnimation->setEndValue(endRect);
|
37
|
527 |
endRect.moveTo( endRect.topRight() );
|
35
|
528 |
mListShowListAnimation->setStartValue(itemRect);
|
|
529 |
mListShowListAnimation->setEndValue(endRect);
|
|
530 |
|
|
531 |
//set initial condition and show to prevent flicker.
|
|
532 |
mAlbumCover->setPos(itemRect.topLeft());
|
|
533 |
mTrackList->setPos(itemRect.topLeft());
|
|
534 |
mTrackList->setGeometry(itemRect);
|
|
535 |
mAlbumCover->show();
|
|
536 |
mTrackList->show();
|
|
537 |
}
|
|
538 |
|