mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 13:14:04 +02:00
fixed display of images
This commit is contained in:
parent
fb535a4521
commit
fd4ce395f5
5 changed files with 84 additions and 63 deletions
|
@ -28,6 +28,7 @@
|
|||
"core:window:allow-show",
|
||||
"core:window:allow-set-focus",
|
||||
"core:window:allow-is-focused",
|
||||
"core:window:allow-is-visible"
|
||||
"core:window:allow-is-visible",
|
||||
"fs:allow-read"
|
||||
]
|
||||
}
|
|
@ -24,11 +24,12 @@ pub fn set_app_data_dir(path: std::path::PathBuf) {
|
|||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn read_image(filename: String) -> Result<Vec<u8>, String> {
|
||||
pub fn read_image(filename: String) -> Result<String, String> {
|
||||
let app_data_dir = APP_DATA_DIR.lock().unwrap();
|
||||
let app_data_dir = app_data_dir.as_ref().expect("App data directory not set");
|
||||
let image_path = app_data_dir.join("images").join(filename);
|
||||
fs::read(image_path).map_err(|e| e.to_string())
|
||||
let image_data = fs::read(image_path).map_err(|e| e.to_string())?;
|
||||
Ok(STANDARD.encode(image_data))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
@ -107,26 +108,22 @@ pub fn setup<R: Runtime>(app: &AppHandle<R>) {
|
|||
let app = app.clone();
|
||||
runtime.block_on(async move {
|
||||
if IS_PROGRAMMATIC_PASTE.load(Ordering::SeqCst) {
|
||||
println!("Ignoring programmatic paste");
|
||||
return;
|
||||
}
|
||||
|
||||
let clipboard = app.state::<Clipboard>();
|
||||
let available_types = clipboard.available_types().unwrap();
|
||||
|
||||
println!("Clipboard update detected");
|
||||
|
||||
match get_pool(&app).await {
|
||||
Ok(pool) => {
|
||||
if available_types.image {
|
||||
println!("Handling image change");
|
||||
if let Ok(image_data) = clipboard.read_image_base64() {
|
||||
let base64_image = STANDARD.encode(&image_data);
|
||||
insert_content_if_not_exists(
|
||||
app.clone(),
|
||||
pool.clone(),
|
||||
"image",
|
||||
base64_image,
|
||||
image_data,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ use tauri::Manager;
|
|||
|
||||
use crate::utils::commands::center_window_on_current_monitor;
|
||||
|
||||
#[warn(dead_code)]
|
||||
pub fn setup(app_handle: tauri::AppHandle) {
|
||||
std::thread::spawn(move || {
|
||||
let mut meta_pressed = false;
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
use tauri::{
|
||||
menu::{MenuBuilder, MenuItemBuilder},
|
||||
tray::{MouseButton, TrayIconBuilder, TrayIconEvent},
|
||||
tray::TrayIconBuilder,
|
||||
Manager,
|
||||
};
|
||||
|
||||
pub fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let window = app.get_webview_window("main").unwrap();
|
||||
let window_clone_for_tray = window.clone();
|
||||
let window_clone_for_click = window.clone();
|
||||
|
||||
let icon_bytes = include_bytes!("../../icons/Square71x71Logo.png");
|
||||
let icon = tauri::image::Image::from_bytes(icon_bytes).unwrap();
|
||||
|
@ -37,14 +36,6 @@ pub fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
|||
}
|
||||
_ => (),
|
||||
})
|
||||
// .on_tray_icon_event(move |_tray, event| {
|
||||
// if let TrayIconEvent::Click { button, .. } = event {
|
||||
// if button == MouseButton::Left {
|
||||
// window_clone_for_click.show().unwrap();
|
||||
// window_clone_for_click.set_focus().unwrap();
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
.icon(icon)
|
||||
.build(app)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue