mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 21:24:05 +02:00
feat: add icon support to app info display and update styles for improved layout in index.scss
This commit is contained in:
parent
f890851a59
commit
1ec040ef1e
5 changed files with 71 additions and 160 deletions
|
@ -1,6 +1,5 @@
|
|||
use active_win_pos_rs::get_active_window;
|
||||
use applications::{AppInfoContext, AppInfo, AppTrait, utils::image::RustImage};
|
||||
use base64::{ engine::general_purpose::STANDARD, Engine };
|
||||
use image::codecs::png::PngEncoder;
|
||||
use tauri::PhysicalPosition;
|
||||
use meta_fetcher;
|
||||
|
||||
|
@ -37,23 +36,24 @@ pub fn center_window_on_current_monitor(window: &tauri::WebviewWindow) {
|
|||
}
|
||||
|
||||
pub fn get_app_info() -> (String, Option<String>) {
|
||||
match get_active_window() {
|
||||
let mut ctx = AppInfoContext::new(vec![]);
|
||||
ctx.refresh_apps().unwrap();
|
||||
match ctx.get_frontmost_application() {
|
||||
Ok(window) => {
|
||||
let app_name = window.app_name;
|
||||
(app_name, None)
|
||||
let name = window.name.clone();
|
||||
let icon = window
|
||||
.load_icon()
|
||||
.ok()
|
||||
.map(|i| {
|
||||
let png = i.to_png().unwrap();
|
||||
STANDARD.encode(png.get_bytes())
|
||||
});
|
||||
(name, icon)
|
||||
}
|
||||
Err(_) => ("System".to_string(), None),
|
||||
}
|
||||
}
|
||||
|
||||
fn _process_icon_to_base64(path: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let img = image::open(path)?;
|
||||
let resized = img.resize(128, 128, image::imageops::FilterType::Lanczos3);
|
||||
let mut png_buffer = Vec::new();
|
||||
resized.write_with_encoder(PngEncoder::new(&mut png_buffer))?;
|
||||
Ok(STANDARD.encode(png_buffer))
|
||||
}
|
||||
|
||||
pub fn detect_color(color: &str) -> bool {
|
||||
let color = color.trim().to_lowercase();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue