musicwidgetplugin/inc/musicwidget.h
changeset 61 3cd404d31176
parent 58 ed94e1e8390e
equal deleted inserted replaced
58:ed94e1e8390e 61:3cd404d31176
    16 */
    16 */
    17 
    17 
    18 #ifndef MUSICWIDGET_H
    18 #ifndef MUSICWIDGET_H
    19 #define MUSICWIDGET_H
    19 #define MUSICWIDGET_H
    20 
    20 
    21 // System includes
    21 // includes
    22 #include <QGraphicsLinearLayout>
       
    23 #include <QGraphicsGridLayout>
       
    24 #include <hbwidget.h>
    22 #include <hbwidget.h>
    25 #include <xqappmgr.h>
    23 #include <xqappmgr.h>
    26 
       
    27 #include "mpplaybackdata.h"
       
    28 
    24 
    29 // Forward declarations
    25 // Forward declarations
    30 class HbLabel;
    26 class HbLabel;
    31 class HbPushButton;
    27 class HbPushButton;
    32 class HbIcon;
    28 class HbIcon;
    33 class HbMarqueeItem;
    29 class HbMarqueeItem;
    34 class MpEngine;
    30 class MpEngine;
    35 class MpAlbumCoverWidget;
    31 class MpAlbumCoverWidget;
       
    32 class MpApplicationMonitor;
       
    33 class MpPlaybackData;
    36 
    34 
    37 /**
    35 /**
    38  * Media key identifier for push button events
    36  * Media key identifier for push button events
    39  */
    37  */
    40 enum MediaKeyIdentifier{
    38 enum MediaKeyIdentifier {
    41     EPrevious = 1,
    39     EPrevious = 1,
    42     EPlayPause,
    40     EPlayPause,
    43     ENext
    41     ENext
    44 };
    42 };
    45 
    43 
    46 /**
    44 /**
    47  * Music Player launch source identifier
    45  * Music Player launch source identifier
    48  */    
    46  */    
    49 enum LaunchIdentifier{
    47 enum LaunchIdentifier {
    50     ELaunchFromPlay,
    48     ELaunchToMainView,
    51     ELaunchFromShortcut
    49     ELaunchToNowPlayingView,
       
    50     ELaunchToNowPlayingViewWithShuffle
    52 };
    51 };
    53 
    52 
    54 class MusicWidget: public HbWidget
    53 class MusicWidget: public HbWidget
    55 {
    54 {
    56     Q_OBJECT
    55     Q_OBJECT
    72     void refreshData();
    71     void refreshData();
    73     
    72     
    74     /**
    73     /**
    75      * Launch Music Player to view
    74      * Launch Music Player to view
    76      */      
    75      */      
    77     void launchMusicPlayer(int launchMode = ELaunchFromShortcut);
    76     void launchMusicPlayer( int launchMode );
    78     
    77     
    79     /**
    78     /**
    80      * Similar to public slots mediaButtonPressed and mediaButtonReleased, but this oen is called internally
    79      * Update widget buttons according to Music Player state
    81      * Draws the spesified button to disabled state
    80      */       
    82      */
    81     void updateButtons();
    83     void mediaButtonDisabled( int aMediaKeyId );
    82 
       
    83     /**
       
    84      * Connect/disconnect Music Player engine and playback data
       
    85      */           
       
    86     void connectMusicPlayerEngine( bool connect );
    84     
    87     
    85     /**
    88     /**
    86      * Similar to public slots mediaButtonPressed and mediaButtonReleased, but this oen is called internally
    89      * Get the playback state
    87      * Draws the spesified button to enabled state
    90      */
    88      */    
    91     int getPlaybackState();
    89     void mediaButtonEnabled( int aMediaKeyId );
    92 
    90     
       
    91     /**
    93     /**
    92      * Disable/enable widget buttons according to Music Player state
    94      * Clear the song data
    93      */       
    95      */
    94     void toggleButtons();
    96     void clearData();
    95     
       
    96 public:
       
    97     QRectF boundingRect() const;
       
    98     QPainterPath shape() const;
       
    99     
    97     
   100 public slots:
    98 public slots:
   101 
    99 
   102     /**
   100     /**
   103      * Widget slots
   101      * Widget related
   104      */    
   102      */    
   105     void onInitialize();
   103     void onInitialize();
   106     void onShow();
   104     void onShow();
   107     void onHide();
   105     void onHide();
   108     void onUninitialize();
   106     void onUninitialize();
   109     
   107     
   110     /**
   108     /**
   111      * MpEngine slots
   109      * MpEngine related
   112      */
   110      */    
   113     void libraryUpdateStarted();
   111     void libraryUpdateStarted();
   114     void libraryUpdated();
   112     void libraryUpdated();
   115     void usbBlocked( bool blocked );    
   113     void usbBlocked( bool blocked );    
   116 
   114 
   117     /**
   115     /**
   118      * MpPlaybackData slots
   116      * MpPlaybackData related
   119      */        
   117      */        
   120     void albumArtReady();
   118     void albumArtReady();
   121     void playbackStateChanged();
   119     void playbackStateChanged();
   122     void playbackInfoChanged();    
   120     void playbackInfoChanged();    
   123     
   121     
   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:
   122 private slots:
   153 
   123 
   154     /**
   124     /**
   155      * Slots to be called after button press
   125      * Slots to be called after button press
   156      */    
   126      */    
   157     void prevSong();
   127     void handlePrevButtonClicked();
   158     void playSong();
   128     void handlePlayButtonClicked();
   159     void nextSong();
   129     void handleNextButtonClicked();
   160     void shortcutButton();
   130     void handleAlbumArtClicked();
       
   131     
       
   132     /**
       
   133      * MpApplicationMonitor related
       
   134      */
       
   135     void applicationStatusChanged( bool isrunning );
   161     
   136     
   162 private:  
   137 private:  
   163     // mShortcutButtonLayout items
       
   164     HbPushButton *mShortcutArea;
       
   165 
       
   166     //mSongDataLayout items
   138     //mSongDataLayout items
   167     HbWidget *mSongDataBG;
   139     HbLabel *mSongDataBackground;
   168     HbLabel *mInformationSongName;
       
   169     HbMarqueeItem *mMarqueeText;
   140     HbMarqueeItem *mMarqueeText;
   170     
   141     
   171     // mControlButtonsLayout items
   142     // mControlButtonsLayout items
   172     HbPushButton *mPreviousPushButton;
   143     HbPushButton *mPreviousPushButton;
   173     HbPushButton *mPlayPushButton;
   144     HbPushButton *mPlayPushButton;
   174     HbPushButton *mNextPushButton;
   145     HbPushButton *mNextPushButton;
   175     
   146     
   176     // MusicPlayer related state identifiers
   147     // MusicPlayer related state identifiers
   177     bool mMusicPlayerNoSongData;
       
   178     bool mMusicPlayerUpdating;
   148     bool mMusicPlayerUpdating;
   179     bool mMusicPlayerBlocked;
   149     bool mMusicPlayerBlocked;
       
   150     bool mMusicPlayerRunning;
   180     
   151     
   181     // Album art for background
   152     // Album art for background
   182     MpAlbumCoverWidget *mAlbumArt;
   153     MpAlbumCoverWidget *mAlbumArt;
   183     
       
   184     // Artist and song title identifiers 
       
   185     QString mArtist;
       
   186     QString mTitle;
       
   187     
   154     
   188     // Used to launch MusicPlayer
   155     // Used to launch MusicPlayer
   189     XQApplicationManager mApplicationManager;
   156     XQApplicationManager mApplicationManager;
   190     
   157     
   191     // MusicPlayer control and state updates
   158     // MusicPlayer control and state updates
   192     MpEngine* mMpEngine;
   159     MpEngine *mMpEngine;
   193     MpPlaybackData* mMpPlaybackData;
   160     MpPlaybackData *mMpPlaybackData;
   194 
   161     
       
   162     // Music Player observer
       
   163     MpApplicationMonitor *mMpApplicationMonitor;
   195 };
   164 };
   196 
   165 
   197 #endif // MUSICWIDGET_H
   166 #endif // MUSICWIDGET_H