Allow type to enter path to select files in dialog
This commit is contained in:
parent
9e8fb60b70
commit
4312179a4d
1 changed files with 24 additions and 12 deletions
|
|
@ -344,7 +344,7 @@ impl<M: Send + 'static> Dialog<M> {
|
||||||
self.cosmic.app.filter_selected = filter_selected;
|
self.cosmic.app.filter_selected = filter_selected;
|
||||||
self.cosmic
|
self.cosmic
|
||||||
.app
|
.app
|
||||||
.rescan_tab()
|
.rescan_tab(None)
|
||||||
.map(DialogMessage)
|
.map(DialogMessage)
|
||||||
.map(move |message| cosmic::action::app(mapper(message)))
|
.map(move |message| cosmic::action::app(mapper(message)))
|
||||||
}
|
}
|
||||||
|
|
@ -431,7 +431,9 @@ enum Message {
|
||||||
Surface(cosmic::surface::Action),
|
Surface(cosmic::surface::Action),
|
||||||
#[allow(clippy::enum_variant_names)]
|
#[allow(clippy::enum_variant_names)]
|
||||||
TabMessage(tab::Message),
|
TabMessage(tab::Message),
|
||||||
TabRescan(Location, Option<tab::Item>, Vec<tab::Item>),
|
TabRescan(Location, Option<tab::Item>, Vec<tab::Item>,
|
||||||
|
Option<Vec<PathBuf>>,
|
||||||
|
),
|
||||||
TabView(tab::View),
|
TabView(tab::View),
|
||||||
TimeConfigChange(TimeConfig),
|
TimeConfigChange(TimeConfig),
|
||||||
ToggleFoldersFirst,
|
ToggleFoldersFirst,
|
||||||
|
|
@ -662,7 +664,9 @@ impl App {
|
||||||
widget::column::with_children(children).into()
|
widget::column::with_children(children).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rescan_tab(&self) -> Task<Message> {
|
fn rescan_tab(&self,
|
||||||
|
selection_paths: Option<Vec<PathBuf>>,
|
||||||
|
) -> Task<Message> {
|
||||||
let location = self.tab.location.clone();
|
let location = self.tab.location.clone();
|
||||||
let icon_sizes = self.tab.config.icon_sizes;
|
let icon_sizes = self.tab.config.icon_sizes;
|
||||||
let mounter_items = self.mounter_items.clone();
|
let mounter_items = self.mounter_items.clone();
|
||||||
|
|
@ -685,7 +689,7 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cosmic::action::app(Message::TabRescan(location, parent_item_opt, items))
|
cosmic::action::app(Message::TabRescan(location, parent_item_opt, items, selection_paths))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::warn!("failed to rescan: {}", err);
|
log::warn!("failed to rescan: {}", err);
|
||||||
|
|
@ -727,7 +731,7 @@ impl App {
|
||||||
return Task::batch([
|
return Task::batch([
|
||||||
self.update_title(),
|
self.update_title(),
|
||||||
self.update_watcher(),
|
self.update_watcher(),
|
||||||
self.rescan_tab(),
|
self.rescan_tab(None),
|
||||||
if focus_search {
|
if focus_search {
|
||||||
widget::text_input::focus(self.search_id.clone())
|
widget::text_input::focus(self.search_id.clone())
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -985,7 +989,7 @@ impl Application for App {
|
||||||
app.update_config(),
|
app.update_config(),
|
||||||
app.update_title(),
|
app.update_title(),
|
||||||
app.update_watcher(),
|
app.update_watcher(),
|
||||||
app.rescan_tab(),
|
app.rescan_tab(None),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
(app, commands)
|
(app, commands)
|
||||||
|
|
@ -1339,7 +1343,7 @@ impl Application for App {
|
||||||
} else {
|
} else {
|
||||||
self.filter_selected = None;
|
self.filter_selected = None;
|
||||||
}
|
}
|
||||||
return self.rescan_tab();
|
return self.rescan_tab(None);
|
||||||
}
|
}
|
||||||
Message::Key(modifiers, key, text) => {
|
Message::Key(modifiers, key, text) => {
|
||||||
for (key_bind, action) in self.key_binds.iter() {
|
for (key_bind, action) in self.key_binds.iter() {
|
||||||
|
|
@ -1426,7 +1430,7 @@ impl Application for App {
|
||||||
if unmounted.contains(&self.tab.location) {
|
if unmounted.contains(&self.tab.location) {
|
||||||
self.tab.change_location(&home_location, None);
|
self.tab.change_location(&home_location, None);
|
||||||
commands.push(self.update_watcher());
|
commands.push(self.update_watcher());
|
||||||
commands.push(self.rescan_tab());
|
commands.push(self.rescan_tab(None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1502,7 +1506,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if contains_change {
|
if contains_change {
|
||||||
return self.rescan_tab();
|
return self.rescan_tab(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1640,8 +1644,8 @@ impl Application for App {
|
||||||
tab::Command::Action(action) => {
|
tab::Command::Action(action) => {
|
||||||
commands.push(self.update(Message::from(action.message())));
|
commands.push(self.update(Message::from(action.message())));
|
||||||
}
|
}
|
||||||
tab::Command::ChangeLocation(_tab_title, _tab_path, _selection_paths) => {
|
tab::Command::ChangeLocation(_tab_title, _tab_path, selection_paths) => {
|
||||||
commands.push(Task::batch([self.update_watcher(), self.rescan_tab()]));
|
commands.push(Task::batch([self.update_watcher(), self.rescan_tab(selection_paths)]));
|
||||||
}
|
}
|
||||||
tab::Command::ContextMenu(point_opt, parent_id) => {
|
tab::Command::ContextMenu(point_opt, parent_id) => {
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "wayland")]
|
||||||
|
|
@ -1753,7 +1757,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
return Task::batch(commands);
|
return Task::batch(commands);
|
||||||
}
|
}
|
||||||
Message::TabRescan(location, parent_item_opt, mut items) => {
|
Message::TabRescan(location, parent_item_opt, mut items, selection_paths) => {
|
||||||
if location == self.tab.location {
|
if location == self.tab.location {
|
||||||
// Filter
|
// Filter
|
||||||
if let Some(filter_i) = self.filter_selected {
|
if let Some(filter_i) = self.filter_selected {
|
||||||
|
|
@ -1826,6 +1830,14 @@ impl Application for App {
|
||||||
self.tab.parent_item_opt = parent_item_opt;
|
self.tab.parent_item_opt = parent_item_opt;
|
||||||
self.tab.set_items(items);
|
self.tab.set_items(items);
|
||||||
|
|
||||||
|
if let Some(mut selection_paths) = selection_paths {
|
||||||
|
if !self.flags.kind.multiple() {
|
||||||
|
selection_paths.truncate(1);
|
||||||
|
}
|
||||||
|
self.tab.select_paths(selection_paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Reset focus on location change
|
// Reset focus on location change
|
||||||
if self.search_get().is_some() {
|
if self.search_get().is_some() {
|
||||||
return widget::text_input::focus(self.search_id.clone());
|
return widget::text_input::focus(self.search_id.clone());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue