Check global switch as well

This commit is contained in:
vladest 2018-05-06 12:51:59 +02:00
parent ac413c8854
commit 1794113f37
4 changed files with 10 additions and 6 deletions

View file

@ -3609,7 +3609,9 @@ void Application::keyPressEvent(QKeyEvent* event) {
AudioInjectorOptions options;
options.localOnly = true;
options.stereo = true;
if (SettingsScriptingInterface::getInstance()->getValue(MenuOption::NotificationSoundsSnapshot).toBool()) {
Setting::Handle<bool> notificationSounds{ MenuOption::NotificationSounds, true};
Setting::Handle<bool> notificationSoundSnapshot{ MenuOption::NotificationSoundsSnapshot, true};
if (notificationSounds.get() && notificationSoundSnapshot.get()) {
if (_snapshotSoundInjector) {
_snapshotSoundInjector->setOptions(options);
_snapshotSoundInjector->restart();

View file

@ -270,9 +270,9 @@ Menu::Menu() {
// Settings > Notifications > Play Notification Sounds
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
action = addCheckableActionToQMenuAndActionHash(notificationsMenu, "Play Notification Sounds", 0,
settings->getValue("play_notification_sounds").toBool());
settings->getValue(MenuOption::NotificationSounds).toBool());
connect(action, &QAction::triggered, [action, settings] {
settings->setValue("play_notification_sounds", action->isChecked());
settings->setValue(MenuOption::NotificationSounds, action->isChecked());
});
notificationsMenu->addSeparator();

View file

@ -217,6 +217,7 @@ namespace MenuOption {
const QString HMDTabletToToolbar = "HMD Tablet Becomes Toolbar";
const QString Shadows = "Shadows";
const QString AmbientOcclusion = "Ambient Occlusion";
const QString NotificationSounds = "play_notification_sounds";
const QString NotificationSoundsSnapshot = "play_notification_sounds_snapshot";
const QString NotificationSoundsTablet = "play_notification_sounds_tablet";
}

View file

@ -441,9 +441,10 @@ void TabletProxy::emitWebEvent(const QVariant& msg) {
void TabletProxy::onTabletShown() {
if (_tabletShown) {
Setting::Handle<bool> notificationSoundTablet{ "play_notification_sounds_tablet", true};
if (notificationSoundTablet.get()) {
static_cast<TabletScriptingInterface*>(parent())->playSound(TabletScriptingInterface::TabletOpen);
Setting::Handle<bool> notificationSounds{ QStringLiteral("play_notification_sounds"), true};
Setting::Handle<bool> notificationSoundTablet{ QStringLiteral("play_notification_sounds_tablet"), true};
if (notificationSounds.get() && notificationSoundTablet.get()) {
dynamic_cast<TabletScriptingInterface*>(parent())->playSound(TabletScriptingInterface::TabletOpen);
}
if (_showRunningScripts) {
_showRunningScripts = false;