feat(settings): add system tray settings
Add tray icon configuration options: - Enable/disable tray icon (requires restart) - Minimize to tray: hide window when clicking minimize - Close to tray: hide window instead of quitting Rust backend: TraySettingsState with SQLite persistence Frontend: SettingsView tray subsection with toggles Related to #15 (title bar settings)
This commit is contained in:
1 parent
3fb597f3fb
commit
077aa01356
7 files changed
+369
-8
No files matched your search
@@ -1,9 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { Minus, Maximize2, Minimize2, X } from 'lucide-svelte';
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
interface TraySettings {
|
||||
enable_tray: boolean;
|
||||
minimize_to_tray: boolean;
|
||||
close_to_tray: boolean;
|
||||
}
|
||||
|
||||
let isMaximized = $state(false);
|
||||
let minimizeToTray = $state(false);
|
||||
let appWindow: ReturnType<typeof getCurrentWindow>;
|
||||
|
||||
onMount(() => {
|
||||
@@ -15,6 +23,14 @@
|
||||
// Check initial maximized state
|
||||
isMaximized = await appWindow.isMaximized();
|
||||
|
||||
// Load tray settings
|
||||
try {
|
||||
const settings = await invoke<TraySettings>('get_tray_settings');
|
||||
minimizeToTray = settings.minimize_to_tray;
|
||||
} catch (e) {
|
||||
console.error('Failed to load tray settings:', e);
|
||||
}
|
||||
|
||||
// Listen for window state changes
|
||||
unlisten = await appWindow.onResized(async () => {
|
||||
isMaximized = await appWindow.isMaximized();
|
||||
@@ -27,7 +43,11 @@
|
||||
});
|
||||
|
||||
async function handleMinimize() {
|
||||
await appWindow?.minimize();
|
||||
if (minimizeToTray) {
|
||||
await appWindow?.hide();
|
||||
} else {
|
||||
await appWindow?.minimize();
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMaximize() {
|
||||
|
||||
Reference in new issue
Block a user