76 lines
2.2 KiB
Plaintext
76 lines
2.2 KiB
Plaintext
import { LineEdit, StandardListView, Button } from "std-widgets.slint";
|
|
import { Style } from "globals.slint";
|
|
import { IconButton } from "widgets/icon-button.slint";
|
|
|
|
export component UserEditView inherits HorizontalLayout {
|
|
padding: Style.spacing;
|
|
spacing: Style.spacing;
|
|
in property <string> username;
|
|
in property <string> key_error;
|
|
in-out property <string> identicon;
|
|
in-out property <string> key_id;
|
|
callback compute_identicon(password: string);
|
|
callback compute_key_id(encrypted_key: string);
|
|
callback confirm(encrypted_key: string);
|
|
callback cancel <=> button_cancel.clicked;
|
|
VerticalLayout {
|
|
spacing: Style.spacing;
|
|
Rectangle { }
|
|
|
|
Text {
|
|
text: "Enter " + username + "'s encrypted key and press Enter:";
|
|
}
|
|
|
|
line_edit_password := LineEdit {
|
|
input-type: InputType.password;
|
|
placeholder-text: "Password";
|
|
edited(text) => {
|
|
root.identicon = "";
|
|
root.key_id = "";
|
|
}
|
|
accepted(text) => {
|
|
compute_identicon(text);
|
|
line_edit_password.focus();
|
|
}
|
|
}
|
|
|
|
Text {
|
|
text: identicon.is-empty ? "" : ("Check the identicon: " + identicon);
|
|
}
|
|
|
|
line_edit_encrypted_key := LineEdit {
|
|
input-type: InputType.text;
|
|
placeholder-text: "Encrypted key";
|
|
enabled: !identicon.is-empty;
|
|
edited(text) => {
|
|
root.key_id = "";
|
|
}
|
|
accepted(text) => {
|
|
compute_key_id(text);
|
|
button_confirm.focus();
|
|
}
|
|
}
|
|
|
|
Text {
|
|
text: !key_error.is-empty ? key_error : (!key_id.is-empty ? ("Key ID: " + key_id) : "");
|
|
}
|
|
|
|
HorizontalLayout {
|
|
spacing: Style.spacing;
|
|
button_cancel := Button {
|
|
text: "Cancel";
|
|
}
|
|
|
|
button_confirm := Button {
|
|
text: "Confirm";
|
|
enabled: !identicon.is-empty && !key_id.is-empty;
|
|
clicked => {
|
|
confirm(line_edit_encrypted_key.text);
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle { }
|
|
}
|
|
}
|