use checkswitch not button

This commit is contained in:
Jeff Becker 2020-09-25 11:05:26 -04:00
parent f777e3c59e
commit f158b58038
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05

View file

@ -101,6 +101,67 @@ Container {
font.capitalization: Font.AllUppercase
}
ListView {
model: ["Exit"]
delegate: SwitchDelegate {
text: "Enable Exit"
onToggled: {
if(busy)
{
return;
}
let exitAddr = exitTextInput.text;
let exitAuth = authTextInput.text;
console.log(exitAddr, exitAuth);
if(hasExit)
{
busy = true;
apiClient.llarpDelExit(function(result, error) {
status = "Exit Off";
busy = false;
hasExit = false;
stautsLabelText.color = Style.weakTextColor;
});
return;
}
status = "Connecting...";
busy = true;
apiClient.llarpAddExit(exitAddr, exitAuth, function(result, error) {
busy = false;
if(error)
{
status = "Error: " +error;
statusLabelText.color = Style.errorRed;
checked = false;
return;
}
let j = JSON.parse(result);
if(j.error)
{
status = "Error: " + j.error;
checked = false;
statusLabelText.color = Style.errorRed;
}
if(j.result)
{
status = "Exit Enabled";
hasExit = true;
stautsLabelText.color = Style.weakTextColor;
}
});
}
}
y: 160
anchors.left: parent.left
anchors.leftMargin: 20
anchors.right: parent.right
anchors.rightMargin: 20
}
/*
Button {
id: exitButton
text: "Enable Exit"
@ -178,4 +239,5 @@ Container {
});
}
}
*/
}