feat(client): add RU/EN localization and native capture preview
This commit is contained in:
parent
8e5ab56611
commit
8460fb28fd
43 changed files with 4103 additions and 275 deletions
67
src/main.rs
67
src/main.rs
|
|
@ -28,6 +28,7 @@ pub struct AppState {
|
|||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
ui::i18n::initialize();
|
||||
let filter = EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| EnvFilter::new("info,wgpu=warn,wgpu_hal=warn,naga=warn"));
|
||||
tracing_subscriber::fmt().with_env_filter(filter).init();
|
||||
|
|
@ -67,6 +68,7 @@ fn main() -> Result<()> {
|
|||
refresh_devices(&window);
|
||||
|
||||
wire_signals(&window, &state);
|
||||
ui::media::wire(&window)?;
|
||||
|
||||
let timer = slint::Timer::default();
|
||||
{
|
||||
|
|
@ -101,6 +103,7 @@ fn load_identity() -> Result<Option<identity::Identity>> {
|
|||
if let Ok(spec) = appearance.resolve() {
|
||||
crate::ui::appearance::apply_unlock(&dialog, &spec);
|
||||
}
|
||||
ui::i18n::set_language(ui::i18n::current());
|
||||
let unlocked = Rc::new(RefCell::new(None));
|
||||
let result = unlocked.clone();
|
||||
let weak = dialog.as_weak();
|
||||
|
|
@ -111,9 +114,12 @@ fn load_identity() -> Result<Option<identity::Identity>> {
|
|||
*result.borrow_mut() = Some(identity);
|
||||
let _ = dialog.hide();
|
||||
}
|
||||
Err(_) => {
|
||||
dialog.set_error("Не удалось открыть профиль. Проверь пароль.".into())
|
||||
}
|
||||
Err(_) => dialog.set_error(
|
||||
crate::ui::i18n::text(
|
||||
"Could not unlock your profile. Check your passphrase.",
|
||||
)
|
||||
.into(),
|
||||
),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -129,7 +135,7 @@ fn refresh_devices(window: &MainWindow) {
|
|||
let devices = vnox_client::audio::devices::enumerate().unwrap_or_default();
|
||||
let model = |mut items: Vec<String>| {
|
||||
if items.is_empty() {
|
||||
items.push("Default".into());
|
||||
items.push(crate::ui::i18n::text("Default"));
|
||||
}
|
||||
Rc::new(slint::VecModel::from(
|
||||
items
|
||||
|
|
@ -145,6 +151,7 @@ fn refresh_devices(window: &MainWindow) {
|
|||
|
||||
fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
|
||||
crate::ui::appearance::wire(window, state, !cfg!(test));
|
||||
ui::i18n::wire(window, !cfg!(test));
|
||||
crate::ui::avatar::wire(window, state, !cfg!(test));
|
||||
{
|
||||
let state = state.clone();
|
||||
|
|
@ -200,7 +207,10 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
|
|||
s.ui.vad_mode = mode.clamp(0, 2) as usize;
|
||||
s.ui.output_volume = volume.clamp(0.0, 100.0);
|
||||
if let Err(error) = crate::ui::preferences::save(&s.ui) {
|
||||
s.ui.status_msg = Some(format!("Cannot save audio settings: {error}"));
|
||||
s.ui.status_msg = Some(ui::i18n::Message::with(
|
||||
"Cannot save audio settings: {error}",
|
||||
vec![("error", error.to_string())],
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -288,7 +298,7 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
|
|||
let mut s = state.borrow_mut();
|
||||
s.ui.conn = ConnState::Connecting;
|
||||
s.ui.connect_input = addr.clone();
|
||||
s.ui.status_msg = Some("connecting...".into());
|
||||
s.ui.status_msg = Some("Connecting…".into());
|
||||
let auto_reconnect = s.ui.auto_reconnect;
|
||||
let net = s.net.clone();
|
||||
drop(s);
|
||||
|
|
@ -324,13 +334,13 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
|
|||
}
|
||||
let mut s = state.borrow_mut();
|
||||
if !matches!(s.ui.conn, ConnState::Connected { .. }) {
|
||||
s.ui.status_msg = Some("Нет соединения с сервером. Черновик сохранён.".into());
|
||||
s.ui.status_msg = Some("Not connected to a server. Your draft has been kept.".into());
|
||||
return;
|
||||
}
|
||||
if let Some(dm_id) = s.ui.active_dm_id.as_ref()
|
||||
&& s.ui.dm_conversations.iter().any(|c| &c.dm_id == dm_id && c.e2ee_enabled)
|
||||
{
|
||||
s.ui.status_msg = Some("Зашифрованные сообщения временно недоступны. Черновик сохранён; сообщение не отправлено.".into());
|
||||
s.ui.status_msg = Some("Encrypted messaging is temporarily unavailable. Your draft has been kept; the message was not sent.".into());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -531,12 +541,12 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
|
|||
window.on_set_passphrase(move |pass, confirm| {
|
||||
let mut s = state.borrow_mut();
|
||||
if pass != confirm {
|
||||
s.ui.settings_passphrase_error = Some("Passphrases do not match".to_string());
|
||||
s.ui.settings_passphrase_error = Some("Passphrases do not match".into());
|
||||
return;
|
||||
}
|
||||
if pass.len() < 8 {
|
||||
s.ui.settings_passphrase_error =
|
||||
Some("Passphrase must be at least 8 characters".to_string());
|
||||
Some("Passphrase must be at least 8 characters".into());
|
||||
return;
|
||||
}
|
||||
s.ui.settings_passphrase_error = None;
|
||||
|
|
@ -544,7 +554,12 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
|
|||
drop(s);
|
||||
match identity::save(&identity, Some(pass.as_str())) {
|
||||
Ok(()) => state.borrow_mut().ui.vault_enabled = true,
|
||||
Err(e) => state.borrow_mut().ui.settings_passphrase_error = Some(format!("{e}")),
|
||||
Err(e) => {
|
||||
state.borrow_mut().ui.settings_passphrase_error = Some(ui::i18n::Message::with(
|
||||
"Could not update profile: {error}",
|
||||
vec![("error", e.to_string())],
|
||||
))
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -557,7 +572,12 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
|
|||
drop(s);
|
||||
match identity::save(&identity, None) {
|
||||
Ok(()) => state.borrow_mut().ui.vault_enabled = false,
|
||||
Err(e) => state.borrow_mut().ui.settings_passphrase_error = Some(format!("{e}")),
|
||||
Err(e) => {
|
||||
state.borrow_mut().ui.settings_passphrase_error = Some(ui::i18n::Message::with(
|
||||
"Could not update profile: {error}",
|
||||
vec![("error", e.to_string())],
|
||||
))
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -567,7 +587,7 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
|
|||
window.on_export_keyfile(move |pass, confirm| {
|
||||
let mut s = state.borrow_mut();
|
||||
if pass != confirm {
|
||||
s.ui.settings_export_error = Some("Passphrases do not match".to_string());
|
||||
s.ui.settings_export_error = Some("Passphrases do not match".into());
|
||||
return;
|
||||
}
|
||||
let passphrase = if pass.is_empty() {
|
||||
|
|
@ -585,7 +605,10 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
|
|||
}
|
||||
Err(e) => {
|
||||
let mut s = state.borrow_mut();
|
||||
s.ui.settings_export_error = Some(format!("{e}"));
|
||||
s.ui.settings_export_error = Some(ui::i18n::Message::with(
|
||||
"Could not update profile: {error}",
|
||||
vec![("error", e.to_string())],
|
||||
));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -604,18 +627,22 @@ fn wire_signals(window: &MainWindow, state: &Rc<RefCell<AppState>>) {
|
|||
match identity::import_keyfile(&input, passphrase) {
|
||||
Ok(identity) => {
|
||||
if let Err(e) = identity::save(&identity, None) {
|
||||
s.ui.settings_import_error = Some(format!("{e}"));
|
||||
s.ui.settings_import_error = Some(ui::i18n::Message::with(
|
||||
"Could not update profile: {error}",
|
||||
vec![("error", e.to_string())],
|
||||
));
|
||||
} else {
|
||||
s.ui.settings_import_error = None;
|
||||
s.ui.vault_enabled = false;
|
||||
s.ui.status_msg = Some(
|
||||
"Профиль импортирован. Перезапусти Vnox, чтобы войти с новыми ключами."
|
||||
.into(),
|
||||
);
|
||||
s.ui.status_msg =
|
||||
Some("Profile imported. Restart Vnox to use your new keys.".into());
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
s.ui.settings_import_error = Some(format!("{e}"));
|
||||
s.ui.settings_import_error = Some(ui::i18n::Message::with(
|
||||
"Could not update profile: {error}",
|
||||
vec![("error", e.to_string())],
|
||||
));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue