diff --git a/apps/desktop-gpui/locales/de.toml b/apps/desktop-gpui/locales/de.toml index b454336e273..9df4cff1841 100644 --- a/apps/desktop-gpui/locales/de.toml +++ b/apps/desktop-gpui/locales/de.toml @@ -136,6 +136,12 @@ label = "Dock-Symbol immer anzeigen" description = "Mitteilungen für Kopien in die Zwischenablage, gespeicherte Dateien und mehr anzeigen. Eventuell müssen Sie Cap in den Mitteilungseinstellungen Ihres Systems erlauben." label = "Systemmitteilungen" +[settings.general.app.open_file] +description = "Legen Sie fest, ob „Datei öffnen“ einen Export öffnet oder im Ordner anzeigt." +label = "Schaltfläche „Datei öffnen“" +open = "Datei öffnen" +show_in_folder = "Im Ordner anzeigen" + [settings.general.recording] description = "Verhalten während und nach der Aufnahme." title = "Aufnahme" diff --git a/apps/desktop-gpui/locales/en.toml b/apps/desktop-gpui/locales/en.toml index a6747ce8074..8291ff6f1a3 100644 --- a/apps/desktop-gpui/locales/en.toml +++ b/apps/desktop-gpui/locales/en.toml @@ -138,6 +138,12 @@ label = "Always show dock icon" description = "Show notifications for clipboard copies, saved files, and more. You may need to allow Cap in your system's notification settings." label = "System notifications" +[settings.general.app.open_file] +description = "Choose whether Open File opens an export or shows it in its folder." +label = "Open File button" +open = "Open the file" +show_in_folder = "Show in folder" + [settings.general.recording] description = "Behaviour while you record and after you stop." title = "Recording" diff --git a/apps/desktop-gpui/locales/es.toml b/apps/desktop-gpui/locales/es.toml index b32dac34ceb..88a7553b33d 100644 --- a/apps/desktop-gpui/locales/es.toml +++ b/apps/desktop-gpui/locales/es.toml @@ -136,6 +136,12 @@ label = "Mostrar siempre el icono en el Dock" description = "Muestra notificaciones al copiar al portapapeles, guardar archivos y más. Puede que tengas que permitir Cap en los ajustes de notificaciones del sistema." label = "Notificaciones del sistema" +[settings.general.app.open_file] +description = "Elige si «Abrir archivo» abre una exportación o la muestra en su carpeta." +label = "Botón «Abrir archivo»" +open = "Abrir archivo" +show_in_folder = "Mostrar en la carpeta" + [settings.general.recording] description = "Comportamiento durante la grabación y al detenerla." title = "Grabación" diff --git a/apps/desktop-gpui/locales/fr.toml b/apps/desktop-gpui/locales/fr.toml index 1363a5a32cc..7d794054d24 100644 --- a/apps/desktop-gpui/locales/fr.toml +++ b/apps/desktop-gpui/locales/fr.toml @@ -136,6 +136,12 @@ label = "Toujours afficher l'icône dans le Dock" description = "Afficher des notifications pour les copies dans le presse-papiers, les fichiers enregistrés, etc. Vous devrez peut-être autoriser Cap dans les réglages de notifications de votre système." label = "Notifications système" +[settings.general.app.open_file] +description = "Choisissez si « Ouvrir le fichier » ouvre un export ou l'affiche dans son dossier." +label = "Bouton « Ouvrir le fichier »" +open = "Ouvrir le fichier" +show_in_folder = "Afficher dans le dossier" + [settings.general.recording] description = "Comportement pendant l'enregistrement et après l'arrêt." title = "Enregistrement" diff --git a/apps/desktop-gpui/locales/hi.toml b/apps/desktop-gpui/locales/hi.toml index d0c3ce84122..22247b4d78e 100644 --- a/apps/desktop-gpui/locales/hi.toml +++ b/apps/desktop-gpui/locales/hi.toml @@ -136,6 +136,12 @@ label = "Dock आइकन हमेशा दिखाएँ" description = "क्लिपबोर्ड पर कॉपी करने, फ़ाइलें सहेजने और अन्य कामों के लिए सूचनाएँ दिखाएँ। आपको अपने सिस्टम की सूचना सेटिंग्स में Cap को अनुमति देनी पड़ सकती है।" label = "सिस्टम सूचनाएँ" +[settings.general.app.open_file] +description = "चुनें कि फ़ाइल खोलें बटन एक्सपोर्ट को खोले या उसे उसके फ़ोल्डर में दिखाए।" +label = "फ़ाइल खोलें बटन" +open = "फ़ाइल खोलें" +show_in_folder = "फ़ोल्डर में दिखाएँ" + [settings.general.recording] description = "रिकॉर्ड करते समय और रोकने के बाद का व्यवहार।" title = "रिकॉर्डिंग" diff --git a/apps/desktop-gpui/locales/ja.toml b/apps/desktop-gpui/locales/ja.toml index 967be8d9989..c38d1826355 100644 --- a/apps/desktop-gpui/locales/ja.toml +++ b/apps/desktop-gpui/locales/ja.toml @@ -136,6 +136,12 @@ label = "Dockアイコンを常に表示" description = "クリップボードへのコピーやファイルの保存などを通知します。システムの通知設定でCapを許可する必要がある場合があります。" label = "システム通知" +[settings.general.app.open_file] +description = "「ファイルを開く」で書き出したファイルを開くか、フォルダ内に表示するかを選びます。" +label = "「ファイルを開く」ボタン" +open = "ファイルを開く" +show_in_folder = "フォルダに表示" + [settings.general.recording] description = "録画中と録画停止後の動作。" title = "録画" diff --git a/apps/desktop-gpui/locales/zh-CN.toml b/apps/desktop-gpui/locales/zh-CN.toml index c7bae3ffead..e169539ca8b 100644 --- a/apps/desktop-gpui/locales/zh-CN.toml +++ b/apps/desktop-gpui/locales/zh-CN.toml @@ -136,6 +136,12 @@ label = "始终显示程序坞图标" description = "在复制到剪贴板、保存文件等操作后显示通知。你可能需要在系统的通知设置中允许 Cap。" label = "系统通知" +[settings.general.app.open_file] +description = "选择“打开文件”是打开导出的文件,还是在所在文件夹中显示它。" +label = "“打开文件”按钮" +open = "打开文件" +show_in_folder = "在文件夹中显示" + [settings.general.recording] description = "录制期间及停止录制后的行为。" title = "录制" diff --git a/apps/desktop-gpui/src/editor_export.rs b/apps/desktop-gpui/src/editor_export.rs index 664ea8ce09c..3bec13c6dc6 100644 --- a/apps/desktop-gpui/src/editor_export.rs +++ b/apps/desktop-gpui/src/editor_export.rs @@ -4196,6 +4196,7 @@ impl EditorWindow { || ui.clipboard_retry_path().is_some(), |this| { let path = ui.output_path.clone(); + let tracks = ui.format == ExportFormatKind::Tracks; this.child( ui::Button::plain( &theme, @@ -4203,14 +4204,16 @@ impl EditorWindow { ui::ButtonVariant::Gray, ui::ButtonSize::Md, ) - .label(if ui.format == ExportFormatKind::Tracks { + .label(if tracks { tr::editor::export::tracks::open_folder() } else { tr::editor::export::done::open_file() }) .on_click(move |_, _, cx| { - if let Some(path) = &path { - library::open_with_system(path, cx); + match &path { + Some(path) if tracks => library::open_with_system(path, cx), + Some(path) => library::open_output(path, cx), + None => {} } }), ) diff --git a/apps/desktop-gpui/src/i18n/tests.rs b/apps/desktop-gpui/src/i18n/tests.rs index 08e515a83c9..f9167ac3926 100644 --- a/apps/desktop-gpui/src/i18n/tests.rs +++ b/apps/desktop-gpui/src/i18n/tests.rs @@ -163,6 +163,22 @@ fn english_matches_the_literals_it_replaced() { tr::settings::general::app::notifications::label(), "System notifications".into(), ), + ( + tr::settings::general::app::open_file::description(), + "Choose whether Open File opens an export or shows it in its folder.".into(), + ), + ( + tr::settings::general::app::open_file::label(), + "Open File button".into(), + ), + ( + tr::settings::general::app::open_file::open(), + "Open the file".into(), + ), + ( + tr::settings::general::app::open_file::show_in_folder(), + "Show in folder".into(), + ), ( tr::settings::general::recording::description(), "Behaviour while you record and after you stop.".into(), diff --git a/apps/desktop-gpui/src/library.rs b/apps/desktop-gpui/src/library.rs index c5d6317e18b..5a123992cb3 100644 --- a/apps/desktop-gpui/src/library.rs +++ b/apps/desktop-gpui/src/library.rs @@ -1187,6 +1187,13 @@ pub fn reveal_path(path: &Path, cx: &App) { cx.reveal_path(dunce::simplified(path)); } +pub fn open_output(path: &Path, cx: &App) { + match crate::store::GeneralSettings::load().open_file_behaviour { + crate::store::OpenFileBehaviour::OpenFile => open_with_system(path, cx), + crate::store::OpenFileBehaviour::ShowInFolder => reveal_path(path, cx), + } +} + pub fn open_with_system(path: &Path, cx: &App) { cx.open_with_system(dunce::simplified(path)); } diff --git a/apps/desktop-gpui/src/settings_window.rs b/apps/desktop-gpui/src/settings_window.rs index 66bb61dd661..0db9dcee2e0 100644 --- a/apps/desktop-gpui/src/settings_window.rs +++ b/apps/desktop-gpui/src/settings_window.rs @@ -3628,6 +3628,20 @@ impl SettingsWindow { ) .into_any_element(), ), + self.setting_row( + tr::settings::general::app::open_file::label(), + Some(tr::settings::general::app::open_file::description()), + self.segmented( + "open-file-behaviour", + self.settings.open_file_behaviour, + cx, + |this, value, cx| { + this.settings.open_file_behaviour = value; + this.write_enum("openFileBehaviour", value, cx); + }, + ) + .into_any_element(), + ), ]) .into_any_element(), ], diff --git a/apps/desktop-gpui/src/store.rs b/apps/desktop-gpui/src/store.rs index 3180cae17c5..c1075d548ab 100644 --- a/apps/desktop-gpui/src/store.rs +++ b/apps/desktop-gpui/src/store.rs @@ -854,6 +854,14 @@ settings_enum! { default = System } +settings_enum! { + OpenFileBehaviour { + OpenFile = "openFile", crate::i18n::tr::settings::general::app::open_file::open(); + ShowInFolder = "showInFolder", crate::i18n::tr::settings::general::app::open_file::show_in_folder(); + } + default = OpenFile +} + settings_enum! { /// `StudioRecordingQuality`, whose Rust default is `balanced`. StudioQuality { @@ -1151,6 +1159,7 @@ pub const DEFAULT_PROJECT_NAME_TEMPLATE: &str = "{target_name} ({target_kind}) { #[derive(Debug, Clone, PartialEq)] pub struct GeneralSettings { pub theme: AppTheme, + pub open_file_behaviour: OpenFileBehaviour, /// `uiLanguage`: absent, `"system"`, or a catalog code such as `"fr"`. A /// GPUI-only key; the Tauri app keeps it as an unknown field. pub ui_language: Option, @@ -1729,6 +1738,7 @@ impl GeneralSettings { ) -> Self { Self { theme: enum_at(general, "theme"), + open_file_behaviour: enum_at(general, "openFileBehaviour"), ui_language: opt_string_at(general, crate::i18n::SETTING_KEY), hide_dock_icon: bool_at(general, "hideDockIcon", false), enable_notifications: bool_at(general, "enableNotifications", true), @@ -4426,4 +4436,42 @@ mod tests { ); } } + + #[test] + fn open_file_behaviour_defaults_for_old_settings() { + let general = serde_json::from_str(r#"{"theme":"dark","maxFps":30}"#).unwrap(); + let settings = GeneralSettings::from_sections(&general, &Map::new(), &Map::new()); + assert_eq!(settings.open_file_behaviour, OpenFileBehaviour::OpenFile); + assert_eq!(settings.theme, AppTheme::Dark); + assert_eq!( + GeneralSettings::default().open_file_behaviour, + OpenFileBehaviour::OpenFile + ); + } + + #[test] + fn open_file_behaviour_persists_across_store_reloads() { + let store = TempStore::new( + "open-file-behaviour", + Some(r#"{"general_settings":{"theme":"dark"}}"#), + ); + assert_eq!( + GeneralSettings::load().open_file_behaviour, + OpenFileBehaviour::OpenFile + ); + for (behaviour, json) in [ + (OpenFileBehaviour::ShowInFolder, "showInFolder"), + (OpenFileBehaviour::OpenFile, "openFile"), + ] { + assert_eq!(behaviour.as_json(), json); + assert!(set_store_setting( + GENERAL_SETTINGS, + "openFileBehaviour", + Value::String(behaviour.as_json().into()) + )); + assert_eq!(store.read()[GENERAL_SETTINGS]["openFileBehaviour"], json); + assert_eq!(GeneralSettings::load().open_file_behaviour, behaviour); + assert_eq!(GeneralSettings::load().theme, AppTheme::Dark); + } + } }