Commit 50559afa authored by Abdel-Rahman Abdel-Rahman's avatar Abdel-Rahman Abdel-Rahman
Browse files

PlayerManager: Unify volume slots

slotVolumeChanged and setVolume should have the same effect but are
effectively different. One propagates the signal, and one sets the
actual volume. Both are used separately and thus the volume value
doesn't become synchronized throughout the application. This commit
unifies both functions into a single slot.

BUG: 405973
parent 5094bdf9
......@@ -258,11 +258,6 @@ void PlayerManager::stop()
m_media->stop();
}
void PlayerManager::setVolume(float volume)
{
m_output->setVolume(volume);
}
void PlayerManager::seek(int seekTime)
{
if(m_media->currentTime() == seekTime)
......@@ -432,13 +427,14 @@ void PlayerManager::slotMutedChanged(bool muted)
emit mutedChanged(muted);
}
void PlayerManager::slotVolumeChanged(qreal volume)
void PlayerManager::setVolume(qreal volume)
{
if(qFuzzyCompare(m_output->volume(), volume))
{
return;
}
m_output->setVolume(volume);
emit volumeChanged(volume);
}
......@@ -450,7 +446,7 @@ void PlayerManager::setupAudio()
{
using namespace Phonon;
connect(m_output, &AudioOutput::mutedChanged, this, &PlayerManager::slotMutedChanged);
connect(m_output, &AudioOutput::volumeChanged, this, &PlayerManager::slotVolumeChanged);
connect(m_output, &AudioOutput::volumeChanged, this, &PlayerManager::setVolume);
connect(m_media, &MediaObject::stateChanged, this, &PlayerManager::slotStateChanged);
connect(m_media, &MediaObject::currentSourceChanged, this, &PlayerManager::trackHasChanged);
......
......@@ -83,7 +83,6 @@ public slots:
void play(); // start or restart playback
void pause();
void stop();
void setVolume(float volume = 1.0);
void seek(int seekTime);
//void seekPosition(int position);
void seekForward();
......@@ -91,6 +90,7 @@ public slots:
void playPause();
void forward();
void back();
void setVolume(qreal);
void volumeUp();
void volumeDown();
void setMuted(bool m);
......@@ -124,7 +124,6 @@ private slots:
void slotStateChanged(Phonon::State, Phonon::State);
void slotSeekableChanged(bool);
void slotMutedChanged(bool);
void slotVolumeChanged(qreal);
private:
FileHandle m_file;
......
......@@ -69,7 +69,7 @@ VolumePopupButton::VolumePopupButton( QWidget * parent )
QWidgetAction *sliderActionWidget = new QWidgetAction( this );
sliderActionWidget->setDefaultWidget( mainWidget );
connect( m_volumeSlider, SIGNAL(volumeChanged(float)), player, SLOT(setVolume(float)) );
connect( m_volumeSlider, &VolumeSlider::volumeChanged, player, &PlayerManager::setVolume );
m_muteAction = new QAction( QIcon::fromTheme(QStringLiteral("audio-volume-muted")), QString(), this );
m_muteAction->setToolTip( i18n( "Mute/Unmute" ) );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment