chore: focus replace & favorite path dialog buttons
This commit is contained in:
parent
ce207a54b3
commit
e6da0a8ae5
2 changed files with 44 additions and 23 deletions
63
src/app.rs
63
src/app.rs
|
|
@ -101,6 +101,12 @@ static CONFIRM_OPEN_WITH_BUTTON_ID: LazyLock<widget::Id> =
|
||||||
static SET_EXECUTABLE_AND_LAUNCH_CONFIRM_BUTTON_ID: LazyLock<widget::Id> =
|
static SET_EXECUTABLE_AND_LAUNCH_CONFIRM_BUTTON_ID: LazyLock<widget::Id> =
|
||||||
LazyLock::new(|| widget::Id::new("set-executable-and-launch-confirm-button"));
|
LazyLock::new(|| widget::Id::new("set-executable-and-launch-confirm-button"));
|
||||||
|
|
||||||
|
static FAVORITE_PATH_ERROR_REMOVE_BUTTON_ID: LazyLock<widget::Id> =
|
||||||
|
LazyLock::new(|| widget::Id::new("favorite-path-error-remove-button"));
|
||||||
|
|
||||||
|
pub(crate) static REPLACE_BUTTON_ID: LazyLock<widget::Id> =
|
||||||
|
LazyLock::new(|| widget::Id::new("replace-button"));
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Mode {
|
pub enum Mode {
|
||||||
App,
|
App,
|
||||||
|
|
@ -2368,27 +2374,36 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
|
|
||||||
log::warn!("failed to open favorite, path does not exist: {:?}", path);
|
log::warn!("failed to open favorite, path does not exist: {:?}", path);
|
||||||
return self.dialog_pages.push_back(DialogPage::FavoritePathError {
|
return self.push_dialog(
|
||||||
path: path.clone(),
|
DialogPage::FavoritePathError {
|
||||||
entity,
|
path: path.clone(),
|
||||||
});
|
entity,
|
||||||
|
},
|
||||||
|
Some(FAVORITE_PATH_ERROR_REMOVE_BUTTON_ID.clone()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Location::Path(path) | Location::Network(_, _, Some(path)) => {
|
Location::Path(path) | Location::Network(_, _, Some(path)) => {
|
||||||
match path.try_exists() {
|
match path.try_exists() {
|
||||||
Ok(true) => true,
|
Ok(true) => true,
|
||||||
Ok(false) => {
|
Ok(false) => {
|
||||||
log::warn!("failed to open favorite, path does not exist: {:?}", path);
|
log::warn!("failed to open favorite, path does not exist: {:?}", path);
|
||||||
return self.dialog_pages.push_back(DialogPage::FavoritePathError {
|
return self.push_dialog(
|
||||||
path: path.clone(),
|
DialogPage::FavoritePathError {
|
||||||
entity,
|
path: path.clone(),
|
||||||
});
|
entity,
|
||||||
|
},
|
||||||
|
Some(FAVORITE_PATH_ERROR_REMOVE_BUTTON_ID.clone()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::warn!("failed to open favorite for path: {:?}, {}", path, err);
|
log::warn!("failed to open favorite for path: {:?}, {}", path, err);
|
||||||
return self.dialog_pages.push_back(DialogPage::FavoritePathError {
|
return self.push_dialog(
|
||||||
path: path.clone(),
|
DialogPage::FavoritePathError {
|
||||||
entity,
|
path: path.clone(),
|
||||||
});
|
entity,
|
||||||
|
},
|
||||||
|
Some(FAVORITE_PATH_ERROR_REMOVE_BUTTON_ID.clone()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2574,16 +2589,16 @@ impl Application for App {
|
||||||
let to = destination.0.to_path_buf();
|
let to = destination.0.to_path_buf();
|
||||||
let name = destination.1.to_str().unwrap_or_default().to_string();
|
let name = destination.1.to_str().unwrap_or_default().to_string();
|
||||||
let archive_type = ArchiveType::default();
|
let archive_type = ArchiveType::default();
|
||||||
return Task::batch([
|
return self.push_dialog(
|
||||||
self.dialog_pages.push_back(DialogPage::Compress {
|
DialogPage::Compress {
|
||||||
paths,
|
paths,
|
||||||
to,
|
to,
|
||||||
name,
|
name,
|
||||||
archive_type,
|
archive_type,
|
||||||
password: None,
|
password: None,
|
||||||
}),
|
},
|
||||||
widget::text_input::focus(self.dialog_text_input.clone()),
|
Some(self.dialog_text_input.clone()),
|
||||||
]);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5422,9 +5437,13 @@ impl Application for App {
|
||||||
from.replace_view(fl!("replace-with"), military_time)
|
from.replace_view(fl!("replace-with"), military_time)
|
||||||
.map(|x| Message::TabMessage(None, x)),
|
.map(|x| Message::TabMessage(None, x)),
|
||||||
)
|
)
|
||||||
.primary_action(widget::button::suggested(fl!("replace")).on_press(
|
.primary_action(
|
||||||
Message::ReplaceResult(ReplaceResult::Replace(*apply_to_all)),
|
widget::button::suggested(fl!("replace"))
|
||||||
));
|
.on_press(Message::ReplaceResult(ReplaceResult::Replace(
|
||||||
|
*apply_to_all,
|
||||||
|
)))
|
||||||
|
.id(REPLACE_BUTTON_ID.clone()),
|
||||||
|
);
|
||||||
if *multiple {
|
if *multiple {
|
||||||
dialog
|
dialog
|
||||||
.control(
|
.control(
|
||||||
|
|
@ -5492,7 +5511,9 @@ impl Application for App {
|
||||||
))
|
))
|
||||||
.icon(icon::from_name("dialog-error").size(64))
|
.icon(icon::from_name("dialog-error").size(64))
|
||||||
.primary_action(
|
.primary_action(
|
||||||
widget::button::destructive(fl!("remove")).on_press(Message::DialogComplete),
|
widget::button::destructive(fl!("remove"))
|
||||||
|
.on_press(Message::DialogComplete)
|
||||||
|
.id(FAVORITE_PATH_ERROR_REMOVE_BUTTON_ID.clone()),
|
||||||
)
|
)
|
||||||
.secondary_action(
|
.secondary_action(
|
||||||
widget::button::standard(fl!("keep")).on_press(Message::DialogCancel),
|
widget::button::standard(fl!("keep")).on_press(Message::DialogCancel),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{ArchiveType, DialogPage, Message},
|
app::{ArchiveType, DialogPage, Message, REPLACE_BUTTON_ID},
|
||||||
config::IconSizes,
|
config::IconSizes,
|
||||||
fl,
|
fl,
|
||||||
spawn_detached::spawn_detached,
|
spawn_detached::spawn_detached,
|
||||||
|
|
@ -61,7 +61,7 @@ async fn handle_replace(
|
||||||
apply_to_all: false,
|
apply_to_all: false,
|
||||||
tx,
|
tx,
|
||||||
},
|
},
|
||||||
None, // TODO which widget to focus?
|
Some(REPLACE_BUTTON_ID.clone()),
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
rx.recv().await.unwrap_or(ReplaceResult::Cancel)
|
rx.recv().await.unwrap_or(ReplaceResult::Cancel)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue