88 */ |
97 */ |
89 void MpPlaybackView::initializeView() |
98 void MpPlaybackView::initializeView() |
90 { |
99 { |
91 TX_ENTRY |
100 TX_ENTRY |
92 |
101 |
|
102 //Load musicplayer and common translators |
|
103 QString lang = QLocale::system().name(); |
|
104 QString path = QString( "z:/resource/qt/translations/" ); |
|
105 bool translatorLoaded = false; |
|
106 |
|
107 mMpTranslator = new QTranslator( this ); |
|
108 translatorLoaded = mMpTranslator->load( path + "musicplayer_" + lang ); |
|
109 TX_LOG_ARGS( "Loading translator ok=" << translatorLoaded ); |
|
110 if ( translatorLoaded ) { |
|
111 qApp->installTranslator( mMpTranslator ); |
|
112 } |
|
113 |
|
114 mCommonTranslator = new QTranslator( this ); |
|
115 translatorLoaded = mCommonTranslator->load( path + "common_" + lang ); |
|
116 TX_LOG_ARGS( "Loading common translator ok=" << translatorLoaded ); |
|
117 if ( translatorLoaded ) { |
|
118 qApp->installTranslator( mCommonTranslator ); |
|
119 } |
|
120 |
93 mWindow = mainWindow(); |
121 mWindow = mainWindow(); |
94 |
122 |
95 mSoftKeyBack = new HbAction(Hb::BackAction, this); |
123 mSoftKeyBack = new HbAction( Hb::BackAction, this ); |
96 connect( mSoftKeyBack, SIGNAL(triggered()), this, SLOT(back()) ); |
124 connect( mSoftKeyBack, SIGNAL( triggered() ), this, SLOT( back() ) ); |
97 |
125 |
98 mFrameworkWrapper = new MpMpxPbFrameworkWrapper(); |
126 mFrameworkWrapper = new MpMpxPbFrameworkWrapper(); |
99 mPlaybackData = mFrameworkWrapper->playbackData(); |
127 mPlaybackData = mFrameworkWrapper->playbackData(); |
100 connect( mPlaybackData, SIGNAL(playbackStateChanged()), |
128 connect( mPlaybackData, SIGNAL( playbackStateChanged() ), |
101 this, SLOT(playbackStateChanged()) ); |
129 this, SLOT( playbackStateChanged() ) ); |
102 |
130 |
103 mPlaybackWidget = new MpPlaybackWidget(mPlaybackData); |
131 mPlaybackWidget = new MpPlaybackWidget( mPlaybackData ); |
104 connect( mPlaybackWidget, SIGNAL(setPlaybackPosition(int)), mFrameworkWrapper, SLOT( setPosition(int) ) ); |
132 connect( mPlaybackWidget, SIGNAL( setPlaybackPosition( int ) ), mFrameworkWrapper, SLOT( setPosition( int ) ) ); |
105 |
133 |
106 setWidget(mPlaybackWidget); |
134 setWidget( mPlaybackWidget ); |
107 setupMenu(); |
135 setupMenu(); |
108 setupToolbar(); |
136 setupToolbar(); |
109 |
137 |
|
138 mEqualizerWidget->prepareDialog(); |
|
139 |
110 // Observe changes in settings. |
140 // Observe changes in settings. |
111 connect( MpSettingsManager::instance(), SIGNAL(shuffleChanged(bool)), |
141 connect( MpSettingsManager::instance(), SIGNAL( shuffleChanged( bool ) ), |
112 this, SLOT(shuffleChanged(bool)) ); |
142 this, SLOT( shuffleChanged( bool ) ) ); |
113 connect( MpSettingsManager::instance(), SIGNAL(repeatChanged(bool)), |
143 connect( MpSettingsManager::instance(), SIGNAL( repeatChanged( bool ) ), |
114 this, SLOT(repeatChanged(bool)) ); |
144 this, SLOT( repeatChanged( bool ) ) ); |
115 |
145 |
116 TX_EXIT |
146 TX_EXIT |
117 } |
147 } |
118 |
148 |
119 /*! |
149 /*! |
201 } |
237 } |
202 TX_EXIT |
238 TX_EXIT |
203 } |
239 } |
204 |
240 |
205 /*! |
241 /*! |
|
242 Slot to handle flip action. |
|
243 */ |
|
244 void MpPlaybackView::flip() |
|
245 { |
|
246 TX_ENTRY |
|
247 emit command( MpCommon::ActivateDetailsView ); |
|
248 TX_EXIT |
|
249 } |
|
250 |
|
251 /*! |
206 Slot to handle shuffle toggle. |
252 Slot to handle shuffle toggle. |
207 */ |
253 */ |
208 void MpPlaybackView::toggleShuffle() |
254 void MpPlaybackView::toggleShuffle() |
209 { |
255 { |
210 mFrameworkWrapper->setShuffle( !mShuffle ); |
256 mFrameworkWrapper->setShuffle( !mShuffle ); |
211 MpSettingsManager::setShuffle(!mShuffle); |
257 MpSettingsManager::setShuffle( !mShuffle ); |
212 } |
258 } |
213 |
259 |
214 /*! |
260 /*! |
215 Slot to handle /a shuffle setting change. |
261 Slot to handle /a shuffle setting change. |
216 */ |
262 */ |
217 void MpPlaybackView::shuffleChanged( bool shuffle ) |
263 void MpPlaybackView::shuffleChanged( bool shuffle ) |
218 { |
264 { |
219 mShuffle = shuffle; |
265 mShuffle = shuffle; |
220 mShuffleAction->setIcon( mShuffle ? *mShuffleOnIcon : *mShuffleOffIcon); |
266 mShuffleAction->setIcon( mShuffle ? *mShuffleOnIcon : *mShuffleOffIcon ); |
221 } |
267 } |
222 |
268 |
223 /*! |
269 /*! |
224 Slot to handle repeat toggle. |
270 Slot to handle repeat toggle. |
225 */ |
271 */ |
226 void MpPlaybackView::toggleRepeat() |
272 void MpPlaybackView::toggleRepeat() |
227 { |
273 { |
228 mFrameworkWrapper->setRepeat(!mRepeat); |
274 mFrameworkWrapper->setRepeat( !mRepeat ); |
229 MpSettingsManager::setRepeat(!mRepeat); |
275 MpSettingsManager::setRepeat( !mRepeat ); |
230 } |
276 } |
231 |
277 |
232 /*! |
278 /*! |
233 Slot to handle /a repeat setting change. |
279 Slot to handle /a repeat setting change. |
234 */ |
280 */ |
235 void MpPlaybackView::repeatChanged(bool repeat) |
281 void MpPlaybackView::repeatChanged( bool repeat ) |
236 { |
282 { |
237 mRepeat = repeat; |
283 mRepeat = repeat; |
238 mRepeatAction->setText( mRepeat ? tr("Repeat off") : tr("Repeat on")); |
284 mRepeatAction->setText( mRepeat ? hbTrId( "txt_mus_opt_repeat_off" ) : hbTrId( "txt_mus_opt_repeat_on" ) ); |
239 } |
285 } |
240 |
286 |
241 /*! |
287 /*! |
242 Slot called when a song is selected in fetch mode. |
288 Slot called when a song is selected in fetch mode. |
243 */ |
289 */ |
272 */ |
319 */ |
273 void MpPlaybackView::setupToolbar() |
320 void MpPlaybackView::setupToolbar() |
274 { |
321 { |
275 TX_ENTRY |
322 TX_ENTRY |
276 HbToolBar *toolBar = this->toolBar(); |
323 HbToolBar *toolBar = this->toolBar(); |
277 toolBar->setOrientation(Qt::Horizontal); |
324 toolBar->setOrientation( Qt::Horizontal ); |
278 QActionGroup *actionsGroup = new QActionGroup( toolBar ); |
325 QActionGroup *actionsGroup = new QActionGroup( toolBar ); |
279 |
326 |
280 if ( mViewMode == MpCommon::DefaultView ) { |
327 if ( mViewMode == MpCommon::DefaultView ) { |
281 mShuffleOnIcon = new HbIcon(":/playbackviewicons/shuffle_on.svg"); |
328 mShuffleOnIcon = new HbIcon( "qtg_mono_shuffle" ); |
282 mShuffleOffIcon = new HbIcon( ":/playbackviewicons/shuffle_off.svg"); |
329 mShuffleOffIcon = new HbIcon( "qtg_mono_shuffle_off" ); |
283 mShuffleAction = new HbAction(actionsGroup); |
330 mShuffleAction = new HbAction( actionsGroup ); |
284 mShuffle = MpSettingsManager::shuffle(); |
331 mShuffle = MpSettingsManager::shuffle(); |
285 mShuffleAction->setIcon( mShuffle ? *mShuffleOnIcon : *mShuffleOffIcon); |
332 mShuffleAction->setIcon( mShuffle ? *mShuffleOnIcon : *mShuffleOffIcon ); |
286 mShuffleAction->setCheckable( false ); |
333 mShuffleAction->setCheckable( false ); |
287 |
334 |
288 connect( mShuffleAction, SIGNAL(triggered(bool)), |
335 connect( mShuffleAction, SIGNAL( triggered( bool ) ), |
289 this, SLOT(toggleShuffle()) ); |
336 this, SLOT( toggleShuffle() ) ); |
290 toolBar->addAction( mShuffleAction ); |
337 toolBar->addAction( mShuffleAction ); |
291 |
338 |
292 HbAction *action = new HbAction(actionsGroup); |
339 HbAction *action = new HbAction( actionsGroup ); |
293 action->setIcon( HbIcon( ":/playbackviewicons/prev.svg") ); |
340 action->setIcon( HbIcon( "qtg_mono_previous" ) ); |
294 action->setCheckable( false ); |
341 action->setCheckable( false ); |
295 connect( action, SIGNAL(triggered(bool)), |
342 connect( action, SIGNAL( triggered( bool ) ), |
296 mFrameworkWrapper, SLOT(skipBackward()) ); |
343 mFrameworkWrapper, SLOT( skipBackward() ) ); |
297 toolBar->addAction( action ); |
344 toolBar->addAction( action ); |
298 |
345 |
299 mPlayPauseAction = new HbAction(actionsGroup); |
346 mPlayPauseAction = new HbAction( actionsGroup ); |
300 mPlayIcon = new HbIcon(":/playbackviewicons/play.svg"); |
347 mPlayIcon = new HbIcon( "qtg_mono_play" ); |
301 mPauseIcon = new HbIcon( ":/playbackviewicons/pause.svg" ); |
348 mPauseIcon = new HbIcon( "qtg_mono_pause" ); |
302 mPlayPauseAction->setIcon( *mPlayIcon ); |
349 mPlayPauseAction->setIcon( *mPlayIcon ); |
303 mPlayPauseAction->setCheckable( false ); |
350 mPlayPauseAction->setCheckable( false ); |
304 connect( mPlayPauseAction, SIGNAL(triggered(bool)), |
351 connect( mPlayPauseAction, SIGNAL( triggered( bool ) ), |
305 mFrameworkWrapper, SLOT(playPause()) ); |
352 mFrameworkWrapper, SLOT( playPause() ) ); |
306 toolBar->addAction( mPlayPauseAction ); |
353 toolBar->addAction( mPlayPauseAction ); |
307 |
354 |
308 action = new HbAction(actionsGroup); |
355 action = new HbAction( actionsGroup ); |
309 action->setIcon( HbIcon(":/playbackviewicons/next.svg") ); |
356 action->setIcon( HbIcon( "qtg_mono_next" ) ); |
310 action->setCheckable( false ); |
357 action->setCheckable( false ); |
311 connect( action, SIGNAL(triggered(bool)), |
358 connect( action, SIGNAL( triggered( bool ) ), |
312 mFrameworkWrapper, SLOT(skipForward()) ); |
359 mFrameworkWrapper, SLOT( skipForward() ) ); |
313 toolBar->addAction( action ); |
360 toolBar->addAction( action ); |
314 |
361 |
315 HbIcon icon( ":/playbackviewicons/info.svg" ); |
362 HbIcon icon( "qtg_mono_info" ); |
316 action = new HbAction(actionsGroup); |
363 action = new HbAction( actionsGroup ); |
317 action->setIcon( icon ); |
364 action->setIcon( icon ); |
318 action->setCheckable( false ); |
365 action->setCheckable( false ); |
319 /* |
366 |
320 connect( action, SIGNAL(triggered(bool)), |
367 connect( action, SIGNAL( triggered( bool ) ), |
321 this, SLOT( flip()) ); |
368 this, SLOT( flip() ) ); |
322 */ |
369 |
323 toolBar->addAction( action ); |
370 toolBar->addAction( action ); |
324 } |
371 } |
325 else { |
372 else { |
326 // Fetch mode |
373 // Fetch mode |
327 HbAction *action = new HbAction(actionsGroup); |
374 HbAction *action = new HbAction( actionsGroup ); |
328 action->setIcon( HbIcon(":/playbackviewicons/select.png") ); |
375 action->setIcon( HbIcon( "qtg_mono_tick" ) ); |
329 action->setCheckable( false ); |
376 action->setCheckable( false ); |
330 connect( action, SIGNAL(triggered(bool)), |
377 connect( action, SIGNAL( triggered( bool ) ), |
331 this, SLOT(handleSongSelected()) ); |
378 this, SLOT( handleSongSelected() ) ); |
332 toolBar->addAction( action ); |
379 toolBar->addAction( action ); |
333 |
380 |
334 mPlayPauseAction = new HbAction(actionsGroup); |
381 mPlayPauseAction = new HbAction( actionsGroup ); |
335 mPlayIcon = new HbIcon(":/playbackviewicons/play.svg"); |
382 mPlayIcon = new HbIcon( "qtg_mono_play" ); |
336 mPauseIcon = new HbIcon( ":/playbackviewicons/pause.svg" ); |
383 mPauseIcon = new HbIcon( "qtg_mono_pause" ); |
337 mPlayPauseAction->setIcon( *mPlayIcon ); |
384 mPlayPauseAction->setIcon( *mPlayIcon ); |
338 mPlayPauseAction->setCheckable( false ); |
385 mPlayPauseAction->setCheckable( false ); |
339 connect( mPlayPauseAction, SIGNAL(triggered(bool)), |
386 connect( mPlayPauseAction, SIGNAL( triggered( bool ) ), |
340 mFrameworkWrapper, SLOT(playPause()) ); |
387 mFrameworkWrapper, SLOT( playPause() ) ); |
341 toolBar->addAction( mPlayPauseAction ); |
388 toolBar->addAction( mPlayPauseAction ); |
342 } |
389 } |
343 TX_EXIT |
390 TX_EXIT |
344 } |
391 } |
345 |
392 |
|
393 /*! |
|
394 Slot to be called to activate equalizer dialog. |
|
395 */ |
|
396 void MpPlaybackView::showEqualizerDialog() |
|
397 { |
|
398 TX_ENTRY |
|
399 |
|
400 if( mEqualizerWidget ) |
|
401 { |
|
402 mEqualizerWidget->exec(); |
|
403 } |
|
404 |
|
405 TX_EXIT |
|
406 } |