Skip to content

Commit 40cb434

Browse files
committed
feat: initial fluent serial assistant
0 parents  commit 40cb434

30 files changed

Lines changed: 3837 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
build:
16+
name: ${{ matrix.name }}
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- name: Windows / MSVC
23+
os: windows-latest
24+
qt-host: windows
25+
qt-arch: win64_msvc2022_64
26+
- name: Linux / GCC
27+
os: ubuntu-latest
28+
qt-host: linux
29+
qt-arch: gcc_64
30+
- name: macOS / Clang
31+
os: macos-13
32+
qt-host: mac
33+
qt-arch: clang_64
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
with:
39+
submodules: recursive
40+
41+
- name: Install Linux packages
42+
if: runner.os == 'Linux'
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install -y ninja-build libgl1-mesa-dev
46+
47+
- name: Install macOS packages
48+
if: runner.os == 'macOS'
49+
run: brew install ninja
50+
51+
- name: Setup MSVC
52+
if: runner.os == 'Windows'
53+
uses: ilammy/msvc-dev-cmd@v1
54+
55+
- name: Install Qt
56+
uses: jurplel/install-qt-action@v4
57+
with:
58+
version: '6.8.3'
59+
host: ${{ matrix.qt-host }}
60+
target: desktop
61+
arch: ${{ matrix.qt-arch }}
62+
modules: qtserialport qtsvg
63+
cache: true
64+
65+
- name: Configure
66+
shell: pwsh
67+
run: |
68+
$qtPrefix = $env:QT_ROOT_DIR
69+
if (-not $qtPrefix -and $env:Qt6_DIR) {
70+
$qtPrefix = (Resolve-Path (Join-Path $env:Qt6_DIR "../../..")).Path
71+
}
72+
if (-not $qtPrefix) {
73+
throw "Qt prefix was not found."
74+
}
75+
cmake -S . -B build/ci -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$qtPrefix"
76+
77+
- name: Build
78+
run: cmake --build build/ci --parallel
79+
80+
- name: Check artifact
81+
shell: pwsh
82+
run: |
83+
$exe = if ($env:RUNNER_OS -eq "Windows") {
84+
"build/ci/FluentSerialAssistant.exe"
85+
} else {
86+
"build/ci/FluentSerialAssistant"
87+
}
88+
if (!(Test-Path $exe)) {
89+
throw "Build output was not found: $exe"
90+
}

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
build/
2+
.vs/
3+
.vscode/
4+
CMakeUserPresets.json
5+
*.user
6+
*.autosave
7+
*.log
8+
*.tmp
9+
*.obj
10+
*.pdb
11+
*.ilk
12+
*.exe
13+
*.dll
14+
*.a
15+
*.lib

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "third_party/FluentQtWidgets"]
2+
path = third_party/FluentQtWidgets
3+
url = https://github.com/txp666/FluentQtWidgets.git

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# 变更记录
2+
3+
本项目遵循面向用户的变更记录格式。版本号在正式发布前可能继续调整。
4+
5+
## [0.1.0] - 未发布
6+
7+
### 新增
8+
9+
- Fluent 风格串口终端工作台。
10+
- 串口扫描、连接和断开。
11+
- 波特率、数据位、校验位、停止位、流控、RTS、DTR 配置。
12+
- 文本、HEX、混合三种终端显示模式。
13+
- 自动断帧显示。
14+
- TX 记录颜色选择。
15+
- 文本和 HEX 数据发送。
16+
- None、CR、LF、CRLF 行结束符。
17+
- 发送历史记录。
18+
- 循环发送。
19+
- RX/TX 字节计数。
20+
- 暂停显示、自动滚动、清空终端、重置计数。
21+
- TXT、CSV、BIN 会话导出。
22+
- 接收数据保存到文件。
23+
- 浅色、深色、跟随系统主题和主题色配置。
24+
- Windows 紧凑发布包脚本。
25+
- GitHub Actions 三平台构建 CI。
26+
27+
### 变更
28+
29+
- UI 聚焦终端和设置两页,隐藏未完成入口。
30+
- 主窗口默认尺寸调整为 `1120x900` 并启动居中。
31+
- 发送按钮改为纯图标按钮。
32+
33+
### 已知限制
34+
35+
- 暂未提供自动化 GUI 测试。
36+
- 暂未提供 macOS 和 Linux 打包脚本。
37+
- 暂未开放包列表、快速绘图、宏命令和测试序列。

