Move image check in the engine
This commit is contained in:
parent
5c875eeaed
commit
283db379c8
|
@ -56,18 +56,13 @@ impl super::ClipboardManager for MacClipboardManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_clipboard_image(&self, image_path: &Path) {
|
fn set_clipboard_image(&self, image_path: &Path) {
|
||||||
// Make sure the image exist beforehand
|
let path_string = image_path.to_string_lossy().into_owned();
|
||||||
if !image_path.exists() {
|
let res = CString::new(path_string);
|
||||||
error!("Image not found in path: {:?}", image_path);
|
if let Ok(path) = res {
|
||||||
}else{
|
unsafe {
|
||||||
let path_string = image_path.to_string_lossy().into_owned();
|
let result = set_clipboard_image(path.as_ptr());
|
||||||
let res = CString::new(path_string);
|
if result != 1 {
|
||||||
if let Ok(path) = res {
|
warn!("Couldn't set clipboard for image: {:?}", image_path)
|
||||||
unsafe {
|
|
||||||
let result = set_clipboard_image(path.as_ptr());
|
|
||||||
if result != 1 {
|
|
||||||
warn!("Couldn't set clipboard for image: {:?}", image_path)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,8 +219,14 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
|
||||||
// Image Match
|
// Image Match
|
||||||
MatchContentType::Image(content) => {
|
MatchContentType::Image(content) => {
|
||||||
let image_path = PathBuf::from(&content.path);
|
let image_path = PathBuf::from(&content.path);
|
||||||
self.clipboard_manager.set_clipboard_image(&image_path);
|
|
||||||
self.keyboard_manager.trigger_paste();
|
// Make sure the image exist beforehand
|
||||||
|
if image_path.exists() {
|
||||||
|
self.clipboard_manager.set_clipboard_image(&image_path);
|
||||||
|
self.keyboard_manager.trigger_paste();
|
||||||
|
}else{
|
||||||
|
error!("Image not found in path: {:?}", image_path);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user