Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

feat(prefs): Show File Name In Title keeps the title bar to the app name (#5037) (#5129)

mroxso96c151525a77
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs
index 3e87d43fc..b551032e9 100644
--- a/crates/engine/src/prefs.rs
+++ b/crates/engine/src/prefs.rs
@@ -286,6 +286,10 @@ pub struct Interface {
/// own one-row title bar (tiling window managers, desktops that draw their own decorations;
/// #1271, #1316). Read when the app starts. macOS always uses the system's.
pub system_title_bar: bool,
+ /// Show the active document's file name in the title bar and the OS window title. The tabs
+ /// already name the file, so this can be turned off for a plain "PhotoCraft" title (#5037).
+ /// The unsaved-changes mark stays either way.
+ pub show_file_name_in_title: bool,
/// Notices (the lower-right cards) hide themselves after
/// [`Interface::notification_duration_seconds`] unless the pointer rests on them (#2022).
pub notification_auto_hide: bool,
@@ -317,6 +321,7 @@ impl Default for Interface {
enable_animations: true,
show_bounding_box_when_dragging_layer: false,
system_title_bar: false,
+ show_file_name_in_title: true,
notification_auto_hide: true,
notification_duration_seconds: 6,
}
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index 6175183cb..7da5cbc30 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -3812,6 +3812,7 @@ navigator Zoom Zvětšení
There are too many sets: delete one first. Sad je příliš mnoho: nejprve jednu smažte.
set name název sady
{set} (modified) {set} (změněno)
+ Show file name in title Zobrazit název souboru v titulu
Accept and Go to Conflict Přijmout a přejít ke konfliktu
Changes undone. Změny vráceny.
Choose a new shortcut for this command, or leave it without one. Zvolte pro tento příkaz novou zkratku, nebo ho nechte bez ní.
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index 5fbbceb44..6faa41f3e 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -3208,6 +3208,7 @@ curves Smooth Glätten
There are too many sets: delete one first. Zu viele Sätze: Löschen Sie zuerst einen.
set name Name des Satzes
{set} (modified) {set} (geändert)
+ Show file name in title Dateiname im Titel anzeigen
Accept and Go to Conflict Übernehmen und zum Konflikt
Changes undone. Änderungen rückgängig gemacht.
Choose a new shortcut for this command, or leave it without one. Wählen Sie einen neuen Kurzbefehl für diesen Befehl oder lassen Sie ihn ohne.
diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv
index d21c3ba6e..ac3b9fbd3 100644
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@ -3904,6 +3904,7 @@ curves Smooth Εξομάλυνση
There are too many sets: delete one first. Υπάρχουν πάρα πολλά σύνολα: διαγράψτε πρώτα ένα.
set name όνομα συνόλου
{set} (modified) {set} (τροποποιημένο)
+ Show file name in title Εμφάνιση ονόματος αρχείου στον τίτλο
Accept and Go to Conflict Αποδοχή και μετάβαση στη σύγκρουση
Changes undone. Οι αλλαγές αναιρέθηκαν.
Choose a new shortcut for this command, or leave it without one. Επιλέξτε νέα συντόμευση για αυτήν την εντολή ή αφήστε την χωρίς.
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index 4956fcd97..b2e63bbc8 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -4166,6 +4166,7 @@ navigator Zoom Zoom
There are too many sets: delete one first. Hay demasiados conjuntos: elimine uno primero.
set name nombre del conjunto
{set} (modified) {set} (modificado)
+ Show file name in title Mostrar nombre de archivo en el título
Accept and Go to Conflict Aceptar e ir al conflicto
Changes undone. Cambios deshechos.
Choose a new shortcut for this command, or leave it without one. Elija un nuevo método abreviado para este comando o déjelo sin ninguno.
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index 62b2e8ea2..2acba73d5 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -3211,6 +3211,7 @@ curves Smooth Lisser
set name nom du jeu
{set} (modified) {set} (modifié)
Random Aléatoire
+ Show file name in title Afficher le nom de fichier dans le titre
Accept and Go to Conflict Accepter et aller au conflit
Changes undone. Modifications annulées.
Choose a new shortcut for this command, or leave it without one. Choisissez un nouveau raccourci pour cette commande ou laissez-la sans raccourci.
diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv
index a52cb5fdb..7393ba295 100644
--- a/crates/ui-egui/src/i18n/hu.tsv
+++ b/crates/ui-egui/src/i18n/hu.tsv
@@ -4123,6 +4123,7 @@ cameraRaw Yellow Sárga
There are too many sets: delete one first. Túl sok készlet van: előbb töröljön egyet.
set name készlet neve
{set} (modified) {set} (módosítva)
+ Show file name in title Fájlnév megjelenítése a címben
Accept and Go to Conflict Elfogadás és ugrás az ütközéshez
Changes undone. Változások visszavonva.
Choose a new shortcut for this command, or leave it without one. Válasszon új billentyűparancsot ehhez a parancshoz, vagy hagyja nélküle.
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index 14e65b2b7..3246a9c37 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -3198,6 +3198,7 @@ curves Smooth Haluskan
set name nama set
{set} (modified) {set} (diubah)
Random Acak
+ Show file name in title Tampilkan nama file di judul
Accept and Go to Conflict Terima dan Buka Konflik
Changes undone. Perubahan dibatalkan.
Choose a new shortcut for this command, or leave it without one. Pilih pintasan baru untuk perintah ini, atau biarkan tanpa pintasan.
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index 857cc66d9..8b664de9f 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -4325,6 +4325,7 @@ shape Appearance Aspetto
There are too many sets: delete one first. Ci sono troppi set: eliminane prima uno.
set name nome del set
{set} (modified) {set} (modificato)
+ Show file name in title Mostra nome file nel titolo
Accept and Go to Conflict Accetta e vai al conflitto
Changes undone. Modifiche annullate.
Choose a new shortcut for this command, or leave it without one. Scegli una nuova scorciatoia per questo comando o lascialo senza.
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index b14f5c119..c41d46a32 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -3880,6 +3880,7 @@ curves Smooth スムーズ
There are too many sets: delete one first. セットが多すぎます。先に 1 つ削除してください。
set name セット名
{set} (modified) {set}(変更あり)
+ Show file name in title タイトルにファイル名を表示
Accept and Go to Conflict 適用して競合へ移動
Changes undone. 変更を取り消しました。
Choose a new shortcut for this command, or leave it without one. このコマンドに新しいショートカットを選択するか、なしのままにしてください。
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index d5d58b2ff..21ef94cff 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -3384,6 +3384,7 @@ curves Smooth 매끄럽게
There are too many sets: delete one first. 세트가 너무 많습니다. 먼저 하나를 삭제하세요.
set name 세트 이름
{set} (modified) {set}(수정됨)
+ Show file name in title 제목에 파일 이름 표시
Accept and Go to Conflict 적용 후 충돌 항목으로 이동
Changes undone. 변경 사항을 취소했습니다.
Choose a new shortcut for this command, or leave it without one. 이 명령의 새 단축키를 선택하거나 단축키 없이 두세요.
diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv
index 394aaecbb..ca9253c34 100644
--- a/crates/ui-egui/src/i18n/nl.tsv
+++ b/crates/ui-egui/src/i18n/nl.tsv
@@ -3964,6 +3964,7 @@ curves Smooth Vloeiend maken
There are too many sets: delete one first. Er zijn te veel sets: verwijder er eerst een.
set name naam van de set
{set} (modified) {set} (gewijzigd)
+ Show file name in title Bestandsnaam in titel weergeven
Accept and Go to Conflict Accepteren en naar conflict
Changes undone. Wijzigingen ongedaan gemaakt.
Choose a new shortcut for this command, or leave it without one. Kies een nieuwe sneltoets voor deze opdracht of laat hem zonder.
diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv
index 660e93bbb..4f8194ccb 100644
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@ -3802,6 +3802,7 @@ curves Smooth Wygładź
There are too many sets: delete one first. Zestawów jest za dużo: najpierw usuń jeden.
set name nazwa zestawu
{set} (modified) {set} (zmieniony)
+ Show file name in title Pokaż nazwę pliku w tytule
Accept and Go to Conflict Akceptuj i przejdź do konfliktu
Changes undone. Zmiany cofnięte.
Choose a new shortcut for this command, or leave it without one. Wybierz nowy skrót dla tego polecenia lub zostaw je bez skrótu.
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index 338c4fadb..65b81cb19 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -3994,6 +3994,7 @@ layerLabel No Color Sem cor
There are too many sets: delete one first. Há conjuntos demais: exclua um primeiro.
set name nome do conjunto
{set} (modified) {set} (modificado)
+ Show file name in title Exibir nome do arquivo no título
Accept and Go to Conflict Aceitar e ir para o conflito
Changes undone. Alterações desfeitas.
Choose a new shortcut for this command, or leave it without one. Escolha um novo atalho para este comando ou deixe-o sem atalho.
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index 11fd43811..aa40b583b 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -3176,6 +3176,7 @@ curves Smooth Сгладить
set name имя набора
{set} (modified) {set} (изменён)
Random Случайно
+ Show file name in title Показывать имя файла в заголовке
Accept and Go to Conflict Принять и перейти к конфликту
Changes undone. Изменения отменены.
Choose a new shortcut for this command, or leave it without one. Выберите новую комбинацию для этой команды или оставьте её без комбинации.
diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv
index 25175aeff..474fedaf2 100644
--- a/crates/ui-egui/src/i18n/sr.tsv
+++ b/crates/ui-egui/src/i18n/sr.tsv
@@ -4277,6 +4277,7 @@ shape Appearance Izgled
There are too many sets: delete one first. Previše skupova: prvo obrišite jedan.
set name ime skupa
{set} (modified) {set} (izmenjen)
+ Show file name in title Prikaži naziv datoteke u naslovu
Accept and Go to Conflict Prihvati i idi na sukob
Changes undone. Izmene su poništene.
Choose a new shortcut for this command, or leave it without one. Izaberite novu prečicu za ovu komandu ili je ostavite bez prečice.
diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv
index 6af551012..8fb253f14 100644
--- a/crates/ui-egui/src/i18n/tr.tsv
+++ b/crates/ui-egui/src/i18n/tr.tsv
@@ -3934,6 +3934,7 @@ cameraData Lens Lens
There are too many sets: delete one first. Çok fazla küme var: önce birini silin.
set name küme adı
{set} (modified) {set} (değiştirildi)
+ Show file name in title Başlıkta dosya adını göster
Accept and Go to Conflict Kabul Et ve Çakışmaya Git
Changes undone. Değişiklikler geri alındı.
Choose a new shortcut for this command, or leave it without one. Bu komut için yeni bir kısayol seçin veya kısayolsuz bırakın.
diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv
index 37851e90f..ee29fb4a0 100644
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@ -3903,6 +3903,7 @@ curves Smooth Згладити
There are too many sets: delete one first. Забагато наборів: спершу видаліть один.
set name назва набору
{set} (modified) {set} (змінено)
+ Show file name in title Показувати ім’я файла в заголовку
Accept and Go to Conflict Прийняти й перейти до конфлікту
Changes undone. Зміни скасовано.
Choose a new shortcut for this command, or leave it without one. Виберіть нове клавіатурне скорочення для цієї команди або залиште її без нього.
diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv
index fd7950b93..03cdfb972 100644
--- a/crates/ui-egui/src/i18n/vi.tsv
+++ b/crates/ui-egui/src/i18n/vi.tsv
@@ -3690,6 +3690,7 @@ curves Smooth Làm mượt
There are too many sets: delete one first. Có quá nhiều bộ: hãy xóa một bộ trước.
set name tên bộ
{set} (modified) {set} (đã sửa đổi)
+ Show file name in title Hiển thị tên tệp trong tiêu đề
Accept and Go to Conflict Chấp nhận và đến xung đột
Changes undone. Đã hoàn tác thay đổi.
Choose a new shortcut for this command, or leave it without one. Chọn phím tắt mới cho lệnh này, hoặc để lệnh không có phím tắt.
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index 0f242f8f6..42704b01b 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -2826,6 +2826,7 @@ curves Smooth 平滑
set name 组名称
{set} (modified) {set}(已修改)
Random 随机
+ Show file name in title 标题中显示文件名
Accept and Go to Conflict 接受并转到冲突
Changes undone. 已撤消更改。
Choose a new shortcut for this command, or leave it without one. 为此命令选择新的快捷键,或保留为无快捷键。
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index 621bee551..1e1a8f04a 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -2811,6 +2811,7 @@ curves Smooth 平滑
set name 組合名稱
{set} (modified) {set}(已修改)
Random 隨機
+ Show file name in title 標題中顯示檔案名稱
Accept and Go to Conflict 接受並前往衝突
Changes undone. 已還原變更。
Choose a new shortcut for this command, or leave it without one. 為此指令選擇新的快速鍵,或保持沒有快速鍵。
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs
index 9a1b07f2b..609007a5e 100644
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@ -602,7 +602,14 @@ pub fn title_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let max = ui.ctx().input(|i| i.viewport().maximized.unwrap_or(false));
ui.ctx().send_viewport_cmd(egui::ViewportCommand::Maximized(!max));
}
- let title = app.session.active().map(|d| format!("{}{}", d.doc.name, if d.is_dirty() { " •" } else { "" })).unwrap_or_else(|| "PhotoCraft".into());
+ // Preferences › Interface › Show File Name In Title: with it off the bar keeps the
+ // app name and the unsaved dot, since the tabs already name the file (#5037).
+ let show_name = app.session.prefs().interface.show_file_name_in_title;
+ let title = app
+ .session
+ .active()
+ .map(|d| format!("{}{}", if show_name { d.doc.name.as_str() } else { "PhotoCraft" }, if d.is_dirty() { " •" } else { "" }))
+ .unwrap_or_else(|| "PhotoCraft".into());
// The menus and the far-end controls are laid out first; the title is centred in
// whatever room is left between them (`free`, left to right: menus then controls, or
// controls then menus in a right-to-left UI), shortened or dropped rather than drawn
@@ -728,8 +735,12 @@ pub fn system_title_bar(app: &PhotocraftApp) -> bool {
/// The OS window title: the active document's name suffixed with the app name (a `*` prefix
/// marks unsaved changes, like the `•` in the app-drawn title), or just the app name with no
-/// document open.
+/// document open. With Preferences › Interface › Show File Name In Title off, the file name
+/// drops out and only the app name (and the `*`) remains (#5037).
pub fn window_title(app: &PhotocraftApp) -> String {
+ if !app.session.prefs().interface.show_file_name_in_title {
+ return format!("{}PhotoCraft", if app.session.active().is_some_and(|d| d.is_dirty()) { "*" } else { "" });
+ }
app.session.active().map(|d| format!("{}{} \u{2014} PhotoCraft", if d.is_dirty() { "*" } else { "" }, d.doc.name)).unwrap_or_else(|| "PhotoCraft".into())
}
@@ -820,6 +831,40 @@ mod title_tests {
assert_eq!(window_title(&app), "*foo.psd \u{2014} PhotoCraft");
}
+ #[test]
+ fn hiding_the_file_name_keeps_the_app_name_and_the_dirty_mark() {
+ let mut app = app(true);
+ open_named(&mut app, "foo.psd");
+ app.session.prefs.edit(|p| p.interface.show_file_name_in_title = false);
+ assert_eq!(window_title(&app), "PhotoCraft");
+ if let Some(st) = app.session.active_mut() {
+ st.revision += 1;
+ }
+ assert_eq!(window_title(&app), "*PhotoCraft");
+ }
+
+ #[test]
+ fn hidden_file_name_leaves_the_app_name_in_the_drawn_title() {
+ let mut app = app(true);
+ open_named(&mut app, "foo.psd");
+ let texts = |app: &mut crate::PhotocraftApp| {
+ let ctx = egui::Context::default();
+ crate::PhotocraftApp::setup_context(&ctx, crate::theme::ThemeKind::ALL[0]);
+ let mut out = ctx.run_ui(egui::RawInput::default(), |ui| super::title_bar(app, ui));
+ out.textures_delta.clear();
+ let mut texts = Vec::new();
+ for shape in &out.shapes {
+ collect_text(&shape.shape, &mut texts);
+ }
+ texts
+ };
+ assert!(texts(&mut app).iter().any(|t| t.contains("foo.psd")), "shown by default");
+ app.session.prefs.edit(|p| p.interface.show_file_name_in_title = false);
+ let hidden = texts(&mut app);
+ assert!(!hidden.iter().any(|t| t.contains("foo.psd")), "file name hidden: {hidden:?}");
+ assert!(hidden.iter().any(|t| t.contains("PhotoCraft")), "app name kept: {hidden:?}");
+ }
+
#[test]
fn system_mode_hides_the_mark_and_the_centred_title() {
for custom in [true, false] {