diff --git a/interface/resources/qml/hifi/tablet/Tablet.qml b/interface/resources/qml/hifi/tablet/Tablet.qml index 0d563ed5bb..d1e11d5242 100644 --- a/interface/resources/qml/hifi/tablet/Tablet.qml +++ b/interface/resources/qml/hifi/tablet/Tablet.qml @@ -6,10 +6,16 @@ Item { id: tablet objectName: "tablet" property double micLevel: 0.8 + property bool micEnabled: true property int rowIndex: 0 property int columnIndex: 0 property int count: (flowMain.children.length - 1) + // called by C++ code to keep mic state updated + function setMicEnabled(newMicEnabled) { + tablet.micEnabled = newMicEnabled; + } + // called by C++ code to keep audio bar updated function setMicLevel(newMicLevel) { tablet.micLevel = newMicLevel; @@ -102,7 +108,7 @@ Item { id: muteIcon width: 40 height: 40 - source: "../../../icons/tablet-mute-icon.svg" + source: tablet.micEnabled ? "../../../icons/tablet-icons/mic-i.svg" : "../../../icons/tablet-icons/mic-a.svg" anchors.verticalCenter: parent.verticalCenter } @@ -175,7 +181,6 @@ Item { GradientStop { position: 0 color: "#2b2b2b" - } GradientStop { diff --git a/libraries/script-engine/src/TabletScriptingInterface.cpp b/libraries/script-engine/src/TabletScriptingInterface.cpp index 71f0073ead..215c3a98e6 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.cpp +++ b/libraries/script-engine/src/TabletScriptingInterface.cpp @@ -309,6 +309,15 @@ void TabletProxy::removeButton(QObject* tabletButtonProxy) { } } +void TabletProxy::updateMicEnabled(const bool micOn) { + auto tablet = getQmlTablet(); + if (!tablet) { + //qCCritical(scriptengine) << "Could not find tablet in TabletRoot.qml"; + } else { + QMetaObject::invokeMethod(tablet, "setMicEnabled", Qt::AutoConnection, Q_ARG(QVariant, QVariant(micOn))); + } +} + void TabletProxy::updateAudioBar(const double micLevel) { auto tablet = getQmlTablet(); if (!tablet) { diff --git a/libraries/script-engine/src/TabletScriptingInterface.h b/libraries/script-engine/src/TabletScriptingInterface.h index 93f5bcf6ba..d5eccb2479 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.h +++ b/libraries/script-engine/src/TabletScriptingInterface.h @@ -106,6 +106,13 @@ public: */ Q_INVOKABLE void removeButton(QObject* tabletButtonProxy); + /**jsdoc + * Updates the tablet's mic enabled state + * @function TabletProxy#updateMicEnabled + * @param micEnabled {bool} mic enabled state + */ + Q_INVOKABLE void updateMicEnabled(const bool micEnabled); + /**jsdoc * Updates the audio bar in tablet to reflect latest mic level * @function TabletProxy#updateAudioBar diff --git a/scripts/system/tablet-ui/tabletUI.js b/scripts/system/tablet-ui/tabletUI.js index dc1d71f402..1dc6b7fef8 100644 --- a/scripts/system/tablet-ui/tabletUI.js +++ b/scripts/system/tablet-ui/tabletUI.js @@ -53,8 +53,11 @@ function updateShowTablet() { if (tabletShown) { + var MUTE_MICROPHONE_MENU_ITEM = "Mute Microphone"; + var currentMicEnabled = !Menu.isOptionChecked(MUTE_MICROPHONE_MENU_ITEM); var currentMicLevel = getMicLevel(); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + tablet.updateMicEnabled(currentMicEnabled); tablet.updateAudioBar(currentMicLevel); }