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