add setting to enable or disable showing the overlay
This commit is contained in:
parent
d9411c5ef6
commit
dd957a894d
11 changed files with 71 additions and 3 deletions
|
|
@ -185,6 +185,7 @@ pub fn run() {
|
|||
shortcut::change_audio_feedback_setting,
|
||||
shortcut::change_translate_to_english_setting,
|
||||
shortcut::change_selected_language_setting,
|
||||
shortcut::change_show_overlay_setting,
|
||||
trigger_update_check,
|
||||
commands::models::get_available_models,
|
||||
commands::models::get_model_info,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::utils;
|
|||
use log::{debug, info};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
use tauri::{App, Emitter, Manager};
|
||||
use tauri::{App, Manager};
|
||||
|
||||
const WHISPER_SAMPLE_RATE: usize = 16000;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ pub struct AppSettings {
|
|||
pub translate_to_english: bool,
|
||||
#[serde(default = "default_selected_language")]
|
||||
pub selected_language: String,
|
||||
#[serde(default = "default_show_overlay")]
|
||||
pub show_overlay: bool,
|
||||
}
|
||||
|
||||
fn default_model() -> String {
|
||||
|
|
@ -54,6 +56,11 @@ fn default_selected_language() -> String {
|
|||
"auto".to_string()
|
||||
}
|
||||
|
||||
fn default_show_overlay() -> bool {
|
||||
// Default to true - users expect visual feedback by default
|
||||
true
|
||||
}
|
||||
|
||||
pub const SETTINGS_STORE_PATH: &str = "settings_store.json";
|
||||
|
||||
pub fn get_default_settings() -> AppSettings {
|
||||
|
|
@ -99,6 +106,7 @@ pub fn get_default_settings() -> AppSettings {
|
|||
selected_output_device: None,
|
||||
translate_to_english: false,
|
||||
selected_language: "auto".to_string(),
|
||||
show_overlay: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,14 @@ pub fn change_selected_language_setting(app: AppHandle, language: String) -> Res
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn change_show_overlay_setting(app: AppHandle, enabled: bool) -> Result<(), String> {
|
||||
let mut settings = settings::get_settings(&app);
|
||||
settings.show_overlay = enabled;
|
||||
settings::write_settings(&app, settings);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn _register_shortcut(app: &AppHandle, binding: ShortcutBinding) -> Result<(), String> {
|
||||
// Parse shortcut and return error if it fails
|
||||
let shortcut = match binding.current_binding.parse::<Shortcut>() {
|
||||
|
|
|
|||
|
|
@ -245,6 +245,12 @@ pub fn create_recording_overlay(app_handle: &AppHandle) {
|
|||
|
||||
/// Shows the recording overlay window with fade-in animation
|
||||
pub fn show_recording_overlay(app_handle: &AppHandle) {
|
||||
// Check if show_overlay is enabled in settings
|
||||
let settings = settings::get_settings(app_handle);
|
||||
if !settings.show_overlay {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(overlay_window) = app_handle.get_webview_window("recording_overlay") {
|
||||
let _ = overlay_window.show();
|
||||
// Emit event to trigger fade-in animation with recording state
|
||||
|
|
@ -254,6 +260,12 @@ pub fn show_recording_overlay(app_handle: &AppHandle) {
|
|||
|
||||
/// Shows the transcribing overlay window
|
||||
pub fn show_transcribing_overlay(app_handle: &AppHandle) {
|
||||
// Check if show_overlay is enabled in settings
|
||||
let settings = settings::get_settings(app_handle);
|
||||
if !settings.show_overlay {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(overlay_window) = app_handle.get_webview_window("recording_overlay") {
|
||||
let _ = overlay_window.show();
|
||||
// Emit event to switch to transcribing state
|
||||
|
|
@ -263,6 +275,8 @@ pub fn show_transcribing_overlay(app_handle: &AppHandle) {
|
|||
|
||||
/// Hides the recording overlay window with fade-out animation
|
||||
pub fn hide_recording_overlay(app_handle: &AppHandle) {
|
||||
// Check if show_overlay is enabled in settings - if disabled, the overlay shouldn't be shown anyway
|
||||
// but we still want to hide it in case the setting was changed while recording
|
||||
if let Some(overlay_window) = app_handle.get_webview_window("recording_overlay") {
|
||||
// Emit event to trigger fade-out animation
|
||||
let _ = overlay_window.emit("hide-overlay", ());
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
{
|
||||
"title": "Handy",
|
||||
"width": 540,
|
||||
"height": 680,
|
||||
"height": 720,
|
||||
"minWidth": 540,
|
||||
"minHeight": 680,
|
||||
"minHeight": 720,
|
||||
"resizable": true,
|
||||
"maximizable": false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { AlwaysOnMicrophone } from "./AlwaysOnMicrophone";
|
|||
import { PushToTalk } from "./PushToTalk";
|
||||
import { AudioFeedback } from "./AudioFeedback";
|
||||
import { OutputDeviceSelector } from "./OutputDeviceSelector";
|
||||
import { ShowOverlay } from "./ShowOverlay";
|
||||
import { HandyShortcut } from "./HandyShortcut";
|
||||
import { TranslateToEnglish } from "./TranslateToEnglish";
|
||||
import { LanguageSelector } from "./LanguageSelector";
|
||||
|
|
@ -22,6 +23,7 @@ export const Settings: React.FC = () => {
|
|||
<PushToTalk descriptionMode="tooltip" grouped={true} />
|
||||
<AudioFeedback descriptionMode="tooltip" grouped={true} />
|
||||
<OutputDeviceSelector descriptionMode="tooltip" grouped={true} />
|
||||
<ShowOverlay descriptionMode="tooltip" grouped={true} />
|
||||
<TranslateToEnglish descriptionMode="tooltip" grouped={true} />
|
||||
<AlwaysOnMicrophone descriptionMode="tooltip" grouped={true} />
|
||||
</SettingsGroup>
|
||||
|
|
|
|||
29
src/components/settings/ShowOverlay.tsx
Normal file
29
src/components/settings/ShowOverlay.tsx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import React from "react";
|
||||
import { ToggleSwitch } from "../ui/ToggleSwitch";
|
||||
import { useSettings } from "../../hooks/useSettings";
|
||||
|
||||
interface ShowOverlayProps {
|
||||
descriptionMode?: "inline" | "tooltip";
|
||||
grouped?: boolean;
|
||||
}
|
||||
|
||||
export const ShowOverlay: React.FC<ShowOverlayProps> = ({
|
||||
descriptionMode = "tooltip",
|
||||
grouped = false,
|
||||
}) => {
|
||||
const { getSetting, updateSetting, isUpdating } = useSettings();
|
||||
|
||||
const showOverlayEnabled = getSetting("show_overlay") ?? true;
|
||||
|
||||
return (
|
||||
<ToggleSwitch
|
||||
checked={showOverlayEnabled}
|
||||
onChange={(enabled) => updateSetting("show_overlay", enabled)}
|
||||
isUpdating={isUpdating("show_overlay")}
|
||||
label="Show Overlay"
|
||||
description="Display visual feedback overlay during recording and transcription"
|
||||
descriptionMode={descriptionMode}
|
||||
grouped={grouped}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
@ -4,5 +4,6 @@ export { OutputDeviceSelector } from "./OutputDeviceSelector";
|
|||
export { AlwaysOnMicrophone } from "./AlwaysOnMicrophone";
|
||||
export { PushToTalk } from "./PushToTalk";
|
||||
export { AudioFeedback } from "./AudioFeedback";
|
||||
export { ShowOverlay } from "./ShowOverlay";
|
||||
export { HandyShortcut } from "./HandyShortcut";
|
||||
export { TranslateToEnglish } from "./TranslateToEnglish";
|
||||
|
|
|
|||
|
|
@ -199,6 +199,9 @@ export const useSettings = (): UseSettingsReturn => {
|
|||
language: value,
|
||||
});
|
||||
break;
|
||||
case "show_overlay":
|
||||
await invoke("change_show_overlay_setting", { enabled: value });
|
||||
break;
|
||||
case "bindings":
|
||||
// Handle bindings separately - they use their own invoke methods
|
||||
break;
|
||||
|
|
@ -243,6 +246,7 @@ export const useSettings = (): UseSettingsReturn => {
|
|||
selected_output_device: "Default",
|
||||
translate_to_english: false,
|
||||
selected_language: "auto",
|
||||
show_overlay: true,
|
||||
};
|
||||
|
||||
const defaultValue = defaults[key];
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ export const SettingsSchema = z.object({
|
|||
selected_output_device: z.string().nullable().optional(),
|
||||
translate_to_english: z.boolean(),
|
||||
selected_language: z.string(),
|
||||
show_overlay: z.boolean(),
|
||||
});
|
||||
|
||||
export const BindingResponseSchema = z.object({
|
||||
|
|
|
|||
Loading…
Reference in a new issue