Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,9 @@ fn app_setting_set(
message: "application settings lock unavailable".to_string(),
})?;
let mut settings = read_app_settings(&app)?;
if key == MINIMIZE_TO_TRAY_SETTING {
set_tray_visible(&app, value.as_bool().unwrap_or(false));
}
settings.insert(key, value);
write_json_file(&app_settings_path(&app)?, &settings)
}
Expand Down Expand Up @@ -1648,6 +1651,13 @@ fn close_or_hide_main_window(app: &tauri::AppHandle) {
app.exit(0);
}

// The tray only exists to bring back a hidden window, so it follows minimize-to-tray (#145).
fn set_tray_visible(app: &tauri::AppHandle, visible: bool) {
if let Some(tray) = app.tray_by_id("main-tray") {
let _ = tray.set_visible(visible);
}
}

fn build_tray(app: &tauri::AppHandle) -> tauri::Result<()> {
use tauri::menu::{Menu, MenuItem};
use tauri::tray::{TrayIconBuilder, TrayIconEvent};
Expand Down Expand Up @@ -5346,6 +5356,7 @@ pub fn run() {
if let Err(error) = build_tray(app.handle()) {
std::eprintln!("[internal][tauri][warn] tray unavailable: {error}");
}
set_tray_visible(app.handle(), minimize_to_tray_enabled(app.handle()));
Ok(())
})
.on_window_event(move |window, event| match event {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ export function SettingsPage({

<SettingToggle
title="Minimize to tray"
description="Closing the window hides Zuno to the system tray and keeps playing. Quit from the tray icon."
description="Closing the window hides Zuno to the system tray and keeps playing. When off, no tray icon is shown."
checked={minimizeToTray}
onCheckedChange={setMinimizeToTray}
/>
Expand Down
Loading