Added filter to profile settings page
This commit is contained in:
1 parent
f720fa00f4
commit
d272adcc4c
2 files changed
+74
-1
No files matched your search
+51
@@ -283,6 +283,7 @@ struct Moorly {
|
|||||||
tabs: Vec<Tab>,
|
tabs: Vec<Tab>,
|
||||||
active_tab: Option<Tab>,
|
active_tab: Option<Tab>,
|
||||||
settings_section: SettingsSection,
|
settings_section: SettingsSection,
|
||||||
|
profile_filter: String,
|
||||||
next_blank_tab: u32,
|
next_blank_tab: u32,
|
||||||
tab_offset: f32,
|
tab_offset: f32,
|
||||||
tab_viewport_width: f32,
|
tab_viewport_width: f32,
|
||||||
@@ -345,6 +346,7 @@ impl Default for Moorly {
|
|||||||
tabs: Vec::new(),
|
tabs: Vec::new(),
|
||||||
active_tab: None,
|
active_tab: None,
|
||||||
settings_section: SettingsSection::default(),
|
settings_section: SettingsSection::default(),
|
||||||
|
profile_filter: String::new(),
|
||||||
next_blank_tab: 1,
|
next_blank_tab: 1,
|
||||||
tab_offset: 0.0,
|
tab_offset: 0.0,
|
||||||
tab_viewport_width: 0.0,
|
tab_viewport_width: 0.0,
|
||||||
@@ -365,6 +367,8 @@ enum Message {
|
|||||||
SelectTab(Tab),
|
SelectTab(Tab),
|
||||||
CloseTab(Tab),
|
CloseTab(Tab),
|
||||||
SelectSettingsSection(SettingsSection),
|
SelectSettingsSection(SettingsSection),
|
||||||
|
ProfileFilterChanged(String),
|
||||||
|
ClearProfileFilter,
|
||||||
OpenShortcutCapture(ShortcutAction),
|
OpenShortcutCapture(ShortcutAction),
|
||||||
CancelShortcut,
|
CancelShortcut,
|
||||||
ClearShortcut(ShortcutAction),
|
ClearShortcut(ShortcutAction),
|
||||||
@@ -446,6 +450,8 @@ fn update(state: &mut Moorly, message: Message) -> Task<Message> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::SelectSettingsSection(section) => state.settings_section = section,
|
Message::SelectSettingsSection(section) => state.settings_section = section,
|
||||||
|
Message::ProfileFilterChanged(value) => state.profile_filter = value,
|
||||||
|
Message::ClearProfileFilter => state.profile_filter.clear(),
|
||||||
Message::OpenShortcutCapture(action) => {
|
Message::OpenShortcutCapture(action) => {
|
||||||
state.shortcut_capture = Some(ShortcutCapture {
|
state.shortcut_capture = Some(ShortcutCapture {
|
||||||
action,
|
action,
|
||||||
@@ -767,6 +773,47 @@ fn shortcut_capture_panel(capture: &ShortcutCapture) -> Element<'_, Message> {
|
|||||||
.into()
|
.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> {
|
fn settings_page(state: &Moorly) -> Element<'_, Message> {
|
||||||
let menu_item = |section: SettingsSection| {
|
let menu_item = |section: SettingsSection| {
|
||||||
let label = container(text(section.label()))
|
let label = container(text(section.label()))
|
||||||
@@ -799,6 +846,9 @@ fn settings_page(state: &Moorly) -> Element<'_, Message> {
|
|||||||
if state.settings_section == SettingsSection::Shortcuts {
|
if state.settings_section == SettingsSection::Shortcuts {
|
||||||
content = content.push(shortcuts_panel(state));
|
content = content.push(shortcuts_panel(state));
|
||||||
}
|
}
|
||||||
|
if state.settings_section == SettingsSection::Profiles {
|
||||||
|
content = content.push(profiles_panel(state));
|
||||||
|
}
|
||||||
|
|
||||||
let content = container(content)
|
let content = container(content)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
@@ -1061,6 +1111,7 @@ mod tests {
|
|||||||
tabs: Vec::new(),
|
tabs: Vec::new(),
|
||||||
active_tab: None,
|
active_tab: None,
|
||||||
settings_section: super::SettingsSection::default(),
|
settings_section: super::SettingsSection::default(),
|
||||||
|
profile_filter: String::new(),
|
||||||
next_blank_tab: 1,
|
next_blank_tab: 1,
|
||||||
tab_offset: 0.0,
|
tab_offset: 0.0,
|
||||||
tab_viewport_width: 0.0,
|
tab_viewport_width: 0.0,
|
||||||
|
|||||||
+23
-1
@@ -8,7 +8,7 @@ use std::env;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use iced::widget::{button, container};
|
use iced::widget::{button, container, text_input};
|
||||||
use iced::{Border, Color, Theme};
|
use iced::{Border, Color, Theme};
|
||||||
|
|
||||||
/// Accent red used for destructive/close affordances in both themes.
|
/// Accent red used for destructive/close affordances in both themes.
|
||||||
@@ -162,6 +162,28 @@ pub fn outlined_option(theme: &Theme, status: button::Status) -> button::Style {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Style for filter/text fields: a thicker outline while focused.
|
||||||
|
pub fn filter_field(theme: &Theme, status: text_input::Status) -> text_input::Style {
|
||||||
|
let palette = theme.extended_palette();
|
||||||
|
let mut style = text_input::default(theme, status);
|
||||||
|
|
||||||
|
style.border = if matches!(status, text_input::Status::Focused { .. }) {
|
||||||
|
Border {
|
||||||
|
color: palette.primary.strong.color,
|
||||||
|
width: 2.0,
|
||||||
|
radius: 4.0.into(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Border {
|
||||||
|
color: palette.background.strong.color,
|
||||||
|
width: 1.0,
|
||||||
|
radius: 4.0.into(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
style
|
||||||
|
}
|
||||||
|
|
||||||
/// Style for the settings window frame.
|
/// Style for the settings window frame.
|
||||||
pub fn settings_frame(theme: &Theme) -> container::Style {
|
pub fn settings_frame(theme: &Theme) -> container::Style {
|
||||||
let palette = theme.extended_palette();
|
let palette = theme.extended_palette();
|
||||||
|
|||||||
Reference in new issue
Block a user