mpviewplugins/mpplaybackviewplugin/src/mpplaybackwidget.cpp
changeset 61 3cd404d31176
parent 54 c5b304f4d89b
equal deleted inserted replaced
58:ed94e1e8390e 61:3cd404d31176
    26 #include "mpplaybackwidget.h"
    26 #include "mpplaybackwidget.h"
    27 #include "mpplaybackdata.h"
    27 #include "mpplaybackdata.h"
    28 #include "mpalbumcoverwidget.h"
    28 #include "mpalbumcoverwidget.h"
    29 #include "mpplaybackdocumentloader.h"
    29 #include "mpplaybackdocumentloader.h"
    30 #include "mptrace.h"
    30 #include "mptrace.h"
       
    31 #include "mplightmonitor.h"
    31 
    32 
    32 const unsigned int KMicroSecToMiliSec( 1000 );
    33 const unsigned int KMicroSecToMiliSec( 1000 );
    33 
    34 
    34 /*!
    35 /*!
    35     \class MpPlaybackWidget
    36     \class MpPlaybackWidget
    42     \fn void setPlaybackPosition(int value)
    43     \fn void setPlaybackPosition(int value)
    43 
    44 
    44     This signal is emitted when the user drags the progressbar to a new
    45     This signal is emitted when the user drags the progressbar to a new
    45     position, \a value indicates the position.
    46     position, \a value indicates the position.
    46  */
    47  */
       
    48 
       
    49  /*!
       
    50     \fn void signalPlaybackInfoChanged()
       
    51 
       
    52     This signal is emitted when playback information has changed. Added for MATTI testing support.
       
    53  */
       
    54 
    47 
    55 
    48 /*!
    56 /*!
    49  Constructs the collection view plugin.
    57  Constructs the collection view plugin.
    50  */
    58  */
    51 MpPlaybackWidget::MpPlaybackWidget(MpPlaybackData *data, QGraphicsItem *parent )
    59 MpPlaybackWidget::MpPlaybackWidget(MpPlaybackData *data, QGraphicsItem *parent )
    52     : HbWidget(parent),
    60     : HbWidget(parent),
    53       mPlaybackData(data),
    61       mPlaybackData(data),
    54       mDocumentLoader(0),
    62       mDocumentLoader(0),
       
    63       mLightMonitor(0),
    55       mProgreesBarDragging(false),
    64       mProgreesBarDragging(false),
    56       mDuration(0)
    65       mDuration(0)
    57 {
    66 {
    58     TX_ENTRY
    67     TX_ENTRY
    59     mLayout = new HbStackedLayout(this);
    68     mLayout = new HbStackedLayout(this);
    96     else {
   105     else {
    97         TX_LOG_ARGS("Error: invalid xml file.");
   106         TX_LOG_ARGS("Error: invalid xml file.");
    98         Q_ASSERT_X(widgetsOk, "MpPlaybackWidget", "invalid xml file - widget");
   107         Q_ASSERT_X(widgetsOk, "MpPlaybackWidget", "invalid xml file - widget");
    99     }
   108     }
   100 
   109 
       
   110     mLightMonitor = new MpLightMonitor (this);
       
   111     connect( mLightMonitor, SIGNAL(lcdLightStatus(bool)), this, SLOT(handleLcdLightStatus(bool)) );
       
   112 
   101     connect( mProgressBar, SIGNAL(sliderPressed()), this, SLOT(handleSliderPressed()) );
   113     connect( mProgressBar, SIGNAL(sliderPressed()), this, SLOT(handleSliderPressed()) );
   102     connect( mProgressBar, SIGNAL(sliderReleased()), this, SLOT(handleSliderReleased()) );
   114     connect( mProgressBar, SIGNAL(sliderReleased()), this, SLOT(handleSliderReleased()) );
   103     connect( mProgressBar, SIGNAL(sliderMoved(int)), this, SLOT(handleSliderMoved(int)) );
   115     connect( mProgressBar, SIGNAL(sliderMoved(int)), this, SLOT(handleSliderMoved(int)) );
   104 
   116 
   105     connect( mPlaybackData, SIGNAL(playbackInfoChanged()), this, SLOT(playbackInfoChanged()) );
   117     connectPlaybackDataSignals(true);
   106     connect( mPlaybackData, SIGNAL(durationChanged()), this, SLOT(durationChanged()) );
   118     // Update to set initial conditions if playback has already started.
   107     connect( mPlaybackData, SIGNAL(positionChanged()), this, SLOT(positionChanged()) );
       
   108     connect( mPlaybackData, SIGNAL(albumArtReady()), this, SLOT(albumArtChanged()) );
       
   109     
       
   110     //Update to set initial conditions if playback has already started.
       
   111     if ( mPlaybackData->playbackState() != MpPlaybackData::NotPlaying ) {
   119     if ( mPlaybackData->playbackState() != MpPlaybackData::NotPlaying ) {
   112         playbackInfoChanged();
   120         updatePlaybackInfo();
   113         durationChanged();
       
   114         positionChanged();
       
   115         albumArtChanged();
       
   116     }
   121     }
   117     TX_EXIT
   122     TX_EXIT
   118 }
   123 }
   119 
   124 
   120 /*!
   125 /*!
   122  */
   127  */
   123 MpPlaybackWidget::~MpPlaybackWidget()
   128 MpPlaybackWidget::~MpPlaybackWidget()
   124 {
   129 {
   125     TX_ENTRY
   130     TX_ENTRY
   126     delete mDocumentLoader;
   131     delete mDocumentLoader;
       
   132     delete mLightMonitor;
   127     TX_EXIT
   133     TX_EXIT
   128 }
   134 }
   129 
   135 
   130 /*!
   136 /*!
   131  Handle Repeat changed.
   137  Handle Repeat changed.
   132  */
   138  */
   133 void MpPlaybackWidget::repeatChanged( bool value )
   139 void MpPlaybackWidget::repeatChanged( bool value )
   134 {
   140 {
   135     mRepeatIndicator->setVisible( value );   
   141     mRepeatIndicator->setVisible( value );
   136 }
   142 }
   137 
   143 
   138 /*!
   144 /*!
   139  Slot to handle playback info changed.
   145  Slot to handle playback info changed.
   140  */
   146  */
   270         return duration.toString( "hh:mm:ss" );
   276         return duration.toString( "hh:mm:ss" );
   271     }
   277     }
   272 }
   278 }
   273 
   279 
   274 
   280 
       
   281 /*!
       
   282  Slot to be called to handle LCD light status change.
       
   283  */
       
   284 void MpPlaybackWidget::handleLcdLightStatus( bool lightOn )
       
   285 {
       
   286     TX_ENTRY
       
   287     if ( lightOn ) {
       
   288         connectPlaybackDataSignals( true );
       
   289         updatePlaybackInfo();
       
   290     }
       
   291     else {
       
   292         connectPlaybackDataSignals( false );
       
   293     }
       
   294     TX_EXIT
       
   295 }
       
   296 
       
   297 /*!
       
   298  Connect/disconnect the signals from the Playback data according to /a connect.
       
   299  */
       
   300 void MpPlaybackWidget::connectPlaybackDataSignals( bool connectSignal )
       
   301 {
       
   302     TX_ENTRY
       
   303     if ( connectSignal ) {
       
   304         connect( mPlaybackData, SIGNAL(playbackInfoChanged()), this, SLOT(playbackInfoChanged()) );
       
   305         connect( mPlaybackData, SIGNAL(durationChanged()), this, SLOT(durationChanged()) );
       
   306         connect( mPlaybackData, SIGNAL(positionChanged()), this, SLOT(positionChanged()) );
       
   307         connect( mPlaybackData, SIGNAL(albumArtReady()), this, SLOT(albumArtChanged()) );
       
   308         connect( mPlaybackData, SIGNAL(collectionPlaylistOpened()), this, SLOT(handleCollectionPlaylistOpened()) );     
       
   309        }
       
   310     else {
       
   311         mPlaybackData->disconnect( this );
       
   312     }
       
   313     TX_EXIT
       
   314 }
       
   315 
       
   316 /*!
       
   317  Update playback information.
       
   318  */
       
   319 void MpPlaybackWidget::updatePlaybackInfo()
       
   320 {
       
   321     TX_ENTRY
       
   322     playbackInfoChanged();
       
   323     durationChanged();
       
   324     positionChanged();
       
   325     albumArtChanged();
       
   326     TX_EXIT
       
   327 }
       
   328 
       
   329 /*!
       
   330  Slot to be called to handle the selection of an item from collection view when playback
       
   331  view was previously activated with another item. We reset or hide the view items 
       
   332  in order to reduce the flickering.
       
   333  */
       
   334 void MpPlaybackWidget::handleCollectionPlaylistOpened()
       
   335 {
       
   336     TX_ENTRY
       
   337     QString blankSpace = " ";   
       
   338     mAlbumArt->setEnabled( false );
       
   339     mArtistName->setPlainText( blankSpace );
       
   340     mAlbumName->setPlainText( blankSpace );
       
   341     mSongTitle->setPlainText( blankSpace );
       
   342     mRealAudioIndicator->setVisible( false );
       
   343     mProgressBar->setProgressValue( 0 );
       
   344     mProgressBar->setSliderValue( 0 );
       
   345     mProgressBar->setMinText( formatDuration( 0 ) );
       
   346     mProgressBar->setMaxText( formatDuration( 0 ) );
       
   347     TX_EXIT
       
   348 }
       
   349