From 7d3b59f72ac397479e6af841f3c5ed703485c0a4 Mon Sep 17 00:00:00 2001 From: ellieplayswow <164806095+ellieplayswow@users.noreply.github.com> Date: Mon, 10 Mar 2025 02:15:23 +0000 Subject: [PATCH 1/3] Use scrollable for open-with dialog and calculate height to ensure open button is visible --- src/app.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index 7fd1792..e2bfa95 100644 --- a/src/app.rs +++ b/src/app.rs @@ -4290,7 +4290,10 @@ impl Application for App { }; let mut column = widget::list_column(); - for (i, app) in self.get_programs_for_mime(&mime).iter().enumerate() { + let available_programs = self.get_programs_for_mime(&mime); + let item_height = 32.0; + + for (i, app) in available_programs.iter().enumerate() { column = column.add( widget::button::custom( widget::row::with_children(vec![ @@ -4314,7 +4317,7 @@ impl Application for App { }, ]) .spacing(space_s) - .height(Length::Fixed(32.0)) + .height(Length::Fixed(item_height)) .align_y(Alignment::Center), ) .width(Length::Fill) @@ -4331,7 +4334,21 @@ impl Application for App { .secondary_action( widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel), ) - .control(column); + .control( + widget::scrollable(column).height(if let Some(size) = self.size { + let max_size = size.height - 256.0; + let scrollable_height = available_programs.len() as f32 + * (item_height + (2.0 * space_xxs as f32)); + + if scrollable_height > max_size { + Length::Fill + } else { + Length::Shrink + } + } else { + Length::Fill + }), + ); if let Some(app) = store_opt { dialog = dialog.tertiary_action( From 1ab7615335a8484c82db6e4b481cbf70ba5268e7 Mon Sep 17 00:00:00 2001 From: ellieplayswow <164806095+ellieplayswow@users.noreply.github.com> Date: Mon, 10 Mar 2025 09:08:37 +0000 Subject: [PATCH 2/3] Fixing incorrect height calculation on scrollable --- src/app.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index e2bfa95..ea9f6de 100644 --- a/src/app.rs +++ b/src/app.rs @@ -4337,8 +4337,9 @@ impl Application for App { .control( widget::scrollable(column).height(if let Some(size) = self.size { let max_size = size.height - 256.0; + // (32 (item_height) + 5.0 (custom button padding)) + (space_xxs (list item spacing) * 2) let scrollable_height = available_programs.len() as f32 - * (item_height + (2.0 * space_xxs as f32)); + * (item_height + 5.0 + (2.0 * space_xxs as f32)); if scrollable_height > max_size { Length::Fill From eac6acc74f69c3e5b13db3b7fad6dc8110e27fd8 Mon Sep 17 00:00:00 2001 From: ellieplayswow <164806095+ellieplayswow@users.noreply.github.com> Date: Mon, 10 Mar 2025 12:51:50 +0000 Subject: [PATCH 3/3] Only show one (default) line --- src/app.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index ea9f6de..5f5b65e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -4292,13 +4292,15 @@ impl Application for App { let mut column = widget::list_column(); let available_programs = self.get_programs_for_mime(&mime); let item_height = 32.0; + let mut displayed_default = false; for (i, app) in available_programs.iter().enumerate() { column = column.add( widget::button::custom( widget::row::with_children(vec![ widget::icon(app.icon.clone()).size(32).into(), - if app.is_default { + if app.is_default && !displayed_default { + displayed_default = true; widget::text::body(fl!( "default-app", name = Some(app.name.as_str())