diff --git a/assets/css/settings.scss b/assets/css/settings.scss index c3ad9d4..c593334 100644 --- a/assets/css/settings.scss +++ b/assets/css/settings.scss @@ -1,10 +1,10 @@ -$primary: #2E2D2B; -$accent: #FEB453; +$primary: #2e2d2b; +$accent: #feb453; $divider: #ffffff0d; -$text: #E5DFD5; -$text2: #ADA9A1; -$mutedtext: #78756F; +$text: #e5dfd5; +$text2: #ada9a1; +$mutedtext: #78756f; .bg { width: 750px; @@ -25,7 +25,7 @@ $mutedtext: #78756F; gap: 8px; align-items: center; - img{ + img { background-color: $divider; border-radius: 6px; padding: 8px 6px; @@ -123,7 +123,7 @@ $mutedtext: #78756F; background-color: $divider; margin-left: 8px; margin-right: 4px; - transition: all .2s; + transition: all 0.2s; } .actions { @@ -134,7 +134,7 @@ $mutedtext: #78756F; gap: 8px; border-radius: 7px; background-color: transparent; - transition: all .2s; + transition: all 0.2s; cursor: pointer; } @@ -142,8 +142,8 @@ $mutedtext: #78756F; background-color: $divider; } - &:hover .actions:hover~.divider { + &:hover .actions:hover ~ .divider { opacity: 0; } } -} \ No newline at end of file +} diff --git a/src-tauri/src/api/tray.rs b/src-tauri/src/api/tray.rs index 8c3d9bc..72d24ec 100644 --- a/src-tauri/src/api/tray.rs +++ b/src-tauri/src/api/tray.rs @@ -23,6 +23,7 @@ pub fn setup(app: &mut tauri::App) -> Result<(), Box> { .build(app)?]) .items(&[&MenuItemBuilder::with_id("show", "Show/Hide").build(app)?]) .items(&[&MenuItemBuilder::with_id("keybind", "Change keybind").build(app)?]) + .items(&[&MenuItemBuilder::with_id("check_updates", "Check for updates").build(app)?]) .items(&[&MenuItemBuilder::with_id("quit", "Quit").build(app)?]) .build()?, ) @@ -48,6 +49,13 @@ pub fn setup(app: &mut tauri::App) -> Result<(), Box> { let _ = _app.track_event("tray_keybind_change", None); window.emit("change_keybind", ()).unwrap(); } + "check_updates" => { + let _ = _app.track_event("tray_check_updates", None); + let app_handle = _app.app_handle().clone(); + tauri::async_runtime::spawn(async move { + crate::api::updater::check_for_updates(app_handle, true).await; + }); + } _ => (), }) .icon(icon) diff --git a/src-tauri/src/api/updater.rs b/src-tauri/src/api/updater.rs index a5e16f9..8c600fa 100644 --- a/src-tauri/src/api/updater.rs +++ b/src-tauri/src/api/updater.rs @@ -1,8 +1,9 @@ +use tauri::Manager; use tauri::{async_runtime, AppHandle}; use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogKind}; use tauri_plugin_updater::UpdaterExt; -pub async fn check_for_updates(app: AppHandle) { +pub async fn check_for_updates(app: AppHandle, prompted: bool) { println!("Checking for updates..."); let updater = app.updater().unwrap(); @@ -18,6 +19,10 @@ pub async fn check_for_updates(app: AppHandle) { "Would you like to install it now?", ]); + let window = app.get_webview_window("main").unwrap(); + window.show().unwrap(); + window.set_focus().unwrap(); + app.dialog() .message(msg) .title("Qopy Update Available") @@ -31,7 +36,7 @@ pub async fn check_for_updates(app: AppHandle) { Ok(_) => { app.dialog() .message("Update installed successfully. The application needs to restart to apply the changes.") - .title("Qopy Update Installed") + .title("Qopy Needs to Restart") .buttons(MessageDialogButtons::OkCancelCustom(String::from("Restart"), String::from("Cancel"))) .show(move |response| { if response { @@ -50,9 +55,22 @@ pub async fn check_for_updates(app: AppHandle) { }); }); } - Ok(None) => println!("No updates available."), + Ok(None) => { + println!("No updates available."); + } Err(e) => { - println!("Failed to check for updates: {:?}", e); + if prompted { + let window = app.get_webview_window("main").unwrap(); + window.show().unwrap(); + window.set_focus().unwrap(); + + app.dialog() + .message("No updates available.") + .title("Qopy Update Check") + .show(|_| {}); + } + + println!("No updates available. {}", e.to_string()); } } } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 7f9fb79..0f2ae6a 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -96,7 +96,7 @@ fn main() { let _ = app.track_event("app_started", None); tauri::async_runtime::spawn(async move { - api::updater::check_for_updates(app_handle).await; + api::updater::check_for_updates(app_handle, false).await; }); Ok(())