mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2025-03-15 06:28:27 +03:00
refactor: implemented #84
This commit is contained in:
parent
b1b3455f8e
commit
7fead37513
4 changed files with 35 additions and 52 deletions
|
@ -20,6 +20,7 @@ relm4 = { version = "0.5", features = ["macros", "libadwaita"] }
|
|||
gtk = { package = "gtk4", version = "0.5", features = ["v4_8"] }
|
||||
adw = { package = "libadwaita", version = "0.2", features = ["v1_2"] }
|
||||
rfd = { version = "0.11", features = ["xdg-portal"], default-features = false }
|
||||
open = "3.2.0"
|
||||
|
||||
anime-launcher-sdk = { path = "anime-launcher-sdk" }
|
||||
|
||||
|
@ -34,5 +35,3 @@ anyhow = "1.0"
|
|||
cached = { version = "0.42", features = ["proc_macro"] }
|
||||
serde_json = "1"
|
||||
md-5 = { version = "0.10", features = ["asm"] }
|
||||
|
||||
open = "3.2.0"
|
||||
|
|
|
@ -206,11 +206,9 @@ impl SimpleComponent for FirstRunApp {
|
|||
|
||||
dialog.set_response_appearance("save", adw::ResponseAppearance::Suggested);
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
dialog.connect_response(Some("save"), |_, _| {
|
||||
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
Ok(()) => {},
|
||||
Err(err) => tracing::error!("Failed to open debug file: {}", err)
|
||||
if let Err(err) = open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
tracing::error!("Failed to open debug file: {err}");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ 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");
|
||||
|
@ -528,56 +526,48 @@ impl SimpleComponent for App {
|
|||
// TODO: reduce code somehow
|
||||
|
||||
group.add_action::<LauncherFolder>(&RelmAction::new_stateless(clone!(@strong sender => move |_| {
|
||||
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}");
|
||||
}
|
||||
if let Err(err) = open::that(LAUNCHER_FOLDER.as_path()) {
|
||||
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 |_| {
|
||||
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}");
|
||||
}
|
||||
if let Err(err) = open::that(&CONFIG.game.path) {
|
||||
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() {
|
||||
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}");
|
||||
}
|
||||
if let Err(err) = open::that(file) {
|
||||
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 |_| {
|
||||
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}");
|
||||
}
|
||||
if let Err(err) = open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("debug-file-opening-error"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
|
||||
tracing::error!("Failed to open debug file: {err}");
|
||||
}
|
||||
})));
|
||||
|
||||
|
@ -1275,11 +1265,9 @@ impl App {
|
|||
|
||||
dialog.set_response_appearance("save", adw::ResponseAppearance::Suggested);
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
dialog.connect_response(Some("save"), |_, _| {
|
||||
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
Ok(()) => {},
|
||||
Err(err) => tracing::error!("Failed to open debug file: {}", err),
|
||||
if let Err(err) = open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
tracing::error!("Failed to open debug file: {err}");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -164,11 +164,9 @@ impl SimpleAsyncComponent for PreferencesApp {
|
|||
|
||||
dialog.set_response_appearance("save", adw::ResponseAppearance::Suggested);
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
dialog.connect_response(Some("save"), |_, _| {
|
||||
match open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
Ok(()) => {},
|
||||
Err(err) => tracing::error!("Failed to open debug file: {}", err)
|
||||
if let Err(err) = open::that(crate::DEBUG_FILE.as_os_str()) {
|
||||
tracing::error!("Failed to open debug file: {err}");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue