Skip to content

Commit

Permalink
Added config to hide user menu
Browse files Browse the repository at this point in the history
  • Loading branch information
casperstorm committed Oct 4, 2024
1 parent 82e31fc commit babd5a9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
10 changes: 9 additions & 1 deletion book/src/configuration/sidebar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@ Specify sidebar width in pixels. Only used if `position` is `"left"` or `"right"

- **type**: integer
- **values**: any positive integer
- **default**: `120"`
- **default**: `120`

## `show_menu_button`

Show or hide the user menu button in the sidemenu.

- **type**: bool
- **values**: `true`, `false`
- **default**: `true`
7 changes: 7 additions & 0 deletions data/src/config/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub struct Sidebar {
pub unread_indicator: UnreadIndicator,
#[serde(default)]
pub position: Position,
#[serde(default = "default_bool_true")]
pub show_user_menu: bool,
}

#[derive(Debug, Copy, Clone, Deserialize, Default)]
Expand Down Expand Up @@ -52,10 +54,15 @@ impl Default for Sidebar {
width: default_sidebar_width(),
unread_indicator: UnreadIndicator::default(),
position: Position::default(),
show_user_menu: default_bool_true(),
}
}
}

fn default_sidebar_width() -> u16 {
120
}

fn default_bool_true() -> bool {
true
}
15 changes: 9 additions & 6 deletions src/screen/dashboard/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl Sidebar {
}
}

fn menu_button<'a>(
fn user_menu_button<'a>(
&self,
keyboard: &'a data::config::Keyboard,
file_transfers: &'a file_transfer::Manager,
Expand Down Expand Up @@ -246,7 +246,9 @@ impl Sidebar {
return None;
}

let menu_button = self.menu_button(keyboard, file_transfers, version);
let user_menu_button = config
.show_user_menu
.then(|| self.user_menu_button(keyboard, file_transfers, version));

let mut buffers = vec![];

Expand Down Expand Up @@ -339,7 +341,8 @@ impl Sidebar {
.scroller_width(0),
)),];

let body = column![container(content).height(Length::Fill), menu_button];
let body =
column![container(content).height(Length::Fill)].push_maybe(user_menu_button);
let padding = match config.position {
sidebar::Position::Left => padding::top(8).bottom(6).left(6),
sidebar::Position::Right => padding::top(8).bottom(6).right(6),
Expand All @@ -363,9 +366,9 @@ impl Sidebar {
.scroller_width(0),
)),];

let body: Row<Message, theme::Theme> =
row![container(content).width(Length::Fill), menu_button]
.align_y(Alignment::Center);
let body: Row<Message, theme::Theme> = row![container(content).width(Length::Fill)]
.push_maybe(user_menu_button)
.align_y(Alignment::Center);
let padding = match config.position {
sidebar::Position::Top => padding::top(8).left(8).right(8),
sidebar::Position::Bottom => padding::bottom(8).left(8).right(8),
Expand Down

0 comments on commit babd5a9

Please sign in to comment.