Optimized settings.js

This commit is contained in:
armored-dragon 2024-08-29 14:55:40 -05:00
parent f3a31a7081
commit f27a52d83e
No known key found for this signature in database
GPG key ID: C7207ACC3382AD8B

View file

@ -23,6 +23,7 @@
var tablet;
var appButton;
var active = false;
const url = Script.resolvePath("./settings.qml")
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
appButton = tablet.addButton({
@ -41,30 +42,27 @@
// Overlay button toggle
appButton.clicked.connect(toolbarButtonClicked);
tablet.fromQml.connect(fromQML);
tablet.screenChanged.connect(onTabletScreenChanged);
function toolbarButtonClicked() {
if (active) {
tablet.gotoHomeScreen();
active = !active;
appButton.editProperties({
isActive: active,
});
} else {
tablet.loadQMLSource(Script.resolvePath("./settings.qml"));
active = !active;
appButton.editProperties({
isActive: active,
});
}
if (active) tablet.gotoHomeScreen();
else tablet.loadQMLSource(url);
active = !active;
appButton.editProperties({
isActive: active,
});
}
// Functions
function getActivePolls(){
// Send hello world
// Add responses to list
function onTabletScreenChanged(type, new_url){
if (url == new_url) active = true;
else active = false;
appButton.editProperties({
isActive: active,
});
}
// Communication
function fromQML(event) {
console.log(`New QML event:\n${JSON.stringify(event)}`);