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,
|
||||
OpenWithDialog(Option<Entity>),
|
||||
OpenWithSelection(usize),
|
||||
OpenWithSearchClear,
|
||||
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
|
||||
Overlap(window::Id, OverlapNotifyEvent),
|
||||
Paste(Option<Entity>),
|
||||
|
|
@ -3835,21 +3836,24 @@ impl Application for App {
|
|||
let Some(path) = item.path_opt() else {
|
||||
continue;
|
||||
};
|
||||
return self.push_dialog(
|
||||
DialogPage::OpenWith {
|
||||
path: path.clone(),
|
||||
mime: item.mime.clone(),
|
||||
selected: 0,
|
||||
store_opt: "x-scheme-handler/mime"
|
||||
.parse::<mime_guess::Mime>()
|
||||
.ok()
|
||||
.and_then(|mime| {
|
||||
self.mime_app_cache.get(&mime).first().cloned()
|
||||
}),
|
||||
search_app_name: String::new(),
|
||||
},
|
||||
Some(CONFIRM_OPEN_WITH_BUTTON_ID.clone()),
|
||||
);
|
||||
return Task::batch([
|
||||
self.push_dialog(
|
||||
DialogPage::OpenWith {
|
||||
path: path.clone(),
|
||||
mime: item.mime.clone(),
|
||||
selected: 0,
|
||||
store_opt: "x-scheme-handler/mime"
|
||||
.parse::<mime_guess::Mime>()
|
||||
.ok()
|
||||
.and_then(|mime| {
|
||||
self.mime_app_cache.get(&mime).first().cloned()
|
||||
}),
|
||||
search_app_name: String::new(),
|
||||
},
|
||||
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;
|
||||
}
|
||||
}
|
||||
Message::OpenWithSearchClear => {
|
||||
if let Some(DialogPage::OpenWith {
|
||||
search_app_name, ..
|
||||
}) = self.dialog_pages.front_mut()
|
||||
{
|
||||
*search_app_name = String::new();
|
||||
}
|
||||
}
|
||||
Message::Paste(entity_opt) => {
|
||||
let entity = entity_opt.unwrap_or_else(|| self.tab_model.active());
|
||||
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),
|
||||
)
|
||||
.control(
|
||||
widget::column::with_children([
|
||||
widget::text::body(fl!("search-application")).into(),
|
||||
widget::text_input("", search_app_name)
|
||||
.id(self.dialog_text_input.clone())
|
||||
.on_input(move |search_app_name| {
|
||||
Message::DialogUpdate(DialogPage::OpenWith {
|
||||
path: path.clone(),
|
||||
mime: mime.clone(),
|
||||
selected: *selected,
|
||||
store_opt: store_opt.clone(),
|
||||
search_app_name,
|
||||
})
|
||||
widget::search_input(fl!("search-application"), search_app_name)
|
||||
.id(self.dialog_text_input.clone())
|
||||
.on_clear(Message::OpenWithSearchClear)
|
||||
.on_input(move |search_app_name| {
|
||||
Message::DialogUpdate(DialogPage::OpenWith {
|
||||
path: path.clone(),
|
||||
mime: mime.clone(),
|
||||
selected: *selected,
|
||||
store_opt: store_opt.clone(),
|
||||
search_app_name,
|
||||
})
|
||||
.into(),
|
||||
])
|
||||
.spacing(space_xxs),
|
||||
}),
|
||||
)
|
||||
.control(widget::scrollable(column).height({
|
||||
let max_size = self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue