diff --git a/bun.lockb b/bun.lockb index ff6d35d..763f999 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 4e670aa..776a339 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "xhotit", "private": true, - "version": "1.1.0", + "version": "1.1.1", "type": "module", "scripts": { "dev": "vite", @@ -16,6 +16,7 @@ "@tauri-apps/api": "~2.2.0", "@tauri-apps/plugin-dialog": "~2.2.0", "@tauri-apps/plugin-fs": "~2.2.0", + "@tauri-apps/plugin-log": "~2.2.0", "@tauri-apps/plugin-opener": "~2.2.4", "@tauri-apps/plugin-upload": "~2.2.1", "@tauri-apps/plugin-window-state": "~2.2.0", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 868dc74..4e0d112 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -31,6 +31,17 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom 0.2.15", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -61,6 +72,23 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" +[[package]] +name = "android_log-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937" + +[[package]] +name = "android_logger" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b07e8e73d720a1f2e4b6014766e6039fd2e96a4fa44e2a78d0e1fa2ff49826" +dependencies = [ + "android_log-sys", + "env_filter", + "log", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -86,6 +114,12 @@ dependencies = [ "objc", ] +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + [[package]] name = "ashpd" version = "0.10.2" @@ -356,6 +390,18 @@ dependencies = [ "serde", ] +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "block" version = "0.1.6" @@ -393,6 +439,29 @@ dependencies = [ "piper", ] +[[package]] +name = "borsh" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb65153674e51d3a42c8f27b05b9508cea85edfaade8aa46bc8fc18cecdfef3" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a396e17ad94059c650db3d253bb6e25927f1eb462eede7e7a153bb6e75dce0a7" +dependencies = [ + "once_cell", + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 2.0.95", +] + [[package]] name = "brotli" version = "7.0.0" @@ -420,6 +489,39 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "byte-unit" +version = "5.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cd29c3c585209b0cbc7309bfe3ed7efd8c84c21b7af29c8bfae908f8777174" +dependencies = [ + "rust_decimal", + "serde", + "utf8-width", +] + +[[package]] +name = "bytecheck" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "bytemuck" version = "1.21.0" @@ -1139,6 +1241,16 @@ dependencies = [ "syn 2.0.95", ] +[[package]] +name = "env_filter" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" +dependencies = [ + "log", + "regex", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -1216,6 +1328,15 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "fern" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4316185f709b23713e41e3195f90edef7fb00c3ed4adc79769cf09cc762a3b29" +dependencies = [ + "log", +] + [[package]] name = "field-offset" version = "0.3.6" @@ -1309,6 +1430,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futf" version = "0.1.5" @@ -1740,6 +1867,9 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] [[package]] name = "hashbrown" @@ -2434,9 +2564,12 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +dependencies = [ + "value-bag", +] [[package]] name = "mac" @@ -2684,6 +2817,15 @@ dependencies = [ "syn 2.0.95", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + [[package]] name = "objc" version = "0.2.7" @@ -3329,6 +3471,26 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "qoi" version = "0.4.1" @@ -3389,6 +3551,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.7.3" @@ -3567,6 +3735,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + [[package]] name = "reqwest" version = "0.12.12" @@ -3639,6 +3816,51 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "rkyv" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rust_decimal" +version = "1.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" +dependencies = [ + "arrayvec", + "borsh", + "bytes", + "num-traits", + "rand 0.8.5", + "rkyv", + "serde", + "serde_json", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -3746,6 +3968,12 @@ dependencies = [ "xcb", ] +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + [[package]] name = "selectors" version = "0.22.0" @@ -3955,6 +4183,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + [[package]] name = "siphasher" version = "0.3.11" @@ -4208,6 +4442,12 @@ dependencies = [ "syn 2.0.95", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "target-lexicon" version = "0.12.16" @@ -4216,9 +4456,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tauri" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2133243fd7dc4932bac10ad18d45043e5cdb69e1bbd1df6f57336ad2c372cca" +checksum = "2979ec5ec5a9310b15d1548db3b8de98d8f75abf2b5b00fec9cd5c0553ecc09c" dependencies = [ "anyhow", "bytes", @@ -4387,6 +4627,28 @@ dependencies = [ "uuid", ] +[[package]] +name = "tauri-plugin-log" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd784c138c08a43954bc3e735402e6b2b2ee8d8c254a7391f4e77c01273dd5" +dependencies = [ + "android_logger", + "byte-unit", + "cocoa", + "fern", + "log", + "objc", + "serde", + "serde_json", + "serde_repr", + "swift-rs", + "tauri", + "tauri-plugin", + "thiserror 2.0.9", + "time", +] + [[package]] name = "tauri-plugin-opener" version = "2.2.4" @@ -4625,7 +4887,9 @@ checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "itoa 1.0.14", + "libc", "num-conv", + "num_threads", "powerfmt", "serde", "time-core", @@ -4658,6 +4922,21 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinyvec" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.42.0" @@ -4955,6 +5234,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" +[[package]] +name = "utf8-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -4977,6 +5262,12 @@ dependencies = [ "serde", ] +[[package]] +name = "value-bag" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef4c4aa54d5d05a279399bfa921ec387b7aba77caf7a682ae8d86785b8fdad2" + [[package]] name = "version-compare" version = "0.2.0" @@ -5925,6 +6216,15 @@ dependencies = [ "x11-dl", ] +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "x11" version = "2.21.0" @@ -5987,7 +6287,7 @@ dependencies = [ [[package]] name = "xhotit" -version = "1.1.0" +version = "1.1.1" dependencies = [ "active-win-pos-rs", "base64 0.22.1", @@ -6000,6 +6300,7 @@ dependencies = [ "jpeg-decoder", "libc", "lodepng", + "log", "mozjpeg-sys", "png", "screenshots", @@ -6009,6 +6310,7 @@ dependencies = [ "tauri-build", "tauri-plugin-dialog", "tauri-plugin-fs", + "tauri-plugin-log", "tauri-plugin-opener", "tauri-plugin-upload", "tauri-plugin-window-state", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 1dcbee5..4d06a8f 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xhotit" -version = "1.1.0" +version = "1.1.1" description = "Xhot It - Screen Capture" authors = ["Irfan Maulana"] edition = "2021" @@ -18,7 +18,7 @@ edition = "2021" tauri-build = { version = "2.0.5", features = [] } [dependencies] -tauri = { version = "2.2.1", features = [ +tauri = { version = "2.2.2", features = [ "macos-private-api", "protocol-asset", "tray-icon", @@ -31,6 +31,7 @@ tauri-plugin-window-state = "2.2.0" tauri-plugin-fs = "2.2.0" tauri-plugin-upload = "2.2.1" tauri-plugin-dialog = "2.2.0" +tauri-plugin-log = "2.2.0" serde = { version = "1.0.217", features = ["derive"] } serde_json = "1.0.135" @@ -43,7 +44,7 @@ fs_extra = "1.3.0" directories = "6.0.0" chrono = "0.4.39" active-win-pos-rs = "0.9" -image = { version = "0.25", default-features = false, features = [ +image = { version = "0.25.5", default-features = false, features = [ "jpeg", "ico", "png", @@ -55,11 +56,12 @@ image = { version = "0.25", default-features = false, features = [ "hdr", "dds", ] } -png = "0.17" -jpeg-decoder = "0.3" -mozjpeg-sys = { version = "2.2", default-features = false } -libc = "0.2" -lodepng = { version = "3.10", default-features = false } +png = "0.17.16" +jpeg-decoder = "0.3.1" +mozjpeg-sys = { version = "2.2.2", default-features = false } +libc = "0.2.169" +lodepng = { version = "3.10.7", default-features = false } +log = "0.4.25" # [target."cfg(not(target_os = \"windows\"))".dependencies] fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs" } diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 9dd2a9d..f4790e7 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -25,6 +25,7 @@ "dialog:allow-confirm", "dialog:allow-message", "dialog:allow-open", - "dialog:allow-save" + "dialog:allow-save", + "log:allow-log" ] } diff --git a/src-tauri/src/app_command.rs b/src-tauri/src/app_command.rs index 09b121b..345e6e8 100644 --- a/src-tauri/src/app_command.rs +++ b/src-tauri/src/app_command.rs @@ -2,9 +2,13 @@ use std::{path::PathBuf, process::Command as ProcessCommand}; use tauri::{command, AppHandle, Emitter, Manager}; use crate::{ - app_directory::{get_app_directory, list_images_in_directory_sorted}, app_win_manager::{reopen_main_window, toggle_compress_window, toggle_overlay_window}, constant::{APP_DOWNLOAD_DIR, ON_SCREENSHOT_EVENT}, image_compressor::{jpeg::process_jpeg, png::process_png, shared::ImageParams}, screenshot::{ + app_directory::{get_app_directory, list_images_in_directory_sorted}, + app_win_manager::{reopen_main_window, toggle_compress_window, toggle_overlay_window}, + constant::{APP_DOWNLOAD_DIR, ON_SCREENSHOT_EVENT}, + image_compressor::{jpeg::process_jpeg, png::process_png, shared::ImageParams}, + screenshot::{ capture_monitor, capture_screen, capture_window, get_screenshot_path, SelectionCoords, - } + }, }; /** @@ -119,7 +123,13 @@ pub fn open_compress(app_handle: AppHandle) { #[command] pub fn exec_compress(app_handle: AppHandle, image: ImageParams) { if image.name.to_lowercase().contains(".png") { - process_png(app_handle, &image.src, image.quality, image.overwrite, image.filter) + process_png( + app_handle, + &image.src, + image.quality, + image.overwrite, + image.filter, + ) } else if image.name.to_lowercase().contains(".jpg") || image.name.to_lowercase().contains(".jpeg") { diff --git a/src-tauri/src/app_menu.rs b/src-tauri/src/app_menu.rs index 699fc3b..2cd1a9d 100644 --- a/src-tauri/src/app_menu.rs +++ b/src-tauri/src/app_menu.rs @@ -1,14 +1,11 @@ use tauri::{ image::Image, menu::{IconMenuItem, MenuBuilder, MenuItem}, - App, Manager, Theme, Wry, + App, Wry, }; -use crate::constant::WINDOW_MAIN_ID; - pub fn get_menu_builder(app: &mut App) -> MenuBuilder<'_, Wry, App> { let capture_area_icon = Image::from_path("./icons/menu/viewfinder-circle.png"); - let capture_area_icon_light = Image::from_path("./icons/menu/viewfinder-circle-light.png"); let capture_area_i = IconMenuItem::with_id( app, @@ -21,7 +18,6 @@ pub fn get_menu_builder(app: &mut App) -> MenuBuilder<'_, Wry, App> { .unwrap(); let capture_active_icon = Image::from_path("./icons/menu/camera.png"); - let capture_active_icon_light = Image::from_path("./icons/menu/camera-light.png"); let capture_active_i = IconMenuItem::with_id( app, "capture_active", @@ -33,7 +29,6 @@ pub fn get_menu_builder(app: &mut App) -> MenuBuilder<'_, Wry, App> { .unwrap(); let capture_screen_icon = Image::from_path("./icons/menu/computer-desktop.png"); - let capture_screen_icon_light = Image::from_path("./icons/menu/computer-desktop-light.png"); let capture_screen_i = IconMenuItem::with_id( app, "capture_screen", @@ -45,7 +40,6 @@ pub fn get_menu_builder(app: &mut App) -> MenuBuilder<'_, Wry, App> { .unwrap(); let compress_icon = Image::from_path("./icons/menu/bolt.png"); - let compress_icon_light = Image::from_path("./icons/menu/bolt-light.png"); let compress_i = IconMenuItem::with_id( app, "compress_image", @@ -66,19 +60,6 @@ pub fn get_menu_builder(app: &mut App) -> MenuBuilder<'_, Wry, App> { let quit_i = MenuItem::with_id(app, "quit", "Quit", true, Some("CmdOrCtrl+Q")).unwrap(); - let win = app.get_webview_window(WINDOW_MAIN_ID); - if let Some(win) = win { - let t = win.theme().ok().unwrap(); - - // Set different icon for light theme - if t == Theme::Light { - capture_area_i.set_icon(Some(capture_area_icon_light.unwrap())).unwrap(); - capture_active_i.set_icon(Some(capture_active_icon_light.unwrap())).unwrap(); - capture_screen_i.set_icon(Some(capture_screen_icon_light.unwrap())).unwrap(); - compress_i.set_icon(Some(compress_icon_light.unwrap())).unwrap(); - } - } - return MenuBuilder::new(app) .items(&[ &capture_area_i, @@ -89,3 +70,32 @@ pub fn get_menu_builder(app: &mut App) -> MenuBuilder<'_, Wry, App> { .separator() .items(&[&reopen_i, &report_bug_i, &donate_i, &quit_i]); } + +// pub fn switch_menu_icon(app: App) { +// let win = app.get_webview_window(WINDOW_MAIN_ID); +// if let Some(win) = win { +// let t = win.theme().ok().unwrap(); + +// // Set different icon for light theme +// if t == Theme::Light { +// let capture_area_icon_light = +// Image::from_path("./icons/menu/viewfinder-circle-light.png"); +// let capture_active_icon_light = Image::from_path("./icons/menu/camera-light.png"); +// let compress_icon_light = Image::from_path("./icons/menu/bolt-light.png"); +// let capture_screen_icon_light = +// Image::from_path("./icons/menu/computer-desktop-light.png"); +// capture_area_i +// .set_icon(Some(capture_area_icon_light.unwrap())) +// .unwrap(); +// capture_active_i +// .set_icon(Some(capture_active_icon_light.unwrap())) +// .unwrap(); +// capture_screen_i +// .set_icon(Some(capture_screen_icon_light.unwrap())) +// .unwrap(); +// compress_i +// .set_icon(Some(compress_icon_light.unwrap())) +// .unwrap(); +// } +// } +// } diff --git a/src-tauri/src/app_win_manager.rs b/src-tauri/src/app_win_manager.rs index b73dce2..3eeba4a 100644 --- a/src-tauri/src/app_win_manager.rs +++ b/src-tauri/src/app_win_manager.rs @@ -76,7 +76,12 @@ pub fn create_compress_window(app: &AppHandle) { WebviewUrl::App(web_view_url.into()), ); - let win = win_builder.resizable(true).title("Xhot It - Compress Image").center().min_inner_size(600.0, 400.0).build().unwrap(); + let win = win_builder + .resizable(true) + .title("Xhot It - Compress Image") + .center() + .build() + .unwrap(); win.show().unwrap(); diff --git a/src-tauri/src/constant.rs b/src-tauri/src/constant.rs index ff900bc..75336d9 100644 --- a/src-tauri/src/constant.rs +++ b/src-tauri/src/constant.rs @@ -10,4 +10,4 @@ pub const APP_DOWNLOAD_DIR: &str = "xhotit-screenshots"; // Window IDs pub const WINDOW_MAIN_ID: &str = "main"; pub const WINDOW_OVERLAY_ID: &str = "overlay"; -pub const WINDOW_COMPRESS_ID: &str = "compress"; \ No newline at end of file +pub const WINDOW_COMPRESS_ID: &str = "compress"; diff --git a/src-tauri/src/image_compressor/jpeg.rs b/src-tauri/src/image_compressor/jpeg.rs index 29c9b18..feebfbe 100644 --- a/src-tauri/src/image_compressor/jpeg.rs +++ b/src-tauri/src/image_compressor/jpeg.rs @@ -192,7 +192,6 @@ unsafe fn encode_jpeg(buffer: &[u8], width: u32, height: u32, quality: i32, dest // (width, height) // } - pub fn get_dest_path_jpg(path_str: &str, overwrite: bool) -> String { if !path_str.contains(".min") && !overwrite { return replace_jpg_ext(path_str); @@ -203,12 +202,12 @@ pub fn get_dest_path_jpg(path_str: &str, overwrite: bool) -> String { fn replace_jpg_ext(path_str: &str) -> String { let res = &path_str - .replace(".jpg", ".min.jpg") - .replace(".JPG", ".min.jpg") - .replace(".jpeg", ".min.jpeg") - .replace(".JPEG", ".min.jpeg"); + .replace(".jpg", ".min.jpg") + .replace(".JPG", ".min.jpg") + .replace(".jpeg", ".min.jpeg") + .replace(".JPEG", ".min.jpeg"); let str = String::from(res); return str; -} \ No newline at end of file +} diff --git a/src-tauri/src/image_compressor/mod.rs b/src-tauri/src/image_compressor/mod.rs index 4acb7e5..80b43ef 100644 --- a/src-tauri/src/image_compressor/mod.rs +++ b/src-tauri/src/image_compressor/mod.rs @@ -1,4 +1,3 @@ - -pub mod shared; pub mod jpeg; -pub mod png; \ No newline at end of file +pub mod png; +pub mod shared; diff --git a/src-tauri/src/image_compressor/png.rs b/src-tauri/src/image_compressor/png.rs index 48ca0a9..6a86217 100644 --- a/src-tauri/src/image_compressor/png.rs +++ b/src-tauri/src/image_compressor/png.rs @@ -81,7 +81,6 @@ pub fn process_png(app_handle: AppHandle, path_str: &str, q: i32, overwrite: boo } } - pub fn get_dest_path_png(path_str: &str, overwrite: bool) -> String { if !path_str.contains(".min") && !overwrite { return replace_png_ext(path_str); @@ -98,4 +97,4 @@ fn replace_png_ext(path_str: &str) -> String { let str = String::from(res); return str; -} \ No newline at end of file +} diff --git a/src-tauri/src/image_compressor/shared.rs b/src-tauri/src/image_compressor/shared.rs index 4fcdccf..21737d8 100644 --- a/src-tauri/src/image_compressor/shared.rs +++ b/src-tauri/src/image_compressor/shared.rs @@ -38,4 +38,3 @@ pub struct DecoderParam { pub overwrite: bool, pub filter: String, } - diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index d7511de..67a3caa 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -3,8 +3,8 @@ mod app_command; mod app_directory; -mod app_win_manager; mod app_menu; +mod app_win_manager; mod constant; mod image_compressor; mod screenshot; @@ -19,10 +19,22 @@ use app_win_manager::{reopen_main_window, toggle_compress_window, toggle_overlay use screenshot::{capture_monitor, capture_window}; use fix_path_env::fix; +use std::backtrace; +use std::io::Write; use tauri::tray::TrayIconBuilder; use tauri_plugin_opener::OpenerExt; fn main() { + std::panic::set_hook(Box::new(|info| { + let backtrace = backtrace::Backtrace::force_capture(); + println!("panic occurred: {:?}", info); + + let _ = std::fs::File::create("xhotit_panic.log") + .and_then(|mut f| f.write_all(format!("{:?}\n{:#?}", info, backtrace).as_bytes())); + + std::process::exit(1); + })); + // Based on issue: https://github.com/tauri-apps/tauri/issues/7063 // https://github.com/tauri-apps/fix-path-env-rs // #[cfg(not(target_os="windows"))] @@ -31,6 +43,18 @@ fn main() { } tauri::Builder::default() + .plugin( + tauri_plugin_log::Builder::new() + .level(log::LevelFilter::Warn) + .target(tauri_plugin_log::Target::new( + tauri_plugin_log::TargetKind::LogDir { + file_name: Some("logs".to_string()), + }, + )) + .timezone_strategy(tauri_plugin_log::TimezoneStrategy::UseLocal) + .rotation_strategy(tauri_plugin_log::RotationStrategy::KeepAll) + .build(), + ) .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_upload::init()) @@ -42,7 +66,7 @@ fn main() { let mb = get_menu_builder(app).build()?; - let _tray = TrayIconBuilder::new() + let _tray = TrayIconBuilder::with_id("xhotit-tray") .icon(app.default_window_icon().unwrap().clone()) .menu(&mb) .on_menu_event(|app, event| match event.id.as_ref() { @@ -93,5 +117,5 @@ fn main() { exec_compress, ]) .run(tauri::generate_context!()) - .expect("ERROR: error while running tauri application"); + .expect("ERROR: error while running Xhot It"); } diff --git a/src-tauri/src/screenshot.rs b/src-tauri/src/screenshot.rs index 778280c..538818f 100644 --- a/src-tauri/src/screenshot.rs +++ b/src-tauri/src/screenshot.rs @@ -7,10 +7,10 @@ use tauri::{AppHandle, Emitter}; use crate::{ app_directory::get_app_directory, + app_win_manager::open_main_window, constant::{ APP_DOWNLOAD_DIR, ON_CAPTURE_MONITOR_EVENT, ON_GET_ACTIVE_WINDOW_EVENT, ON_SCREENSHOT_EVENT, }, - app_win_manager::open_main_window, }; // TODO: Migrate to XCap: https://github.com/nashaofu/xcap @@ -120,9 +120,7 @@ pub fn capture_monitor(app_handle: &AppHandle) { let screenshot_path = get_screenshot_path(&app_handle); let screen = Screen::from_point(0, 0).unwrap(); - let image = screen - .capture() - .unwrap(); + let image = screen.capture().unwrap(); image.save(&screenshot_path).unwrap(); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 926d177..59eae04 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Xhot It", - "version": "1.1.0", + "version": "1.1.1", "identifier": "com.xhotit.app", "build": { "beforeDevCommand": "bun run dev", diff --git a/src/main/EmptyState.tsx b/src/main/EmptyState.tsx index 9050afb..4865bd3 100644 --- a/src/main/EmptyState.tsx +++ b/src/main/EmptyState.tsx @@ -107,7 +107,7 @@ export function EmptyState({

Version:{' '} - {'1.1.0'} + {'1.1.1'}

);