chore: focus empty trash and mount error buttons
This commit is contained in:
parent
e6da0a8ae5
commit
ee550266c6
2 changed files with 54 additions and 31 deletions
80
src/app.rs
80
src/app.rs
|
|
@ -98,12 +98,18 @@ static PERMANENT_DELETE_BUTTON_ID: LazyLock<widget::Id> =
|
|||
static CONFIRM_OPEN_WITH_BUTTON_ID: LazyLock<widget::Id> =
|
||||
LazyLock::new(|| widget::Id::new("confirm-open-with-button"));
|
||||
|
||||
static EMPTY_TRASH_BUTTON_ID: LazyLock<widget::Id> =
|
||||
LazyLock::new(|| widget::Id::new("empty-trash-button"));
|
||||
|
||||
static SET_EXECUTABLE_AND_LAUNCH_CONFIRM_BUTTON_ID: LazyLock<widget::Id> =
|
||||
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"));
|
||||
|
||||
static MOUNT_ERROR_TRY_AGAIN_BUTTON_ID: LazyLock<widget::Id> =
|
||||
LazyLock::new(|| widget::Id::new("mount-error-try-again-button"));
|
||||
|
||||
pub(crate) static REPLACE_BUTTON_ID: LazyLock<widget::Id> =
|
||||
LazyLock::new(|| widget::Id::new("replace-button"));
|
||||
|
||||
|
|
@ -3103,23 +3109,26 @@ impl Application for App {
|
|||
}
|
||||
Err(error) => {
|
||||
log::warn!("failed to connect to {:?}: {}", item, error);
|
||||
return self.dialog_pages.push_back(DialogPage::MountError {
|
||||
mounter_key,
|
||||
item,
|
||||
error,
|
||||
});
|
||||
return self.push_dialog(
|
||||
DialogPage::MountError {
|
||||
mounter_key,
|
||||
item,
|
||||
error,
|
||||
},
|
||||
Some(MOUNT_ERROR_TRY_AGAIN_BUTTON_ID.clone()),
|
||||
);
|
||||
}
|
||||
},
|
||||
Message::NetworkAuth(mounter_key, uri, auth, auth_tx) => {
|
||||
return Task::batch([
|
||||
self.dialog_pages.push_back(DialogPage::NetworkAuth {
|
||||
return self.push_dialog(
|
||||
DialogPage::NetworkAuth {
|
||||
mounter_key,
|
||||
uri,
|
||||
auth,
|
||||
auth_tx,
|
||||
}),
|
||||
widget::text_input::focus(self.dialog_text_input.clone()),
|
||||
]);
|
||||
},
|
||||
Some(self.dialog_text_input.clone()),
|
||||
);
|
||||
}
|
||||
Message::NetworkDriveInput(input) => {
|
||||
self.network_drive_input = input;
|
||||
|
|
@ -3533,6 +3542,8 @@ impl Application for App {
|
|||
},
|
||||
}));
|
||||
}
|
||||
tasks.push(widget::text_input::focus(self.dialog_text_input.clone()));
|
||||
|
||||
// Remove from progress
|
||||
self.progress_operations.remove(&id);
|
||||
self.failed_operations
|
||||
|
|
@ -3990,7 +4001,10 @@ impl Application for App {
|
|||
commands.push(self.update(Message::PasteContents(to, from)));
|
||||
}
|
||||
tab::Command::EmptyTrash => {
|
||||
return self.dialog_pages.push_back(DialogPage::EmptyTrash);
|
||||
return self.push_dialog(
|
||||
DialogPage::EmptyTrash,
|
||||
Some(EMPTY_TRASH_BUTTON_ID.clone()),
|
||||
);
|
||||
}
|
||||
#[cfg(feature = "desktop")]
|
||||
tab::Command::ExecEntryAction(entry, action) => {
|
||||
|
|
@ -4566,7 +4580,8 @@ impl Application for App {
|
|||
}
|
||||
|
||||
NavMenuAction::EmptyTrash => {
|
||||
return self.dialog_pages.push_front(DialogPage::EmptyTrash);
|
||||
return self
|
||||
.push_dialog(DialogPage::EmptyTrash, Some(EMPTY_TRASH_BUTTON_ID.clone()));
|
||||
}
|
||||
},
|
||||
Message::Recents => {
|
||||
|
|
@ -4951,7 +4966,9 @@ impl Application for App {
|
|||
.title(fl!("empty-trash"))
|
||||
.body(fl!("empty-trash-warning"))
|
||||
.primary_action(
|
||||
widget::button::suggested(fl!("empty-trash")).on_press(Message::DialogComplete),
|
||||
widget::button::suggested(fl!("empty-trash"))
|
||||
.on_press(Message::DialogComplete)
|
||||
.id(EMPTY_TRASH_BUTTON_ID.clone()),
|
||||
)
|
||||
.secondary_action(
|
||||
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
|
||||
|
|
@ -4970,23 +4987,24 @@ impl Application for App {
|
|||
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
|
||||
)
|
||||
}
|
||||
DialogPage::ExtractPassword { id, password } => {
|
||||
widget::dialog()
|
||||
.title(fl!("extract-password-required"))
|
||||
.icon(icon::from_name("dialog-error").size(64))
|
||||
.control(widget::text_input("", password).password().on_input(
|
||||
move |password| {
|
||||
DialogPage::ExtractPassword { id, password } => widget::dialog()
|
||||
.title(fl!("extract-password-required"))
|
||||
.icon(icon::from_name("dialog-error").size(64))
|
||||
.control(
|
||||
widget::text_input("", password)
|
||||
.password()
|
||||
.on_input(move |password| {
|
||||
Message::DialogUpdate(DialogPage::ExtractPassword { id: *id, password })
|
||||
},
|
||||
))
|
||||
.primary_action(
|
||||
widget::button::suggested(fl!("extract-here"))
|
||||
.on_press(Message::DialogComplete),
|
||||
)
|
||||
.secondary_action(
|
||||
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
|
||||
)
|
||||
}
|
||||
})
|
||||
.id(self.dialog_text_input.clone()),
|
||||
)
|
||||
.primary_action(
|
||||
widget::button::suggested(fl!("extract-here"))
|
||||
.on_press(Message::DialogComplete),
|
||||
)
|
||||
.secondary_action(
|
||||
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
|
||||
),
|
||||
DialogPage::MountError {
|
||||
mounter_key: _,
|
||||
item: _,
|
||||
|
|
@ -4996,7 +5014,9 @@ impl Application for App {
|
|||
.body(error)
|
||||
.icon(icon::from_name("dialog-error").size(64))
|
||||
.primary_action(
|
||||
widget::button::standard(fl!("try-again")).on_press(Message::DialogComplete),
|
||||
widget::button::standard(fl!("try-again"))
|
||||
.on_press(Message::DialogComplete)
|
||||
.id(MOUNT_ERROR_TRY_AGAIN_BUTTON_ID.clone()),
|
||||
)
|
||||
.secondary_action(
|
||||
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@ use std::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
app::{Action, ContextPage, Message as AppMessage, PreviewItem, PreviewKind},
|
||||
app::{
|
||||
Action, ContextPage, Message as AppMessage, PreviewItem, PreviewKind, REPLACE_BUTTON_ID,
|
||||
},
|
||||
config::{Config, DialogConfig, Favorite, TIME_CONFIG_ID, ThumbCfg, TimeConfig, TypeToSearch},
|
||||
fl, home_dir,
|
||||
key_bind::key_binds,
|
||||
|
|
@ -1597,6 +1599,7 @@ impl Application for App {
|
|||
self.dialog_pages.push_back(DialogPage::Replace {
|
||||
filename: filename.clone(),
|
||||
});
|
||||
return widget::button::focus(REPLACE_BUTTON_ID.clone());
|
||||
} else {
|
||||
self.result_opt = Some(DialogResult::Open(vec![path]));
|
||||
return window::close(self.flags.window_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue