Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(settings): Change test sound button to checkbox
Browse files Browse the repository at this point in the history
Fixes #3800 & #3809
  • Loading branch information
AliceGrey committed Oct 12, 2016
1 parent e7e6cc4 commit 22b89be
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 29 deletions.
16 changes: 16 additions & 0 deletions src/persistence/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
11 changes: 8 additions & 3 deletions src/persistence/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public slots:
void outDevChanged(const QString& name);
void audioOutDevEnabledChanged(bool enabled);
void outVolumeChanged(int volume);
void enableTestSoundChanged(bool enabled);

// Video
void videoDevChanged(const QString& name);
Expand Down Expand Up @@ -301,13 +302,13 @@ public slots:

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;

Expand Down Expand Up @@ -370,6 +371,9 @@ public slots:
int getOutVolume() const;
void setOutVolume(int volume);

bool getEnableTestSound() const;
void setEnableTestSound(bool newValue);

QString getVideoDev() const;
void setVideoDev(const QString& deviceSpecifier);

Expand Down Expand Up @@ -619,6 +623,7 @@ private slots:
QString outDev;
bool audioOutDevEnabled;
int outVolume;
bool enableTestSound;

// Video
QString videoDev;
Expand Down
12 changes: 7 additions & 5 deletions src/widget/form/settings/avform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}

Expand Down
3 changes: 1 addition & 2 deletions src/widget/form/settings/avform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -80,7 +80,6 @@ private slots:

private:
bool subscribedToAudioIn;
bool mPlayTestSound;
VideoSurface *camVideoSurface;
CameraSource &camera;
QVector<QPair<QString, QString>> videoDeviceList;
Expand Down
32 changes: 13 additions & 19 deletions src/widget/form/settings/avform.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>

0 comments on commit 22b89be

Please sign in to comment.