From 5a7e04460843ec30437c50464d8b71bdc276429d Mon Sep 17 00:00:00 2001 From: Anton Yemelyanov Date: Thu, 28 Dec 2023 16:51:10 +0200 Subject: [PATCH] CI + user_agent + window frame --- .github/workflows/ci.yaml | 17 +++-- README.md | 2 +- core/Cargo.toml | 2 +- core/src/core.rs | 6 +- core/src/frame.rs | 79 ++++++++++++++++++----- core/src/runtime/services/kaspa/config.rs | 13 +++- core/src/status.rs | 7 +- 7 files changed, 100 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5b7e85b..800efa6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ jobs: - name: Install desktop dependencies run: | - sudo apt install -y librust-atk-dev + sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev - name: Checkout sources uses: actions/checkout@v3 @@ -84,7 +84,6 @@ jobs: swap-storage: true - - name: Install desktop dependencies run: | sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev @@ -134,6 +133,11 @@ jobs: name: Lints runs-on: ubuntu-latest steps: + + - name: Install desktop dependencies + run: | + sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev + - name: Checkout sources uses: actions/checkout@v3 @@ -201,7 +205,7 @@ jobs: - name: Install desktop dependencies run: | - sudo apt install -y librust-atk-dev + sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev - name: Install stable toolchain if: steps.install_llvm.outcome == 'success' && steps.install_llvm.conclusion == 'success' @@ -262,7 +266,7 @@ jobs: - name: Install desktop dependencies run: | - sudo apt install -y librust-atk-dev + sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev - name: Install stable toolchain if: steps.install_llvm.outcome == 'success' && steps.install_llvm.conclusion == 'success' @@ -306,6 +310,11 @@ jobs: name: Build Ubuntu Release runs-on: ubuntu-latest steps: + + - name: Install desktop dependencies + run: | + sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev + - name: Checkout sources uses: actions/checkout@v3 diff --git a/README.md b/README.md index c212708..0488ba0 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ In addition, on linux, you need to perform the following installs: #### Ubuntu/Debian: ```bash -sudo apt-get install libglib2.0-dev libatk1.0-dev libgtk-3-dev +sudo apt-get install libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev ``` #### Fedora: diff --git a/core/Cargo.toml b/core/Cargo.toml index 5f4ed98..32509cc 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -70,7 +70,7 @@ egui_plot.workspace = true egui_extras.workspace = true chrono.workspace = true eframe = { workspace = true, default-features = false, features = [ - # "accesskit", # Make egui comptaible with screen readers. NOTE: adds a lot of dependencies. + "accesskit", # Make egui comptaible with screen readers. NOTE: adds a lot of dependencies. "default_fonts", # Embed the default egui fonts. # "wgpu", # Use the glow rendering backend. Alternative: "wgpu". "glow", # Use the glow rendering backend. Alternative: "wgpu". diff --git a/core/src/core.rs b/core/src/core.rs index ca51b03..efe2824 100644 --- a/core/src/core.rs +++ b/core/src/core.rs @@ -406,7 +406,10 @@ impl eframe::App for Core { impl Core { fn render_frame(&mut self, ctx: &Context, frame: &mut eframe::Frame) { - window_frame(self.window_frame, ctx, "Kaspa NG", |ui| { + + let is_fullscreen = ctx.input(|i| i.viewport().fullscreen.unwrap_or(false)); + + window_frame(self.window_frame && !is_fullscreen, ctx, "Kaspa NG", |ui| { if !self.settings.initialized { cfg_if! { if #[cfg(not(target_arch = "wasm32"))] { @@ -523,6 +526,7 @@ impl Core { }); } + #[cfg(not(target_arch = "wasm32"))] fn handle_screenshot(&mut self, ctx: &Context, screenshot: Arc) { match rfd::FileDialog::new().save_file() { Some(mut path) => { diff --git a/core/src/frame.rs b/core/src/frame.rs index 2584b4e..08318f7 100644 --- a/core/src/frame.rs +++ b/core/src/frame.rs @@ -118,7 +118,8 @@ fn title_bar_ui(ui: &mut egui::Ui, title_bar_rect: eframe::epaint::Rect, title: fn close_maximize_minimize(ui: &mut egui::Ui) { use egui_phosphor::light::*; - let button_height = 14.0; + let spacing = 8.0; + let button_height = 16.0; let close_response = ui .add(Button::new( @@ -129,27 +130,75 @@ fn close_maximize_minimize(ui: &mut egui::Ui) { if close_response.clicked() { ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close); } + + + cfg_if! { + if #[cfg(target_os = "macos")] { + let support_fullscreen = true; + let support_maximize = true; + } else { + let support_fullscreen = true; + let support_maximize = true; + } + } - let is_maximized = ui.input(|i| i.viewport().maximized.unwrap_or(false)); - if is_maximized { - let maximized_response = ui - .add(Button::new(RichText::new("🗗").size(button_height))) - .on_hover_text("Restore window"); - if maximized_response.clicked() { - ui.ctx() - .send_viewport_cmd(ViewportCommand::Maximized(false)); + if support_fullscreen { + + ui.add_space(spacing); + + let is_fullscreen = ui.input(|i| i.viewport().fullscreen.unwrap_or(false)); + if is_fullscreen { + let fullscreen_response = ui + // .add(Button::new(RichText::new("🗗").size(button_height))) + .add(Button::new(RichText::new(ARROWS_IN.to_string()).size(button_height))) + .on_hover_text("Exit Full Screen"); + if fullscreen_response.clicked() { + ui.ctx().send_viewport_cmd(ViewportCommand::Fullscreen(false)); + } + } else { + let fullscreen_response = ui + // .add(Button::new(RichText::new("🗗").size(button_height))) + .add(Button::new(RichText::new(ARROWS_OUT.to_string()).size(button_height))) + // .add(Button::new(RichText::new(ARROWS_OUT.to_string()).size(button_height))) + .on_hover_text("Full Screen"); + if fullscreen_response.clicked() { + ui.ctx().send_viewport_cmd(ViewportCommand::Fullscreen(true)); + } } - } else { - let maximized_response = ui - .add(Button::new(RichText::new("🗗").size(button_height))) - .on_hover_text("Maximize window"); - if maximized_response.clicked() { - ui.ctx().send_viewport_cmd(ViewportCommand::Maximized(true)); + } + + if support_maximize { + + ui.add_space(spacing); + + let is_maximized = ui.input(|i| i.viewport().maximized.unwrap_or(false)); + if is_maximized { + let maximized_response = ui + // .add(Button::new(RichText::new("🗗").size(button_height))) + .add(Button::new(RichText::new(RECTANGLE.to_string()).size(button_height))) + .on_hover_text("Restore window"); + if maximized_response.clicked() { + ui.ctx().send_viewport_cmd(ViewportCommand::Maximized(false)); + } + } else { + let maximized_response = ui + // .add(Button::new(RichText::new("🗗").size(button_height))) + .add(Button::new(RichText::new(SQUARE.to_string()).size(button_height))) + // .add(Button::new(RichText::new(ARROWS_OUT.to_string()).size(button_height))) + .on_hover_text("Maximize window"); + if maximized_response.clicked() { + ui.ctx().send_viewport_cmd(ViewportCommand::Maximized(true)); + } } } + + ui.add_space(spacing+2.0); + let minimized_response = ui .add(Button::new(RichText::new("🗕").size(button_height))) + // .add(Button::new(RichText::new(ARROW_SQUARE_DOWN.to_string()).size(button_height))) + // .add(Button::new(RichText::new(ARROW_LINE_DOWN.to_string()).size(button_height))) .on_hover_text("Minimize the window"); if minimized_response.clicked() { ui.ctx().send_viewport_cmd(ViewportCommand::Minimized(true)); diff --git a/core/src/runtime/services/kaspa/config.rs b/core/src/runtime/services/kaspa/config.rs index fe2a538..f53cecf 100644 --- a/core/src/runtime/services/kaspa/config.rs +++ b/core/src/runtime/services/kaspa/config.rs @@ -1,9 +1,14 @@ use crate::imports::*; +use kaspa_core::kaspad_env; +use crate::app::{VERSION,GIT_DESCRIBE}; use crate::utils::Arglist; - #[cfg(not(target_arch = "wasm32"))] pub use kaspad_lib::args::Args; +fn user_agent_comment() -> String { + format!("/{}:{}/kaspa-ng:{}-{}/", kaspad_env::name(),kaspad_env::version(), VERSION, GIT_DESCRIBE) +} + #[derive(Debug, Clone)] pub struct Config { network: Network, @@ -56,6 +61,10 @@ cfg_if! { args.rpclisten = Some(config.grpc_network_interface.into()); } + args.user_agent_comments = vec![user_agent_comment()]; + + // TODO - parse custom args and overlap on top of the defaults + Ok(args) } } @@ -92,6 +101,8 @@ cfg_if! { args.push("--rpclisten-borsh=default"); + args.push(format!("--uacomment={}", user_agent_comment())); + if config.kaspad_daemon_args_enable { config.kaspad_daemon_args.trim().split(' ').filter(|arg|!arg.trim().is_empty()).for_each(|arg| { args.push(arg); diff --git a/core/src/status.rs b/core/src/status.rs index 366e856..8c42b9d 100644 --- a/core/src/status.rs +++ b/core/src/status.rs @@ -118,10 +118,11 @@ impl<'core> Status<'core> { let status_area_width = ui.available_width() - 24.; let status_icon_size = theme_style().status_icon_size; let module = self.module().clone(); + let left_padding = 8.0; match state { ConnectionStatus::Disconnected => { - ui.add_space(4.); + ui.add_space(left_padding); match self.settings().node.node_kind { KaspadNodeKind::Disable => { @@ -195,7 +196,7 @@ impl<'core> Status<'core> { peers, tps: _, } => { - ui.add_space(4.); + ui.add_space(left_padding); ui.label( RichText::new(egui_phosphor::light::CPU) .size(status_icon_size) @@ -234,7 +235,7 @@ impl<'core> Status<'core> { ConnectionStatus::Syncing { sync_status, peers } => { ui.vertical(|ui| { ui.horizontal(|ui| { - ui.add_space(4.); + ui.add_space(left_padding); ui.label( RichText::new(egui_phosphor::light::CLOUD_ARROW_DOWN) .size(status_icon_size)