import { AvatarView } from "../avatar-view.slint"; import { Theme, ActionButton } from "../theme.slint"; import { ThemeInput, ThemeEditor } from "../controls.slint"; export component IdentitySettings inherits Rectangle { in property own-avatar; in property has-avatar; in property avatar-error; callback choose-avatar(); callback remove-avatar(); in-out property identity-pubkey; in-out property vault-enabled; in-out property passphrase-modal-open; in-out property passphrase-input; in-out property passphrase-confirm; in-out property passphrase-error; in-out property export-modal-open; in-out property export-pass-input; in-out property export-pass-confirm; in-out property export-output; in-out property export-error; in-out property import-modal-open; in-out property import-keyfile-input; in-out property import-pass-input; in-out property import-error; private property confirm-remove; callback set-passphrase(string, string); callback remove-passphrase(); callback export-keyfile(string, string); callback import-keyfile(string, string); VerticalLayout { spacing: 0; alignment: start; Text { text: @tr("Profile photo"); color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; } Text { text: @tr("Choose an image and crop it for your avatar."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } Rectangle { height: 18px; } HorizontalLayout { spacing: 20px; AvatarView { width: 82px; height: 82px; source: root.own-avatar; has-source: root.has-avatar; initials: @tr("Photo"); mask: Theme.bg-base; } VerticalLayout { spacing: 9px; alignment: center; HorizontalLayout { spacing: 9px; ActionButton { text: root.has-avatar ? @tr("Change photo") : @tr("Choose photo"); clicked => { root.choose-avatar(); } } if root.has-avatar : ActionButton { text: @tr("Delete"); quiet: true; danger: true; clicked => { root.remove-avatar(); } } Rectangle { horizontal-stretch: 1; } } Text { text: @tr("Currently stored only on this device."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 4px, 11px); wrap: word-wrap; } } } Rectangle { height: 26px; } Rectangle { height: 1px; background: Theme.border; } Rectangle { height: 24px; } Text { text: @tr("Your key"); color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; } Text { text: @tr("Your public key identifies your profile. You can share it; your secret key stays on this device."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } Rectangle { height: 16px; } ThemeEditor { text: root.identity-pubkey; read-only: true; height: 78px; } if root.avatar-error != "" : Text { text: root.avatar-error; color: Theme.danger; font-size: Math.max(11px, Theme.font-size - 3px); wrap: word-wrap; } Rectangle { height: 28px; } Rectangle { height: 1px; background: Theme.border; } Rectangle { height: 24px; } HorizontalLayout { Text { text: @tr("Device security"); color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; horizontal-stretch: 1; } Text { text: root.vault-enabled ? @tr("Passphrase protected") : @tr("No passphrase"); color: root.vault-enabled ? Theme.success : Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); vertical-alignment: center; } } Rectangle { height: 6px; } Text { text: root.vault-enabled ? @tr("Vnox will ask for your passphrase to unlock your keys on startup.") : @tr("Add a passphrase to encrypt your saved secret key."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } Rectangle { height: 15px; } HorizontalLayout { spacing: 9px; ActionButton { text: root.vault-enabled ? @tr("Change passphrase") : @tr("Add passphrase"); clicked => { root.passphrase-modal-open = !root.passphrase-modal-open; root.export-modal-open = false; root.import-modal-open = false; } } if root.vault-enabled : ActionButton { text: @tr("Remove passphrase"); danger: true; quiet: true; clicked => { root.confirm-remove = true; } } Rectangle { horizontal-stretch: 1; } } if root.confirm-remove : VerticalLayout { spacing: 10px; alignment: start; Text { text: @tr("Your key will be stored without encryption. Remove the passphrase?"); color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } HorizontalLayout { spacing: 9px; ActionButton { text: @tr("Cancel"); quiet: true; clicked => { root.confirm-remove = false; } } ActionButton { text: @tr("Remove passphrase"); danger: true; clicked => { root.remove-passphrase(); root.confirm-remove = false; } } Rectangle { horizontal-stretch: 1; } } } if root.passphrase-modal-open : VerticalLayout { spacing: 10px; alignment: start; Rectangle { height: 8px; } ThemeInput { input-type: InputType.password; text <=> root.passphrase-input; placeholder-text: @tr("New passphrase · at least 8 characters"); } ThemeInput { input-type: InputType.password; text <=> root.passphrase-confirm; placeholder-text: @tr("Repeat passphrase"); accepted => { root.set-passphrase(root.passphrase-input, root.passphrase-confirm); } } if root.passphrase-error != "" : Text { text: root.passphrase-error; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } HorizontalLayout { spacing: 9px; ActionButton { text: @tr("Save passphrase"); active: true; clicked => { root.set-passphrase(root.passphrase-input, root.passphrase-confirm); } } ActionButton { text: @tr("Collapse"); quiet: true; clicked => { root.passphrase-modal-open = false; } } Rectangle { horizontal-stretch: 1; } } } Rectangle { height: 28px; } Rectangle { height: 1px; background: Theme.border; } Rectangle { height: 24px; } Text { text: @tr("Backup"); color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; } Text { text: @tr("Keep your keys in a safe place to restore your profile on another device."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } Rectangle { height: 15px; } HorizontalLayout { spacing: 9px; ActionButton { text: @tr("Export keys"); clicked => { root.export-modal-open = !root.export-modal-open; root.passphrase-modal-open = false; root.import-modal-open = false; } } ActionButton { text: @tr("Import"); quiet: true; clicked => { root.import-modal-open = !root.import-modal-open; root.passphrase-modal-open = false; root.export-modal-open = false; } } Rectangle { horizontal-stretch: 1; } } if root.export-modal-open : VerticalLayout { spacing: 10px; alignment: start; Rectangle { height: 8px; } Text { text: @tr("The backup passphrase is optional. Without it, your backup contains an unprotected secret key."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } ThemeInput { input-type: InputType.password; text <=> root.export-pass-input; placeholder-text: @tr("Backup passphrase · optional"); } ThemeInput { input-type: InputType.password; text <=> root.export-pass-confirm; placeholder-text: @tr("Repeat backup passphrase"); } if root.export-error != "" : Text { text: root.export-error; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } HorizontalLayout { spacing: 9px; ActionButton { text: @tr("Create backup"); active: true; clicked => { root.export-keyfile(root.export-pass-input, root.export-pass-confirm); } } ActionButton { text: @tr("Collapse"); quiet: true; clicked => { root.export-modal-open = false; } } Rectangle { horizontal-stretch: 1; } } if root.export-output != "" : VerticalLayout { spacing: 8px; Text { text: @tr("Copy this content into a file and keep it separately from this device."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } ThemeEditor { text: root.export-output; read-only: true; height: 180px; } } } if root.import-modal-open : VerticalLayout { spacing: 10px; alignment: start; Rectangle { height: 8px; } Text { text: @tr("Importing replaces your saved profile. Back up your current keys first."); color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } ThemeEditor { text <=> root.import-keyfile-input; height: 150px; } ThemeInput { input-type: InputType.password; text <=> root.import-pass-input; placeholder-text: @tr("Backup passphrase, if set"); } if root.import-error != "" : Text { text: root.import-error; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; } HorizontalLayout { spacing: 9px; ActionButton { text: @tr("Import and replace"); danger: true; clicked => { root.import-keyfile(root.import-keyfile-input, root.import-pass-input); } } ActionButton { text: @tr("Collapse"); quiet: true; clicked => { root.import-modal-open = false; } } Rectangle { horizontal-stretch: 1; } } } Rectangle { height: 28px; } } }