Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphics App: adding a setting to hide or display the app in the tablet/toolbar #1275

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 43 additions & 11 deletions scripts/system/graphicsSettings.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
//
// graphicsSettings.js
//
// Created by Kalila L. on 8/5/2020
// Created by Kalila L. on August 5th, 2020
// Copyright 2020 Vircadia contributors.
// 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
//

(function() { // BEGIN LOCAL_SCOPE

var channelComm = "Overte-ShowGraphicsIconChanged";
var appStatus = false;
var GRAPHICS_HIDE_AND_SHOW_SETTING_KEY = "showGraphicsIcon";
var GRAPHICS_HIDE_AND_SHOW_DEFAULT_VALUE = true;

var AppUi = Script.require('appUi');

// cellphone-cog MDI
Expand Down Expand Up @@ -49,22 +54,49 @@
}

function startup() {
ui = new AppUi({
buttonName: BUTTON_NAME,
sortOrder: 8,
normalButton: getIcon(),
activeButton: getIcon().replace('white', 'black'),
home: GRAPHICS_QML_SOURCE
});
if (!appStatus) {
ui = new AppUi({
buttonName: BUTTON_NAME,
sortOrder: 8,
normalButton: getIcon(),
activeButton: getIcon().replace('white', 'black'),
home: GRAPHICS_QML_SOURCE
});
}
appStatus = true;
}

function shutdown() {
if (appStatus) {
ui.onScriptEnding();
appStatus = false;
}
}

function cleanup() {
Messages.messageReceived.disconnect(onMessageReceived);
Messages.unsubscribe(channelComm);
}

function onMessageReceived(channel, message, sender, localOnly) {
if (channel === channelComm && localOnly) {
if (Settings.getValue(GRAPHICS_HIDE_AND_SHOW_SETTING_KEY, GRAPHICS_HIDE_AND_SHOW_DEFAULT_VALUE)) {
startup();
} else {
shutdown();
}
}
}

//
// Run the functions.
//
startup();
Script.scriptEnding.connect(shutdown);
if (Settings.getValue(GRAPHICS_HIDE_AND_SHOW_SETTING_KEY, GRAPHICS_HIDE_AND_SHOW_DEFAULT_VALUE)) {
startup();
}
Messages.subscribe(channelComm);
Messages.messageReceived.connect(onMessageReceived);

Script.scriptEnding.connect(cleanup);

}()); // END LOCAL_SCOPE