void PlayerWidget::mousePressEvent(QMouseEvent *e) { QPoint pos(myrtlpoint(e->pos())); if (e->button() == Qt::LeftButton) { _down = OverNone; if (_song && _over == OverPlay) { playPausePressed(); return; } else if (_over == OverPrev) { prevPressed(); } else if (_over == OverNext) { nextPressed(); } else if (_over == OverClose) { _down = OverClose; } else if (_over == OverVolume) { _down = OverVolume; _downCoord = pos.x() - _volumeRect.x(); cSetSongVolume(snap((_downCoord - ((_volumeRect.width() - st::playerVolume.pxWidth()) / 2)) / float64(st::playerVolume.pxWidth()), 0., 1.)); emit audioPlayer()->songVolumeChanged(); rtlupdate(_volumeRect); } else if (_over == OverPlayback) { SongMsgId playing; AudioPlayerState playingState = AudioPlayerStopped; int64 playingPosition = 0, playingDuration = 0; int32 playingFrequency = 0; audioPlayer()->currentState(&playing, &playingState, &playingPosition, &playingDuration, &playingFrequency); if (playing == _song && playingDuration) { if (playingState == AudioPlayerPlaying || playingState == AudioPlayerStarting || playingState == AudioPlayerResuming) { audioPlayer()->pauseresume(OverviewDocuments); } _down = OverPlayback; _downProgress = snap((pos.x() - _playbackRect.x()) / float64(_playbackRect.width()), 0., 1.); _downDuration = playingDuration; _downFrequency = (playingFrequency ? playingFrequency : AudioVoiceMsgFrequency); rtlupdate(_playbackRect); updateDownTime(); } } else if (_over == OverFull && _song) { if (HistoryItem *item = App::histItemById(_song.msgId)) { App::main()->showMediaOverview(item->history()->peer, OverviewAudioDocuments); } } else if (_over == OverRepeat) { _repeat = !_repeat; updateOverRect(OverRepeat); } } }
/* * Description : constructor */ IRNowPlayingView::IRNowPlayingView(IRApplication* aApplication, TIRViewId aViewId) : IRBaseView(aApplication, aViewId), iStatisticsReporter(NULL), iStationShare(NULL), iPlayStopAction(NULL), iLogoDownloadState(EIdle), iSongNameLabel(NULL), iSongNameMarquee(NULL), iArtistName(NULL), iStationName(NULL), iStationLogo(NULL), iLogoNeedUpdate(true), iFindinNmsAllowed(false), iSongNameAvailable(false) #ifdef ADV_ENABLED ,iAdvImage(NULL) ,iAdvImageNeedUpdate(true) ,iAdvUrl(KDefaultAdvLink) #endif { LOG_METHOD; iLaunchActionNeeded = (0 == getViewManager()->views().count()); // this is the starting view initialize(); iStatisticsReporter = IRQStatisticsReporter::openInstance(); connect(iPlayController, SIGNAL(metaDataAvailable(IRQMetaData*)), this, SLOT(updateMetaData(IRQMetaData*))); connect(iPlayController, SIGNAL(playingStarted()), this, SLOT(handlePlayStarted())); connect(iPlayController, SIGNAL(playingStopped()), this, SLOT(handlePlayStopped())); connect(iNetworkController, SIGNAL(networkRequestNotified(IRQNetworkEvent)), this, SLOT(handleNetworkEvent(IRQNetworkEvent))); connect(iApplication->getMediaKeyObserver(), SIGNAL(playPausePressed()), this, SLOT(handlePlayPauseMediaKey())); connect(iApplication->getMediaKeyObserver(), SIGNAL(stopPressed()), this, SLOT(handleStopMediaKey())); connect( getViewManager(), SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( handleOrientationChanged(Qt::Orientation) ) ); setFlag(EViewFlag_StickyViewEnabled); }