diff --git a/CHANGELOG.md b/CHANGELOG.md index f173aff31..d92f99738 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Added: - Support for CTCP queries CLIENTINFO, PING, SOURCE, and VERSION - Custom notification sounds. Use your own sounds or select from a few new built-in options. For more details, see [notification configuration](https://halloy.squidowl.org/configuration/notifications.html). - Support DCC Send requests with spaces in the filename +- Reload config button in Sidebar Fixed: diff --git a/assets/icons/fontello-config.json b/assets/fontello/config.json old mode 100755 new mode 100644 similarity index 92% rename from assets/icons/fontello-config.json rename to assets/fontello/config.json index 67d9f1cd1..85bf53331 --- a/assets/icons/fontello-config.json +++ b/assets/fontello/config.json @@ -71,6 +71,12 @@ "css": "search-1", "code": 59400, "src": "entypo" + }, + { + "uid": "3bd18d47a12b8709e9f4fe9ead4f7518", + "css": "arrows-ccw", + "code": 59399, + "src": "entypo" } ] } \ No newline at end of file diff --git a/book/src/configuration/sidebar.md b/book/src/configuration/sidebar.md index 75e748bfa..5212ac02a 100644 --- a/book/src/configuration/sidebar.md +++ b/book/src/configuration/sidebar.md @@ -21,9 +21,11 @@ show_unread_indicators = true | false [sidebar.buttons] file_transfer = true | false command_bar = true | false +reload_config = true | false ``` | Key | Description | Default | | --------------- | -------------------------------- | ------- | | `file_transfer` | File transfer button in sidebar. | `true` | | `command_bar` | Command bar button in sidebar. | `true` | +| `reload_config` | Reload config button in sidebar. | `true` | diff --git a/data/src/config/sidebar.rs b/data/src/config/sidebar.rs index b52873359..9120103cd 100644 --- a/data/src/config/sidebar.rs +++ b/data/src/config/sidebar.rs @@ -31,6 +31,8 @@ pub struct Buttons { pub file_transfer: bool, #[serde(default = "default_bool_true")] pub command_bar: bool, + #[serde(default = "default_bool_true")] + pub reload_config: bool, } impl Default for Buttons { @@ -38,6 +40,7 @@ impl Default for Buttons { Buttons { file_transfer: default_bool_true(), command_bar: default_bool_true(), + reload_config: default_bool_true(), } } } diff --git a/fonts/halloy-icons.ttf b/fonts/halloy-icons.ttf index f8e6b272b..35786485b 100755 Binary files a/fonts/halloy-icons.ttf and b/fonts/halloy-icons.ttf differ diff --git a/src/icon.rs b/src/icon.rs index d1c39284a..b01a5d03b 100644 --- a/src/icon.rs +++ b/src/icon.rs @@ -48,6 +48,10 @@ pub fn file_transfer<'a>() -> Text<'a> { to_text('\u{E802}') } +pub fn refresh<'a>() -> Text<'a> { + to_text('\u{E807}') +} + fn to_text<'a>(unicode: char) -> Text<'a> { text(unicode.to_string()) .style(theme::text::primary) diff --git a/src/main.rs b/src/main.rs index 97d5f1465..33837a92c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -659,9 +659,11 @@ impl Halloy { } fn view(&self) -> Element { + let now = Instant::now(); + let screen = match &self.screen { Screen::Dashboard(dashboard) => dashboard - .view(&self.clients, &self.version, &self.config, &self.theme) + .view(now, &self.clients, &self.version, &self.config, &self.theme) .map(Message::Dashboard), Screen::Help(help) => help.view().map(Message::Help), Screen::Welcome(welcome) => welcome.view().map(Message::Welcome), diff --git a/src/screen/dashboard.rs b/src/screen/dashboard.rs index 28b1919d3..fbe568b8c 100644 --- a/src/screen/dashboard.rs +++ b/src/screen/dashboard.rs @@ -305,6 +305,9 @@ impl Dashboard { None, ); } + sidebar::Event::ReloadConfigFile => { + return (Task::none(), Some(Event::ReloadConfiguration)); + } } } Message::SelectedText(contents) => { @@ -582,6 +585,7 @@ impl Dashboard { pub fn view<'a>( &'a self, + now: Instant, clients: &'a client::Map, version: &'a Version, config: &'a Config, @@ -618,6 +622,7 @@ impl Dashboard { let side_menu = self .side_menu .view( + now, clients, &self.history, &self.panes, diff --git a/src/screen/dashboard/sidebar.rs b/src/screen/dashboard/sidebar.rs index 859c4fa64..20c2cde94 100644 --- a/src/screen/dashboard/sidebar.rs +++ b/src/screen/dashboard/sidebar.rs @@ -1,3 +1,5 @@ +use std::time::{Duration, Instant}; + use data::dashboard::DefaultAction; use data::{file_transfer, history, Buffer}; use iced::widget::{ @@ -19,6 +21,7 @@ pub enum Message { Leave(Buffer), ToggleFileTransfers, ToggleCommandBar, + ReloadConfigFile, } #[derive(Debug, Clone)] @@ -30,16 +33,21 @@ pub enum Event { Leave(Buffer), ToggleFileTransfers, ToggleCommandBar, + ReloadConfigFile, } #[derive(Clone)] pub struct Sidebar { hidden: bool, + timestamp: Option, } impl Sidebar { pub fn new() -> Self { - Self { hidden: false } + Self { + hidden: false, + timestamp: None, + } } pub fn toggle_visibility(&mut self) { @@ -55,11 +63,16 @@ impl Sidebar { Message::Leave(buffer) => Event::Leave(buffer), Message::ToggleFileTransfers => Event::ToggleFileTransfers, Message::ToggleCommandBar => Event::ToggleCommandBar, + Message::ReloadConfigFile => { + self.timestamp = Some(Instant::now()); + Event::ReloadConfigFile + } } } pub fn view<'a>( &'a self, + now: Instant, clients: &data::client::Map, history: &'a history::Manager, panes: &pane_grid::State, @@ -139,6 +152,28 @@ impl Sidebar { let mut menu_buttons = row![].spacing(1).padding(padding::bottom(4)); + if config.buttons.reload_config { + let icon = self + .timestamp + .filter(|×tamp| now.saturating_duration_since(timestamp) < Duration::new(1, 0)) + .map_or_else(|| icon::refresh().style(theme::text::primary), |_| icon::checkmark().style(theme::text::success)); + + let button = button(center(icon)) + .on_press(Message::ReloadConfigFile) + .padding(5) + .width(22) + .height(22) + .style(theme::button::side_menu); + + let button_with_tooltip = tooltip( + button, + show_tooltips.then_some("Reload config file"), + tooltip::Position::Top, + ); + + menu_buttons = menu_buttons.push(button_with_tooltip); + } + if config.buttons.command_bar { let button = button(center(icon::search())) .on_press(Message::ToggleCommandBar)