mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Use paste button instead of auto paste (#111)
This commit is contained in:
+6
-18
@@ -182,23 +182,18 @@ impl MyEguiApp {
|
|||||||
.auth_key
|
.auth_key
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap_or(&mut empty_string);
|
.unwrap_or(&mut empty_string);
|
||||||
let mut auth_key_clipboard = false;
|
|
||||||
ui.label("Authentication key: ");
|
ui.label("Authentication key: ");
|
||||||
|
if ui.text_edit_singleline(auth_key).changed() {
|
||||||
|
*auth_key = auth_key.to_string();
|
||||||
|
}
|
||||||
|
if auth_key.is_empty() {
|
||||||
|
if ui.button("Paste from clipboard").clicked() {
|
||||||
if let Ok(mut clipboard_ctx) = copypasta::ClipboardContext::new() {
|
if let Ok(mut clipboard_ctx) = copypasta::ClipboardContext::new() {
|
||||||
if let Ok(content) = clipboard_ctx.get_contents() {
|
if let Ok(content) = clipboard_ctx.get_contents() {
|
||||||
if auth_key.is_empty() && looks_like_auth_key(&content) {
|
self.settings.steamgrid_db.auth_key = Some(content.clone());
|
||||||
*auth_key = content.clone();
|
|
||||||
auth_key_clipboard = true;
|
|
||||||
} else if content.eq(auth_key) {
|
|
||||||
auth_key_clipboard = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ui.text_edit_singleline(auth_key).changed() {
|
|
||||||
self.settings.steamgrid_db.auth_key = Some(auth_key.to_string());
|
|
||||||
}
|
|
||||||
if auth_key_clipboard {
|
|
||||||
ui.label("Found API Key in clipboard");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
@@ -294,10 +289,3 @@ impl MyEguiApp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn looks_like_auth_key(content: &String) -> bool {
|
|
||||||
content.len() == 32
|
|
||||||
&& content.is_ascii()
|
|
||||||
&& content.chars().all(char::is_alphanumeric)
|
|
||||||
&& content.chars().all(char::is_lowercase)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user