ui: update i18n lib
This commit is contained in:
Generated
+50
-73
@@ -1021,6 +1021,12 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
|
||||
|
||||
[[package]]
|
||||
name = "base62"
|
||||
version = "2.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1adf9755786e27479693dedd3271691a92b5e242ab139cacb9fb8e7fb5381111"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.9.3"
|
||||
@@ -5431,6 +5437,15 @@ version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.13.0"
|
||||
@@ -5846,7 +5861,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde-value",
|
||||
"serde_json",
|
||||
"serde_yaml 0.9.34+deprecated",
|
||||
"serde_yaml",
|
||||
"thiserror 2.0.18",
|
||||
"thread-id",
|
||||
"typemap-ors",
|
||||
@@ -8519,22 +8534,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n"
|
||||
version = "2.3.1"
|
||||
version = "3.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0689038d25403d8f4437ef84070cacf8c438a9f66fa27402ffaa5d426c6c1019"
|
||||
checksum = "fda2551fdfaf6cc5ee283adc15e157047b92ae6535cf80f6d4962d05717dc332"
|
||||
dependencies = [
|
||||
"globwalk",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"rust-i18n-macro",
|
||||
"rust-i18n-support",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n-macro"
|
||||
version = "2.3.1"
|
||||
version = "3.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8531ce329f57af4dc91cb56f22e17eeb6507f7e80d09c24073fc2c9d334624f1"
|
||||
checksum = "22baf7d7f56656d23ebe24f6bb57a5d40d2bce2a5f1c503e692b5b2fa450f965"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"once_cell",
|
||||
@@ -8543,17 +8559,20 @@ dependencies = [
|
||||
"rust-i18n-support",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml 0.8.26",
|
||||
"serde_yaml",
|
||||
"syn 2.0.114",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-i18n-support"
|
||||
version = "2.3.0"
|
||||
version = "3.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "151a35407f48bac5521e9c9813d1ec97289a36aca4ad6444ab9430fd76835b71"
|
||||
checksum = "940ed4f52bba4c0152056d771e563b7133ad9607d4384af016a134b58d758f19"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"base62",
|
||||
"globwalk",
|
||||
"itertools 0.11.0",
|
||||
"lazy_static",
|
||||
"normpath",
|
||||
"once_cell",
|
||||
@@ -8561,8 +8580,10 @@ dependencies = [
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml 0.8.26",
|
||||
"toml 0.7.8",
|
||||
"serde_yaml",
|
||||
"siphasher 1.0.2",
|
||||
"toml 0.8.23",
|
||||
"triomphe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9066,18 +9087,6 @@ dependencies = [
|
||||
"syn 2.0.114",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.8.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b"
|
||||
dependencies = [
|
||||
"indexmap 1.9.3",
|
||||
"ryu",
|
||||
"serde",
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.9.34+deprecated"
|
||||
@@ -10063,18 +10072,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.7.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned 0.6.9",
|
||||
"toml_datetime 0.6.11",
|
||||
"toml_edit 0.19.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.23"
|
||||
@@ -10099,7 +10096,7 @@ dependencies = [
|
||||
"toml_datetime 0.7.5+spec-1.1.0",
|
||||
"toml_parser",
|
||||
"toml_writer",
|
||||
"winnow 0.7.14",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -10120,19 +10117,6 @@ dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.19.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
|
||||
dependencies = [
|
||||
"indexmap 2.13.0",
|
||||
"serde",
|
||||
"serde_spanned 0.6.9",
|
||||
"toml_datetime 0.6.11",
|
||||
"winnow 0.5.40",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.27"
|
||||
@@ -10144,7 +10128,7 @@ dependencies = [
|
||||
"serde_spanned 0.6.9",
|
||||
"toml_datetime 0.6.11",
|
||||
"toml_write",
|
||||
"winnow 0.7.14",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -10156,7 +10140,7 @@ dependencies = [
|
||||
"indexmap 2.13.0",
|
||||
"toml_datetime 0.7.5+spec-1.1.0",
|
||||
"toml_parser",
|
||||
"winnow 0.7.14",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -10165,7 +10149,7 @@ version = "1.0.6+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44"
|
||||
dependencies = [
|
||||
"winnow 0.7.14",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -11388,6 +11372,17 @@ dependencies = [
|
||||
"syn 2.0.114",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "triomphe"
|
||||
version = "0.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd69c5aa8f924c7519d6372789a74eac5b94fb0f8fcf0d4a97eb0bfc3e785f39"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"serde",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "try-lock"
|
||||
version = "0.2.5"
|
||||
@@ -12877,15 +12872,6 @@ dependencies = [
|
||||
"xkbcommon-dl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.5.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.7.14"
|
||||
@@ -13132,15 +13118,6 @@ version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448"
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
|
||||
dependencies = [
|
||||
"linked-hash-map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yoke"
|
||||
version = "0.8.1"
|
||||
@@ -13193,7 +13170,7 @@ dependencies = [
|
||||
"uds_windows",
|
||||
"uuid 1.20.0",
|
||||
"windows-sys 0.61.2",
|
||||
"winnow 0.7.14",
|
||||
"winnow",
|
||||
"zbus_macros",
|
||||
"zbus_names",
|
||||
"zvariant",
|
||||
@@ -13245,7 +13222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffd8af6d5b78619bab301ff3c560a5bd22426150253db278f164d6cf3b72c50f"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"winnow 0.7.14",
|
||||
"winnow",
|
||||
"zvariant",
|
||||
]
|
||||
|
||||
@@ -13449,7 +13426,7 @@ dependencies = [
|
||||
"endi",
|
||||
"enumflags2",
|
||||
"serde",
|
||||
"winnow 0.7.14",
|
||||
"winnow",
|
||||
"zvariant_derive",
|
||||
"zvariant_utils",
|
||||
]
|
||||
@@ -13477,5 +13454,5 @@ dependencies = [
|
||||
"quote 1.0.44",
|
||||
"serde",
|
||||
"syn 2.0.114",
|
||||
"winnow 0.7.14",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ grin_wallet_controller = { path = "wallet/controller" }
|
||||
egui = { version = "0.33.3", default-features = false }
|
||||
egui_extras = { version = "0.33.3", features = ["image", "svg"] }
|
||||
egui-async = "0.3.4"
|
||||
rust-i18n = "2.3.1"
|
||||
rust-i18n = "3.1.5"
|
||||
|
||||
## other
|
||||
anyhow = "1.0.97"
|
||||
|
||||
@@ -25,7 +25,7 @@ use crate::gui::Colors;
|
||||
|
||||
/// Type of button.
|
||||
pub enum FilePickContentType {
|
||||
Button, ItemButton(CornerRadius), Tab
|
||||
Button(String), ItemButton(CornerRadius), Tab
|
||||
}
|
||||
|
||||
/// Button to pick file and parse its data into text.
|
||||
@@ -116,9 +116,9 @@ impl FilePickContent {
|
||||
}
|
||||
} else {
|
||||
// Draw button to pick file.
|
||||
match self.content_type {
|
||||
FilePickContentType::Button => {
|
||||
let text = format!("{} {}", ARCHIVE_BOX, t!("choose_file"));
|
||||
match &self.content_type {
|
||||
FilePickContentType::Button(text) => {
|
||||
let text = format!("{} {}", ARCHIVE_BOX, text);
|
||||
let text_color = Colors::blue();
|
||||
let fill = Colors::white_or_black(false);
|
||||
View::colored_text_button(ui, text, text_color, fill, || {
|
||||
@@ -126,7 +126,7 @@ impl FilePickContent {
|
||||
});
|
||||
}
|
||||
FilePickContentType::ItemButton(r) => {
|
||||
View::item_button(ui, r, ARCHIVE_BOX, Some(Colors::blue()), || {
|
||||
View::item_button(ui, r.clone(), ARCHIVE_BOX, Some(Colors::blue()), || {
|
||||
self.on_file_pick(pick, cb);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ impl KeyboardContent {
|
||||
/// Draw input button.
|
||||
fn input_button_ui(&mut self, s: &str, translate: bool, ui: &mut egui::Ui) -> Rect {
|
||||
let value = if translate {
|
||||
t!(format!("keyboard.{}", s).as_str(), locale = Self::input_locale().as_str())
|
||||
t!(format!("keyboard.{}", s), locale = Self::input_locale().as_str()).into()
|
||||
} else {
|
||||
s.to_string()
|
||||
};
|
||||
|
||||
@@ -104,8 +104,8 @@ impl Modal {
|
||||
}
|
||||
|
||||
/// Set title text on [`Modal`] creation.
|
||||
pub fn title(mut self, title: String) -> Self {
|
||||
self.title = Some(title.to_uppercase());
|
||||
pub fn title(mut self, title: impl Into<String>) -> Self {
|
||||
self.title = Some(title.into().to_uppercase());
|
||||
self
|
||||
}
|
||||
|
||||
@@ -157,11 +157,11 @@ impl Modal {
|
||||
}
|
||||
|
||||
/// Set title text for current opened [`Modal`].
|
||||
pub fn set_title(title: String) {
|
||||
pub fn set_title(title: impl Into<String>) {
|
||||
let mut w_state = MODAL_STATE.write();
|
||||
if w_state.modal.is_some() {
|
||||
let mut modal = w_state.modal.clone().unwrap();
|
||||
modal.title = Some(title.to_uppercase());
|
||||
modal.title = Some(title.into().to_uppercase());
|
||||
w_state.modal = Some(modal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,9 +173,9 @@ impl ConnectionsContent {
|
||||
DOTS_THREE_CIRCLE
|
||||
};
|
||||
let status_text = format!("{} {}", status_icon, if has_error {
|
||||
t!("error")
|
||||
t!("error").into()
|
||||
} else {
|
||||
Node::get_sync_status_text()
|
||||
Node::get_sync_status_text().into()
|
||||
});
|
||||
View::ellipsize_text(ui, status_text, 15.0, Colors::text(false));
|
||||
ui.add_space(1.0);
|
||||
|
||||
@@ -140,7 +140,7 @@ impl NetworkContent {
|
||||
disabled_node_ui(ui);
|
||||
} else if Node::get_stats().is_none() || Node::is_restarting() ||
|
||||
Node::is_stopping() {
|
||||
NetworkContent::loading_ui(ui, None);
|
||||
NetworkContent::loading_ui(ui, None::<String>);
|
||||
} else {
|
||||
self.node_tab_content.tab_ui(ui, cb);
|
||||
}
|
||||
@@ -278,14 +278,14 @@ impl NetworkContent {
|
||||
|
||||
// Setup values for title panel.
|
||||
let title_text = self.node_tab_content.get_type().title();
|
||||
let subtitle_text = Node::get_sync_status_text();
|
||||
let subtitle_text = Node::get_sync_status_text().into();
|
||||
let not_syncing = Node::not_syncing() && !Node::data_dir_changing();
|
||||
let title_content = if show_settings {
|
||||
TitleContentType::Title(t!("settings"))
|
||||
TitleContentType::Title(t!("settings").into())
|
||||
} else if !show_connections {
|
||||
TitleContentType::WithSubTitle(title_text, subtitle_text, !not_syncing)
|
||||
} else {
|
||||
TitleContentType::Title(t!("network.connections"))
|
||||
TitleContentType::Title(t!("network.connections").into())
|
||||
};
|
||||
|
||||
// Draw title panel.
|
||||
@@ -313,7 +313,7 @@ impl NetworkContent {
|
||||
}
|
||||
|
||||
/// Content to draw on loading.
|
||||
pub fn loading_ui(ui: &mut egui::Ui, text: Option<String>) {
|
||||
pub fn loading_ui(ui: &mut egui::Ui, text: Option<impl Into<String>>) {
|
||||
match text {
|
||||
None => {
|
||||
ui.centered_and_justified(|ui| {
|
||||
|
||||
@@ -392,9 +392,9 @@ impl P2PSetup {
|
||||
};
|
||||
// Select modal title.
|
||||
let modal_title = match peer_type {
|
||||
PeerType::Allowed => t!("network_settings.allow_list"),
|
||||
PeerType::Denied => t!("network_settings.deny_list"),
|
||||
PeerType::Preferred => t!("network_settings.favourites"),
|
||||
PeerType::Allowed => t!("network_settings.allow_list").into(),
|
||||
PeerType::Denied => t!("network_settings.deny_list").into(),
|
||||
PeerType::Preferred => t!("network_settings.favourites").into(),
|
||||
_ => DNS_SEEDS_TITLE.to_string()
|
||||
};
|
||||
// Show modal to add peer.
|
||||
|
||||
@@ -32,10 +32,10 @@ pub enum NodeTabType {
|
||||
impl NodeTabType {
|
||||
pub fn title(&self) -> String {
|
||||
match *self {
|
||||
NodeTabType::Info => { t!("network.node") }
|
||||
NodeTabType::Metrics => { t!("network.metrics") }
|
||||
NodeTabType::Mining => { t!("network.mining") }
|
||||
NodeTabType::Settings => { t!("network.settings") }
|
||||
NodeTabType::Info => t!("network.node").into(),
|
||||
NodeTabType::Metrics => t!("network.metrics").into(),
|
||||
NodeTabType::Mining => t!("network.mining").into(),
|
||||
NodeTabType::Settings => t!("network.settings").into()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ impl Default for InterfaceSettingsContent {
|
||||
let locale = if let Some(lang) = AppConfig::locale() {
|
||||
lang
|
||||
} else {
|
||||
rust_i18n::locale()
|
||||
rust_i18n::locale().to_string()
|
||||
};
|
||||
Self {
|
||||
locale,
|
||||
|
||||
@@ -244,7 +244,7 @@ impl NetworkSettingsContent {
|
||||
(url, Colors::title(false), CLOUD_CHECK, t!("network_settings.enabled"))
|
||||
} else {
|
||||
(
|
||||
t!("enter_url"),
|
||||
t!("enter_url").into(),
|
||||
Colors::inactive_text(),
|
||||
CLOUD_SLASH,
|
||||
t!("network_settings.disabled")
|
||||
|
||||
+27
-20
@@ -119,8 +119,8 @@ impl View {
|
||||
}
|
||||
|
||||
/// Cut long text with ﹍ character.
|
||||
fn ellipsize(text: String, size: f32, color: Color32) -> LayoutJob {
|
||||
let mut job = LayoutJob::single_section(text, TextFormat {
|
||||
fn ellipsize(text: impl Into<String>, size: f32, color: Color32) -> LayoutJob {
|
||||
let mut job = LayoutJob::single_section(text.into(), TextFormat {
|
||||
font_id: FontId::proportional(size), color, ..Default::default()
|
||||
});
|
||||
job.wrap = TextWrapping {
|
||||
@@ -133,12 +133,16 @@ impl View {
|
||||
}
|
||||
|
||||
/// Draw ellipsized text.
|
||||
pub fn ellipsize_text(ui: &mut egui::Ui, text: String, size: f32, color: Color32) {
|
||||
pub fn ellipsize_text(ui: &mut egui::Ui, text: impl Into<String>, size: f32, color: Color32) {
|
||||
ui.label(Self::ellipsize(text, size, color));
|
||||
}
|
||||
|
||||
/// Draw animated ellipsized text.
|
||||
pub fn animate_text(ui: &mut egui::Ui, text: String, size: f32, color: Color32, animate: bool) {
|
||||
pub fn animate_text(ui: &mut egui::Ui,
|
||||
text: impl Into<String>,
|
||||
size: f32,
|
||||
color: Color32,
|
||||
animate: bool) {
|
||||
// Setup text color animation if needed.
|
||||
let (dark, bright) = (0.3, 1.0);
|
||||
let color_factor = if animate {
|
||||
@@ -287,10 +291,10 @@ impl View {
|
||||
}
|
||||
|
||||
/// Draw [`Button`] with specified background fill color and default text color.
|
||||
pub fn button(ui: &mut egui::Ui, text: String, fill: Color32, action: impl FnOnce()) {
|
||||
let br = Self::button_resp(ui, text, Colors::text_button(), fill);
|
||||
pub fn button(ui: &mut egui::Ui, text: impl Into<String>, fill: Color32, cb: impl FnOnce()) {
|
||||
let br = Self::button_resp(ui, text.into(), Colors::text_button(), fill);
|
||||
if br.clicked() {
|
||||
action();
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,16 +324,16 @@ impl View {
|
||||
|
||||
/// Draw gold action [`Button`].
|
||||
pub fn action_button(ui: &mut egui::Ui,
|
||||
text: String, action: impl FnOnce()) {
|
||||
Self::colored_text_button(ui, text, Colors::title(true), Colors::gold(), action);
|
||||
text: impl Into<String>, action: impl FnOnce()) {
|
||||
Self::colored_text_button(ui, text.into(), Colors::title(true), Colors::gold(), action);
|
||||
}
|
||||
|
||||
/// Draw [`Button`] with specified background fill color and ui at callback.
|
||||
pub fn button_ui(ui: &mut egui::Ui,
|
||||
text: String,
|
||||
text: impl Into<String>,
|
||||
fill: Color32,
|
||||
action: impl FnOnce(&mut egui::Ui)) {
|
||||
let button_text = Self::ellipsize(text.to_uppercase(), 17.0, Colors::text_button());
|
||||
let button_text = Self::ellipsize(text.into().to_uppercase(), 17.0, Colors::text_button());
|
||||
let br = Button::new(button_text)
|
||||
.stroke(Self::default_stroke())
|
||||
.fill(fill)
|
||||
@@ -443,7 +447,7 @@ impl View {
|
||||
/// where is r = (top_left, top_right, bottom_left, bottom_right).
|
||||
/// | VALUE |
|
||||
/// | label |
|
||||
pub fn label_box(ui: &mut egui::Ui, text: String, label: String, r: [bool; 4]) {
|
||||
pub fn label_box(ui: &mut egui::Ui, v: impl Into<String>, l: impl Into<String>, r: [bool; 4]) {
|
||||
let rect = ui.available_rect_before_wrap();
|
||||
|
||||
// Create background shape.
|
||||
@@ -464,7 +468,7 @@ impl View {
|
||||
ui.style_mut().spacing.item_spacing.y = -3.0;
|
||||
|
||||
// Draw box value.
|
||||
let mut job = LayoutJob::single_section(text, TextFormat {
|
||||
let mut job = LayoutJob::single_section(v.into(), TextFormat {
|
||||
font_id: FontId::proportional(17.0),
|
||||
color: Colors::white_or_black(true),
|
||||
..Default::default()
|
||||
@@ -478,7 +482,7 @@ impl View {
|
||||
ui.label(job);
|
||||
|
||||
// Draw box label.
|
||||
ui.label(RichText::new(label).color(Colors::gray()).size(15.0));
|
||||
ui.label(RichText::new(l).color(Colors::gray()).size(15.0));
|
||||
});
|
||||
ui.add_space(2.0);
|
||||
});
|
||||
@@ -524,10 +528,10 @@ impl View {
|
||||
}
|
||||
|
||||
/// Draw the button that looks like checkbox with callback on check.
|
||||
pub fn checkbox(ui: &mut egui::Ui, checked: bool, text: String, action: impl FnOnce()) {
|
||||
pub fn checkbox(ui: &mut egui::Ui, checked: bool, text: impl Into<String>, cb: impl FnOnce()) {
|
||||
let (text_value, color) = match checked {
|
||||
true => (format!("{} {}", CHECK_SQUARE, text), Colors::text_button()),
|
||||
false => (format!("{} {}", SQUARE, text), Colors::checkbox())
|
||||
true => (format!("{} {}", CHECK_SQUARE, text.into()), Colors::text_button()),
|
||||
false => (format!("{} {}", SQUARE, text.into()), Colors::checkbox())
|
||||
};
|
||||
|
||||
let br = Button::new(RichText::new(text_value).size(17.0).color(color))
|
||||
@@ -537,18 +541,21 @@ impl View {
|
||||
.ui(ui)
|
||||
.on_hover_cursor(CursorIcon::PointingHand);
|
||||
if br.clicked() {
|
||||
action();
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
/// Show a [`RadioButton`]. It is selected if `*current_value == selected_value`.
|
||||
/// If clicked, `selected_value` is assigned to `*current_value`.
|
||||
pub fn radio_value<T: PartialEq>(ui: &mut egui::Ui, current: &mut T, value: T, text: String) {
|
||||
pub fn radio_value<T: PartialEq>(ui: &mut egui::Ui,
|
||||
current: &mut T,
|
||||
value: T,
|
||||
text: impl Into<String>) {
|
||||
ui.scope(|ui| {
|
||||
// Setup background color.
|
||||
ui.visuals_mut().widgets.inactive.bg_fill = Colors::fill_deep();
|
||||
// Draw radio button.
|
||||
let mut response = ui.radio(*current == value, text)
|
||||
let mut response = ui.radio(*current == value, text.into())
|
||||
.on_hover_cursor(CursorIcon::PointingHand);
|
||||
if response.clicked() && *current != value {
|
||||
*current = value;
|
||||
|
||||
@@ -424,7 +424,7 @@ impl WalletsContent {
|
||||
// Setup title.
|
||||
let title_content = if show_wallet && (!dual_panel
|
||||
|| (dual_panel && !show_list)) && !creating_wallet && !showing_settings {
|
||||
let title = self.wallet_content.title();
|
||||
let title = self.wallet_content.title().into();
|
||||
let subtitle = self.wallets.selected().unwrap().get_config().name;
|
||||
TitleType::Single(TitleContentType::WithSubTitle(title, subtitle, false))
|
||||
} else {
|
||||
@@ -434,11 +434,11 @@ impl WalletsContent {
|
||||
t!("wallets.add")
|
||||
} else {
|
||||
t!("wallets.title")
|
||||
};
|
||||
}.into();
|
||||
let dual_title = !showing_settings && !creating_wallet &&
|
||||
show_wallet && dual_panel;
|
||||
if dual_title {
|
||||
let title = self.wallet_content.title();
|
||||
let title = self.wallet_content.title().into();
|
||||
let subtitle = self.wallets.selected().unwrap().get_config().name;
|
||||
let wallet_title_content = TitleContentType::WithSubTitle(title, subtitle, false);
|
||||
TitleType::Dual(TitleContentType::Title(title_text), wallet_title_content)
|
||||
|
||||
@@ -213,7 +213,7 @@ impl WalletCreationContent {
|
||||
.color(Colors::red()));
|
||||
ui.add_space(10.0);
|
||||
} else {
|
||||
ui.label(RichText::new(&t!("wallets.not_valid_phrase"))
|
||||
ui.label(RichText::new(t!("wallets.not_valid_phrase"))
|
||||
.size(16.0)
|
||||
.color(Colors::red()));
|
||||
ui.add_space(4.0);
|
||||
@@ -303,7 +303,7 @@ impl WalletCreationContent {
|
||||
let (next_text, text_color, bg_color) = if self.step == Step::SetupConnection {
|
||||
(format!("{} {}", CHECK, t!("complete")), Colors::title(true), Colors::gold())
|
||||
} else {
|
||||
(t!("continue"), Colors::green(), Colors::white_or_black(false))
|
||||
(t!("continue").into(), Colors::green(), Colors::white_or_black(false))
|
||||
};
|
||||
|
||||
// Show next step button.
|
||||
|
||||
@@ -30,7 +30,7 @@ pub struct AddWalletModal {
|
||||
impl Default for AddWalletModal {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name_edit: t!("wallets.default_wallet"),
|
||||
name_edit: t!("wallets.default_wallet").into(),
|
||||
pass_edit: "".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ impl AccountContent {
|
||||
let account = wallet.get_config().account;
|
||||
let default_acc_label = WalletConfig::DEFAULT_ACCOUNT_LABEL.to_string();
|
||||
let acc_label = if account == default_acc_label {
|
||||
t!("wallets.default_account")
|
||||
t!("wallets.default_account").into()
|
||||
} else {
|
||||
account.to_owned()
|
||||
};
|
||||
|
||||
@@ -111,7 +111,7 @@ impl WalletAccountsContent {
|
||||
// Show account name.
|
||||
let default_acc_label = WalletConfig::DEFAULT_ACCOUNT_LABEL.to_string();
|
||||
let acc_label = if acc.label == default_acc_label {
|
||||
t!("wallets.default_account")
|
||||
t!("wallets.default_account").into()
|
||||
} else {
|
||||
acc.label.to_owned()
|
||||
};
|
||||
|
||||
@@ -313,7 +313,7 @@ impl Default for WalletContent {
|
||||
|
||||
impl WalletContent {
|
||||
/// Get title based on current navigation state.
|
||||
pub fn title(&self) -> String {
|
||||
pub fn title(&self) -> impl Into<String> {
|
||||
if self.account_content.qr_scan_showing() {
|
||||
t!("scan_qr")
|
||||
} else if self.account_content.list_content.is_some() {
|
||||
@@ -595,26 +595,26 @@ fn sync_progress_ui(ui: &mut egui::Ui, wallet: &Wallet) {
|
||||
let info_progress = wallet.info_sync_progress();
|
||||
|
||||
if wallet.files_moving() {
|
||||
t!("moving_files")
|
||||
t!("moving_files").into()
|
||||
} else if wallet.is_closing() {
|
||||
t!("wallets.wallet_closing")
|
||||
t!("wallets.wallet_closing").into()
|
||||
} else if int_node && !int_ready {
|
||||
t!("wallets.node_loading", "settings" => GEAR_FINE)
|
||||
t!("wallets.node_loading", "settings" => GEAR_FINE).into()
|
||||
} else if wallet.is_repairing() {
|
||||
let repair_progress = wallet.repairing_progress();
|
||||
if repair_progress == 0 {
|
||||
t!("wallets.wallet_checking")
|
||||
t!("wallets.wallet_checking").into()
|
||||
} else {
|
||||
format!("{}: {}%", t!("wallets.wallet_checking"), repair_progress)
|
||||
}
|
||||
} else if info_progress != 100 {
|
||||
if info_progress == 0 {
|
||||
t!("wallets.wallet_loading")
|
||||
t!("wallets.wallet_loading").into()
|
||||
} else {
|
||||
format!("{}: {}%", t!("wallets.wallet_loading"), info_progress)
|
||||
}
|
||||
} else {
|
||||
t!("wallets.tx_loading")
|
||||
t!("wallets.tx_loading").into()
|
||||
}
|
||||
};
|
||||
ui.label(RichText::new(text).size(16.0).color(Colors::inactive_text()));
|
||||
|
||||
@@ -46,7 +46,9 @@ impl Default for MessageInputContent {
|
||||
message_edit: "".to_string(),
|
||||
parse_error: false,
|
||||
scan_qr_content: None,
|
||||
file_pick_button: FilePickContent::new(FilePickContentType::Button),
|
||||
file_pick_button: FilePickContent::new(
|
||||
FilePickContentType::Button(t!("choose_file").into())
|
||||
),
|
||||
proof_content: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ impl PaymentProofContent {
|
||||
pub fn new(proof_text: Option<String>) -> Self {
|
||||
Self {
|
||||
input_edit: proof_text.unwrap_or("".to_string()),
|
||||
pick_button: FilePickContent::new(FilePickContentType::Button),
|
||||
pick_button: FilePickContent::new(FilePickContentType::Button(t!("file").into())),
|
||||
parse_error: false,
|
||||
validation_result: None,
|
||||
}
|
||||
@@ -159,7 +159,7 @@ impl PaymentProofContent {
|
||||
ui.add_space(6.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
let (desc_text, color) = if tx.data.tx_type == TxLogEntryType::TxReceived {
|
||||
(t!("wallets.payment_proof_valid"), Colors::green())
|
||||
(t!("wallets.payment_proof_valid").into(), Colors::green())
|
||||
} else {
|
||||
(format!("{}:", t!("wallets.payment_proof")), Colors::inactive_text())
|
||||
};
|
||||
|
||||
@@ -573,7 +573,7 @@ impl WalletTransactionsContent {
|
||||
}
|
||||
|
||||
/// Draw awaiting balance item content.
|
||||
fn awaiting_item_ui(ui: &mut egui::Ui, amount: u64, label: String) {
|
||||
fn awaiting_item_ui(ui: &mut egui::Ui, amount: u64, label: impl Into<String>) {
|
||||
let rect = ui.available_rect_before_wrap();
|
||||
View::line(ui, LinePosition::TOP, &rect, Colors::item_stroke());
|
||||
ui.add_space(4.0);
|
||||
|
||||
+1
-2
@@ -14,6 +14,7 @@
|
||||
|
||||
#[macro_use]
|
||||
extern crate rust_i18n;
|
||||
rust_i18n::i18n!("locales");
|
||||
|
||||
use eframe::NativeOptions;
|
||||
use egui::{Context, Stroke, Theme};
|
||||
@@ -32,8 +33,6 @@ use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::View;
|
||||
use crate::node::Node;
|
||||
|
||||
i18n!("locales");
|
||||
|
||||
mod node;
|
||||
mod wallet;
|
||||
mod tor;
|
||||
|
||||
+1
-1
@@ -456,7 +456,7 @@ impl Node {
|
||||
}
|
||||
|
||||
/// Get synchronization status i18n text.
|
||||
pub fn get_sync_status_text() -> String {
|
||||
pub fn get_sync_status_text() -> impl Into<String> {
|
||||
if Node::data_dir_changing() {
|
||||
return t!("moving_files");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user