App window size lowered

Open logs button added
Better links handling
Multiple UI fixes/improvements
etc
This commit is contained in:
Abraham 2023-05-01 16:54:50 +05:00
parent fc764c0c85
commit 488f5c0786
23 changed files with 202 additions and 114 deletions

View file

@ -1,3 +1,7 @@
use std::iter::Once;
use once_cell::sync::OnceCell;
// use const_concat::const_concat;
// pub const IS_DEV: bool = cfg!(debug_assertions);// cfg!(debug_assertions);
@ -22,6 +26,8 @@ pub const LOG_FILE_NAME: &str = "log.txt";
pub const APP_VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION");
pub const AUTHOR_NAME: Option<&str> = option_env!("CARGO_PKG_AUTHORS");
pub const REPOSITORY_LINK: Option<&str> = option_env!("CARGO_PKG_REPOSITORY");
pub const TG_OFFICIAL_LINK: Option<&str> = Some("https://t.me/howdyho_official");
pub const FEEDBACK_LINK: Option<&str> = Some("https://t.me/jarvis_feedback_bot");
// RUSPOTTER
pub const RUSPOTTER_MIN_SCORE: f32 = 0.62;
@ -38,10 +44,11 @@ pub const VOSK_MIN_RATIO: f64 = 70.0;
// ETC
pub const CMD_RATIO_THRESHOLD: f64 = 60f64;
pub const CMS_WAIT_DELAY: std::time::Duration = std::time::Duration::from_secs(10);
pub const CMS_WAIT_DELAY: std::time::Duration = std::time::Duration::from_secs(15);
pub const ASSISTANT_GREET_PHRASES: [&str; 3] = ["greet1", "greet2", "greet3"];
pub const ASSISTANT_PHRASES_TBR: [&str; 16] = [
pub const ASSISTANT_PHRASES_TBR: [&str; 17] = [
"джарвис",
"сэр",
"слушаю сэр",
"всегда к услугам",

View file

@ -78,7 +78,7 @@ fn main() {
// log to file
let log_file_path = format!("{}/{}", APP_LOG_DIR.lock().unwrap(), config::LOG_FILE_NAME);
println!("!!!===============!!!\nLOGGING TO {}\n!!!===============!!!\n", &log_file_path);
simple_logging::log_to_file(log_file_path, LevelFilter::max()).expect("Failed to start logger ... is directory writable?");
simple_logging::log_to_file(&log_file_path, LevelFilter::max()).expect("Failed to start logger ... is directory writable?");
Ok(())
})
@ -100,10 +100,15 @@ fn main() {
tauri_commands::get_cpu_usage,
// sound commands
tauri_commands::play_sound,
// fs commands
tauri_commands::show_in_folder,
// etc commands
tauri_commands::get_app_version,
tauri_commands::get_author_name,
tauri_commands::get_repository_link
tauri_commands::get_repository_link,
tauri_commands::get_tg_official_link,
tauri_commands::get_feedback_link,
tauri_commands::get_log_file_path
])
.run(tauri::generate_context!())
.expect("error while running tauri application");

View file

@ -18,6 +18,10 @@ pub use sys::*;
mod voice;
pub use voice::*;
// import FS commands
mod fs;
pub use fs::*;
// import ETC commands
mod etc;
pub use etc::*;

View file

@ -1,13 +1,12 @@
use crate::config::APP_VERSION;
use crate::config::AUTHOR_NAME;
use crate::config::REPOSITORY_LINK;
use crate::config;
use crate::APP_LOG_DIR;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
pub fn get_app_version() -> String {
if let Some(ver) = APP_VERSION {
ver.to_string()
if let Some(res) = config::APP_VERSION {
res.to_string()
} else {
String::from("error")
}
@ -15,8 +14,8 @@ pub fn get_app_version() -> String {
#[tauri::command]
pub fn get_author_name() -> String {
if let Some(ver) = AUTHOR_NAME {
ver.to_string()
if let Some(res) = config::AUTHOR_NAME {
res.to_string()
} else {
String::from("error")
}
@ -24,9 +23,32 @@ pub fn get_author_name() -> String {
#[tauri::command]
pub fn get_repository_link() -> String {
if let Some(ver) = REPOSITORY_LINK {
if let Some(res) = config::REPOSITORY_LINK {
res.to_string()
} else {
String::from("error")
}
}
#[tauri::command]
pub fn get_tg_official_link() -> String {
if let Some(ver) = config::TG_OFFICIAL_LINK {
ver.to_string()
} else {
String::from("error")
}
}
#[tauri::command]
pub fn get_feedback_link() -> String {
if let Some(res) = config::FEEDBACK_LINK {
res.to_string()
} else {
String::from("error")
}
}
#[tauri::command]
pub fn get_log_file_path() -> String {
format!("{}", APP_LOG_DIR.lock().unwrap())
}

View file

@ -0,0 +1,47 @@
use std::process::Command;
// taken from https://github.com/tauri-apps/tauri/issues/4062#issuecomment-1338048169
#[tauri::command]
pub fn show_in_folder(path: String) {
#[cfg(target_os = "windows")]
{
Command::new("explorer")
.args(["/select,", &path]) // The comma after select is not a typo
.spawn()
.unwrap();
}
#[cfg(target_os = "linux")]
{
if path.contains(",") {
// see https://gitlab.freedesktop.org/dbus/dbus/-/issues/76
let new_path = match metadata(&path).unwrap().is_dir() {
true => path,
false => {
let mut path2 = PathBuf::from(path);
path2.pop();
path2.into_os_string().into_string().unwrap()
}
};
Command::new("xdg-open")
.arg(&new_path)
.spawn()
.unwrap();
} else {
Command::new("dbus-send")
.args(["--session", "--dest=org.freedesktop.FileManager1", "--type=method_call",
"/org/freedesktop/FileManager1", "org.freedesktop.FileManager1.ShowItems",
format!("array:string:\"file://{path}\"").as_str(), "string:\"\""])
.spawn()
.unwrap();
}
}
#[cfg(target_os = "macos")]
{
Command::new("open")
.args(["-R", &path])
.spawn()
.unwrap();
}
}

View file

@ -134,6 +134,7 @@ fn keyword_callback(_keyword_index: i32) {
for tbr in config::ASSISTANT_PHRASES_TBR {
test = test.replace(tbr, "");
}
test = test.trim().into();
// infer command
if let Some((cmd_path, cmd_config)) =