disable cancel on linux (#392)
This commit is contained in:
parent
6d6d7fb279
commit
6c35a8d912
2 changed files with 44 additions and 19 deletions
|
|
@ -739,24 +739,44 @@ pub fn resume_binding(app: AppHandle, id: String) -> Result<(), String> {
|
|||
}
|
||||
|
||||
pub fn register_cancel_shortcut(app: &AppHandle) {
|
||||
let app_clone = app.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
if let Some(cancel_binding) = get_settings(&app_clone).bindings.get("cancel").cloned() {
|
||||
if let Err(e) = register_shortcut(&app_clone, cancel_binding) {
|
||||
eprintln!("Failed to register cancel shortcut: {}", e);
|
||||
// Cancel shortcut is disabled on Linux due to instability with dynamic shortcut registration
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let _ = app;
|
||||
return;
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
let app_clone = app.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
if let Some(cancel_binding) = get_settings(&app_clone).bindings.get("cancel").cloned() {
|
||||
if let Err(e) = register_shortcut(&app_clone, cancel_binding) {
|
||||
eprintln!("Failed to register cancel shortcut: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unregister_cancel_shortcut(app: &AppHandle) {
|
||||
let app_clone = app.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
if let Some(cancel_binding) = get_settings(&app_clone).bindings.get("cancel").cloned() {
|
||||
// We ignore errors here as it might already be unregistered
|
||||
let _ = unregister_shortcut(&app_clone, cancel_binding);
|
||||
}
|
||||
});
|
||||
// Cancel shortcut is disabled on Linux due to instability with dynamic shortcut registration
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let _ = app;
|
||||
return;
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
let app_clone = app.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
if let Some(cancel_binding) = get_settings(&app_clone).bindings.get("cancel").cloned() {
|
||||
// We ignore errors here as it might already be unregistered
|
||||
let _ = unregister_shortcut(&app_clone, cancel_binding);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register_shortcut(app: &AppHandle, binding: ShortcutBinding) -> Result<(), String> {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import React from "react";
|
||||
import { type } from "@tauri-apps/plugin-os";
|
||||
import { WordCorrectionThreshold } from "./WordCorrectionThreshold";
|
||||
import { LogDirectory } from "./LogDirectory";
|
||||
import { LogLevelSelector } from "./LogLevelSelector";
|
||||
|
|
@ -17,6 +18,7 @@ import { useSettings } from "../../../hooks/useSettings";
|
|||
export const DebugSettings: React.FC = () => {
|
||||
const { getSetting } = useSettings();
|
||||
const pushToTalk = getSetting("push_to_talk");
|
||||
const isLinux = type() === "linux";
|
||||
|
||||
return (
|
||||
<div className="max-w-3xl w-full mx-auto space-y-6">
|
||||
|
|
@ -38,11 +40,14 @@ export const DebugSettings: React.FC = () => {
|
|||
<ClamshellMicrophoneSelector descriptionMode="tooltip" grouped={true} />
|
||||
<PostProcessingToggle descriptionMode="tooltip" grouped={true} />
|
||||
<MuteWhileRecording descriptionMode="tooltip" grouped={true} />
|
||||
<HandyShortcut
|
||||
shortcutId="cancel"
|
||||
grouped={true}
|
||||
disabled={pushToTalk}
|
||||
/>
|
||||
{/* Cancel shortcut is disabled on Linux due to instability with dynamic shortcut registration */}
|
||||
{!isLinux && (
|
||||
<HandyShortcut
|
||||
shortcutId="cancel"
|
||||
grouped={true}
|
||||
disabled={pushToTalk}
|
||||
/>
|
||||
)}
|
||||
</SettingsGroup>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue