Skip to content

Commit

Permalink
Merge pull request #1275 from AleziaKurdis/GraphisApp_toggle
Browse files Browse the repository at this point in the history
Graphics App: adding a setting to hide or display the app in the tablet/toolbar
  • Loading branch information
ksuprynowicz authored Dec 20, 2024
2 parents 06ebb0c + 3883de2 commit fba519e
Showing 1 changed file with 43 additions and 11 deletions.
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

0 comments on commit fba519e

Please sign in to comment.