From b7d44403e16e76e8d7b1c672c457946e1933a378 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 6 Mar 2019 17:29:32 -0800 Subject: [PATCH] updating compile failure + icons/settings update --- .../icons/tablet-icons/mic-ptt-a.svg | 1 + .../icons/tablet-icons/mic-ptt-i.svg | 24 +++++++ interface/resources/qml/hifi/audio/Audio.qml | 64 ++++++++++++++++--- interface/resources/qml/hifi/audio/MicBar.qml | 8 ++- interface/src/scripting/Audio.cpp | 20 ------ scripts/system/audio.js | 14 ++-- 6 files changed, 93 insertions(+), 38 deletions(-) create mode 100644 interface/resources/icons/tablet-icons/mic-ptt-a.svg create mode 100644 interface/resources/icons/tablet-icons/mic-ptt-i.svg diff --git a/interface/resources/icons/tablet-icons/mic-ptt-a.svg b/interface/resources/icons/tablet-icons/mic-ptt-a.svg new file mode 100644 index 0000000000..e6df3c69d7 --- /dev/null +++ b/interface/resources/icons/tablet-icons/mic-ptt-a.svg @@ -0,0 +1 @@ +mic-ptt-a \ No newline at end of file diff --git a/interface/resources/icons/tablet-icons/mic-ptt-i.svg b/interface/resources/icons/tablet-icons/mic-ptt-i.svg new file mode 100644 index 0000000000..2141ea5229 --- /dev/null +++ b/interface/resources/icons/tablet-icons/mic-ptt-i.svg @@ -0,0 +1,24 @@ + + + + + + diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index 45358f59a2..d44a9c862e 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -120,6 +120,10 @@ Rectangle { isRedCheck: true; checked: AudioScriptingInterface.muted; onClicked: { + if (AudioScriptingInterface.pushToTalk && !checked) { + // disable push to talk if unmuting + AudioScriptingInterface.pushToTalk = false; + } AudioScriptingInterface.muted = checked; checked = Qt.binding(function() { return AudioScriptingInterface.muted; }); // restore binding } @@ -150,7 +154,23 @@ Rectangle { } AudioControls.CheckBox { spacing: muteMic.spacing - text: qsTr("Push To Talk"); + text: qsTr("Show audio level meter"); + checked: AvatarInputs.showAudioTools; + onClicked: { + AvatarInputs.showAudioTools = checked; + checked = Qt.binding(function() { return AvatarInputs.showAudioTools; }); // restore binding + } + onXChanged: rightMostInputLevelPos = x + width + } + } + + Separator {} + + ColumnLayout { + spacing: muteMic.spacing; + AudioControls.CheckBox { + spacing: muteMic.spacing + text: qsTr("Push To Talk (T)"); checked: isVR ? AudioScriptingInterface.pushToTalkHMD : AudioScriptingInterface.pushToTalkDesktop; onClicked: { if (isVR) { @@ -167,15 +187,41 @@ Rectangle { }); // restore binding } } - AudioControls.CheckBox { - spacing: muteMic.spacing - text: qsTr("Show audio level meter"); - checked: AvatarInputs.showAudioTools; - onClicked: { - AvatarInputs.showAudioTools = checked; - checked = Qt.binding(function() { return AvatarInputs.showAudioTools; }); // restore binding + Item { + id: pttTextContainer + x: margins.paddings; + width: rightMostInputLevelPos + height: pttTextMetrics.height + visible: true + TextMetrics { + id: pttTextMetrics + text: pttText.text + font: pttText.font + } + RalewayRegular { + id: pttText + wrapMode: Text.WordWrap + color: hifi.colors.white; + width: parent.width; + font.italic: true + size: 16; + text: isVR ? qsTr("Press and hold grip triggers on both of your controllers to unmute.") : + qsTr("Press and hold the button \"T\" to unmute."); + onTextChanged: { + if (pttTextMetrics.width > rightMostInputLevelPos) { + pttTextContainer.height = Math.ceil(pttTextMetrics.width / rightMostInputLevelPos) * pttTextMetrics.height; + } else { + pttTextContainer.height = pttTextMetrics.height; + } + } + } + Component.onCompleted: { + if (pttTextMetrics.width > rightMostInputLevelPos) { + pttTextContainer.height = Math.ceil(pttTextMetrics.width / rightMostInputLevelPos) * pttTextMetrics.height; + } else { + pttTextContainer.height = pttTextMetrics.height; + } } - onXChanged: rightMostInputLevelPos = x + width } } } diff --git a/interface/resources/qml/hifi/audio/MicBar.qml b/interface/resources/qml/hifi/audio/MicBar.qml index 9d1cbfbc6c..50477b82f8 100644 --- a/interface/resources/qml/hifi/audio/MicBar.qml +++ b/interface/resources/qml/hifi/audio/MicBar.qml @@ -67,6 +67,9 @@ Rectangle { hoverEnabled: true; scrollGestureEnabled: false; onClicked: { + if (AudioScriptingInterface.pushToTalk) { + return; + } AudioScriptingInterface.muted = !AudioScriptingInterface.muted; Tablet.playSound(TabletEnums.ButtonClick); } @@ -109,9 +112,10 @@ Rectangle { Image { readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg"; readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg"; + readonly property string pushToTalkIcon: "../../../icons/tablet-icons/mic-ptt-i.svg"; id: image; - source: AudioScriptingInterface.muted ? mutedIcon : unmutedIcon; + source: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? pushToTalkIcon : AudioScriptingInterface.muted ? mutedIcon : unmutedIcon; width: 30; height: 30; @@ -155,7 +159,7 @@ Rectangle { color: parent.color; - text: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? "MUTED-PTT (T)" : (AudioScriptingInterface.muted ? "MUTED" : "MUTE"); + text: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? "MUTED PTT-(T)" : (AudioScriptingInterface.muted ? "MUTED" : "MUTE"); font.pointSize: 12; } diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index 45bb15f1a3..63ce9d2b2e 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -231,26 +231,6 @@ void Audio::loadData() { _pttHMD = _pttHMDSetting.get(); } -bool Audio::getPTTHMD() const { - return resultWithReadLock([&] { - return _pttHMD; - }); -} - -void Audio::saveData() { - _desktopMutedSetting.set(getMutedDesktop()); - _hmdMutedSetting.set(getMutedHMD()); - _pttDesktopSetting.set(getPTTDesktop()); - _pttHMDSetting.set(getPTTHMD()); -} - -void Audio::loadData() { - _desktopMuted = _desktopMutedSetting.get(); - _hmdMuted = _hmdMutedSetting.get(); - _pttDesktop = _pttDesktopSetting.get(); - _pttHMD = _pttHMDSetting.get(); -} - bool Audio::noiseReductionEnabled() const { return resultWithReadLock([&] { return _enableNoiseReduction; diff --git a/scripts/system/audio.js b/scripts/system/audio.js index bf44cfa7cc..19ed3faef2 100644 --- a/scripts/system/audio.js +++ b/scripts/system/audio.js @@ -27,12 +27,12 @@ var UNMUTE_ICONS = { activeIcon: "icons/tablet-icons/mic-unmute-a.svg" }; var PTT_ICONS = { - icon: "icons/tablet-icons/mic-unmute-i.svg", - activeIcon: "icons/tablet-icons/mic-unmute-a.svg" + icon: "icons/tablet-icons/mic-ptt-i.svg", + activeIcon: "icons/tablet-icons/mic-ptt-a.svg" }; function onMuteToggled() { - if (Audio.pushingToTalk) { + if (Audio.pushToTalk) { button.editProperties(PTT_ICONS); } else if (Audio.muted) { button.editProperties(MUTE_ICONS); @@ -63,8 +63,8 @@ function onScreenChanged(type, url) { var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ - icon: Audio.muted ? MUTE_ICONS.icon : UNMUTE_ICONS.icon, - activeIcon: Audio.muted ? MUTE_ICONS.activeIcon : UNMUTE_ICONS.activeIcon, + icon: Audio.pushToTalk ? PTT_ICONS.icon : Audio.muted ? MUTE_ICONS.icon : UNMUTE_ICONS.icon, + activeIcon: Audio.pushToTalk ? PTT_ICONS.activeIcon : Audio.muted ? MUTE_ICONS.activeIcon : UNMUTE_ICONS.activeIcon, text: TABLET_BUTTON_NAME, sortOrder: 1 }); @@ -74,7 +74,7 @@ onMuteToggled(); button.clicked.connect(onClicked); tablet.screenChanged.connect(onScreenChanged); Audio.mutedChanged.connect(onMuteToggled); -Audio.pushingToTalkChanged.connect(onMuteToggled); +Audio.pushToTalkChanged.connect(onMuteToggled); Script.scriptEnding.connect(function () { if (onAudioScreen) { @@ -83,7 +83,7 @@ Script.scriptEnding.connect(function () { button.clicked.disconnect(onClicked); tablet.screenChanged.disconnect(onScreenChanged); Audio.mutedChanged.disconnect(onMuteToggled); - Audio.pushingToTalkChanged.disconnect(onMuteToggled); + Audio.pushToTalkChanged.disconnect(onMuteToggled); tablet.removeButton(button); });