mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2025-02-17 02:09:46 +03:00
commit
824da89578
5 changed files with 66 additions and 46 deletions
17
Cargo.lock
generated
17
Cargo.lock
generated
|
@ -64,6 +64,7 @@ dependencies = [
|
|||
"lazy_static",
|
||||
"libadwaita",
|
||||
"md-5",
|
||||
"open",
|
||||
"relm4",
|
||||
"rfd",
|
||||
"serde_json",
|
||||
|
@ -1684,6 +1685,16 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||
|
||||
[[package]]
|
||||
name = "open"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2078c0039e6a54a0c42c28faa984e115fb4c2d5bf2208f77d1961002df8576f8"
|
||||
dependencies = [
|
||||
"pathdiff",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-probe"
|
||||
version = "0.1.5"
|
||||
|
@ -1785,6 +1796,12 @@ dependencies = [
|
|||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pathdiff"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
|
||||
|
||||
[[package]]
|
||||
name = "pbkdf2"
|
||||
version = "0.11.0"
|
||||
|
|
|
@ -34,3 +34,5 @@ anyhow = "1.0"
|
|||
cached = { version = "0.42", features = ["proc_macro"] }
|
||||
serde_json = "1"
|
||||
md-5 = { version = "0.10", features = ["asm"] }
|
||||
|
||||
open = "3.2.0"
|
||||
|
|
|
@ -208,12 +208,9 @@ impl SimpleComponent for FirstRunApp {
|
|||
|
||||
#[allow(unused_must_use)]
|
||||
dialog.connect_response(Some("save"), |_, _| {
|
||||
let result = std::process::Command::new("xdg-open")
|
||||
.arg(crate::DEBUG_FILE.as_os_str())
|
||||
.output();
|
||||
|
||||
if let Err(err) = result {
|
||||
tracing::error!("Failed to open debug file: {}", err);
|
||||
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
Ok(()) => {},
|
||||
Err(err) => tracing::error!("Failed to open debug file: {}", err)
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ use crate::ui::components::*;
|
|||
use super::preferences::main::*;
|
||||
use super::about::*;
|
||||
|
||||
use open::*;
|
||||
|
||||
relm4::new_action_group!(WindowActionGroup, "win");
|
||||
|
||||
relm4::new_stateless_action!(LauncherFolder, WindowActionGroup, "launcher_folder");
|
||||
|
@ -526,48 +528,56 @@ impl SimpleComponent for App {
|
|||
// TODO: reduce code somehow
|
||||
|
||||
group.add_action::<LauncherFolder>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
||||
if let Err(err) = std::process::Command::new("xdg-open").arg(LAUNCHER_FOLDER.as_path()).spawn() {
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("launcher-folder-opening-error"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
|
||||
tracing::error!("Failed to open launcher folder: {err}");
|
||||
match open::that(LAUNCHER_FOLDER.as_path()) {
|
||||
Ok(()) => {},
|
||||
Err(err) => {
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("launcher-folder-opening-error"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
tracing::error!("Failed to open launcher folder: {err}");
|
||||
}
|
||||
}
|
||||
})));
|
||||
|
||||
group.add_action::<GameFolder>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
||||
if let Err(err) = std::process::Command::new("xdg-open").arg(&CONFIG.game.path).spawn() {
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("game-folder-opening-error"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
|
||||
tracing::error!("Failed to open game folder: {err}");
|
||||
match open::that(&CONFIG.game.path) {
|
||||
Ok(()) => {},
|
||||
Err(err) => {
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("game-folder-opening-error"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
tracing::error!("Failed to open game folder: {err}");
|
||||
}
|
||||
}
|
||||
})));
|
||||
|
||||
group.add_action::<ConfigFile>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
||||
if let Some(file) = anime_launcher_sdk::consts::config_file() {
|
||||
if let Err(err) = std::process::Command::new("xdg-open").arg(file).spawn() {
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("config-file-opening-error"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
|
||||
tracing::error!("Failed to open config file: {err}");
|
||||
match open::that(file) {
|
||||
Ok(()) => {},
|
||||
Err(err) => {
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("config-file-opening-error"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
tracing::error!("Failed to open config file: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
})));
|
||||
|
||||
group.add_action::<DebugFile>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
||||
if let Err(err) = std::process::Command::new("xdg-open").arg(DEBUG_FILE.as_os_str()).spawn() {
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("debug-file-opening-error"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
|
||||
tracing::error!("Failed to open debug file: {err}");
|
||||
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
Ok(()) => {},
|
||||
Err(err) => {
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("debug-file-opening-error"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
tracing::error!("Failed to open debug file: {err}");
|
||||
}
|
||||
}
|
||||
})));
|
||||
|
||||
|
@ -1277,12 +1287,9 @@ impl App {
|
|||
|
||||
#[allow(unused_must_use)]
|
||||
dialog.connect_response(Some("save"), |_, _| {
|
||||
let result = std::process::Command::new("xdg-open")
|
||||
.arg(crate::DEBUG_FILE.as_os_str())
|
||||
.output();
|
||||
|
||||
if let Err(err) = result {
|
||||
tracing::error!("Failed to open debug file: {}", err);
|
||||
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
Ok(()) => {},
|
||||
Err(err) => tracing::error!("Failed to open debug file: {}", err),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -166,12 +166,9 @@ impl SimpleAsyncComponent for PreferencesApp {
|
|||
|
||||
#[allow(unused_must_use)]
|
||||
dialog.connect_response(Some("save"), |_, _| {
|
||||
let result = std::process::Command::new("xdg-open")
|
||||
.arg(crate::DEBUG_FILE.as_os_str())
|
||||
.output();
|
||||
|
||||
if let Err(err) = result {
|
||||
tracing::error!("Failed to open debug file: {}", err);
|
||||
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
Ok(()) => {},
|
||||
Err(err) => tracing::error!("Failed to open debug file: {}", err)
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue