From 22b89beaf14f82f623464967f1980e5d78040649 Mon Sep 17 00:00:00 2001 From: Alice Weigt Date: Mon, 10 Oct 2016 17:51:54 -0700 Subject: [PATCH] fix(settings): Change test sound button to checkbox Fixes #3800 & #3809 --- src/persistence/settings.cpp | 16 +++++++++++++++ src/persistence/settings.h | 11 +++++++--- src/widget/form/settings/avform.cpp | 12 ++++++----- src/widget/form/settings/avform.h | 3 +-- src/widget/form/settings/avform.ui | 32 ++++++++++++----------------- 5 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/persistence/settings.cpp b/src/persistence/settings.cpp index 15312fbde..11490dbd7 100644 --- a/src/persistence/settings.cpp +++ b/src/persistence/settings.cpp @@ -839,6 +839,22 @@ void Settings::setDhtServerList(const QList& newDhtServerList) emit dhtServerListChanged(dhtServerList); } } +bool Settings::getEnableTestSound() const +{ + QMutexLocker locker{&bigLock}; + return enableTestSound; +} + +void Settings::setEnableTestSound(bool newValue) +{ + QMutexLocker locker{&bigLock}; + + if (newValue != enableTestSound) + { + enableTestSound = newValue; + emit enableTestSoundChanged(enableTestSound); + } +} bool Settings::getEnableIPv6() const { diff --git a/src/persistence/settings.h b/src/persistence/settings.h index 0f38b38e5..2357b3b73 100644 --- a/src/persistence/settings.h +++ b/src/persistence/settings.h @@ -244,6 +244,7 @@ signals: void outDevChanged(const QString& name); void audioOutDevEnabledChanged(bool enabled); void outVolumeChanged(int volume); + void enableTestSoundChanged(bool enabled); // Video void videoDevChanged(const QString& name); @@ -301,13 +302,13 @@ public: QString getToxmeBio() const; void setToxmeBio(const QString& bio); - + bool getToxmePriv() const; void setToxmePriv(bool priv); - + QString getToxmePass() const; void setToxmePass(const QString& pass); - + void setAutoSaveEnabled(bool newValue); bool getAutoSaveEnabled() const; @@ -370,6 +371,9 @@ public: int getOutVolume() const; void setOutVolume(int volume); + bool getEnableTestSound() const; + void setEnableTestSound(bool newValue); + QString getVideoDev() const; void setVideoDev(const QString& deviceSpecifier); @@ -619,6 +623,7 @@ private: QString outDev; bool audioOutDevEnabled; int outVolume; + bool enableTestSound; // Video QString videoDev; diff --git a/src/widget/form/settings/avform.cpp b/src/widget/form/settings/avform.cpp index 851401eb4..3037e8cbb 100644 --- a/src/widget/form/settings/avform.cpp +++ b/src/widget/form/settings/avform.cpp @@ -56,7 +56,9 @@ AVForm::AVForm() const Audio& audio = Audio::getInstance(); const Settings& s = Settings::getInstance(); - btnPlayTestSound->setToolTip( + cbEnableTestSound->setChecked(s.getEnableTestSound()); + + cbEnableTestSound->setToolTip( tr("Play a test sound while changing the output volume.")); connect(rescanButton, &QPushButton::clicked, this, &AVForm::rescanDevices); @@ -527,17 +529,17 @@ void AVForm::on_playbackSlider_valueChanged(int value) const qreal percentage = value / 100.0; audio.setOutputVolume(percentage); - if (mPlayTestSound) + if (cbEnableTestSound->isChecked()) audio.playMono16Sound(Audio::getSound(Audio::Sound::Test)); } } -void AVForm::on_btnPlayTestSound_clicked(bool checked) +void AVForm::on_cbEnableTestSound_stateChanged() { - mPlayTestSound = checked; + Settings::getInstance().setEnableTestSound(cbEnableTestSound->isChecked()); Audio& audio = Audio::getInstance(); - if (mPlayTestSound && audio.isOutputReady()) + if (cbEnableTestSound->isChecked() && audio.isOutputReady()) audio.playMono16Sound(Audio::getSound(Audio::Sound::Test)); } diff --git a/src/widget/form/settings/avform.h b/src/widget/form/settings/avform.h index 28e71ed43..2e9f56a3d 100644 --- a/src/widget/form/settings/avform.h +++ b/src/widget/form/settings/avform.h @@ -61,7 +61,7 @@ private slots: void on_inDevCombobox_currentIndexChanged(int deviceIndex); void on_outDevCombobox_currentIndexChanged(int deviceIndex); void on_playbackSlider_valueChanged(int value); - void on_btnPlayTestSound_clicked(bool checked); + void on_cbEnableTestSound_stateChanged(); void on_microphoneSlider_valueChanged(int value); // camera @@ -80,7 +80,6 @@ private: private: bool subscribedToAudioIn; - bool mPlayTestSound; VideoSurface *camVideoSurface; CameraSource &camera; QVector> videoDeviceList; diff --git a/src/widget/form/settings/avform.ui b/src/widget/form/settings/avform.ui index 4d221be23..9d3400071 100644 --- a/src/widget/form/settings/avform.ui +++ b/src/widget/form/settings/avform.ui @@ -30,8 +30,8 @@ 0 0 - 830 - 495 + 824 + 489 @@ -71,20 +71,6 @@ - - - - ... - - - - :/ui/volButton/volButton.png:/ui/volButton/volButton.png - - - true - - - @@ -112,6 +98,16 @@ + + + + Test Sound + + + true + + + @@ -207,8 +203,6 @@ which may lead to problems with video calls. 1 - - - +