36
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 home screen widget
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef MUSICWIDGET_H
|
|
19 |
#define MUSICWIDGET_H
|
|
20 |
|
|
21 |
// System includes
|
|
22 |
#include <QGraphicsLinearLayout>
|
|
23 |
#include <QGraphicsGridLayout>
|
|
24 |
#include <hbwidget.h>
|
|
25 |
#include <xqappmgr.h>
|
|
26 |
|
|
27 |
#include "mpplaybackdata.h"
|
|
28 |
|
|
29 |
// Forward declarations
|
|
30 |
class HbLabel;
|
|
31 |
class HbPushButton;
|
|
32 |
class HbIcon;
|
|
33 |
class HbMarqueeItem;
|
|
34 |
class MpEngine;
|
43
|
35 |
class MpAlbumCoverWidget;
|
36
|
36 |
|
|
37 |
/**
|
|
38 |
* Media key identifier for push button events
|
|
39 |
*/
|
|
40 |
enum MediaKeyIdentifier{
|
|
41 |
EPrevious = 1,
|
|
42 |
EPlayPause,
|
|
43 |
ENext
|
|
44 |
};
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Music Player launch source identifier
|
|
48 |
*/
|
|
49 |
enum LaunchIdentifier{
|
|
50 |
ELaunchFromPlay,
|
|
51 |
ELaunchFromShortcut
|
|
52 |
};
|
|
53 |
|
|
54 |
class MusicWidget: public HbWidget
|
|
55 |
{
|
|
56 |
Q_OBJECT
|
|
57 |
|
|
58 |
public:
|
|
59 |
MusicWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
|
|
60 |
~MusicWidget();
|
|
61 |
|
|
62 |
private:
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Setup graphics
|
|
66 |
*/
|
|
67 |
void setupUi();
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Get latest song data, player state and album art
|
|
71 |
*/
|
|
72 |
void refreshData();
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Launch Music Player to view
|
|
76 |
*/
|
|
77 |
void launchMusicPlayer(int launchMode = ELaunchFromShortcut);
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Similar to public slots mediaButtonPressed and mediaButtonReleased, but this oen is called internally
|
|
81 |
* Draws the spesified button to disabled state
|
|
82 |
*/
|
|
83 |
void mediaButtonDisabled( int aMediaKeyId );
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Similar to public slots mediaButtonPressed and mediaButtonReleased, but this oen is called internally
|
|
87 |
* Draws the spesified button to enabled state
|
|
88 |
*/
|
|
89 |
void mediaButtonEnabled( int aMediaKeyId );
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Disable/enable widget buttons according to Music Player state
|
|
93 |
*/
|
|
94 |
void toggleButtons();
|
|
95 |
|
|
96 |
public:
|
|
97 |
QRectF boundingRect() const;
|
|
98 |
QPainterPath shape() const;
|
|
99 |
|
|
100 |
public slots:
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Widget slots
|
|
104 |
*/
|
|
105 |
void onInitialize();
|
|
106 |
void onShow();
|
|
107 |
void onHide();
|
|
108 |
void onUninitialize();
|
|
109 |
|
|
110 |
/**
|
|
111 |
* MpEngine slots
|
|
112 |
*/
|
|
113 |
void libraryAboutToUpdate();
|
|
114 |
void libraryUpdated();
|
|
115 |
void usbBlocked( bool blocked );
|
|
116 |
|
|
117 |
/**
|
|
118 |
* MpPlaybackData slots
|
|
119 |
*/
|
|
120 |
void albumArtReady();
|
|
121 |
void playbackStateChanged();
|
|
122 |
void playbackInfoChanged();
|
|
123 |
|
|
124 |
/**
|
|
125 |
* ?????
|
|
126 |
*/
|
|
127 |
bool eventFilter(QObject *target, QEvent *event);
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Button specific slots
|
|
131 |
*/
|
|
132 |
void mediaButtonPressed( int aMediaKeyId );
|
|
133 |
void mediaButtonReleased( int aMediaKeyId );
|
|
134 |
|
|
135 |
protected:
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Called from mediaButtonPressed and from mediaButtonReleased slots.
|
|
139 |
* Calls defineMediaButton to redraw the media button
|
|
140 |
*/
|
|
141 |
void mediaButtonEvent( MediaKeyIdentifier aMediaKeyId, QString aGraphicsId, QString aIconColor );
|
|
142 |
|
|
143 |
/**
|
|
144 |
* Creates the aTarget push button based on params aGraphicsId and aSuffix.
|
|
145 |
* Used to change the look and feel of the button based to the aState
|
|
146 |
* param: aTarget is the push button to be changed, must not be Null
|
|
147 |
* param: aGraphicsId defines the button background graphics
|
|
148 |
* param: aSuffix filename suffix, see KPrevButPrefix for example from musicwidget.cpp
|
|
149 |
*/
|
|
150 |
void defineMediaButton( HbPushButton& aTarget, QString aGraphicsId, QStringList aSuffix, QString aIconColor );
|
|
151 |
|
|
152 |
private slots:
|
|
153 |
|
|
154 |
/**
|
|
155 |
* Slots to be called after button press
|
|
156 |
*/
|
|
157 |
void prevSong();
|
|
158 |
void playSong();
|
|
159 |
void nextSong();
|
|
160 |
void shortcutButton();
|
|
161 |
|
|
162 |
private:
|
|
163 |
// mShortcutButtonLayout items
|
|
164 |
HbPushButton *mShortcutArea;
|
|
165 |
|
|
166 |
//mSongDataLayout items
|
|
167 |
HbWidget *mSongDataBG;
|
|
168 |
HbLabel *mInformationSongName;
|
|
169 |
HbMarqueeItem *mMarqueeText;
|
|
170 |
|
|
171 |
// mControlButtonsLayout items
|
|
172 |
HbPushButton *mPreviousPushButton;
|
|
173 |
HbPushButton *mPlayPushButton;
|
|
174 |
HbPushButton *mNextPushButton;
|
|
175 |
|
|
176 |
// MusicPlayer related state identifiers
|
|
177 |
bool mMusicPlayerNoSongData;
|
|
178 |
bool mMusicPlayerUpdating;
|
|
179 |
bool mMusicPlayerBlocked;
|
|
180 |
|
|
181 |
// Album art for background
|
43
|
182 |
MpAlbumCoverWidget *mAlbumArt;
|
36
|
183 |
|
|
184 |
// Artist and song title identifiers
|
|
185 |
QString mArtist;
|
|
186 |
QString mTitle;
|
|
187 |
|
|
188 |
// Used to launch MusicPlayer
|
|
189 |
XQApplicationManager mApplicationManager;
|
|
190 |
|
|
191 |
// MusicPlayer control and state updates
|
|
192 |
MpEngine* mMpEngine;
|
|
193 |
MpPlaybackData* mMpPlaybackData;
|
|
194 |
|
|
195 |
};
|
|
196 |
|
|
197 |
#endif // MUSICWIDGET_H
|