"use strict";/* jslint vars: true, plusplus: true */ //// simplifiedUI.js//// Authors: Wayne Chen & Zach Fox// Created: 2019-05-01// Copyright 2019 High Fidelity, Inc.// Copyright 2024 Overte e.V.//// Distributed under the Apache License, Version 2.0.// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html// // START CONFIG OPTIONSvar TOOLBAR_NAME = "com.highfidelity.interface.toolbar.system";var DEFAULT_SCRIPTS_PATH_PREFIX = ScriptDiscoveryService.defaultScriptsPath + "/";// END CONFIG OPTIONS var MENU_NAMES = ["File", "Edit", "Display", "View", "Navigate", "Settings", "Developer", "Help"];var keepMenusSetting = Settings.getValue("simplifiedUI/keepMenus", true);function maybeRemoveDesktopMenu() { if (!keepMenusSetting) { MENU_NAMES.forEach(function(menu) { Menu.removeMenu(menu); }); }} function handleUpdateAvatarThumbnailURL(avatarThumbnailURL) { if (topBarWindow) { topBarWindow.sendToQml({ "source": "simplifiedUI.js", "method": "updateAvatarThumbnailURL", "data": { "avatarThumbnailURL": avatarThumbnailURL } }); }} var AVATAR_APP_MESSAGE_SOURCE = "AvatarApp.qml";function onMessageFromAvatarApp(message) { if (message.source !== AVATAR_APP_MESSAGE_SOURCE) { return; } switch (message.method) { case "updateAvatarThumbnailURL": handleUpdateAvatarThumbnailURL(message.data.avatarThumbnailURL); break; default: console.log("Unrecognized message from " + AVATAR_APP_MESSAGE_SOURCE + ": " + JSON.stringify(message)); break; }} function onAvatarAppClosed() { if (avatarAppWindow) { avatarAppWindow.fromQml.disconnect(onMessageFromAvatarApp); avatarAppWindow.closed.disconnect(onAvatarAppClosed); } avatarAppWindow = false;} var AVATAR_APP_QML_PATH = Script.resourcesPath() + "qml/hifi/simplifiedUI/avatarApp/AvatarApp.qml";var AVATAR_APP_WINDOW_TITLE = "Your Profile";var AVATAR_APP_PRESENTATION_MODE = Desktop.PresentationMode.NATIVE;var AVATAR_APP_WIDTH_PX = 480;var AVATAR_APP_HEIGHT_PX = 615;var avatarAppWindow = false;var POPOUT_SAFE_MARGIN_X = 30;var POPOUT_SAFE_MARGIN_Y = 30;var AVATAR_APP_WINDOW_FLAGS = 0x00000001 | // Qt::Window 0x00001000 | // Qt::WindowTitleHint 0x00002000 | // Qt::WindowSystemMenuHint 0x08000000 | // Qt::WindowCloseButtonHint 0x00008000 | // Qt::WindowMaximizeButtonHint 0x00004000; // Qt::WindowMinimizeButtonHintfunction toggleAvatarApp() { if (avatarAppWindow) { avatarAppWindow.close(); // This really shouldn't be necessary. // This signal really should automatically be called by the signal handler set up below. // But fixing that requires an engine change, so this workaround will do. onAvatarAppClosed(); return; } avatarAppWindow = Desktop.createWindow(AVATAR_APP_QML_PATH, { title: AVATAR_APP_WINDOW_TITLE, presentationMode: AVATAR_APP_PRESENTATION_MODE, size: { x: AVATAR_APP_WIDTH_PX, y: AVATAR_APP_HEIGHT_PX }, position: { x: Math.max(Window.x + POPOUT_SAFE_MARGIN_X, Window.x + Window.innerWidth / 2 - AVATAR_APP_WIDTH_PX / 2), y: Math.max(Window.y + POPOUT_SAFE_MARGIN_Y, Window.y + Window.innerHeight / 2 - AVATAR_APP_HEIGHT_PX / 2) }, overrideFlags: AVATAR_APP_WINDOW_FLAGS }); avatarAppWindow.fromQml.connect(onMessageFromAvatarApp); avatarAppWindow.closed.connect(onAvatarAppClosed);} function handleAvatarNametagMode(newAvatarNametagMode) { nametag.handleAvatarNametagMode(newAvatarNametagMode);} var SETTINGS_APP_MESSAGE_SOURCE = "SettingsApp.qml";function onMessageFromSettingsApp(message) { if (message.source !== SETTINGS_APP_MESSAGE_SOURCE) { return; } switch (message.method) { /* This calls an update methon on the module apis because I can't get a signal from Settings.QML to the emoji.js without it being a module like nametag. */ case "handleAvatarNametagMode": handleAvatarNametagMode(message.avatarNametagMode); break; default: console.log("Unrecognized message from " + SETTINGS_APP_MESSAGE_SOURCE + ": " + JSON.stringify(message)); break; }} function onSettingsAppClosed() { if (settingsAppWindow) { settingsAppWindow.fromQml.disconnect(onMessageFromSettingsApp); settingsAppWindow.closed.disconnect(onSettingsAppClosed); } settingsAppWindow = false;} var SETTINGS_APP_QML_PATH = Script.resourcesPath() + "qml/hifi/simplifiedUI/settingsApp/SettingsApp.qml";var SETTINGS_APP_WINDOW_TITLE = "Settings";var SETTINGS_APP_PRESENTATION_MODE = Desktop.PresentationMode.NATIVE;var SETTINGS_APP_WIDTH_PX = 480;var SETTINGS_APP_HEIGHT_PX = 615;var SETTINGS_APP_WINDOW_FLAGS = 0x00000001 | // Qt::Window 0x00001000 | // Qt::WindowTitleHint 0x00002000 | // Qt::WindowSystemMenuHint 0x08000000 | // Qt::WindowCloseButtonHint 0x00008000 | // Qt::WindowMaximizeButtonHint 0x00004000; // Qt::WindowMinimizeButtonHintvar SETTINGS_APP_RIGHT_MARGIN = 48;var settingsAppWindow = false;function toggleSettingsApp() { if (settingsAppWindow) { settingsAppWindow.close(); // This really shouldn't be necessary. // This signal really should automatically be called by the signal handler set up below. // But fixing that requires an engine change, so this workaround will do. onSettingsAppClosed(); return; } settingsAppWindow = Desktop.createWindow(SETTINGS_APP_QML_PATH, { title: SETTINGS_APP_WINDOW_TITLE, presentationMode: SETTINGS_APP_PRESENTATION_MODE, size: { x: SETTINGS_APP_WIDTH_PX, y: SETTINGS_APP_HEIGHT_PX }, position: { x: Window.x + Window.innerWidth - SETTINGS_APP_WIDTH_PX - SETTINGS_APP_RIGHT_MARGIN, y: Math.max(Window.y + POPOUT_SAFE_MARGIN_Y, Window.y + Window.innerHeight / 2 - SETTINGS_APP_HEIGHT_PX / 2) }, overrideFlags: SETTINGS_APP_WINDOW_FLAGS }); settingsAppWindow.fromQml.connect(onMessageFromSettingsApp); settingsAppWindow.closed.connect(onSettingsAppClosed);} function handleGoToAudioSettings() { if (!settingsAppWindow) { toggleSettingsApp(); } settingsAppWindow.sendToQml({ "source": "simplifiedUI.js", "method": "goToSettingsTab", "data": { "settingsTab": "audio" } });} var HELP_APP_MESSAGE_SOURCE = "HelpApp.qml";function onMessageFromHelpApp(message) { if (message.source !== HELP_APP_MESSAGE_SOURCE) { return; } switch (message.method) { case "goToAudioSettings": handleGoToAudioSettings(); break; default: console.log("Unrecognized message from " + HELP_APP_MESSAGE_SOURCE + ": " + JSON.stringify(message)); break; }} function onHelpAppClosed() { if (helpAppWindow) { helpAppWindow.fromQml.disconnect(onMessageFromHelpApp); helpAppWindow.closed.disconnect(onHelpAppClosed); } helpAppWindow = false;} var HELP_APP_QML_PATH = Script.resourcesPath() + "qml/hifi/simplifiedUI/helpApp/HelpApp.qml";var HELP_APP_WINDOW_TITLE = "Help";var HELP_APP_PRESENTATION_MODE = Desktop.PresentationMode.NATIVE;var HELP_APP_WIDTH_PX = 480;var HELP_APP_HEIGHT_PX = 615;var HELP_APP_WINDOW_FLAGS = 0x00000001 | // Qt::Window 0x00001000 | // Qt::WindowTitleHint 0x00002000 | // Qt::WindowSystemMenuHint 0x08000000 | // Qt::WindowCloseButtonHint 0x00008000 | // Qt::WindowMaximizeButtonHint 0x00004000; // Qt::WindowMinimizeButtonHintvar helpAppWindow = false;function toggleHelpApp() { if (helpAppWindow) { helpAppWindow.close(); // This really shouldn't be necessary. // This signal really should automatically be called by the signal handler set up below. // But fixing that requires an engine change, so this workaround will do. onHelpAppClosed(); return; } helpAppWindow = Desktop.createWindow(HELP_APP_QML_PATH, { title: HELP_APP_WINDOW_TITLE, presentationMode: HELP_APP_PRESENTATION_MODE, size: { x: HELP_APP_WIDTH_PX, y: HELP_APP_HEIGHT_PX }, position: { x: Math.max(Window.x + POPOUT_SAFE_MARGIN_X, Window.x + Window.innerWidth / 2 - HELP_APP_WIDTH_PX / 2), y: Math.max(Window.y + POPOUT_SAFE_MARGIN_Y, Window.y + Window.innerHeight / 2 - HELP_APP_HEIGHT_PX / 2) }, overrideFlags: HELP_APP_WINDOW_FLAGS }); helpAppWindow.fromQml.connect(onMessageFromHelpApp); helpAppWindow.closed.connect(onHelpAppClosed);} function maybeDeleteOutputDeviceMutedOverlay() { if (outputDeviceMutedOverlay) { Overlays.deleteOverlay(outputDeviceMutedOverlay); outputDeviceMutedOverlay = false; }} var outputDeviceMutedOverlay = false;var OUTPUT_DEVICE_MUTED_OVERLAY_DEFAULT_DIMS_PX = 300;var OUTPUT_DEVICE_MUTED_OVERLAY_DEFAULT_MARGINS_PX = 20;var OUTPUT_DEVICE_MUTED_DIMS_RATIO_TO_WINDOW_SIZE = 0.8;function updateOutputDeviceMutedOverlay(isMuted) { if (isMuted) { var props = { imageURL: Script.resolvePath("images/outputDeviceMuted.svg"), alpha: 0.5 }; var overlayDims = OUTPUT_DEVICE_MUTED_OVERLAY_DEFAULT_DIMS_PX; var overlayWithMarginsDims = overlayDims + 2 * OUTPUT_DEVICE_MUTED_OVERLAY_DEFAULT_MARGINS_PX; if (overlayWithMarginsDims > Window.innerHeight || overlayWithMarginsDims > Window.innerWidth) { var minWindowDims = Math.min(Window.innerHeight, Window.innerWidth); overlayDims = Math.round(minWindowDims * OUTPUT_DEVICE_MUTED_DIMS_RATIO_TO_WINDOW_SIZE); } props.width = overlayDims; props.height = overlayDims; props.x = Window.innerWidth / 2 - overlayDims / 2; props.y = Window.innerHeight / 2 - overlayDims / 2; if (outputDeviceMutedOverlay) { Overlays.editOverlay(outputDeviceMutedOverlay, props); } else { outputDeviceMutedOverlay = Overlays.addOverlay("image", props); } } else { maybeDeleteOutputDeviceMutedOverlay(); }} var savedAvatarGain = Audio.avatarGain;var savedServerInjectorGain = Audio.serverInjectorGain;var savedLocalInjectorGain = Audio.localInjectorGain;var savedSystemInjectorGain = Audio.systemInjectorGain;var MUTED_VALUE_DB = -60; // This should always match `SimplifiedConstants.qml` -> numericConstants -> mutedValue!function setOutputMuted(outputMuted) { if (outputMuted) { savedAvatarGain = Audio.avatarGain; savedServerInjectorGain = Audio.serverInjectorGain; savedLocalInjectorGain = Audio.localInjectorGain; savedSystemInjectorGain = Audio.systemInjectorGain; Audio.avatarGain = MUTED_VALUE_DB; Audio.serverInjectorGain = MUTED_VALUE_DB; Audio.localInjectorGain = MUTED_VALUE_DB; Audio.systemInjectorGain = MUTED_VALUE_DB; } else { if (savedAvatarGain === MUTED_VALUE_DB) { savedAvatarGain = 0; } Audio.avatarGain = savedAvatarGain; if (savedServerInjectorGain === MUTED_VALUE_DB) { savedServerInjectorGain = 0; } Audio.serverInjectorGain = savedServerInjectorGain; if (savedLocalInjectorGain === MUTED_VALUE_DB) { savedLocalInjectorGain = 0; } Audio.localInjectorGain = savedLocalInjectorGain; if (savedSystemInjectorGain === MUTED_VALUE_DB) { savedSystemInjectorGain = 0; } Audio.systemInjectorGain = savedSystemInjectorGain; }} var TOP_BAR_HEIGHT_PX = 48;var INITIAL_LAUNCH_QML_PATH = Script.resolvePath("./simplifiedFTUE/InitialLaunchWindow.qml");var INITIAL_LAUNCH_WINDOW_TITLE = "Initial Launch";var INITIAL_LAUNCH_PRESENTATION_MODE = Desktop.PresentationMode.NATIVE;var INITIAL_WINDOW_FLAGS = 0x00000001 | // Qt::Window0x00000008 | // Qt::Popup0x00000002 | // Qt::Tool0x00000800 | // Qt::FramelessWindowHint0x40000000; // Qt::NoDropShadowWindowHintvar initialLaunchWindow = false;function displayInitialLaunchWindow() { if (initialLaunchWindow) { return; } simplifiedEmote.handleFTUEScreensVisibilityChanged(true); initialLaunchWindow = Desktop.createWindow(INITIAL_LAUNCH_QML_PATH, { title: INITIAL_LAUNCH_WINDOW_TITLE, presentationMode: INITIAL_LAUNCH_PRESENTATION_MODE, isFullScreenWindow: true, overrideFlags: INITIAL_WINDOW_FLAGS }); initialLaunchWindow.fromQml.connect(onMessageFromInitialLaunchWindow); Window.location = "file:///~/serverless/empty.json";} var SECOND_LAUNCH_QML_PATH = Script.resolvePath("simplifiedFTUE/SecondLaunchWindow.qml");var SECOND_LAUNCH_WINDOW_TITLE = "Second Launch";var SECOND_LAUNCH_PRESENTATION_MODE = Desktop.PresentationMode.NATIVE;var SECOND_WINDOW_FLAGS = 0x00000001 | // Qt::Window0x00000008 | // Qt::Popup0x00000002 | // Qt::Tool0x00000800 | // Qt::FramelessWindowHint0x40000000; // Qt::NoDropShadowWindowHintvar secondLaunchWindow = false;function displaySecondLaunchWindow() { if (secondLaunchWindow) { return; } simplifiedEmote.handleFTUEScreensVisibilityChanged(true); secondLaunchWindow = Desktop.createWindow(SECOND_LAUNCH_QML_PATH, { title: SECOND_LAUNCH_WINDOW_TITLE, presentationMode: SECOND_LAUNCH_PRESENTATION_MODE, isFullScreenWindow: true, overrideFlags: SECOND_WINDOW_FLAGS }); secondLaunchWindow.fromQml.connect(onMessageFromSecondLaunchWindow); Window.location = "file:///~/serverless/empty.json";} function closeInitialLaunchWindow() { if (initialLaunchWindow) { initialLaunchWindow.fromQml.disconnect(onMessageFromInitialLaunchWindow); initialLaunchWindow.close(); initialLaunchWindow = null; } simplifiedEmote.handleFTUEScreensVisibilityChanged(false);} function closeSecondLaunchWindow() { if (secondLaunchWindow) { secondLaunchWindow.fromQml.disconnect(onMessageFromSecondLaunchWindow); secondLaunchWindow.close(); secondLaunchWindow = null; } simplifiedEmote.handleFTUEScreensVisibilityChanged(false);} var INITIAL_LAUNCH_WINDOW_MESSAGE_SOURCE = "InitialLaunchWindow.qml";function onMessageFromInitialLaunchWindow(message) { if (message.source !== INITIAL_LAUNCH_WINDOW_MESSAGE_SOURCE) { return; } switch (message.method) { case "closeInitialLaunchWindow": closeInitialLaunchWindow(); var homeLocation = LocationBookmarks.getAddress("hqhome"); if (homeLocation) { Window.location = homeLocation; } break; default: console.log("Unrecognized message from " + INITIAL_LAUNCH_WINDOW_MESSAGE_SOURCE + ": " + JSON.stringify(message)); break; }} var SECOND_LAUNCH_WINDOW_MESSAGE_SOURCE = "SecondLaunchWindow.qml";function onMessageFromSecondLaunchWindow(message) { if (message.source !== SECOND_LAUNCH_WINDOW_MESSAGE_SOURCE) { return; } switch (message.method) { case "closeSecondLaunchWindow": closeSecondLaunchWindow(); var homeLocation = LocationBookmarks.getAddress("hqhome"); if (homeLocation) { Window.location = homeLocation; } break; default: console.log("Unrecognized message from " + SECOND_LAUNCH_WINDOW_MESSAGE_SOURCE + ": " + JSON.stringify(message)); break; }} var WAIT_FOR_TOP_BAR_MS = 1000;function sendLocalStatusToQml() { var currentStatus = si.getLocalStatus(); if (topBarWindow && currentStatus) { topBarWindow.sendToQml({ "source": "simplifiedUI.js", "method": "updateStatusButton", "data": { "currentStatus": currentStatus } }); } else { Script.setTimeout(sendLocalStatusToQml, WAIT_FOR_TOP_BAR_MS); }} var TOP_BAR_MESSAGE_SOURCE = "SimplifiedTopBar.qml";function onMessageFromTopBar(message) { if (message.source !== TOP_BAR_MESSAGE_SOURCE) { return; } switch (message.method) { case "toggleAvatarApp": toggleAvatarApp(); break;Lines 1–500 of 817. Load more
"use strict"; /* jslint vars: true, plusplus: true */ // // simplifiedUI.js // // Authors: Wayne Chen & Zach Fox // Created: 2019-05-01 // Copyright 2019 High Fidelity, Inc. // Copyright 2024 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // // START CONFIG OPTIONS var TOOLBAR_NAME = "com.highfidelity.interface.toolbar.system"; var DEFAULT_SCRIPTS_PATH_PREFIX = ScriptDiscoveryService.defaultScriptsPath + "/"; // END CONFIG OPTIONS var MENU_NAMES = ["File", "Edit", "Display", "View", "Navigate", "Settings", "Developer", "Help"]; var keepMenusSetting = Settings.getValue("simplifiedUI/keepMenus", true); function maybeRemoveDesktopMenu() { if (!keepMenusSetting) { MENU_NAMES.forEach(function(menu) { Menu.removeMenu(menu); }); } } function handleUpdateAvatarThumbnailURL(avatarThumbnailURL) { if (topBarWindow) { topBarWindow.sendToQml({ "source": "simplifiedUI.js", "method": "updateAvatarThumbnailURL", "data": { "avatarThumbnailURL": avatarThumbnailURL } }); } } var AVATAR_APP_MESSAGE_SOURCE = "AvatarApp.qml"; function onMessageFromAvatarApp(message) { if (message.source !== AVATAR_APP_MESSAGE_SOURCE) { return; } switch (message.method) { case "updateAvatarThumbnailURL": handleUpdateAvatarThumbnailURL(message.data.avatarThumbnailURL); break; default: console.log("Unrecognized message from " + AVATAR_APP_MESSAGE_SOURCE + ": " + JSON.stringify(message)); break; } } function onAvatarAppClosed() { if (avatarAppWindow) { avatarAppWindow.fromQml.disconnect(onMessageFromAvatarApp); avatarAppWindow.closed.disconnect(onAvatarAppClosed); } avatarAppWindow = false; } var AVATAR_APP_QML_PATH = Script.resourcesPath() + "qml/hifi/simplifiedUI/avatarApp/AvatarApp.qml"; var AVATAR_APP_WINDOW_TITLE = "Your Profile"; var AVATAR_APP_PRESENTATION_MODE = Desktop.PresentationMode.NATIVE; var AVATAR_APP_WIDTH_PX = 480; var AVATAR_APP_HEIGHT_PX = 615; var avatarAppWindow = false; var POPOUT_SAFE_MARGIN_X = 30; var POPOUT_SAFE_MARGIN_Y = 30; var AVATAR_APP_WINDOW_FLAGS = 0x00000001 | // Qt::Window 0x00001000 | // Qt::WindowTitleHint 0x00002000 | // Qt::WindowSystemMenuHint 0x08000000 | // Qt::WindowCloseButtonHint 0x00008000 | // Qt::WindowMaximizeButtonHint 0x00004000; // Qt::WindowMinimizeButtonHint function toggleAvatarApp() { if (avatarAppWindow) { avatarAppWindow.close(); // This really shouldn't be necessary. // This signal really should automatically be called by the signal handler set up below. // But fixing that requires an engine change, so this workaround will do. onAvatarAppClosed(); return; } avatarAppWindow = Desktop.createWindow(AVATAR_APP_QML_PATH, { title: AVATAR_APP_WINDOW_TITLE, presentationMode: AVATAR_APP_PRESENTATION_MODE, size: { x: AVATAR_APP_WIDTH_PX, y: AVATAR_APP_HEIGHT_PX }, position: { x: Math.max(Window.x + POPOUT_SAFE_MARGIN_X, Window.x + Window.innerWidth / 2 - AVATAR_APP_WIDTH_PX / 2), y: Math.max(Window.y + POPOUT_SAFE_MARGIN_Y, Window.y + Window.innerHeight / 2 - AVATAR_APP_HEIGHT_PX / 2) }, overrideFlags: AVATAR_APP_WINDOW_FLAGS }); avatarAppWindow.fromQml.connect(onMessageFromAvatarApp); avatarAppWindow.closed.connect(onAvatarAppClosed); } function handleAvatarNametagMode(newAvatarNametagMode) { nametag.handleAvatarNametagMode(newAvatarNametagMode); } var SETTINGS_APP_MESSAGE_SOURCE = "SettingsApp.qml"; function onMessageFromSettingsApp(message) { if (message.source !== SETTINGS_APP_MESSAGE_SOURCE) { return; } switch (message.method) { /* This calls an update methon on the module apis because I can't get a signal from Settings.QML to the emoji.js without it being a module like nametag. */ case "handleAvatarNametagMode": handleAvatarNametagMode(message.avatarNametagMode); break; default: console.log("Unrecognized message from " + SETTINGS_APP_MESSAGE_SOURCE + ": " + JSON.stringify(message)); break; } } function onSettingsAppClosed() { if (settingsAppWindow) { settingsAppWindow.fromQml.disconnect(onMessageFromSettingsApp); settingsAppWindow.closed.disconnect(onSettingsAppClosed); } settingsAppWindow = false; } var SETTINGS_APP_QML_PATH = Script.resourcesPath() + "qml/hifi/simplifiedUI/settingsApp/SettingsApp.qml"; var SETTINGS_APP_WINDOW_TITLE = "Settings"; var SETTINGS_APP_PRESENTATION_MODE = Desktop.PresentationMode.NATIVE; var SETTINGS_APP_WIDTH_PX = 480; var SETTINGS_APP_HEIGHT_PX = 615; var SETTINGS_APP_WINDOW_FLAGS = 0x00000001 | // Qt::Window 0x00001000 | // Qt::WindowTitleHint 0x00002000 | // Qt::WindowSystemMenuHint 0x08000000 | // Qt::WindowCloseButtonHint 0x00008000 | // Qt::WindowMaximizeButtonHint 0x00004000; // Qt::WindowMinimizeButtonHint var SETTINGS_APP_RIGHT_MARGIN = 48; var settingsAppWindow = false; function toggleSettingsApp() { if (settingsAppWindow) { settingsAppWindow.close(); // This really shouldn't be necessary. // This signal really should automatically be called by the signal handler set up below. // But fixing that requires an engine change, so this workaround will do. onSettingsAppClosed(); return; } settingsAppWindow = Desktop.createWindow(SETTINGS_APP_QML_PATH, { title: SETTINGS_APP_WINDOW_TITLE, presentationMode: SETTINGS_APP_PRESENTATION_MODE, size: { x: SETTINGS_APP_WIDTH_PX, y: SETTINGS_APP_HEIGHT_PX }, position: { x: Window.x + Window.innerWidth - SETTINGS_APP_WIDTH_PX - SETTINGS_APP_RIGHT_MARGIN, y: Math.max(Window.y + POPOUT_SAFE_MARGIN_Y, Window.y + Window.innerHeight / 2 - SETTINGS_APP_HEIGHT_PX / 2) }, overrideFlags: SETTINGS_APP_WINDOW_FLAGS }); settingsAppWindow.fromQml.connect(onMessageFromSettingsApp); settingsAppWindow.closed.connect(onSettingsAppClosed); } function handleGoToAudioSettings() { if (!settingsAppWindow) { toggleSettingsApp(); } settingsAppWindow.sendToQml({ "source": "simplifiedUI.js", "method": "goToSettingsTab", "data": { "settingsTab": "audio" } }); } var HELP_APP_MESSAGE_SOURCE = "HelpApp.qml"; function onMessageFromHelpApp(message) { if (message.source !== HELP_APP_MESSAGE_SOURCE) { return; } switch (message.method) { case "goToAudioSettings": handleGoToAudioSettings(); break; default: console.log("Unrecognized message from " + HELP_APP_MESSAGE_SOURCE + ": " + JSON.stringify(message)); break; } } function onHelpAppClosed() { if (helpAppWindow) { helpAppWindow.fromQml.disconnect(onMessageFromHelpApp); helpAppWindow.closed.disconnect(onHelpAppClosed); } helpAppWindow = false; } var HELP_APP_QML_PATH = Script.resourcesPath() + "qml/hifi/simplifiedUI/helpApp/HelpApp.qml"; var HELP_APP_WINDOW_TITLE = "Help"; var HELP_APP_PRESENTATION_MODE = Desktop.PresentationMode.NATIVE; var HELP_APP_WIDTH_PX = 480; var HELP_APP_HEIGHT_PX = 615; var HELP_APP_WINDOW_FLAGS = 0x00000001 | // Qt::Window 0x00001000 | // Qt::WindowTitleHint 0x00002000 | // Qt::WindowSystemMenuHint 0x08000000 | // Qt::WindowCloseButtonHint 0x00008000 | // Qt::WindowMaximizeButtonHint 0x00004000; // Qt::WindowMinimizeButtonHint var helpAppWindow = false; function toggleHelpApp() { if (helpAppWindow) { helpAppWindow.close(); // This really shouldn't be necessary. // This signal really should automatically be called by the signal handler set up below. // But fixing that requires an engine change, so this workaround will do. onHelpAppClosed(); return; } helpAppWindow = Desktop.createWindow(HELP_APP_QML_PATH, { title: HELP_APP_WINDOW_TITLE, presentationMode: HELP_APP_PRESENTATION_MODE, size: { x: HELP_APP_WIDTH_PX, y: HELP_APP_HEIGHT_PX }, position: { x: Math.max(Window.x + POPOUT_SAFE_MARGIN_X, Window.x + Window.innerWidth / 2 - HELP_APP_WIDTH_PX / 2), y: Math.max(Window.y + POPOUT_SAFE_MARGIN_Y, Window.y + Window.innerHeight / 2 - HELP_APP_HEIGHT_PX / 2) }, overrideFlags: HELP_APP_WINDOW_FLAGS }); helpAppWindow.fromQml.connect(onMessageFromHelpApp); helpAppWindow.closed.connect(onHelpAppClosed); } function maybeDeleteOutputDeviceMutedOverlay() { if (outputDeviceMutedOverlay) { Overlays.deleteOverlay(outputDeviceMutedOverlay); outputDeviceMutedOverlay = false; } } var outputDeviceMutedOverlay = false; var OUTPUT_DEVICE_MUTED_OVERLAY_DEFAULT_DIMS_PX = 300; var OUTPUT_DEVICE_MUTED_OVERLAY_DEFAULT_MARGINS_PX = 20; var OUTPUT_DEVICE_MUTED_DIMS_RATIO_TO_WINDOW_SIZE = 0.8; function updateOutputDeviceMutedOverlay(isMuted) { if (isMuted) { var props = { imageURL: Script.resolvePath("images/outputDeviceMuted.svg"), alpha: 0.5 }; var overlayDims = OUTPUT_DEVICE_MUTED_OVERLAY_DEFAULT_DIMS_PX; var overlayWithMarginsDims = overlayDims + 2 * OUTPUT_DEVICE_MUTED_OVERLAY_DEFAULT_MARGINS_PX; if (overlayWithMarginsDims > Window.innerHeight || overlayWithMarginsDims > Window.innerWidth) { var minWindowDims = Math.min(Window.innerHeight, Window.innerWidth); overlayDims = Math.round(minWindowDims * OUTPUT_DEVICE_MUTED_DIMS_RATIO_TO_WINDOW_SIZE); } props.width = overlayDims; props.height = overlayDims; props.x = Window.innerWidth / 2 - overlayDims / 2; props.y = Window.innerHeight / 2 - overlayDims / 2; if (outputDeviceMutedOverlay) { Overlays.editOverlay(outputDeviceMutedOverlay, props); } else { outputDeviceMutedOverlay = Overlays.addOverlay("image", props); } } else { maybeDeleteOutputDeviceMutedOverlay(); } } var savedAvatarGain = Audio.avatarGain; var savedServerInjectorGain = Audio.serverInjectorGain; var savedLocalInjectorGain = Audio.localInjectorGain; var savedSystemInjectorGain = Audio.systemInjectorGain; var MUTED_VALUE_DB = -60; // This should always match `SimplifiedConstants.qml` -> numericConstants -> mutedValue! function setOutputMuted(outputMuted) { if (outputMuted) { savedAvatarGain = Audio.avatarGain; savedServerInjectorGain = Audio.serverInjectorGain; savedLocalInjectorGain = Audio.localInjectorGain; savedSystemInjectorGain = Audio.systemInjectorGain; Audio.avatarGain = MUTED_VALUE_DB; Audio.serverInjectorGain = MUTED_VALUE_DB; Audio.localInjectorGain = MUTED_VALUE_DB; Audio.systemInjectorGain = MUTED_VALUE_DB; } else { if (savedAvatarGain === MUTED_VALUE_DB) { savedAvatarGain = 0; } Audio.avatarGain = savedAvatarGain; if (savedServerInjectorGain === MUTED_VALUE_DB) { savedServerInjectorGain = 0; } Audio.serverInjectorGain = savedServerInjectorGain; if (savedLocalInjectorGain === MUTED_VALUE_DB) { savedLocalInjectorGain = 0; } Audio.localInjectorGain = savedLocalInjectorGain; if (savedSystemInjectorGain === MUTED_VALUE_DB) { savedSystemInjectorGain = 0; } Audio.systemInjectorGain = savedSystemInjectorGain; } } var TOP_BAR_HEIGHT_PX = 48; var INITIAL_LAUNCH_QML_PATH = Script.resolvePath("./simplifiedFTUE/InitialLaunchWindow.qml"); var INITIAL_LAUNCH_WINDOW_TITLE = "Initial Launch"; var INITIAL_LAUNCH_PRESENTATION_MODE = Desktop.PresentationMode.NATIVE; var INITIAL_WINDOW_FLAGS = 0x00000001 | // Qt::Window 0x00000008 | // Qt::Popup 0x00000002 | // Qt::Tool 0x00000800 | // Qt::FramelessWindowHint 0x40000000; // Qt::NoDropShadowWindowHint var initialLaunchWindow = false; function displayInitialLaunchWindow() { if (initialLaunchWindow) { return; } simplifiedEmote.handleFTUEScreensVisibilityChanged(true); initialLaunchWindow = Desktop.createWindow(INITIAL_LAUNCH_QML_PATH, { title: INITIAL_LAUNCH_WINDOW_TITLE, presentationMode: INITIAL_LAUNCH_PRESENTATION_MODE, isFullScreenWindow: true, overrideFlags: INITIAL_WINDOW_FLAGS }); initialLaunchWindow.fromQml.connect(onMessageFromInitialLaunchWindow); Window.location = "file:///~/serverless/empty.json"; } var SECOND_LAUNCH_QML_PATH = Script.resolvePath("simplifiedFTUE/SecondLaunchWindow.qml"); var SECOND_LAUNCH_WINDOW_TITLE = "Second Launch"; var SECOND_LAUNCH_PRESENTATION_MODE = Desktop.PresentationMode.NATIVE; var SECOND_WINDOW_FLAGS = 0x00000001 | // Qt::Window 0x00000008 | // Qt::Popup 0x00000002 | // Qt::Tool 0x00000800 | // Qt::FramelessWindowHint 0x40000000; // Qt::NoDropShadowWindowHint var secondLaunchWindow = false; function displaySecondLaunchWindow() { if (secondLaunchWindow) { return; } simplifiedEmote.handleFTUEScreensVisibilityChanged(true); secondLaunchWindow = Desktop.createWindow(SECOND_LAUNCH_QML_PATH, { title: SECOND_LAUNCH_WINDOW_TITLE, presentationMode: SECOND_LAUNCH_PRESENTATION_MODE, isFullScreenWindow: true, overrideFlags: SECOND_WINDOW_FLAGS }); secondLaunchWindow.fromQml.connect(onMessageFromSecondLaunchWindow); Window.location = "file:///~/serverless/empty.json"; } function closeInitialLaunchWindow() { if (initialLaunchWindow) { initialLaunchWindow.fromQml.disconnect(onMessageFromInitialLaunchWindow); initialLaunchWindow.close(); initialLaunchWindow = null; } simplifiedEmote.handleFTUEScreensVisibilityChanged(false); } function closeSecondLaunchWindow() { if (secondLaunchWindow) { secondLaunchWindow.fromQml.disconnect(onMessageFromSecondLaunchWindow); secondLaunchWindow.close(); secondLaunchWindow = null; } simplifiedEmote.handleFTUEScreensVisibilityChanged(false); } var INITIAL_LAUNCH_WINDOW_MESSAGE_SOURCE = "InitialLaunchWindow.qml"; function onMessageFromInitialLaunchWindow(message) { if (message.source !== INITIAL_LAUNCH_WINDOW_MESSAGE_SOURCE) { return; } switch (message.method) { case "closeInitialLaunchWindow": closeInitialLaunchWindow(); var homeLocation = LocationBookmarks.getAddress("hqhome"); if (homeLocation) { Window.location = homeLocation; } break; default: console.log("Unrecognized message from " + INITIAL_LAUNCH_WINDOW_MESSAGE_SOURCE + ": " + JSON.stringify(message)); break; } } var SECOND_LAUNCH_WINDOW_MESSAGE_SOURCE = "SecondLaunchWindow.qml"; function onMessageFromSecondLaunchWindow(message) { if (message.source !== SECOND_LAUNCH_WINDOW_MESSAGE_SOURCE) { return; } switch (message.method) { case "closeSecondLaunchWindow": closeSecondLaunchWindow(); var homeLocation = LocationBookmarks.getAddress("hqhome"); if (homeLocation) { Window.location = homeLocation; } break; default: console.log("Unrecognized message from " + SECOND_LAUNCH_WINDOW_MESSAGE_SOURCE + ": " + JSON.stringify(message)); break; } } var WAIT_FOR_TOP_BAR_MS = 1000; function sendLocalStatusToQml() { var currentStatus = si.getLocalStatus(); if (topBarWindow && currentStatus) { topBarWindow.sendToQml({ "source": "simplifiedUI.js", "method": "updateStatusButton", "data": { "currentStatus": currentStatus } }); } else { Script.setTimeout(sendLocalStatusToQml, WAIT_FOR_TOP_BAR_MS); } } var TOP_BAR_MESSAGE_SOURCE = "SimplifiedTopBar.qml"; function onMessageFromTopBar(message) { if (message.source !== TOP_BAR_MESSAGE_SOURCE) { return; } switch (message.method) { case "toggleAvatarApp": toggleAvatarApp(); break;