Change the "Mute" tablet button to "Audio"

This commit is contained in:
David Rowe 2017-02-11 22:40:19 +13:00
parent 98c1a18326
commit 77f0fb1491
6 changed files with 52 additions and 16 deletions

View file

@ -14,6 +14,7 @@ FocusScope {
property var rootMenu: Menu { objectName:"rootMenu" }
property var point: Qt.point(50, 50)
property string subMenu: ""
TabletMouseHandler { id: menuPopperUpper }
@ -101,6 +102,24 @@ FocusScope {
buildMenu()
}
function buildMenu() {
menuPopperUpper.popup(tabletMenu, rootMenu.items)
// Build submenu if specified.
if (subMenu !== "") {
var index = 0;
var found = false;
while (!found && index < rootMenu.items.length) {
found = rootMenu.items[index].title === subMenu;
if (!found) {
index += 1;
}
}
subMenu = ""; // Continue with full menu after initially displaying submenu.
if (found) {
menuPopperUpper.popup(tabletMenu, rootMenu.items[index].items);
return;
}
}
// Otherwise build whole menu.
menuPopperUpper.popup(tabletMenu, rootMenu.items);
}
}

View file

@ -6,9 +6,14 @@ Item {
objectName: "tabletRoot"
property string username: "Unknown user"
property var eventBridge;
property string option: ""
signal showDesktop();
function setOption(value) {
option = value;
}
function loadSource(url) {
loader.source = url;
}
@ -72,6 +77,9 @@ Item {
if (loader.item.hasOwnProperty("sendToScript")) {
loader.item.sendToScript.connect(tabletRoot.sendToScript);
}
if (loader.item.hasOwnProperty("subMenu")) {
loader.item.subMenu = option;
}
loader.item.forceActiveFocus();
}
}

View file

@ -213,10 +213,11 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr
}
}
void TabletProxy::gotoMenuScreen() {
void TabletProxy::gotoMenuScreen(const QString& submenu) {
if (_qmlTabletRoot) {
if (_state != State::Menu) {
removeButtonsFromHomeScreen();
QMetaObject::invokeMethod(_qmlTabletRoot, "setOption", Q_ARG(const QVariant&, QVariant(submenu)));
auto loader = _qmlTabletRoot->findChild<QQuickItem*>("loader");
QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToMenuScreen()), Qt::DirectConnection);
QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL)));

View file

@ -72,7 +72,7 @@ public:
void setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface);
Q_INVOKABLE void gotoMenuScreen();
Q_INVOKABLE void gotoMenuScreen(const QString& submenu = "");
/**jsdoc
* transition to the home screen

View file

@ -14,7 +14,7 @@
var DEFAULT_SCRIPTS = [
"system/progress.js",
"system/away.js",
"system/mute.js",
"system/audio.js",
"system/hmd.js",
"system/menu.js",
"system/bubble.js",

View file

@ -1,8 +1,7 @@
"use strict";
//
// goto.js
// scripts/system/
// audio.js
//
// Created by Howard Stearns on 2 Jun 2016
// Copyright 2016 High Fidelity, Inc.
@ -14,22 +13,33 @@
(function() { // BEGIN LOCAL_SCOPE
var button;
var buttonName = "MUTE";
var TOOLBAR_BUTTON_NAME = "MUTE";
var TABLET_BUTTON_NAME = "AUDIO";
var toolBar = null;
var tablet = null;
var isHUDUIEnabled = Settings.getValue("HUDUIEnabled");
var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
function onMuteToggled() {
button.editProperties({isActive: AudioDevice.getMuted()});
if (isHUDUIEnabled) {
button.editProperties({ isActive: AudioDevice.getMuted() });
}
}
function onClicked(){
var menuItem = "Mute Microphone";
Menu.setIsOptionChecked(menuItem, !Menu.isOptionChecked(menuItem));
if (isHUDUIEnabled) {
var menuItem = "Mute Microphone";
Menu.setIsOptionChecked(menuItem, !Menu.isOptionChecked(menuItem));
} else {
var entity = HMD.tabletID;
Entities.editEntity(entity, { textures: JSON.stringify({ "tex.close": HOME_BUTTON_TEXTURE }) });
tablet.gotoMenuScreen("Audio");
}
}
if (Settings.getValue("HUDUIEnabled")) {
toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
button = toolBar.addButton({
objectName: buttonName,
objectName: TOOLBAR_BUTTON_NAME,
imageURL: Script.resolvePath("assets/images/tools/mic.svg"),
visible: true,
alpha: 0.9
@ -37,10 +47,8 @@ if (Settings.getValue("HUDUIEnabled")) {
} else {
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
button = tablet.addButton({
icon: "icons/tablet-icons/mic-a.svg",
text: buttonName,
activeIcon: "icons/tablet-icons/mic-i.svg",
activeText: "UNMUTE",
icon: "icons/tablet-icons/mic-i.svg",
text: TABLET_BUTTON_NAME,
sortOrder: 1
});
}
@ -56,7 +64,7 @@ Script.scriptEnding.connect(function () {
tablet.removeButton(button);
}
if (toolBar) {
toolBar.removeButton(buttonName);
toolBar.removeButton(TOOLBAR_BUTTON_NAME);
}
});