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 tablet;
var appButton; var appButton;
var active = false; var active = false;
const url = Script.resolvePath("./settings.qml")
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
appButton = tablet.addButton({ appButton = tablet.addButton({
@ -41,29 +42,26 @@
// Overlay button toggle // Overlay button toggle
appButton.clicked.connect(toolbarButtonClicked); appButton.clicked.connect(toolbarButtonClicked);
tablet.fromQml.connect(fromQML); tablet.fromQml.connect(fromQML);
tablet.screenChanged.connect(onTabletScreenChanged);
function toolbarButtonClicked() { function toolbarButtonClicked() {
if (active) { if (active) tablet.gotoHomeScreen();
tablet.gotoHomeScreen(); else tablet.loadQMLSource(url);
active = !active;
appButton.editProperties({ active = !active;
isActive: active, appButton.editProperties({
}); isActive: active,
} else { });
tablet.loadQMLSource(Script.resolvePath("./settings.qml"));
active = !active;
appButton.editProperties({
isActive: active,
});
}
} }
// Functions function onTabletScreenChanged(type, new_url){
function getActivePolls(){ if (url == new_url) active = true;
// Send hello world else active = false;
// Add responses to list
}
appButton.editProperties({
isActive: active,
});
}
// Communication // Communication
function fromQML(event) { function fromQML(event) {