From 1794113f37b7d2f2799e652acb4b64e16d369a79 Mon Sep 17 00:00:00 2001 From: vladest Date: Sun, 6 May 2018 12:51:59 +0200 Subject: [PATCH] Check global switch as well --- interface/src/Application.cpp | 4 +++- interface/src/Menu.cpp | 4 ++-- interface/src/Menu.h | 1 + libraries/ui/src/ui/TabletScriptingInterface.cpp | 7 ++++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e2010c199e..76e20434b0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -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 notificationSounds{ MenuOption::NotificationSounds, true}; + Setting::Handle notificationSoundSnapshot{ MenuOption::NotificationSoundsSnapshot, true}; + if (notificationSounds.get() && notificationSoundSnapshot.get()) { if (_snapshotSoundInjector) { _snapshotSoundInjector->setOptions(options); _snapshotSoundInjector->restart(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index ceef87f97b..e040f7a22c 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -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(); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 496368c30b..86e44775c5 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -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"; } diff --git a/libraries/ui/src/ui/TabletScriptingInterface.cpp b/libraries/ui/src/ui/TabletScriptingInterface.cpp index 89751b142e..9070d87a3c 100644 --- a/libraries/ui/src/ui/TabletScriptingInterface.cpp +++ b/libraries/ui/src/ui/TabletScriptingInterface.cpp @@ -441,9 +441,10 @@ void TabletProxy::emitWebEvent(const QVariant& msg) { void TabletProxy::onTabletShown() { if (_tabletShown) { - Setting::Handle notificationSoundTablet{ "play_notification_sounds_tablet", true}; - if (notificationSoundTablet.get()) { - static_cast(parent())->playSound(TabletScriptingInterface::TabletOpen); + Setting::Handle notificationSounds{ QStringLiteral("play_notification_sounds"), true}; + Setting::Handle notificationSoundTablet{ QStringLiteral("play_notification_sounds_tablet"), true}; + if (notificationSounds.get() && notificationSoundTablet.get()) { + dynamic_cast(parent())->playSound(TabletScriptingInterface::TabletOpen); } if (_showRunningScripts) { _showRunningScripts = false;