add autofocus, move label to placeholder, add search and clear icons
This commit is contained in:
parent
9a4f78aa75
commit
6273fe6505
1 changed files with 38 additions and 30 deletions
68
src/app.rs
68
src/app.rs
|
|
@ -395,6 +395,7 @@ pub enum Message {
|
||||||
OpenWithBrowse,
|
OpenWithBrowse,
|
||||||
OpenWithDialog(Option<Entity>),
|
OpenWithDialog(Option<Entity>),
|
||||||
OpenWithSelection(usize),
|
OpenWithSelection(usize),
|
||||||
|
OpenWithSearchClear,
|
||||||
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
|
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
|
||||||
Overlap(window::Id, OverlapNotifyEvent),
|
Overlap(window::Id, OverlapNotifyEvent),
|
||||||
Paste(Option<Entity>),
|
Paste(Option<Entity>),
|
||||||
|
|
@ -3835,21 +3836,24 @@ impl Application for App {
|
||||||
let Some(path) = item.path_opt() else {
|
let Some(path) = item.path_opt() else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
return self.push_dialog(
|
return Task::batch([
|
||||||
DialogPage::OpenWith {
|
self.push_dialog(
|
||||||
path: path.clone(),
|
DialogPage::OpenWith {
|
||||||
mime: item.mime.clone(),
|
path: path.clone(),
|
||||||
selected: 0,
|
mime: item.mime.clone(),
|
||||||
store_opt: "x-scheme-handler/mime"
|
selected: 0,
|
||||||
.parse::<mime_guess::Mime>()
|
store_opt: "x-scheme-handler/mime"
|
||||||
.ok()
|
.parse::<mime_guess::Mime>()
|
||||||
.and_then(|mime| {
|
.ok()
|
||||||
self.mime_app_cache.get(&mime).first().cloned()
|
.and_then(|mime| {
|
||||||
}),
|
self.mime_app_cache.get(&mime).first().cloned()
|
||||||
search_app_name: String::new(),
|
}),
|
||||||
},
|
search_app_name: String::new(),
|
||||||
Some(CONFIRM_OPEN_WITH_BUTTON_ID.clone()),
|
},
|
||||||
);
|
Some(CONFIRM_OPEN_WITH_BUTTON_ID.clone()),
|
||||||
|
),
|
||||||
|
widget::text_input::focus(self.dialog_text_input.clone()),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3858,6 +3862,14 @@ impl Application for App {
|
||||||
*selected = index;
|
*selected = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::OpenWithSearchClear => {
|
||||||
|
if let Some(DialogPage::OpenWith {
|
||||||
|
search_app_name, ..
|
||||||
|
}) = self.dialog_pages.front_mut()
|
||||||
|
{
|
||||||
|
*search_app_name = String::new();
|
||||||
|
}
|
||||||
|
}
|
||||||
Message::Paste(entity_opt) => {
|
Message::Paste(entity_opt) => {
|
||||||
let entity = entity_opt.unwrap_or_else(|| self.tab_model.active());
|
let entity = entity_opt.unwrap_or_else(|| self.tab_model.active());
|
||||||
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity)
|
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity)
|
||||||
|
|
@ -6049,22 +6061,18 @@ impl Application for App {
|
||||||
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
|
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
|
||||||
)
|
)
|
||||||
.control(
|
.control(
|
||||||
widget::column::with_children([
|
widget::search_input(fl!("search-application"), search_app_name)
|
||||||
widget::text::body(fl!("search-application")).into(),
|
.id(self.dialog_text_input.clone())
|
||||||
widget::text_input("", search_app_name)
|
.on_clear(Message::OpenWithSearchClear)
|
||||||
.id(self.dialog_text_input.clone())
|
.on_input(move |search_app_name| {
|
||||||
.on_input(move |search_app_name| {
|
Message::DialogUpdate(DialogPage::OpenWith {
|
||||||
Message::DialogUpdate(DialogPage::OpenWith {
|
path: path.clone(),
|
||||||
path: path.clone(),
|
mime: mime.clone(),
|
||||||
mime: mime.clone(),
|
selected: *selected,
|
||||||
selected: *selected,
|
store_opt: store_opt.clone(),
|
||||||
store_opt: store_opt.clone(),
|
search_app_name,
|
||||||
search_app_name,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.into(),
|
}),
|
||||||
])
|
|
||||||
.spacing(space_xxs),
|
|
||||||
)
|
)
|
||||||
.control(widget::scrollable(column).height({
|
.control(widget::scrollable(column).height({
|
||||||
let max_size = self
|
let max_size = self
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue