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