Fix: remove context actions from open/save dialog
This commit is contained in:
parent
39281a6336
commit
ad0e66dceb
2 changed files with 3 additions and 56 deletions
|
|
@ -70,10 +70,6 @@ impl ContextActionPreset {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn action_name(actions: &[ContextActionPreset], action: usize) -> Option<String> {
|
|
||||||
actions.get(action).map(|preset| preset.name.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run(actions: &[ContextActionPreset], action: usize, paths: &[PathBuf]) {
|
pub fn run(actions: &[ContextActionPreset], action: usize, paths: &[PathBuf]) {
|
||||||
if let Some(preset) = actions.get(action) {
|
if let Some(preset) = actions.get(action) {
|
||||||
preset.run(paths);
|
preset.run(paths);
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ use crate::{
|
||||||
Action, ContextPage, Message as AppMessage, PreviewItem, PreviewKind, REPLACE_BUTTON_ID,
|
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},
|
||||||
context_action, fl, home_dir,
|
fl, home_dir,
|
||||||
key_bind::key_binds,
|
key_bind::key_binds,
|
||||||
localize::LANGUAGE_SORTER,
|
localize::LANGUAGE_SORTER,
|
||||||
menu,
|
menu,
|
||||||
|
|
@ -445,10 +445,6 @@ enum DialogPage {
|
||||||
parent: PathBuf,
|
parent: PathBuf,
|
||||||
name: String,
|
name: String,
|
||||||
},
|
},
|
||||||
RunContextAction {
|
|
||||||
action: usize,
|
|
||||||
paths: Box<[PathBuf]>,
|
|
||||||
},
|
|
||||||
Replace {
|
Replace {
|
||||||
filename: String,
|
filename: String,
|
||||||
},
|
},
|
||||||
|
|
@ -1212,21 +1208,6 @@ impl Application for App {
|
||||||
.spacing(space_xxs),
|
.spacing(space_xxs),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
DialogPage::RunContextAction { action, paths } => {
|
|
||||||
let name = context_action::action_name(&self.flags.config.context_actions, *action)
|
|
||||||
.unwrap_or_else(|| fl!("context-action"));
|
|
||||||
|
|
||||||
widget::dialog()
|
|
||||||
.title(fl!("context-action-confirm-title", name = name))
|
|
||||||
.body(fl!("context-action-confirm-warning", items = paths.len()))
|
|
||||||
.icon(widget::icon::from_name("dialog-error").size(64))
|
|
||||||
.primary_action(
|
|
||||||
widget::button::suggested(fl!("run")).on_press(Message::DialogComplete),
|
|
||||||
)
|
|
||||||
.secondary_action(
|
|
||||||
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
DialogPage::Replace { filename } => widget::dialog()
|
DialogPage::Replace { filename } => widget::dialog()
|
||||||
.title(fl!("replace-title", filename = filename.as_str()))
|
.title(fl!("replace-title", filename = filename.as_str()))
|
||||||
.icon(widget::icon::from_name("dialog-question").size(64))
|
.icon(widget::icon::from_name("dialog-question").size(64))
|
||||||
|
|
@ -1449,9 +1430,6 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DialogPage::RunContextAction { action, paths } => {
|
|
||||||
context_action::run(&self.flags.config.context_actions, action, &paths);
|
|
||||||
}
|
|
||||||
DialogPage::Replace { .. } => {
|
DialogPage::Replace { .. } => {
|
||||||
return self.update(Message::Save(true));
|
return self.update(Message::Save(true));
|
||||||
}
|
}
|
||||||
|
|
@ -1879,28 +1857,6 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tab::Command::RunContextAction(action) => {
|
|
||||||
let paths: Box<[_]> = self
|
|
||||||
.tab
|
|
||||||
.selected_locations()
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(Location::into_path_opt)
|
|
||||||
.collect();
|
|
||||||
if let Some(preset) = self.flags.config.context_actions.get(action) {
|
|
||||||
if preset.confirm {
|
|
||||||
self.dialog_pages
|
|
||||||
.push_back(DialogPage::RunContextAction { action, paths });
|
|
||||||
} else {
|
|
||||||
context_action::run(
|
|
||||||
&self.flags.config.context_actions,
|
|
||||||
action,
|
|
||||||
&paths,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log::warn!("invalid context action index `{action}`");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tab::Command::Iced(iced_command) => {
|
tab::Command::Iced(iced_command) => {
|
||||||
commands.push(iced_command.0.map(|tab_message| {
|
commands.push(iced_command.0.map(|tab_message| {
|
||||||
cosmic::action::app(Message::TabMessage(tab_message))
|
cosmic::action::app(Message::TabMessage(tab_message))
|
||||||
|
|
@ -2073,13 +2029,8 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
|
|
||||||
col = col.push(
|
col = col.push(
|
||||||
self.tab
|
self.tab
|
||||||
.view(
|
.view(&self.key_binds, &self.modifiers, false, &[])
|
||||||
&self.key_binds,
|
|
||||||
&self.modifiers,
|
|
||||||
false,
|
|
||||||
&self.flags.config.context_actions,
|
|
||||||
)
|
|
||||||
.map(Message::TabMessage),
|
.map(Message::TabMessage),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue