feat: add Report/About/Changelog buttons to Support ribbon group
- REPORT opens GitHub new-issue page - ABOUT opens a dialog window with version, OS and arch info + Copy Info button - CHANGELOG opens GitHub releases page - Fix Windows build: add windows-sys as target-specific dependency for PRINT command Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
62fbaf5da4
commit
070ad1f9c5
15 changed files with 222 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -18,6 +18,7 @@ dependencies = [
|
|||
"truck-meshalgo",
|
||||
"truck-modeling",
|
||||
"truck-polymesh",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -17,3 +17,6 @@ open = "5"
|
|||
printpdf = "0.9.1"
|
||||
flate2 = "1"
|
||||
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
windows-sys = { version = "0.59", features = ["Win32_UI_Shell", "Win32_UI_WindowsAndMessaging"] }
|
||||
|
|
|
|||
8
assets/icons/about.svg
Normal file
8
assets/icons/about.svg
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<!-- Circle -->
|
||||
<circle cx="12" cy="12" r="9"/>
|
||||
<!-- i dot -->
|
||||
<circle cx="12" cy="8" r="0.8" fill="currentColor" stroke="none"/>
|
||||
<!-- i stem -->
|
||||
<line x1="12" y1="11" x2="12" y2="16"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 366 B |
9
assets/icons/changelog.svg
Normal file
9
assets/icons/changelog.svg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<!-- Clock circle -->
|
||||
<circle cx="12" cy="12" r="9"/>
|
||||
<!-- Clock hands -->
|
||||
<polyline points="12,7 12,12 15.5,15.5"/>
|
||||
<!-- Counter-clockwise arrow suggesting history -->
|
||||
<path d="M5.6 5.6 A8.5 8.5 0 0 0 3 12" stroke-width="1.5"/>
|
||||
<polyline points="2,9.5 3,12 5.5,10.8"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 452 B |
17
assets/icons/report.svg
Normal file
17
assets/icons/report.svg
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<!-- Bug body (oval) -->
|
||||
<ellipse cx="12" cy="13" rx="5" ry="6"/>
|
||||
<!-- Head -->
|
||||
<circle cx="12" cy="6" r="2.2"/>
|
||||
<!-- Antennae -->
|
||||
<line x1="10.5" y1="4.2" x2="8" y2="2"/>
|
||||
<line x1="13.5" y1="4.2" x2="16" y2="2"/>
|
||||
<!-- Left legs -->
|
||||
<line x1="7" y1="10" x2="4" y2="9"/>
|
||||
<line x1="7" y1="13" x2="4" y2="13"/>
|
||||
<line x1="7" y1="16" x2="4" y2="17"/>
|
||||
<!-- Right legs -->
|
||||
<line x1="17" y1="10" x2="20" y2="9"/>
|
||||
<line x1="17" y1="13" x2="20" y2="13"/>
|
||||
<line x1="17" y1="16" x2="20" y2="17"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 683 B |
|
|
@ -2042,6 +2042,20 @@ impl H7CAD {
|
|||
self.command_line.push_info("Opening Patreon page...");
|
||||
}
|
||||
|
||||
"REPORT" => {
|
||||
let _ = open::that("https://github.com/HakanSeven12/H7CAD/issues/new");
|
||||
self.command_line.push_info("Opening GitHub issue page...");
|
||||
}
|
||||
|
||||
"ABOUT" => {
|
||||
return Task::done(Message::AboutOpen);
|
||||
}
|
||||
|
||||
"CHANGELOG" => {
|
||||
let _ = open::that("https://github.com/HakanSeven12/H7CAD/releases");
|
||||
self.command_line.push_info("Opening release notes...");
|
||||
}
|
||||
|
||||
// ── Keyboard Shortcuts panel ──────────────────────────────────
|
||||
cmd if cmd == "SHORTCUTS" || cmd.starts_with("SHORTCUTS ") => {
|
||||
let raw_rest = cmd.trim_start_matches("SHORTCUTS").trim();
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ pub(super) struct H7CAD {
|
|||
plotstyle_window: Option<window::Id>,
|
||||
dimstyle_window: Option<window::Id>,
|
||||
shortcuts_window: Option<window::Id>,
|
||||
about_window: Option<window::Id>,
|
||||
/// In-memory clipboard: cloned entities waiting to be pasted.
|
||||
clipboard: Vec<acadrust::EntityType>,
|
||||
/// Centroid of the clipboard entities (XZ plane, Y-up).
|
||||
|
|
@ -372,6 +373,9 @@ pub enum Message {
|
|||
ShortcutsPanelOpen,
|
||||
#[allow(dead_code)]
|
||||
ShortcutsPanelClose,
|
||||
// ── About window ────────────────────────────────────────────────────
|
||||
AboutOpen,
|
||||
AboutCopyInfo,
|
||||
/// Close the viewport right-click context menu without performing any action.
|
||||
ViewportContextMenuClose,
|
||||
/// A window was closed by the OS (e.g. the user clicked the title-bar ✕).
|
||||
|
|
@ -552,6 +556,7 @@ impl H7CAD {
|
|||
plotstyle_window: None,
|
||||
dimstyle_window: None,
|
||||
shortcuts_window: None,
|
||||
about_window: None,
|
||||
clipboard: Vec::new(),
|
||||
clipboard_centroid: glam::Vec3::ZERO,
|
||||
layout_context_menu: None,
|
||||
|
|
@ -644,6 +649,7 @@ pub fn run() -> iced::Result {
|
|||
if Some(window_id) == state.plotstyle_window { return "Plot Style Table Editor".into(); }
|
||||
if Some(window_id) == state.dimstyle_window { return "Dimension Style Manager".into(); }
|
||||
if Some(window_id) == state.shortcuts_window { return "Keyboard Shortcuts".into(); }
|
||||
if Some(window_id) == state.about_window { return "About H7CAD".into(); }
|
||||
if let Some(tab) = state.tabs.get(state.active_tab) {
|
||||
let dot = if tab.dirty { "● " } else { "" };
|
||||
let name = tab.tab_display_name();
|
||||
|
|
|
|||
|
|
@ -704,6 +704,7 @@ impl H7CAD {
|
|||
if self.plotstyle_window == Some(id) { self.plotstyle_window = None; }
|
||||
if self.dimstyle_window == Some(id) { self.dimstyle_window = None; }
|
||||
if self.shortcuts_window == Some(id) { self.shortcuts_window = None; }
|
||||
if self.about_window == Some(id) { self.about_window = None; }
|
||||
Task::none()
|
||||
}
|
||||
|
||||
|
|
@ -2502,6 +2503,30 @@ impl H7CAD {
|
|||
}
|
||||
}
|
||||
|
||||
// ── About window ──────────────────────────────────────────────
|
||||
Message::AboutOpen => {
|
||||
if let Some(id) = self.about_window {
|
||||
return window::gain_focus(id);
|
||||
}
|
||||
let (id, task) = window::open(window::Settings {
|
||||
size: iced::Size::new(340.0, 240.0),
|
||||
resizable: false,
|
||||
..Default::default()
|
||||
});
|
||||
self.about_window = Some(id);
|
||||
task.map(|_| Message::Noop)
|
||||
}
|
||||
|
||||
Message::AboutCopyInfo => {
|
||||
let info = format!(
|
||||
"H7CAD v{}\nOS: {}\nArch: {}",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
std::env::consts::OS,
|
||||
std::env::consts::ARCH,
|
||||
);
|
||||
iced::clipboard::write(info)
|
||||
}
|
||||
|
||||
Message::ViewportContextMenuClose => {
|
||||
let i = self.active_tab;
|
||||
self.tabs[i].scene.selection.borrow_mut().context_menu = None;
|
||||
|
|
|
|||
|
|
@ -96,6 +96,9 @@ impl H7CAD {
|
|||
if Some(window_id) == self.shortcuts_window {
|
||||
return crate::ui::shortcuts::view_window(&self.shortcut_overrides);
|
||||
}
|
||||
if Some(window_id) == self.about_window {
|
||||
return crate::ui::about::view_window();
|
||||
}
|
||||
|
||||
let i = self.active_tab;
|
||||
let tab = &self.tabs[i];
|
||||
|
|
|
|||
10
src/modules/home/about.rs
Normal file
10
src/modules/home/about.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "ABOUT",
|
||||
label: "About",
|
||||
icon: IconKind::Svg(include_bytes!("../../../assets/icons/about.svg")),
|
||||
event: ModuleEvent::Command("ABOUT".to_string()),
|
||||
}
|
||||
}
|
||||
10
src/modules/home/changelog.rs
Normal file
10
src/modules/home/changelog.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "CHANGELOG",
|
||||
label: "Changelog",
|
||||
icon: IconKind::Svg(include_bytes!("../../../assets/icons/changelog.svg")),
|
||||
event: ModuleEvent::Command("CHANGELOG".to_string()),
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
pub mod clipboard;
|
||||
pub mod defaults;
|
||||
mod about;
|
||||
mod changelog;
|
||||
mod donate;
|
||||
pub mod draw;
|
||||
mod report;
|
||||
pub mod groups;
|
||||
pub mod inquiry;
|
||||
pub mod layers;
|
||||
|
|
@ -27,7 +30,10 @@ impl CadModule for HomeModule {
|
|||
use crate::modules::annotate::{angular_dim, leader_cmd, linear_dim, mleader_cmd, mtext, radius_dim, text};
|
||||
use crate::modules::insert::{create_block, insert_block};
|
||||
use clipboard::{copy_clip, cut, paste};
|
||||
use about;
|
||||
use changelog;
|
||||
use donate;
|
||||
use report;
|
||||
use draw::{arc, circle, ellipse, hatch, line, polyline, shapes};
|
||||
use layers::{layfrz, laylck, layoff, layon, laythw, layulk, make_current, match_layer, panel};
|
||||
use groups::{group, ungroup};
|
||||
|
|
@ -187,6 +193,9 @@ impl CadModule for HomeModule {
|
|||
title: "Support",
|
||||
tools: vec![
|
||||
RibbonItem::LargeTool(donate::tool()),
|
||||
report::tool().into(),
|
||||
about::tool().into(),
|
||||
changelog::tool().into(),
|
||||
],
|
||||
},
|
||||
]
|
||||
|
|
|
|||
10
src/modules/home/report.rs
Normal file
10
src/modules/home/report.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
|
||||
pub fn tool() -> ToolDef {
|
||||
ToolDef {
|
||||
id: "REPORT",
|
||||
label: "Report",
|
||||
icon: IconKind::Svg(include_bytes!("../../../assets/icons/report.svg")),
|
||||
event: ModuleEvent::Command("REPORT".to_string()),
|
||||
}
|
||||
}
|
||||
96
src/ui/about.rs
Normal file
96
src/ui/about.rs
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
use crate::app::Message;
|
||||
use iced::widget::{button, column, container, row, text, Space};
|
||||
use iced::{Background, Border, Color, Element, Fill, Theme};
|
||||
|
||||
const BG: Color = Color { r: 0.15, g: 0.15, b: 0.15, a: 1.0 };
|
||||
const PANEL: Color = Color { r: 0.12, g: 0.12, b: 0.12, a: 1.0 };
|
||||
const BORDER: Color = Color { r: 0.30, g: 0.30, b: 0.30, a: 1.0 };
|
||||
const DIM: Color = Color { r: 0.55, g: 0.55, b: 0.55, a: 1.0 };
|
||||
const ACCENT: Color = Color { r: 0.25, g: 0.50, b: 0.85, a: 1.0 };
|
||||
const WHITE: Color = Color { r: 0.92, g: 0.92, b: 0.92, a: 1.0 };
|
||||
|
||||
fn info_row<'a>(label: &'static str, value: String) -> Element<'a, Message> {
|
||||
row![
|
||||
text(label).size(11).color(DIM).width(100),
|
||||
text(value).size(11).color(WHITE),
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center)
|
||||
.padding([3, 0])
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn view_window<'a>() -> Element<'a, Message> {
|
||||
let version = env!("CARGO_PKG_VERSION");
|
||||
let os = std::env::consts::OS;
|
||||
let arch = std::env::consts::ARCH;
|
||||
|
||||
let logo = container(
|
||||
column![
|
||||
text("H7CAD").size(32).color(ACCENT),
|
||||
text("CAD application for Architecture & Engineering")
|
||||
.size(11).color(DIM),
|
||||
]
|
||||
.spacing(4)
|
||||
.align_x(iced::Center),
|
||||
)
|
||||
.width(Fill)
|
||||
.padding(iced::Padding { top: 20.0, right: 0.0, bottom: 16.0, left: 0.0 })
|
||||
.align_x(iced::Center);
|
||||
|
||||
let info_block = container(
|
||||
column![
|
||||
info_row("Version", format!("v{}", version)),
|
||||
info_row("Platform", os.to_string()),
|
||||
info_row("Arch", arch.to_string()),
|
||||
]
|
||||
.spacing(2)
|
||||
.padding([12, 16]),
|
||||
)
|
||||
.width(Fill)
|
||||
.style(|_: &Theme| container::Style {
|
||||
background: Some(Background::Color(PANEL)),
|
||||
border: Border {
|
||||
color: BORDER,
|
||||
width: 1.0,
|
||||
radius: 4.0.into(),
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
let copy_btn = button(
|
||||
text("Copy Info").size(11),
|
||||
)
|
||||
.on_press(Message::AboutCopyInfo)
|
||||
.style(|_: &Theme, st| button::Style {
|
||||
background: Some(Background::Color(match st {
|
||||
button::Status::Hovered | button::Status::Pressed =>
|
||||
Color { r: 0.20, g: 0.42, b: 0.72, a: 1.0 },
|
||||
_ => ACCENT,
|
||||
})),
|
||||
text_color: WHITE,
|
||||
border: Border { radius: 4.0.into(), ..Default::default() },
|
||||
..Default::default()
|
||||
})
|
||||
.padding([6, 16]);
|
||||
|
||||
let footer = row![
|
||||
Space::new().width(Fill),
|
||||
copy_btn,
|
||||
]
|
||||
.align_y(iced::Center)
|
||||
.padding(iced::Padding { top: 12.0, right: 0.0, bottom: 0.0, left: 0.0 });
|
||||
|
||||
container(
|
||||
column![logo, info_block, footer]
|
||||
.spacing(0)
|
||||
.padding(iced::Padding { top: 0.0, right: 20.0, bottom: 20.0, left: 20.0 }),
|
||||
)
|
||||
.style(|_: &Theme| container::Style {
|
||||
background: Some(Background::Color(BG)),
|
||||
..Default::default()
|
||||
})
|
||||
.width(Fill)
|
||||
.height(Fill)
|
||||
.into()
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
/// Change this to scale the ribbon, layer manager rows, and property panel rows uniformly.
|
||||
pub const ROW_H: f32 = 26.0;
|
||||
|
||||
pub mod about;
|
||||
pub mod app_menu;
|
||||
pub mod command_line;
|
||||
pub mod dimstyle;
|
||||
|
|
|
|||
Loading…
Reference in a new issue