Ref T644, audio volume for notification sounds can be set

This commit is contained in:
Klaus Basan
2019-05-01 17:10:17 +02:00
parent e42a205f5e
commit 77fcde6465
9 changed files with 50 additions and 15 deletions

View File

@@ -104,6 +104,8 @@ namespace BlackGui
Q_ASSERT(c);
c = connect(ui->pb_SoundDir, &QPushButton::released, this, &CAudioSetupComponent::selectNotificationSoundsDir, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(ui->sb_NotificationValueVolume, qOverload<int>(&QSpinBox::valueChanged), this, &CAudioSetupComponent::onVolumeChanged);
Q_ASSERT(c);
}
Q_UNUSED(c);
}
@@ -135,6 +137,7 @@ namespace BlackGui
ui->cb_SetupAudioNoTransmission->setChecked(as.isNotificationFlagSet(CNotificationSounds::NotificationNoAudioTransmission));
ui->le_SoundDir->setText(as.getNotificationSoundDirectory());
ui->sb_NotificationValueVolume->setValue(as.getNotificationVolume());
}
void CAudioSetupComponent::initAudioDeviceLists()
@@ -149,6 +152,15 @@ namespace BlackGui
return sGui && sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject();
}
void CAudioSetupComponent::onVolumeChanged(int volume)
{
volume = qMax(25, qMin(100, volume));
CSettings as(m_audioSettings.getThreadLocal());
if (as.getNotificationVolume() == volume) { return; }
as.setNotificationVolume(volume);
m_audioSettings.set(as);
}
CNotificationSounds::NotificationFlag CAudioSetupComponent::checkBoxToFlag(const QCheckBox *cb) const
{
if (!cb) { return CNotificationSounds::NoNotifications; }
@@ -252,7 +264,7 @@ namespace BlackGui
if (checked && this->hasAudio() && sender)
{
const CNotificationSounds::NotificationFlag f = this->checkBoxToFlag(sender);
sGui->getIContextAudio()->playNotification(f, false);
sGui->getIContextAudio()->playNotification(f, false, as.getNotificationVolume());
}
}