default for post-process and revert ui changes

This commit is contained in:
CJ Pais 2026-02-06 16:46:17 +08:00
parent 462b03b024
commit db854363b4
5 changed files with 23 additions and 25 deletions

View file

@ -562,6 +562,15 @@ pub fn get_default_settings() -> AppSettings {
current_binding: default_shortcut.to_string(),
},
);
#[cfg(target_os = "windows")]
let default_post_process_shortcut = "ctrl+shift+space";
#[cfg(target_os = "macos")]
let default_post_process_shortcut = "option+shift+space";
#[cfg(target_os = "linux")]
let default_post_process_shortcut = "ctrl+shift+space";
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
let default_post_process_shortcut = "alt+shift+space";
bindings.insert(
"transcribe_with_post_process".to_string(),
ShortcutBinding {
@ -569,8 +578,8 @@ pub fn get_default_settings() -> AppSettings {
name: "Transcribe with Post-Processing".to_string(),
description: "Converts your speech into text and applies AI post-processing."
.to_string(),
default_binding: String::new(),
current_binding: String::new(),
default_binding: default_post_process_shortcut.to_string(),
current_binding: default_post_process_shortcut.to_string(),
},
);
bindings.insert(

View file

@ -108,6 +108,11 @@ pub fn change_binding(
id: String,
binding: String,
) -> Result<BindingResponse, String> {
// Reject empty bindings — every shortcut should have a value
if binding.trim().is_empty() {
return Err("Binding cannot be empty".to_string());
}
let mut settings = settings::get_settings(&app);
// Get the binding to modify, or create it from defaults if it doesn't exist
@ -707,10 +712,7 @@ pub fn change_post_process_enabled_setting(app: AppHandle, enabled: bool) -> Res
.cloned()
{
if enabled {
// Only register if the user has actually set a binding
if !binding.current_binding.is_empty() {
let _ = register_shortcut(&app, binding);
}
let _ = register_shortcut(&app, binding);
} else {
let _ = unregister_shortcut(&app, binding);
}

View file

@ -293,22 +293,16 @@ export const GlobalShortcutInput: React.FC<GlobalShortcutInputProps> = ({
{editingShortcutId === shortcutId ? (
<div
ref={(ref) => setShortcutRef(shortcutId, ref)}
className="px-2 py-1 text-sm font-semibold border border-logo-primary bg-logo-primary/30 rounded min-w-[120px] text-center"
className="px-2 py-1 text-sm font-semibold border border-logo-primary bg-logo-primary/30 rounded"
>
{formatCurrentKeys()}
</div>
) : (
<div
className={`px-2 py-1 text-sm font-semibold rounded cursor-pointer min-w-[120px] text-center ${
binding.current_binding
? "bg-mid-gray/10 border border-mid-gray/80 hover:bg-logo-primary/10 hover:border-logo-primary"
: "bg-mid-gray/5 border border-mid-gray/40 hover:bg-logo-primary/10 hover:border-logo-primary text-mid-gray/60"
}`}
className="px-2 py-1 text-sm font-semibold bg-mid-gray/10 border border-mid-gray/80 hover:bg-logo-primary/10 rounded cursor-pointer hover:border-logo-primary"
onClick={() => startRecording(shortcutId)}
>
{binding.current_binding
? formatKeyCombination(binding.current_binding, osType)
: t("settings.general.shortcut.notSet")}
{formatKeyCombination(binding.current_binding, osType)}
</div>
)}
<ResetButton

View file

@ -278,22 +278,16 @@ export const HandyKeysShortcutInput: React.FC<HandyKeysShortcutInputProps> = ({
{isRecording ? (
<div
ref={shortcutRef}
className="px-2 py-1 text-sm font-semibold border border-logo-primary bg-logo-primary/30 rounded min-w-[120px] text-center"
className="px-2 py-1 text-sm font-semibold border border-logo-primary bg-logo-primary/30 rounded"
>
{formatCurrentKeys()}
</div>
) : (
<div
className={`px-2 py-1 text-sm font-semibold rounded cursor-pointer min-w-[120px] text-center ${
binding.current_binding
? "bg-mid-gray/10 border border-mid-gray/80 hover:bg-logo-primary/10 hover:border-logo-primary"
: "bg-mid-gray/5 border border-mid-gray/40 hover:bg-logo-primary/10 hover:border-logo-primary text-mid-gray/60"
}`}
className="px-2 py-1 text-sm font-semibold bg-mid-gray/10 border border-mid-gray/80 hover:bg-logo-primary/10 rounded cursor-pointer hover:border-logo-primary"
onClick={startRecording}
>
{binding.current_binding
? formatKeyCombination(binding.current_binding, osType)
: t("settings.general.shortcut.notSet")}
{formatKeyCombination(binding.current_binding, osType)}
</div>
)}
<ResetButton

View file

@ -110,7 +110,6 @@
"loading": "Loading shortcuts...",
"none": "No shortcuts configured",
"notFound": "Shortcut not found",
"notSet": "Not set",
"pressKeys": "Press keys...",
"bindings": {
"transcribe": {