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

Added option to disable notification sounds.

This commit is contained in:
Jookia 2015-03-22 11:57:28 +11:00
parent ff4b431e5e
commit e3bdd6d221
6 changed files with 46 additions and 9 deletions

View File

@ -209,6 +209,7 @@ void Settings::load()
checkUpdates = s.value("checkUpdates", false).toBool();
showWindow = s.value("showWindow", true).toBool();
showInFront = s.value("showInFront", false).toBool();
notifySound = s.value("notifySound", true).toBool();
groupAlwaysNotify = s.value("groupAlwaysNotify", false).toBool();
fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool();
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
@ -380,6 +381,7 @@ void Settings::saveGlobal(QString path)
s.setValue("checkUpdates", checkUpdates);
s.setValue("showWindow", showWindow);
s.setValue("showInFront", showInFront);
s.setValue("notifySound", notifySound);
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
s.setValue("compactLayout", compactLayout);
@ -693,6 +695,16 @@ void Settings::setShowInFront(bool newValue)
showInFront = newValue;
}
bool Settings::getNotifySound() const
{
return notifySound;
}
void Settings::setNotifySound(bool newValue)
{
notifySound = newValue;
}
bool Settings::getGroupAlwaysNotify() const
{
return groupAlwaysNotify;

View File

@ -128,6 +128,9 @@ public:
bool getShowInFront() const;
void setShowInFront(bool newValue);
bool getNotifySound() const;
void setNotifySound(bool newValue);
bool getGroupAlwaysNotify() const;
void setGroupAlwaysNotify(bool newValue);
@ -280,6 +283,7 @@ private:
bool checkUpdates;
bool showWindow;
bool showInFront;
bool notifySound;
bool groupAlwaysNotify;
bool forceTCP;

View File

@ -73,6 +73,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir());
bodyUI->showWindow->setChecked(Settings::getInstance().getShowWindow());
bodyUI->showInFront->setChecked(Settings::getInstance().getShowInFront());
bodyUI->notifySound->setChecked(Settings::getInstance().getNotifySound());
bodyUI->groupAlwaysNotify->setChecked(Settings::getInstance().getGroupAlwaysNotify());
bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging());
bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout());
@ -132,6 +133,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged()));
connect(bodyUI->showWindow, &QCheckBox::stateChanged, this, &GeneralForm::onShowWindowChanged);
connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront);
connect(bodyUI->notifySound, &QCheckBox::stateChanged, this, &GeneralForm::onSetNotifySound);
connect(bodyUI->groupAlwaysNotify, &QCheckBox::stateChanged, this, &GeneralForm::onSetGroupAlwaysNotify);
connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange);
if (bodyUI->autoacceptFiles->isChecked())
@ -371,6 +373,11 @@ void GeneralForm::onSetShowInFront()
Settings::getInstance().setShowInFront(bodyUI->showInFront->isChecked());
}
void GeneralForm::onSetNotifySound()
{
Settings::getInstance().setNotifySound(bodyUI->notifySound->isChecked());
}
void GeneralForm::onSetGroupAlwaysNotify()
{
Settings::getInstance().setGroupAlwaysNotify(bodyUI->groupAlwaysNotify->isChecked());

View File

@ -56,6 +56,7 @@ private slots:
void onCheckUpdateChanged();
void onShowWindowChanged();
void onSetShowInFront();
void onSetNotifySound();
void onSetGroupAlwaysNotify();
void onFauxOfflineMessaging();
void onCompactLayout();

View File

@ -345,6 +345,16 @@ instead of system taskbar.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="notifySound">
<property name="toolTip">
<string comment="toolTip for Notify sound setting">Play a sound when you recieve message.</string>
</property>
<property name="text">
<string>Play sound</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">

View File

@ -745,6 +745,8 @@ void Widget::newMessageAlert(GenericChatroomWidget* chat)
setWindowState(Qt::WindowActive);
}
if (Settings::getInstance().getNotifySound())
{
static QFile sndFile(":audio/notification.pcm");
static QByteArray sndData;
@ -756,6 +758,7 @@ void Widget::newMessageAlert(GenericChatroomWidget* chat)
}
Audio::playMono16Sound(sndData);
}
}
void Widget::playRingtone()