1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(settings): Change test sound button to checkbox

Fixes #3800 & #3809
This commit is contained in:
Alice Weigt 2016-10-10 17:51:54 -07:00
parent e7e6cc4d9a
commit 22b89beaf1
5 changed files with 45 additions and 29 deletions

View File

@ -839,6 +839,22 @@ void Settings::setDhtServerList(const QList<DhtServer>& 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
{

View File

@ -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);
@ -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;

View File

@ -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));
}

View File

@ -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<QPair<QString, QString>> videoDeviceList;

View File

@ -30,8 +30,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>830</width>
<height>495</height>
<width>824</width>
<height>489</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
@ -71,20 +71,6 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="btnPlayTestSound">
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../../res.qrc">
<normaloff>:/ui/volButton/volButton.png</normaloff>:/ui/volButton/volButton.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="playbackSlider">
<property name="toolTip">
@ -112,6 +98,16 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="cbEnableTestSound">
<property name="text">
<string>Test Sound</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -207,8 +203,6 @@ which may lead to problems with video calls.</string>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../res.qrc"/>
</resources>
<resources/>
<connections/>
</ui>