diff --git a/interface/resources/qml/hifi/Audio.qml b/interface/resources/qml/hifi/Audio.qml index adb0cd4cba..09075e6fb5 100644 --- a/interface/resources/qml/hifi/Audio.qml +++ b/interface/resources/qml/hifi/Audio.qml @@ -79,7 +79,7 @@ Rectangle { } Connections { - target: AvatarInputs + target: AvatarInputs !== undefined ? AvatarInputs : null onShowAudioToolsChanged: { audioTools.checkbox.checked = showAudioTools } @@ -100,10 +100,12 @@ Rectangle { id: audioTools width: parent.width anchors { left: parent.left; right: parent.right; leftMargin: 30 } - checkbox.checked: AvatarInputs.showAudioTools + checkbox.checked: AvatarInputs !== undefined ? AvatarInputs.showAudioTools : false text.text: qsTr("Show audio level meter") onCheckBoxClicked: { - AvatarInputs.showAudioTools = checked + if (AvatarInputs !== undefined) { + AvatarInputs.showAudioTools = checked + } } } diff --git a/interface/resources/qml/hifi/components/AudioCheckbox.qml b/interface/resources/qml/hifi/components/AudioCheckbox.qml index b23c9b42fe..b037fe4c7d 100644 --- a/interface/resources/qml/hifi/components/AudioCheckbox.qml +++ b/interface/resources/qml/hifi/components/AudioCheckbox.qml @@ -18,7 +18,6 @@ Row { colorScheme: hifi.colorSchemes.dark anchors.verticalCenter: parent.verticalCenter onClicked: checkBoxClicked(cb.checked) - onCheckedChanged: console.log("checked", checked, "device ",txt.text) } RalewayBold { id: txt diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 171c755101..4cf97ed6b1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2057,6 +2057,8 @@ void Application::initializeUi() { rootContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor()); + rootContext->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); + if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { rootContext->setContextProperty("Steam", new SteamScriptingInterface(engine, steamClient.get())); } diff --git a/scripts/system/selectAudioDevice.js b/scripts/system/selectAudioDevice.js index eb20dc0c92..9dcfb86ea5 100644 --- a/scripts/system/selectAudioDevice.js +++ b/scripts/system/selectAudioDevice.js @@ -137,7 +137,16 @@ function onMenuEvent(audioDeviceMenuString) { function onCurrentDeviceChanged() { debug("System audio device switched. "); - setupAudioMenus() + var interfaceInputDevice = "Use " + AudioDevice.getInputDevice() + " for Input"; + var interfaceOutputDevice = "Use " + AudioDevice.getOutputDevice() + " for Output"; + for (var index = 0; index < audioDevicesList.length; index++) { + if (audioDevicesList[index] === interfaceInputDevice || + audioDevicesList[index] === interfaceOutputDevice) { + Menu.setIsOptionChecked(audioDevicesList[index], true); + } else { + Menu.setIsOptionChecked(audioDevicesList[index], false); + } + } } function switchAudioDevice(audioDeviceMenuString) { @@ -279,6 +288,8 @@ Script.scriptEnding.connect(function () { removeAudioMenus(); Menu.menuItemEvent.disconnect(onMenuEvent); HMD.displayModeChanged.disconnect(checkHMDAudio); + AudioDevice.currentInputDeviceChanged.disconnect(onCurrentDeviceChanged); + AudioDevice.currentOutputDeviceChanged.disconnect(onCurrentDeviceChanged); AudioDevice.deviceChanged.disconnect(onDevicechanged); });