Apply suggestions from code review

Co-authored-by: David Rowe <david@ctrlaltstudio.com>
This commit is contained in:
Kalila 2021-02-23 20:29:46 -05:00 committed by GitHub
parent 88b9ebb11a
commit 0a6e220c74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 20 deletions

View file

@ -106,7 +106,7 @@ Rectangle {
} }
} }
function updateNoiseReductionThresholdFromQML(sliderValue) { function updateNoiseReductionThresholdFromQML(sliderValue) {
if (AudioScriptingInterface.getNoiseReductionThreshold() != sliderValue) { if (AudioScriptingInterface.getNoiseReductionThreshold() !== sliderValue) {
AudioScriptingInterface.setNoiseReductionThreshold(sliderValue); AudioScriptingInterface.setNoiseReductionThreshold(sliderValue);
} }
} }
@ -496,7 +496,7 @@ Rectangle {
Item { Item {
id: noiseReductionHeader id: noiseReductionHeader
x: margins.paddings; x: margins.paddings;
width: parent.width - margins.paddings*2; width: parent.width - margins.paddings * 2;
height: 36; height: 36;
anchors.top: secondSeparator.bottom; anchors.top: secondSeparator.bottom;
anchors.topMargin: 10; anchors.topMargin: 10;
@ -506,7 +506,7 @@ Rectangle {
text: hifi.glyphs.mic; text: hifi.glyphs.mic;
color: hifi.colors.white; color: hifi.colors.white;
anchors.left: parent.left; anchors.left: parent.left;
anchors.leftMargin: -size/4; //the glyph has empty space at left about 25% anchors.leftMargin: -size / 4; // The glyph has empty space at left about 25%
anchors.verticalCenter: parent.verticalCenter; anchors.verticalCenter: parent.verticalCenter;
size: 30; size: 30;
} }
@ -552,7 +552,7 @@ Rectangle {
checked: AudioScriptingInterface.acousticEchoCancellation; checked: AudioScriptingInterface.acousticEchoCancellation;
onCheckedChanged: { onCheckedChanged: {
AudioScriptingInterface.acousticEchoCancellation = checked; AudioScriptingInterface.acousticEchoCancellation = checked;
checked = Qt.binding(function() { return AudioScriptingInterface.acousticEchoCancellation; }); checked = Qt.binding(function () { return AudioScriptingInterface.acousticEchoCancellation; });
} }
} }
@ -569,7 +569,7 @@ Rectangle {
checked: AudioScriptingInterface.noiseReduction; checked: AudioScriptingInterface.noiseReduction;
onCheckedChanged: { onCheckedChanged: {
AudioScriptingInterface.noiseReduction = checked; AudioScriptingInterface.noiseReduction = checked;
checked = Qt.binding(function() { return AudioScriptingInterface.noiseReduction; }); // restore binding checked = Qt.binding(function () { return AudioScriptingInterface.noiseReduction; }); // restore binding
} }
} }
@ -584,10 +584,10 @@ Rectangle {
labelTextSize: 16; labelTextSize: 16;
backgroundOnColor: "#E3E3E3"; backgroundOnColor: "#E3E3E3";
checked: !AudioScriptingInterface.noiseReductionAutomatic; checked: !AudioScriptingInterface.noiseReductionAutomatic;
visible: AudioScriptingInterface.noiseReduction === true; visible: AudioScriptingInterface.noiseReduction;
onCheckedChanged: { onCheckedChanged: {
AudioScriptingInterface.noiseReductionAutomatic = !checked; AudioScriptingInterface.noiseReductionAutomatic = !checked;
checked = Qt.binding(function() { return !AudioScriptingInterface.noiseReductionAutomatic; }); // restore binding checked = Qt.binding(function () { return !AudioScriptingInterface.noiseReductionAutomatic; }); // restore binding
} }
} }
} }
@ -598,9 +598,9 @@ Rectangle {
x: margins.paddings; x: margins.paddings;
anchors.top: noiseReductionSwitches.bottom; anchors.top: noiseReductionSwitches.bottom;
anchors.topMargin: 16; anchors.topMargin: 16;
width: parent.width - margins.paddings*2; width: parent.width - margins.paddings * 2;
height: avatarGainSliderTextMetrics.height + 10; height: avatarGainSliderTextMetrics.height + 10;
visible: AudioScriptingInterface.noiseReduction === true && AudioScriptingInterface.noiseReductionAutomatic !== true; visible: AudioScriptingInterface.noiseReduction && !AudioScriptingInterface.noiseReductionAutomatic;
HifiControlsUit.Slider { HifiControlsUit.Slider {
id: noiseReductionThresholdSlider id: noiseReductionThresholdSlider
@ -626,16 +626,16 @@ Rectangle {
// Do nothing. // Do nothing.
} }
onDoubleClicked: { onDoubleClicked: {
noiseReductionThresholdSlider.value = 0.0 noiseReductionThresholdSlider.value = 0.0;
} }
onPressed: { onPressed: {
// Pass through to Slider // Pass through to Slider
mouse.accepted = false mouse.accepted = false;
} }
onReleased: { onReleased: {
// the above mouse.accepted seems to make this // the above mouse.accepted seems to make this
// never get called, nonetheless... // never get called, nonetheless...
mouse.accepted = false mouse.accepted = false;
} }
} }
} }
@ -693,9 +693,9 @@ Rectangle {
visible: !status.visible; visible: !status.visible;
Component.onCompleted: { Component.onCompleted: {
AudioScriptingInterface.noiseGateOpened.connect(function() { noiseBar.gated = false; }); AudioScriptingInterface.noiseGateOpened.connect(function () { noiseBar.gated = false; });
AudioScriptingInterface.noiseGateClosed.connect(function() { noiseBar.gated = true; }); AudioScriptingInterface.noiseGateClosed.connect(function () { noiseBar.gated = true; });
AudioScriptingInterface.inputLevelChanged.connect(function() { noiseBar.level = AudioScriptingInterface.inputLevel; }); AudioScriptingInterface.inputLevelChanged.connect(function () { noiseBar.level = AudioScriptingInterface.inputLevel; });
} }
Rectangle { // base Rectangle { // base
@ -908,4 +908,4 @@ Rectangle {
} }
} }
} }
} }

