-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsettings.slint
More file actions
72 lines (62 loc) · 2.84 KB
/
settings.slint
File metadata and controls
72 lines (62 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-FileCopyrightText: 2025 Foundation Devices, Inc. <hello@foundation.xyz>
// SPDX-License-Identifier: GPL-3.0-or-later
import { TR2, TrId } from "gen/tr.slint";
@rust-attr(derive(serde::Serialize, serde::Deserialize))
export enum DisplayAmount {
Auto,
Btc,
Sats,
}
@rust-attr(derive(serde::Serialize, serde::Deserialize, num_derive::FromPrimitive, num_derive::ToPrimitive))
export enum ShowFiatValue {
Disabled,
// Major currencies first
USD, EUR, GBP, JPY, AUD, CHF, CAD, INR, AED,
// Rest in alphabetical order
AFN, ALL, AMD, ANG, AOA, ARS, AWG, AZN, BAM,
BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL,
BSD, BTN, BWP, BYN, BZD, CDF, CLF, CLP, CNH,
CNY, COP, CRC, CUC, CUP, CVE, CZK, DJF, DKK,
DOP, DZD, EGP, ERN, ETB, FJD, FKP, GEL, GGP,
GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK,
HTG, HUF, IDR, ILS, IMP, IQD, IRR, ISK, JEP,
JMD, JOD, KES, KGS, KHR, KMF, KPW, KRW, KWD,
KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD,
MDL, MGA, MKD, MMK, MNT, MOP, MUR, MVR, MWK,
MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD,
OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR,
RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK,
SGD, SHP, SLL, SOS, SRD, SSP, STD, SVC, SYP,
SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD,
TZS, UAH, UGX, UYU, UZS, VES, VND, VUV, WST,
XAG, XAU, XCD, XDR, XPD, XPF, XPT, YER, ZAR,
ZMW, ZWL,
}
@rust-attr(derive(serde::Serialize, serde::Deserialize))
export enum ImportPolicy {
AskToImport,
RequireExisting,
SkipVerification,
}
export global Settings {
in-out property <DisplayAmount> display-amount;
callback set-display-amount(amount: DisplayAmount);
in-out property <ShowFiatValue> show-fiat-value;
callback set-show-fiat-value(value: ShowFiatValue);
out property <bool> show-fiat-value-enabled: show-fiat-value != ShowFiatValue.Disabled;
in-out property <[ShowFiatValue]> all-currencies;
callback search-show-fiat-value(text: string);
pure callback fiat-value-code(value: ShowFiatValue) -> string;
pure callback fiat-value-symbol(value: ShowFiatValue) -> string;
pure callback fiat-value-name(value: ShowFiatValue) -> string;
in-out property <ImportPolicy> import-policy;
callback set-import-policy(policy: ImportPolicy);
in-out property <bool> show-passphrase-warning;
callback set-show-passphrase-warning(show: bool);
public pure function display-amount-to-string(amount: DisplayAmount) -> string {
amount == DisplayAmount.Auto ? "Auto" : amount == DisplayAmount.Btc ? "BTC" : "Sats";
}
public pure function import-policy-to-string(policy: ImportPolicy) -> string {
policy == ImportPolicy.AskToImport ? TR2.lookup(TrId.SettingsPolicyAskToImport) : policy == ImportPolicy.RequireExisting ? TR2.lookup(TrId.SettingsPolicyRequireExisting) : TR2.lookup(TrId.SettingsPolicySkipVerification);
}
}