mpviewplugins/mpplaybackviewplugin/src/mpplaybackview.cpp
changeset 41 ea59c434026a
parent 29 8192e5b5c935
child 43 0f32e550d9d8
child 48 af3740e3753f
equal deleted inserted replaced
32:c163ef0b758d 41:ea59c434026a
    22 #include <hbinstance.h>
    22 #include <hbinstance.h>
    23 #include <hbtoolbar.h>
    23 #include <hbtoolbar.h>
    24 #include <hbtoolbutton.h>
    24 #include <hbtoolbutton.h>
    25 #include <hbaction.h>
    25 #include <hbaction.h>
    26 #include <hbicon.h>
    26 #include <hbicon.h>
    27 #include <QTranslator>
       
    28 #include <QLocale>
       
    29 
    27 
    30 #include "mpplaybackview.h"
    28 #include "mpplaybackview.h"
    31 #include "mpplaybackwidget.h"
    29 #include "mpplaybackwidget.h"
    32 #include "mpenginefactory.h"
    30 #include "mpenginefactory.h"
    33 #include "mpplaybackdata.h"
    31 #include "mpplaybackdata.h"
    66       mActivated( false ),
    64       mActivated( false ),
    67       mPlayIcon( 0 ),
    65       mPlayIcon( 0 ),
    68       mPauseIcon( 0 ),
    66       mPauseIcon( 0 ),
    69       mShuffleOnIcon( 0 ),
    67       mShuffleOnIcon( 0 ),
    70       mShuffleOffIcon( 0 ),
    68       mShuffleOffIcon( 0 ),
    71       mMpTranslator( 0 ),
       
    72       mCommonTranslator( 0 ),
       
    73       mTimer(0),
    69       mTimer(0),
    74       mSeeking(false)
    70       mSeeking(false)
    75 
    71 
    76 {
    72 {
    77     TX_LOG
    73     TX_LOG
    87     delete mPlayIcon;
    83     delete mPlayIcon;
    88     delete mPauseIcon;
    84     delete mPauseIcon;
    89     delete mShuffleOnIcon;
    85     delete mShuffleOnIcon;
    90     delete mShuffleOffIcon;
    86     delete mShuffleOffIcon;
    91     delete mEqualizerWidget;
    87     delete mEqualizerWidget;
    92     delete mMpTranslator;
       
    93     delete mCommonTranslator;
       
    94     TX_EXIT
    88     TX_EXIT
    95 }
    89 }
    96 
    90 
    97 
    91 
    98 /*!
    92 /*!
    99  Initializes the playback view.
    93  Initializes the playback view.
   100  */
    94  */
   101 void MpPlaybackView::initializeView()
    95 void MpPlaybackView::initializeView()
   102 {
    96 {
   103     TX_ENTRY
    97     TX_ENTRY
   104 
       
   105     //Load musicplayer and common translators
       
   106     QString lang = QLocale::system().name();
       
   107     QString path = QString( "z:/resource/qt/translations/" );
       
   108     bool translatorLoaded = false;
       
   109 
       
   110     mMpTranslator = new QTranslator( this );
       
   111     translatorLoaded = mMpTranslator->load( path + "musicplayer_" + lang );
       
   112     TX_LOG_ARGS( "Loading translator ok=" << translatorLoaded );
       
   113     if ( translatorLoaded ) {
       
   114         qApp->installTranslator( mMpTranslator );
       
   115     }
       
   116 
       
   117     mCommonTranslator = new QTranslator( this );
       
   118     translatorLoaded = mCommonTranslator->load( path + "common_" + lang );
       
   119     TX_LOG_ARGS( "Loading common translator ok=" << translatorLoaded );
       
   120     if ( translatorLoaded ) {
       
   121         qApp->installTranslator( mCommonTranslator );
       
   122     }
       
   123 
    98 
   124     mWindow = mainWindow();
    99     mWindow = mainWindow();
   125 
   100 
   126     mSoftKeyBack = new HbAction( Hb::BackNaviAction, this );
   101     mSoftKeyBack = new HbAction( Hb::BackNaviAction, this );
   127     connect( mSoftKeyBack, SIGNAL( triggered() ), this, SLOT( back() ) );
   102     connect( mSoftKeyBack, SIGNAL( triggered() ), this, SLOT( back() ) );
   149         // Observe changes in settings.
   124         // Observe changes in settings.
   150         connect( MpSettingsManager::instance(), SIGNAL( shuffleChanged( bool ) ),
   125         connect( MpSettingsManager::instance(), SIGNAL( shuffleChanged( bool ) ),
   151                  this, SLOT( shuffleChanged( bool ) ) );
   126                  this, SLOT( shuffleChanged( bool ) ) );
   152         connect( MpSettingsManager::instance(), SIGNAL( repeatChanged( bool ) ),
   127         connect( MpSettingsManager::instance(), SIGNAL( repeatChanged( bool ) ),
   153                  this, SLOT( repeatChanged( bool ) ) );
   128                  this, SLOT( repeatChanged( bool ) ) );
       
   129         connect( mMpEngine, SIGNAL( libraryUpdated() ), this, SLOT( closeEqualizerDialog() ) );
   154     }
   130     }
   155 
   131 
   156     TX_EXIT
   132     TX_EXIT
   157 }
   133 }
   158 
   134 
   171  Deactivates the playback view.
   147  Deactivates the playback view.
   172  */
   148  */
   173 void MpPlaybackView::deactivateView()
   149 void MpPlaybackView::deactivateView()
   174 {
   150 {
   175     TX_ENTRY
   151     TX_ENTRY
   176     if ( mEqualizerWidget && mEqualizerWidget->isActive() ) {
       
   177         mEqualizerWidget->close();
       
   178     }
       
   179 
       
   180     menu()->close();
   152     menu()->close();
   181 
       
   182     setNavigationAction( 0 );
   153     setNavigationAction( 0 );
   183     mActivated = false;
   154     mActivated = false;
   184     TX_EXIT
   155     TX_EXIT
       
   156 }
       
   157 
       
   158 /*!
       
   159  Gets the current status of the view in a form of string
       
   160  */
       
   161 QString MpPlaybackView::playbackStatus()
       
   162 {
       
   163     TX_ENTRY
       
   164     QString currentStatus;
       
   165     
       
   166         switch ( mPlaybackData->playbackState() ) {
       
   167             case MpPlaybackData::NotPlaying:
       
   168                 TX_LOG_ARGS( "playbackStatus: NotPlaying" )
       
   169                 currentStatus = "NotPlaying";
       
   170                 break;
       
   171 			case MpPlaybackData::Playing:
       
   172                 TX_LOG_ARGS( "playbackStatus: Playing" )
       
   173                 currentStatus = "Playing";
       
   174                 break;
       
   175             case MpPlaybackData::Paused:
       
   176                 TX_LOG_ARGS( "playbackStatus: Paused" )
       
   177                 currentStatus ="Paused";
       
   178                 break;
       
   179             case MpPlaybackData::Stopped:
       
   180                 TX_LOG_ARGS( "playbackStatus: Stopped" )
       
   181                 currentStatus = "Stopped";
       
   182                 break;
       
   183             default:
       
   184                 break;
       
   185         }
       
   186     TX_EXIT
       
   187     return currentStatus;
       
   188     
       
   189 }
       
   190 
       
   191 /*!
       
   192  Gets the current Shuffle setting value
       
   193  */
       
   194 bool MpPlaybackView::shuffleEnabled()
       
   195 {
       
   196     TX_ENTRY
       
   197     return mShuffle;
       
   198 }
       
   199 
       
   200 /*!
       
   201  Gets the current Repeat setting value
       
   202  */
       
   203 bool MpPlaybackView::repeatEnabled()
       
   204 {
       
   205     TX_ENTRY
       
   206     return mRepeat;
   185 }
   207 }
   186 
   208 
   187 /*!
   209 /*!
   188  Slot to be called to activate settings view.
   210  Slot to be called to activate settings view.
   189  */
   211  */
   322  */
   344  */
   323 void MpPlaybackView::setupToolbar()
   345 void MpPlaybackView::setupToolbar()
   324 {
   346 {
   325     TX_ENTRY
   347     TX_ENTRY
   326     HbToolBar *myToolBar = toolBar();
   348     HbToolBar *myToolBar = toolBar();
       
   349     myToolBar->setObjectName("PlaybackToolbar");
   327     myToolBar->setOrientation( Qt::Horizontal );
   350     myToolBar->setOrientation( Qt::Horizontal );
   328     QActionGroup *actionsGroup = new QActionGroup( myToolBar );
   351     QActionGroup *actionsGroup = new QActionGroup( myToolBar );
   329 
   352 
   330     if ( mViewMode == MpCommon::DefaultView || mViewMode == MpCommon::EmbeddedView ) {
   353     if ( mViewMode == MpCommon::DefaultView || mViewMode == MpCommon::EmbeddedView ) {
   331         mShuffleOnIcon = new HbIcon( "qtg_mono_shuffle" );
   354         mShuffleOnIcon = new HbIcon( "qtg_mono_shuffle" );
   537                 disconnect ( mWindow, SIGNAL( viewReady() ), this, SLOT( connectButtons() ) );
   560                 disconnect ( mWindow, SIGNAL( viewReady() ), this, SLOT( connectButtons() ) );
   538             }
   561             }
   539         }
   562         }
   540     }
   563     }
   541 }
   564 }
       
   565 
   542 /*!
   566 /*!
   543  Slot to be called to activate equalizer dialog.
   567  Slot to be called to activate equalizer dialog.
   544  */
   568  */
   545 void MpPlaybackView::showEqualizerDialog()
   569 void MpPlaybackView::showEqualizerDialog()
   546 {
   570 {
   551         mEqualizerWidget->show();
   575         mEqualizerWidget->show();
   552     }
   576     }
   553 
   577 
   554     TX_EXIT
   578     TX_EXIT
   555 }
   579 }
       
   580 
       
   581 /*!
       
   582  Slot to be called when library has been updated
       
   583  */
       
   584 void MpPlaybackView::closeEqualizerDialog()
       
   585 {
       
   586     TX_ENTRY
       
   587     
       
   588     if ( mEqualizerWidget ) {
       
   589         mEqualizerWidget->close();
       
   590     }
       
   591     
       
   592     TX_EXIT
       
   593 }