View file

@ -275,7 +275,7 @@ public:
Q_INVOKABLE float getSystemInjectorGain(); Q_INVOKABLE float getSystemInjectorGain();
/**jsdoc /**jsdoc
* Sets the noise gate threshold before your mic audio is transmitted. (Applies only if Audio.noiseReductionAutomatic is off.) * Sets the noise gate threshold before your mic audio is transmitted. (Applies only if <code>Audio.noiseReductionAutomatic</code> is <code>false</code>.)
* @function Audio.setNoiseReductionThreshold * @function Audio.setNoiseReductionThreshold
* @param {number} threshold - The level that your input must surpass to be transmitted. <code>0.0</code> (open the gate completely) &ndash; <code>1.0</code> * @param {number} threshold - The level that your input must surpass to be transmitted. <code>0.0</code> (open the gate completely) &ndash; <code>1.0</code>
*/ */
@ -419,14 +419,13 @@ signals:
/**jsdoc /**jsdoc
* Triggered when the audio input noise reduction mode is changed. * Triggered when the audio input noise reduction mode is changed.
* @function Audio.noiseReductionAutomaticChanged * @function Audio.noiseReductionAutomaticChanged
* @param {boolean} isEnabled - <code>true</code> if audio input noise reduction automatic mode is enabled, otherwise <code>false</code>. * @param {boolean} isEnabled - <code>true</code> if audio input noise reduction automatic mode is enabled, <code>false</code> if in manual mode.
* This means the mode is set to 'manual'.
* @returns {Signal} * @returns {Signal}
*/ */
void noiseReductionAutomaticChanged(bool isEnabled); void noiseReductionAutomaticChanged(bool isEnabled);
/**jsdoc /**jsdoc
* Triggered when audio input noise reduction threshold is changed. * Triggered when the audio input noise reduction threshold is changed.
* @function Audio.noiseReductionThresholdChanged * @function Audio.noiseReductionThresholdChanged
* @param {number} threshold - The threshold for the audio input noise reduction, range <code>0.0</code> (open the gate completely) &ndash; <code>1.0</code> * @param {number} threshold - The threshold for the audio input noise reduction, range <code>0.0</code> (open the gate completely) &ndash; <code>1.0</code>
* (close the gate completely). * (close the gate completely).