Remove duplicate dialog frames and give source lists enough height

This commit is contained in:
Samuel Onoja committed 2026-09-30 05:57:37 +01:00
1 parent 518b083472
commit 88e4f3c135
3 files changed
+26 -6

No files matched your search

+1
View File
@@ -104,6 +104,7 @@ impl cosmic::Application for Consent {
core.window.show_headerbar = false; core.window.show_headerbar = false;
core.window.border_padding = Some(0); core.window.border_padding = Some(0);
core.window.content_container = false; core.window.content_container = false;
core.window.use_template = false;
let app = Self { let app = Self {
core, core,
prompt, prompt,
+24 -6
View File
@@ -24,6 +24,25 @@ pub struct Prompt {
pub rememberable: Vec<String>, pub rememberable: Vec<String>,
} }
impl Prompt {
fn source_list_height(&self) -> f32 {
let visible = &self.sources[..self.sources.len().min(4)];
let mut sections = 0;
let mut previous_kind = None;
if !self.window_capture {
for source in visible {
let is_window = source.window_id().is_some();
if previous_kind != Some(is_window) {
sections += 1;
previous_kind = Some(is_window);
}
}
}
let rows = visible.len();
(rows * 64 + rows.saturating_sub(1) * 6 + sections * 24) as f32
}
}
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub(crate) struct Selection { pub(crate) struct Selection {
@@ -76,9 +95,8 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
} }
let (theme, font, background, palette) = appearance(); let (theme, font, background, palette) = appearance();
let height = 180. let height =
+ (prompt.sources.len().min(4) as f32 * 56.) 180. + prompt.source_list_height() + if prompt.persist_mode > 0 { 64. } else { 0. };
+ if prompt.persist_mode > 0 { 64. } else { 0. };
cosmic::app::run::<Picker>( cosmic::app::run::<Picker>(
Settings::default() Settings::default()
.size(cosmic::iced::Size::new(400., height)) .size(cosmic::iced::Size::new(400., height))
@@ -120,6 +138,7 @@ impl cosmic::Application for Picker {
core.window.show_headerbar = false; core.window.show_headerbar = false;
core.window.border_padding = Some(0); core.window.border_padding = Some(0);
core.window.content_container = false; core.window.content_container = false;
core.window.use_template = false;
// No preselected source: clicking Share must be a deliberate choice. // No preselected source: clicking Share must be a deliberate choice.
let mut app = Self { let mut app = Self {
core, core,
@@ -310,9 +329,8 @@ impl cosmic::Application for Picker {
.on_press(Message::Select(index)), .on_press(Message::Select(index)),
); );
} }
content = content.push(scrollable(sources).height(Length::Fixed( content = content
(self.prompt.sources.len().min(4) * 56) as f32, .push(scrollable(sources).height(Length::Fixed(self.prompt.source_list_height())));
)));
content = content.push( content = content.push(
self.text(if self.prompt.window_capture { self.text(if self.prompt.window_capture {
"Only the selected window will be captured." "Only the selected window will be captured."
+1
View File
@@ -216,6 +216,7 @@ impl cosmic::Application for Prompt {
core.window.show_headerbar = false; core.window.show_headerbar = false;
core.window.border_padding = Some(0); core.window.border_padding = Some(0);
core.window.content_container = false; core.window.content_container = false;
core.window.use_template = false;
let height = content_height(&description, None); let height = content_height(&description, None);
let bounds = core let bounds = core
.main_window_id() .main_window_id()