CMakeLists.txt

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
cmake_minimum_required(VERSION 3.21)
2+
3+
project(
4+
FluentSerialAssistant
5+
VERSION 0.1.0
6+
DESCRIPTION "A Fluent Qt serial assistant prototype"
7+
LANGUAGES CXX
8+
)
9+
10+
set(CMAKE_CXX_STANDARD 17)
11+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
12+
set(CMAKE_CXX_EXTENSIONS OFF)
13+
set(CMAKE_AUTOMOC ON)
14+
set(CMAKE_AUTORCC ON)
15+
set(CMAKE_AUTOUIC ON)
16+
17+
if(MINGW)
18+
string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " -ffunction-sections -fdata-sections")
19+
string(APPEND CMAKE_C_FLAGS_MINSIZEREL " -ffunction-sections -fdata-sections")
20+
string(APPEND CMAKE_EXE_LINKER_FLAGS_MINSIZEREL " -Wl,--gc-sections -s")
21+
endif()
22+
23+
find_package(Qt6 6.5 REQUIRED COMPONENTS Core Gui Widgets SerialPort Svg)
24+
25+
set(FLUENTQTWIDGETS_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third_party/FluentQtWidgets" CACHE PATH "Path to FluentQtWidgets checkout")
26+
if(NOT EXISTS "${FLUENTQTWIDGETS_ROOT}/CMakeLists.txt")
27+
message(FATAL_ERROR "FLUENTQTWIDGETS_ROOT does not point to a FluentQtWidgets checkout: ${FLUENTQTWIDGETS_ROOT}")
28+
endif()
29+
30+
set(CMAKE_DISABLE_FIND_PACKAGE_Qt6Multimedia ON CACHE BOOL "" FORCE)
31+
set(CMAKE_DISABLE_FIND_PACKAGE_Qt6MultimediaWidgets ON CACHE BOOL "" FORCE)
32+
set(CMAKE_DISABLE_FIND_PACKAGE_Qt6WebEngineWidgets ON CACHE BOOL "" FORCE)
33+
set(FQW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
34+
set(FQW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
35+
set(FQW_BUILD_SHARED OFF CACHE BOOL "" FORCE)
36+
set(FQW_ENABLE_NETWORK OFF CACHE BOOL "" FORCE)
37+
set(FQW_COMPACT_BUILD ON CACHE BOOL "" FORCE)
38+
add_subdirectory("${FLUENTQTWIDGETS_ROOT}" "${CMAKE_BINARY_DIR}/_deps/fluentqtwidgets")
39+
40+
add_executable(FluentSerialAssistant
41+
src/app/core/hex_utils.cpp
42+
src/app/core/hex_utils.h
43+
src/app/serial/serial_controller.cpp
44+
src/app/serial/serial_controller.h
45+
src/app/view/app_page.cpp
46+
src/app/view/app_page.h
47+
src/app/view/main_window.cpp
48+
src/app/view/main_window.h
49+
src/app/view/settings_page.cpp
50+
src/app/view/settings_page.h
51+
src/app/view/workbench_page.cpp
52+
src/app/view/workbench_page.h
53+
src/app/resources/app.qrc
54+
src/main.cpp
55+
)
56+
57+
if(WIN32)
58+
set(APP_ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/logo.ico")
59+
configure_file(
60+
src/app/resources/app_icon.rc.in
61+
"${CMAKE_CURRENT_BINARY_DIR}/app_icon.rc"
62+
@ONLY
63+
)
64+
target_sources(FluentSerialAssistant PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/app_icon.rc")
65+
endif()
66+
67+
target_include_directories(FluentSerialAssistant PRIVATE src src/app)
68+
69+
target_link_libraries(FluentSerialAssistant
70+
PRIVATE
71+
Qt6::Core
72+
Qt6::Gui
73+
Qt6::Widgets
74+
Qt6::SerialPort
75+
FluentQtWidgets::Widgets
76+
)
77+
78+
if(MSVC)
79+
target_compile_options(FluentSerialAssistant PRIVATE /utf-8)
80+
endif()
81+
82+
if(MINGW)
83+
target_link_options(FluentSerialAssistant PRIVATE
84+
$<$<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>>:-s>
85+
$<$<CONFIG:MinSizeRel>:-Wl,--gc-sections>
86+
)
87+
endif()
88+
89+
set_target_properties(FluentSerialAssistant PROPERTIES
90+
WIN32_EXECUTABLE TRUE
91+
)

CMakePresets.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"version": 6,
3+
"configurePresets": [
4+
{
5+
"name": "mingw-debug",
6+
"displayName": "MinGW Debug",
7+
"generator": "Ninja",
8+
"binaryDir": "${sourceDir}/build/mingw-debug",
9+
"cacheVariables": {
10+
"CMAKE_BUILD_TYPE": "Debug",
11+
"CMAKE_PREFIX_PATH": "C:/Qt/6.11.1/mingw_64",
12+
"CMAKE_C_COMPILER": "C:/Qt/Tools/mingw1310_64/bin/gcc.exe",
13+
"CMAKE_CXX_COMPILER": "C:/Qt/Tools/mingw1310_64/bin/g++.exe",
14+
"CMAKE_MAKE_PROGRAM": "C:/Qt/Tools/Ninja/ninja.exe"
15+
}
16+
},
17+
{
18+
"name": "mingw-release",
19+
"displayName": "MinGW Release (compact)",
20+
"generator": "Ninja",
21+
"binaryDir": "${sourceDir}/build/mingw-release",
22+
"cacheVariables": {
23+
"CMAKE_BUILD_TYPE": "MinSizeRel",
24+
"CMAKE_PREFIX_PATH": "C:/Qt/6.11.1/mingw_64",
25+
"CMAKE_C_COMPILER": "C:/Qt/Tools/mingw1310_64/bin/gcc.exe",
26+
"CMAKE_CXX_COMPILER": "C:/Qt/Tools/mingw1310_64/bin/g++.exe",
27+
"CMAKE_MAKE_PROGRAM": "C:/Qt/Tools/Ninja/ninja.exe"
28+
}
29+
}
30+
],
31+
"buildPresets": [
32+
{
33+
"name": "mingw-debug",
34+
"configurePreset": "mingw-debug"
35+
},
36+
{
37+
"name": "mingw-release",
38+
"configurePreset": "mingw-release"
39+
}
40+
]
41+
}

CONTRIBUTING.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# 贡献指南
2+
3+
感谢你愿意参与 Fluent 串口助手。这个项目处于早期阶段,欢迎提交问题反馈、功能建议、文档改进和代码贡献。
4+
5+
## 开发准备
6+
7+
1. Fork 本仓库。
8+
2. 克隆时拉取子模块:
9+
10+
```powershell
11+
git clone --recursive <your-fork-url>
12+
cd FluentSerialAssistant
13+
```
14+
15+
如果已经克隆:
16+
17+
```powershell
18+
git submodule update --init --recursive
19+
```
20+
21+
3. 安装 Qt 6.5+,确保包含 `SerialPort``Svg` 模块。
22+
4. 使用 CMake 构建:
23+
24+
```powershell
25+
cmake --preset mingw-debug
26+
cmake --build --preset mingw-debug --parallel
27+
```
28+
29+
## 提交 Pull Request
30+
31+
- 保持改动聚焦,避免把无关重构混在同一个 PR。
32+
- UI 改动请尽量附截图或录屏。
33+
- 串口行为改动请说明测试设备、波特率和复现步骤。
34+
- 新功能需要同步更新 README 或相关文档。
35+
- 构建前请至少执行一次本地 Debug 构建。
36+
37+
## 代码风格
38+
39+
- 使用 C++17。
40+
- 优先遵循现有 Qt Widgets 和 FluentQtWidgets 写法。
41+
- 可见业务 UI 尽量使用 FluentQtWidgets 组件。
42+
- 不引入与当前目标无关的大型依赖。
43+
- 注释应解释必要的业务意图,避免重复代码字面含义。
44+
45+
## Issue 建议
46+
47+
提交 Bug 时请包含:
48+
49+
- 系统版本
50+
- Qt 版本
51+
- 构建方式
52+
- 串口设备或虚拟串口工具
53+
- 复现步骤
54+
- 期望行为和实际行为
55+
- 相关截图或日志
56+
57+
提交功能建议时请说明:
58+
59+
- 具体使用场景
60+
- 预期工作流
61+
- 是否有参考工具或截图
62+
63+
## 许可证
64+
65+
提交代码即表示你同意贡献内容按本项目的 GPL-3.0-or-later 许可证发布。

0 commit comments

Comments
 (0)