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