mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 21:24:05 +02:00
Merge branch 'main' into dev/live-sync
This commit is contained in:
commit
4381232af1
7 changed files with 186 additions and 63 deletions
|
@ -33,6 +33,8 @@ pub async fn write_and_paste(
|
|||
|
||||
match content_type.as_str() {
|
||||
"text" => clipboard.write_text(content).map_err(|e| e.to_string())?,
|
||||
"link" => clipboard.write_text(content).map_err(|e| e.to_string())?,
|
||||
"color" => clipboard.write_text(content).map_err(|e| e.to_string())?,
|
||||
"image" => {
|
||||
clipboard.write_image_base64(content).map_err(|e| e.to_string())?;
|
||||
}
|
||||
|
|
|
@ -18,9 +18,10 @@ struct HotkeyState {
|
|||
registered_hotkey: Option<HotKey>,
|
||||
}
|
||||
|
||||
unsafe impl Send for HotkeyState {}
|
||||
|
||||
pub fn setup(app_handle: tauri::AppHandle) {
|
||||
let state = Arc::new(Mutex::new(HotkeyState::default()));
|
||||
|
||||
let manager = match GlobalHotKeyManager::new() {
|
||||
Ok(manager) => manager,
|
||||
Err(err) => {
|
||||
|
@ -43,7 +44,7 @@ pub fn setup(app_handle: tauri::AppHandle) {
|
|||
eprintln!("Error registering initial shortcut: {:?}", e);
|
||||
}
|
||||
|
||||
let state_clone = state.clone();
|
||||
let state_clone = Arc::clone(&state);
|
||||
app_handle.listen("update-shortcut", move |event| {
|
||||
let payload_str = event.payload().replace("\\\"", "\"");
|
||||
let trimmed_str = payload_str.trim_matches('"');
|
||||
|
@ -55,7 +56,7 @@ pub fn setup(app_handle: tauri::AppHandle) {
|
|||
}
|
||||
});
|
||||
|
||||
let state_clone = state.clone();
|
||||
let state_clone = Arc::clone(&state);
|
||||
app_handle.listen("save_keybind", move |event| {
|
||||
let payload_str = event.payload().to_string();
|
||||
unregister_current_hotkey(&state_clone);
|
||||
|
|
|
@ -1,23 +1,26 @@
|
|||
use crate::utils::types::{ ContentType, HistoryItem };
|
||||
use base64::{ engine::general_purpose::STANDARD, Engine };
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::{ thread_rng, Rng };
|
||||
use rand::{ rng, Rng };
|
||||
use rand::distr::Alphanumeric;
|
||||
use sqlx::{ Row, SqlitePool };
|
||||
use std::fs;
|
||||
use tauri_plugin_aptabase::EventTracker;
|
||||
|
||||
pub async fn initialize_history(pool: &SqlitePool) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let id: String = thread_rng().sample_iter(&Alphanumeric).take(16).map(char::from).collect();
|
||||
let id: String = rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(16)
|
||||
.map(char::from)
|
||||
.collect();
|
||||
|
||||
sqlx
|
||||
::query(
|
||||
"INSERT INTO history (id, source, content_type, content, timestamp) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)"
|
||||
)
|
||||
.bind(id)
|
||||
.bind("System")
|
||||
.bind("text")
|
||||
.bind("Welcome to your clipboard history!")
|
||||
.execute(pool).await?;
|
||||
sqlx::query(
|
||||
"INSERT INTO history (id, source, content_type, content, timestamp) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)"
|
||||
)
|
||||
.bind(id)
|
||||
.bind("System")
|
||||
.bind("text")
|
||||
.bind("Welcome to your clipboard history!")
|
||||
.execute(pool).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue