Make the tablet's mic icon reflect the current mute state

This commit is contained in:
David Rowe 2017-02-11 09:53:02 +13:00
parent 8a995cc1d2
commit b5b92c1508
4 changed files with 26 additions and 2 deletions

View file

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

View file

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

View file

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

View file

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