Get rid of QML errors in HMD mode. Sync Audio menu in Tablet/HMD without recreating menu items

This commit is contained in:
Vladyslav Stelmakhovskyi 2017-05-01 18:41:38 +02:00
parent 3fe8675b0c
commit 28447cde0b
4 changed files with 19 additions and 5 deletions

View file

@ -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
}
}
}

View file

@ -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

View file

@ -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()));
}

View file

@ -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);
});