Confirm language changes with timed rollback
This commit is contained in:
parent
6da8772210
commit
5359f31438
|
|
@ -451,5 +451,9 @@
|
|||
"viewport.screen": "SCREEN 1",
|
||||
"viewport.offline": "OFFLINE",
|
||||
"viewport.pixels": "Screen pixels / %{width} × %{height}",
|
||||
"language.font-license": "Font licenses"
|
||||
"language.font-license": "Font licenses",
|
||||
"language.confirm": "Does this new language choice suit you?",
|
||||
"language.keep": "Yes",
|
||||
"language.rollback": "Your previous language returns in %{seconds} seconds unless you confirm.",
|
||||
"language.cancel": "No, I clicked on this language by accident"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,5 +451,9 @@
|
|||
"viewport.screen": "SCREEN 1",
|
||||
"viewport.offline": "SENKONEKTE",
|
||||
"viewport.pixels": "Ekranaj bilderoj / %{width} × %{height}",
|
||||
"language.font-license": "Tiparaj permesiloj"
|
||||
"language.font-license": "Tiparaj permesiloj",
|
||||
"language.confirm": "Ĉu ĉi tiu nova lingvo taŭgas por vi?",
|
||||
"language.keep": "Jes",
|
||||
"language.rollback": "Sen konfirmo, la antaŭa lingvo revenos post %{seconds} sekundoj.",
|
||||
"language.cancel": "Ne, mi elektis ĉi tiun lingvon erare"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,5 +451,9 @@
|
|||
"viewport.screen": "SCREEN 1",
|
||||
"viewport.offline": "SIN CONEXIÓN",
|
||||
"viewport.pixels": "Píxeles de pantalla / %{width} × %{height}",
|
||||
"language.font-license": "Licencias de fuentes"
|
||||
"language.font-license": "Licencias de fuentes",
|
||||
"language.confirm": "¿Te parece bien este nuevo idioma?",
|
||||
"language.keep": "Sí",
|
||||
"language.rollback": "Si no confirmas, se volverá al idioma anterior en %{seconds} segundos.",
|
||||
"language.cancel": "No, elegí este idioma por accidente"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,5 +451,9 @@
|
|||
"viewport.screen": "ÉCRAN 1",
|
||||
"viewport.offline": "HORS LIGNE",
|
||||
"viewport.pixels": "Pixels écran / %{width} × %{height}",
|
||||
"language.font-license": "Licences des polices"
|
||||
"language.font-license": "Licences des polices",
|
||||
"language.confirm": "Ce nouveau choix de langue vous convient-il ?",
|
||||
"language.keep": "Oui",
|
||||
"language.rollback": "Sans confirmation, la langue précédente sera rétablie dans %{seconds} secondes.",
|
||||
"language.cancel": "Non, j’ai choisi cette langue par erreur"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,5 +451,9 @@
|
|||
"viewport.screen": "SCREEN 1",
|
||||
"viewport.offline": "Ἄνευ συνδέσεως",
|
||||
"viewport.pixels": "Ψηφῖδες πετάσματος / %{width} × %{height}",
|
||||
"language.font-license": "Ἄδειαι γραμματοσειρῶν"
|
||||
"language.font-license": "Ἄδειαι γραμματοσειρῶν",
|
||||
"language.confirm": "Ἆρά σοι ἀρέσκει ἡ νέα γλῶττα;",
|
||||
"language.keep": "Ναί",
|
||||
"language.rollback": "Ἡ προτέρα γλῶττα ἐπανήξει μετὰ %{seconds} δευτερόλεπτα, ἐὰν μὴ βεβαιώσῃς.",
|
||||
"language.cancel": "Οὔ, κατὰ τύχην ταύτην τὴν γλῶτταν εἱλόμην"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,5 +451,9 @@
|
|||
"viewport.screen": "SCREEN 1",
|
||||
"viewport.offline": "オフライン",
|
||||
"viewport.pixels": "画面ピクセル / %{width} × %{height}",
|
||||
"language.font-license": "フォントのライセンス"
|
||||
"language.font-license": "フォントのライセンス",
|
||||
"language.confirm": "この言語設定でよろしいですか?",
|
||||
"language.keep": "はい",
|
||||
"language.rollback": "確認しない場合、%{seconds} 秒後に元の言語に戻ります。",
|
||||
"language.cancel": "いいえ、間違えてこの言語を選びました"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,5 +451,9 @@
|
|||
"viewport.screen": "SCREEN 1",
|
||||
"viewport.offline": "离线",
|
||||
"viewport.pixels": "屏幕像素 / %{width} × %{height}",
|
||||
"language.font-license": "字体许可证"
|
||||
"language.font-license": "字体许可证",
|
||||
"language.confirm": "您要保留这个语言选择吗?",
|
||||
"language.keep": "是",
|
||||
"language.rollback": "如果不确认,将在 %{seconds} 秒后恢复原来的语言。",
|
||||
"language.cancel": "不,我不小心选错了语言"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ pub struct Editor {
|
|||
layer_ui: layers_ui::LayerUi,
|
||||
settings: settings::Store,
|
||||
language: localization::Language,
|
||||
language_preview: Option<preferences_ui::LanguagePreview>,
|
||||
recovery: recovery_ui::Recovery,
|
||||
themes_open: bool,
|
||||
preferences_open: bool,
|
||||
|
|
@ -363,6 +364,7 @@ impl Default for Editor {
|
|||
capture: Default::default(),
|
||||
layer_ui: Default::default(),
|
||||
language: localization::Language::default(),
|
||||
language_preview: None,
|
||||
settings: settings::Store::default(),
|
||||
recovery: recovery_ui::Recovery::default(),
|
||||
themes_open: false,
|
||||
|
|
@ -504,7 +506,10 @@ impl Editor {
|
|||
}
|
||||
fn application_settings(&self, ctx: &egui::Context) -> settings::Settings {
|
||||
settings::Settings {
|
||||
language: self.language,
|
||||
language: self
|
||||
.language_preview
|
||||
.as_ref()
|
||||
.map_or(self.language, |preview| preview.previous),
|
||||
midra_host: self.device.host.clone(),
|
||||
recent_midra_hosts: self.device.recent_hosts.clone(),
|
||||
autoconnect_at_startup: self.device.autoconnect_at_startup,
|
||||
|
|
@ -3906,6 +3911,10 @@ fn click(ui: &egui::Ui, ink: &Ink, b: [f32; 4], id: impl std::hash::Hash) -> boo
|
|||
}
|
||||
impl Editor {
|
||||
fn ui(&mut self, ctx: &egui::Context) {
|
||||
self.main_ui(ctx);
|
||||
self.language_confirmation(ctx);
|
||||
}
|
||||
fn main_ui(&mut self, ctx: &egui::Context) {
|
||||
if self.fields_edited
|
||||
&& self.fields_pending()
|
||||
&& !self.layout.dragging()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,95 @@ impl Section {
|
|||
(Self::Device, "ui.device-integration"),
|
||||
];
|
||||
}
|
||||
pub(super) struct LanguagePreview {
|
||||
pub(super) previous: localization::Language,
|
||||
previous_locale: &'static str,
|
||||
deadline: std::time::Instant,
|
||||
}
|
||||
|
||||
impl Editor {
|
||||
fn preview_language(&mut self, ctx: &egui::Context, language: localization::Language) {
|
||||
if language == self.language {
|
||||
return;
|
||||
}
|
||||
let previous = self
|
||||
.language_preview
|
||||
.as_ref()
|
||||
.map_or(self.language, |p| p.previous);
|
||||
let previous_locale = self
|
||||
.language_preview
|
||||
.as_ref()
|
||||
.map_or(localization::locale(ctx), |p| p.previous_locale);
|
||||
self.language_preview = Some(LanguagePreview {
|
||||
previous,
|
||||
previous_locale,
|
||||
deadline: std::time::Instant::now() + std::time::Duration::from_secs(20),
|
||||
});
|
||||
self.language = language;
|
||||
language.apply(ctx);
|
||||
}
|
||||
|
||||
fn finish_language_preview(&mut self, ctx: &egui::Context, keep: bool) {
|
||||
let Some(preview) = self.language_preview.take() else {
|
||||
return;
|
||||
};
|
||||
if keep {
|
||||
self.settings.save(&self.application_settings(ctx));
|
||||
} else {
|
||||
self.language = preview.previous;
|
||||
self.language.apply(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn language_confirmation(&mut self, ctx: &egui::Context) {
|
||||
let Some(preview) = &self.language_preview else {
|
||||
return;
|
||||
};
|
||||
let remaining = preview
|
||||
.deadline
|
||||
.saturating_duration_since(std::time::Instant::now());
|
||||
if remaining.is_zero() {
|
||||
self.finish_language_preview(ctx, false);
|
||||
return;
|
||||
}
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(100));
|
||||
let response = egui::Modal::new(egui::Id::new("confirm-language")).show(ctx, |ui| {
|
||||
ui.set_max_width(480.0);
|
||||
ui.heading(tr(ctx, "language.confirm"));
|
||||
ui.label(
|
||||
rust_i18n::t!(
|
||||
"language.rollback",
|
||||
locale = localization::locale(ctx),
|
||||
seconds = remaining.as_secs() + 1
|
||||
)
|
||||
.into_owned(),
|
||||
);
|
||||
// Use the previously displayed language, including the resolved System locale.
|
||||
if preview.previous_locale != localization::locale(ctx) {
|
||||
ui.label(
|
||||
rust_i18n::t!(
|
||||
"language.rollback",
|
||||
locale = preview.previous_locale,
|
||||
seconds = remaining.as_secs() + 1
|
||||
)
|
||||
.into_owned(),
|
||||
);
|
||||
}
|
||||
let keep = ui.button(tr(ctx, "language.keep")).clicked();
|
||||
let cancel = ui
|
||||
.button(
|
||||
rust_i18n::t!("language.cancel", locale = preview.previous_locale).into_owned(),
|
||||
)
|
||||
.clicked();
|
||||
(keep, cancel)
|
||||
});
|
||||
if response.inner.1 || response.should_close() {
|
||||
self.finish_language_preview(ctx, false);
|
||||
} else if response.inner.0 {
|
||||
self.finish_language_preview(ctx, true);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn preferences_window(&mut self, ctx: &egui::Context) {
|
||||
if !self.preferences_open {
|
||||
return;
|
||||
|
|
@ -38,8 +126,8 @@ impl Editor {
|
|||
.show_ui(ui, |ui| {
|
||||
for language in localization::Language::ALL {
|
||||
let name = language.name(ctx);
|
||||
if ui.selectable_value(&mut self.language, language, name).changed() {
|
||||
self.language.apply(ctx);
|
||||
if ui.selectable_label(self.language == language, name).clicked() {
|
||||
self.preview_language(ctx, language);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -225,9 +313,14 @@ mod tests {
|
|||
.skip(2)
|
||||
.chain(std::iter::once(localization::Language::En))
|
||||
{
|
||||
let previous = app.language;
|
||||
let current_name = app.language.name(&ctx);
|
||||
click_label(&mut app, &ctx, ¤t_name);
|
||||
click_label(&mut app, &ctx, &language.name(&ctx));
|
||||
assert_eq!(app.language, language);
|
||||
assert_eq!(app.application_settings(&ctx).language, previous);
|
||||
let yes = tr(&ctx, "language.keep");
|
||||
click_label(&mut app, &ctx, &yes);
|
||||
assert_eq!(settings::Store::at(path.clone()).1.language, language);
|
||||
assert_eq!(app.project().to_json().unwrap(), project);
|
||||
assert_eq!(
|
||||
|
|
@ -239,6 +332,7 @@ mod tests {
|
|||
}
|
||||
click_label(&mut app, &ctx, "English");
|
||||
click_label(&mut app, &ctx, "Français");
|
||||
click_label(&mut app, &ctx, "Oui");
|
||||
click_label(&mut app, &ctx, "Fermer");
|
||||
assert!(!app.preferences_open);
|
||||
let (store, saved) = settings::Store::at(path);
|
||||
|
|
@ -251,6 +345,52 @@ mod tests {
|
|||
assert_eq!(localization::locale(&restored_ctx), "en");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn language_preview_cancel_escape_timeout_and_restart_keep_previous_choice() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("settings.json");
|
||||
let (mut store, mut saved) = settings::Store::at(path.clone());
|
||||
saved.language = localization::Language::Fr;
|
||||
store.save(&saved);
|
||||
let ctx = egui::Context::default();
|
||||
let mut app = Editor::with_settings(&ctx, store, saved);
|
||||
let project = app.project().to_json().unwrap();
|
||||
app.preview_language(&ctx, localization::Language::Ja);
|
||||
// Even an unrelated preferences save or restart must not retain the preview.
|
||||
app.settings.save(&app.application_settings(&ctx));
|
||||
assert_eq!(
|
||||
settings::Store::at(path.clone()).1.language,
|
||||
localization::Language::Fr
|
||||
);
|
||||
click_label(&mut app, &ctx, "Non, j’ai choisi cette langue par erreur");
|
||||
assert_eq!(localization::locale(&ctx), "fr");
|
||||
assert!(app.language_preview.is_none());
|
||||
|
||||
app.preview_language(&ctx, localization::Language::ZhCn);
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
vec![egui::Event::Key {
|
||||
key: egui::Key::Escape,
|
||||
physical_key: None,
|
||||
pressed: true,
|
||||
repeat: false,
|
||||
modifiers: egui::Modifiers::NONE,
|
||||
}],
|
||||
);
|
||||
assert_eq!(app.language, localization::Language::Fr);
|
||||
app.preview_language(&ctx, localization::Language::Es);
|
||||
app.language_preview.as_mut().unwrap().deadline = std::time::Instant::now();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
assert_eq!(app.language, localization::Language::Fr);
|
||||
assert_eq!(localization::locale(&ctx), "fr");
|
||||
assert!(app.language_preview.is_none());
|
||||
app.preview_language(&ctx, localization::Language::Fr);
|
||||
assert!(app.language_preview.is_none());
|
||||
assert_eq!(app.project().to_json().unwrap(), project);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settings_language_and_close_stay_visible_at_minimum_window_size() {
|
||||
let screen = Rect::from_min_size(Pos2::ZERO, Vec2::new(1000.0, 720.0));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
- Language changes now preview for 20 seconds and require confirmation. The
|
||||
cancellation button stays in the previous language; cancellation, Escape or
|
||||
timeout restores it. Unconfirmed choices are never saved. Regression tests cover
|
||||
confirmation, cancellation, timeout, restart safety and unchanged project data.
|
||||
|
||||
- Updated the French quick start to the accepted French interface terminology,
|
||||
with new offline workspace, layer-properties and crop screenshots. English
|
||||
remains the authoritative manual; English screenshots and project names are
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ ligne : aucun processeur vidéo n’est nécessaire.
|
|||
Suivez d’abord les [instructions d’installation et de mise à jour (en anglais)](../install.md),
|
||||
puis lancez Canvas Pilot. Dans **Menu → Ouvrir tous les réglages…**, choisissez
|
||||
**Français** dans **Language / Langue**, en haut des réglages. Le changement est
|
||||
immédiat et reste enregistré au prochain lancement.
|
||||
immédiat : confirmez avec **Oui** dans les 20 secondes pour le conserver au prochain
|
||||
lancement. Le bouton de refus reste dans la langue précédente. Un refus, la touche
|
||||
Échap ou la fin du décompte rétablit cette langue.
|
||||
|
||||
Si vous travaillez depuis les sources du projet, exécutez
|
||||
cette commande à la racine du dépôt :
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ project; older projects open with captions off.
|
|||
Open **Menu → Open all settings…** and use **Language / Langue** at the top.
|
||||
Choose **System default**, **English**, **Français**, **日本語**, **简体中文**,
|
||||
**Español**, **Ἑλληνικὴ ἀρχαία** (Ancient Greek), or **Esperanto**. The change takes effect
|
||||
immediately, saves automatically and survives restarting. In French, the route is
|
||||
immediately as a preview. Choose **Yes** within 20 seconds to save it for future
|
||||
launches. The cancellation button uses your previous language; clicking it, pressing
|
||||
Escape or letting the countdown expire restores that language. Closing the app
|
||||
without confirming also leaves the previous saved choice intact. In French, the route is
|
||||
**Menu → Ouvrir tous les réglages…**; language names stay recognizable in either UI.
|
||||
|
||||
System default follows supported system languages, with English fallback. Chinese
|
||||
|
|
|
|||
|
|
@ -60,7 +60,11 @@ files; translators do not need to touch Rust code to trigger a rebuild.
|
|||
Settings v10 adds `ja`, `zh-CN`, `es`, `grc` and `eo` to v9’s `system`, `en`, `fr`.
|
||||
Versions 1–8 migrate with System default; v9 preserves its language and all other
|
||||
preferences. Unknown old language values are rejected rather than reinterpreted. The always
|
||||
visible **Language / Langue** selector at the top of Settings applies immediately.
|
||||
visible **Language / Langue** selector at the top of Settings previews immediately,
|
||||
then requires confirmation within 20 seconds. Question and acceptance use the new
|
||||
locale; cancellation and an additional countdown use the previously displayed
|
||||
locale. Escape and timeout roll back; settings writes retain the old choice until
|
||||
confirmation. The transient preview is not project or settings data.
|
||||
Project, export, clipboard and device contracts are unchanged. Every non-English
|
||||
language has the same preview status, not a human-reviewed complete translation: technical diagnostics, some advanced
|
||||
controls, device-supplied labels and native file dialogs can still be English.
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ unknown theme names are rejected. There are no numeric coordinates or units.
|
|||
| `snapping` | Object with required boolean fields `enabled` (false), `pixels` (true), `screen_edges` (true; screen edges plus 25%, 50% and 75% guides on both axes), `layer_edges` (true), `grid` (false), `show_grid` (true), and `grid_divisions` ([8, 6]); unknown fields rejected |
|
||||
|
||||
Language is a workstation preference, never a project field or exchange value.
|
||||
Changing **Settings → Language / Langue** applies immediately and saves without
|
||||
restarting or reinstalling the project. It preserves selections, undo, numeric
|
||||
Changing **Settings → Language / Langue** previews immediately and saves after
|
||||
confirmation, without restarting or reinstalling the project. It preserves selections, undo, numeric
|
||||
entry drafts, device links and staged proposals, and never connects or sends.
|
||||
Resetting defaults restores System default. System language is resolved at startup
|
||||
and when explicitly selected; external OS language changes are not watched live.
|
||||
|
|
@ -115,8 +115,16 @@ The picker includes both light and dark themes with color swatches.
|
|||
| Verdant Rebel | `verdant_rebel` | `theme-verdant-rebel.css` |
|
||||
| Weicat Industrial | `weicat_industrial` | `theme-weicat-industrial.css` |
|
||||
|
||||
Language selection previews the new UI for 20 seconds. Only confirmation persists
|
||||
the new `language` value. Cancellation, Escape or timeout restores the previous
|
||||
choice. While a preview is pending, all settings writes retain the previous
|
||||
confirmed language, so quitting or crashing cannot persist an accidental selection.
|
||||
The cancel button uses the previously displayed locale, including resolved System
|
||||
default. Preview state and its deadline are not serialized; the v10 schema is unchanged.
|
||||
|
||||
The Settings window and quick menus share the same settings. Changes apply
|
||||
and save immediately; closing the window requires no Apply step. Restore default
|
||||
and save immediately, except for language confirmation described above; closing
|
||||
the window requires no general Apply step. Restore default
|
||||
preferences resets appearance and editing values, including theme history and snapping, without
|
||||
changing layer geometry or pending position/size text fields. Snapping uses a
|
||||
fixed six-logical-pixel proximity radius converted by viewport scale. It affects
|
||||
|
|
|
|||
Loading…
Reference in New Issue