Added filter to profile settings page

This commit is contained in:
Squid committed 2026-10-31 22:04:48 +01:00
1 parent f720fa00f4
commit d272adcc4c
2 files changed
+74 -1

No files matched your search

+51
View File
@@ -283,6 +283,7 @@ struct Moorly {
tabs: Vec<Tab>,
active_tab: Option<Tab>,
settings_section: SettingsSection,
profile_filter: String,
next_blank_tab: u32,
tab_offset: f32,
tab_viewport_width: f32,
@@ -345,6 +346,7 @@ impl Default for Moorly {
tabs: Vec::new(),
active_tab: None,
settings_section: SettingsSection::default(),
profile_filter: String::new(),
next_blank_tab: 1,
tab_offset: 0.0,
tab_viewport_width: 0.0,
@@ -365,6 +367,8 @@ enum Message {
SelectTab(Tab),
CloseTab(Tab),
SelectSettingsSection(SettingsSection),
ProfileFilterChanged(String),
ClearProfileFilter,
OpenShortcutCapture(ShortcutAction),
CancelShortcut,
ClearShortcut(ShortcutAction),
@@ -446,6 +450,8 @@ fn update(state: &mut Moorly, message: Message) -> Task<Message> {
}
}
Message::SelectSettingsSection(section) => state.settings_section = section,
Message::ProfileFilterChanged(value) => state.profile_filter = value,
Message::ClearProfileFilter => state.profile_filter.clear(),
Message::OpenShortcutCapture(action) => {
state.shortcut_capture = Some(ShortcutCapture {
action,
@@ -767,6 +773,47 @@ fn shortcut_capture_panel(capture: &ShortcutCapture) -> Element<'_, Message> {
.into()
}
/// Profile list with a search filter row.
fn profiles_panel(state: &Moorly) -> Element<'_, Message> {
let field = text_input("Filter", &state.profile_filter)
.on_input(Message::ProfileFilterChanged)
.padding(Padding {
top: 6.0,
right: 32.0,
bottom: 6.0,
left: 28.0,
})
.style(theme::filter_field)
.width(Length::Fill);
let search = container(text("⌕").size(24))
.width(Length::Fill)
.height(Length::Fill)
.align_x(Alignment::Start)
.align_y(Alignment::Center)
.padding(Padding::ZERO.left(9.0));
let mut filter = stack![field, search].width(320);
if !state.profile_filter.is_empty() {
let clear = container(
button(text("✕").size(15))
.on_press(Message::ClearProfileFilter)
.padding([2, 4])
.style(button::text),
)
.width(Length::Fill)
.height(Length::Fill)
.align_x(Alignment::End)
.align_y(Alignment::Center)
.padding(Padding::ZERO.right(6.0));
filter = filter.push(clear);
}
filter.into()
}
fn settings_page(state: &Moorly) -> Element<'_, Message> {
let menu_item = |section: SettingsSection| {
let label = container(text(section.label()))
@@ -799,6 +846,9 @@ fn settings_page(state: &Moorly) -> Element<'_, Message> {
if state.settings_section == SettingsSection::Shortcuts {
content = content.push(shortcuts_panel(state));
}
if state.settings_section == SettingsSection::Profiles {
content = content.push(profiles_panel(state));
}
let content = container(content)
.width(Length::Fill)
@@ -1061,6 +1111,7 @@ mod tests {
tabs: Vec::new(),
active_tab: None,
settings_section: super::SettingsSection::default(),
profile_filter: String::new(),
next_blank_tab: 1,
tab_offset: 0.0,
tab_viewport_width: 0.0,