-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
139a7be
commit 264ebe1
Showing
4 changed files
with
115 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#[tauri::command] | ||
pub fn update_tray( | ||
app_handle: tauri::AppHandle, | ||
title: Option<String>, | ||
description: Option<String>, | ||
new_icon: Option<bool>, | ||
) { | ||
let tray_handle = app_handle.tray_handle(); | ||
#[cfg(target_os = "macos")] | ||
if let Some(title) = title { | ||
tray_handle.set_title(&title).unwrap(); | ||
} | ||
if let Some(description) = description { | ||
tray_handle.get_item("text").set_title(description).unwrap(); | ||
} | ||
if let Some(new_icon) = new_icon { | ||
if new_icon { | ||
tray_handle | ||
.set_icon(tauri::Icon::Raw( | ||
include_bytes!("../icons/tray-new.png").to_vec(), | ||
)) | ||
.unwrap(); | ||
} else { | ||
tray_handle | ||
.set_icon(tauri::Icon::Raw( | ||
include_bytes!("../icons/tray-base.png").to_vec(), | ||
)) | ||
.unwrap(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use tauri::{LogicalSize, Manager, Size}; | ||
use tauri_plugin_window_state::{AppHandleExt, StateFlags, WindowExt}; | ||
|
||
pub fn activate_tray_mode(app: &tauri::AppHandle) { | ||
app.save_window_state(StateFlags::all()).unwrap(); | ||
let window = app.get_window("main").unwrap(); | ||
window.set_decorations(false).unwrap(); | ||
window | ||
.set_size(Size::Logical(LogicalSize { | ||
width: 400.0, | ||
height: 600.0, | ||
})) | ||
.unwrap(); | ||
} | ||
|
||
pub fn deactivate_tray_mode(app: &tauri::AppHandle) { | ||
let window = app.get_window("main").unwrap(); | ||
window.restore_state(StateFlags::all()).unwrap(); | ||
window.set_decorations(true).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters