Compare commits

2 Commits

Author SHA1 Message Date
Jokul 6bc1a3e3fb fix:ipv6背景色 2026-07-19 14:03:14 +08:00
Jokul 903e0f1801 refactor: 统一版本号管理,metadata.json 由 CMake 模板生成 2026-07-19 13:44:42 +08:00
5 changed files with 25 additions and 9 deletions
+16 -5
View File
@@ -1,7 +1,7 @@
# AGENTS.md # AGENTS.md
Guidance for AI agents working in this repo. Verified against `CMakeLists.txt`, Guidance for AI agents working in this repo. Verified against `CMakeLists.txt`,
`package/metadata.json`, and the installed macro file at `package/metadata.json.in`, and the installed macro file at
`/usr/lib/x86_64-linux-gnu/cmake/DDEShell/DDEShellPackageMacros.cmake`. `/usr/lib/x86_64-linux-gnu/cmake/DDEShell/DDEShellPackageMacros.cmake`.
## What this is ## What this is
@@ -71,7 +71,7 @@ then restart `dde-shell` (it discovers applets by scanning the install dir for
├── networkmonitorapplet.h # C++ backend header ├── networkmonitorapplet.h # C++ backend header
├── networkmonitorapplet.cpp # C++ backend implementation ├── networkmonitorapplet.cpp # C++ backend implementation
├── package/ ├── package/
│ ├── metadata.json # Plugin metadata │ ├── metadata.json.in # Plugin metadata 模板(由 CMake 生成 metadata.json
│ └── networkview.qml # QML UI │ └── networkview.qml # QML UI
├── docs/ # Design docs and implementation plans ├── docs/ # Design docs and implementation plans
└── AGENTS.md # This file └── AGENTS.md # This file
@@ -112,15 +112,26 @@ Inherits from `DApplet`, provides:
|---|---|---| |---|---|---|
| `CMakeLists.txt` | `add_library(...)` target | `space.jokul.JNetApplet` | | `CMakeLists.txt` | `add_library(...)` target | `space.jokul.JNetApplet` |
| `CMakeLists.txt` | `PLUGIN_ID` | `space.jokul.JNetApplet` | | `CMakeLists.txt` | `PLUGIN_ID` | `space.jokul.JNetApplet` |
| `package/metadata.json` | `Plugin.Id` | `space.jokul.JNetApplet` | | `package/metadata.json.in` | `Plugin.Id` | `space.jokul.JNetApplet` |
`Plugin.Url` (`networkview.qml`) is a path **relative to `package/`**, not an identifier. `Plugin.Url` (`networkview.qml`) is a path **relative to `package/`**, not an identifier.
Keep it pointing at the entry QML. Keep it pointing at the entry QML.
## Required metadata fields (QML applet) ## Required metadata fields (QML applet)
`metadata.json` must contain `Plugin.Version`, `Plugin.Id`, `Plugin.Url`, and `package/metadata.json.in` is the template; CMake's `configure_file()` generates the
`Plugin.Parent`. The current file is complete — don't drop any. final `metadata.json` in the build directory at configure time. The template must
contain `Plugin.Version`, `Plugin.Id`, `Plugin.Url`, and `Plugin.Parent`. Don't drop any.
## Version management
**Single source of truth**: `CMakeLists.txt` line 3 `project(JNetApplet VERSION x.y.z)`.
- `package/metadata.json.in` uses `@PROJECT_VERSION@` placeholder, substituted at
configure time -> installed `metadata.json` always matches.
- `build-deb.sh` extracts the version directly from `CMakeLists.txt` via grep.
- **To bump the version**: edit only the `project(... VERSION ...)` line in
`CMakeLists.txt`. All downstream consumers (install, deb) pick it up automatically.
## Conventions ## Conventions
+6 -1
View File
@@ -36,5 +36,10 @@ target_link_libraries(space.jokul.JNetApplet PRIVATE
# 安装到dde-shell插件目录 # 安装到dde-shell插件目录
install(TARGETS space.jokul.JNetApplet DESTINATION /usr/lib/x86_64-linux-gnu/dde-shell) install(TARGETS space.jokul.JNetApplet DESTINATION /usr/lib/x86_64-linux-gnu/dde-shell)
install(FILES package/metadata.json DESTINATION /usr/share/dde-shell/${PLUGIN_ID})
# 由模板生成 metadata.json,版本号从 project() 取,避免多处手动维护
# 设计原因:版本号唯一源为 CMakeLists.txt 顶部的 project(... VERSION)
# configure_file 在构建目录生成最终 metadata.jsoninstall 安装生成文件
configure_file(package/metadata.json.in ${CMAKE_CURRENT_BINARY_DIR}/metadata.json @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/metadata.json DESTINATION /usr/share/dde-shell/${PLUGIN_ID})
install(FILES package/networkview.qml DESTINATION /usr/share/dde-shell/${PLUGIN_ID}) install(FILES package/networkview.qml DESTINATION /usr/share/dde-shell/${PLUGIN_ID})
+1 -1
View File
@@ -68,7 +68,7 @@ bash build-deb.sh
├── networkmonitorapplet.h # C++ 后端头文件 ├── networkmonitorapplet.h # C++ 后端头文件
├── networkmonitorapplet.cpp # C++ 后端实现 ├── networkmonitorapplet.cpp # C++ 后端实现
├── package/ ├── package/
│ ├── metadata.json # 插件元数据 │ ├── metadata.json.in # 插件元数据模板(由 CMake 生成 metadata.json
│ └── networkview.qml # QML 界面 │ └── networkview.qml # QML 界面
├── docs/ # 设计文档与实现计划 ├── docs/ # 设计文档与实现计划
├── README.md # 本文件 ├── README.md # 本文件
@@ -1,6 +1,6 @@
{ {
"Plugin": { "Plugin": {
"Version": "1.0", "Version": "@PROJECT_VERSION@",
"Id": "space.jokul.JNetApplet", "Id": "space.jokul.JNetApplet",
"Url": "networkview.qml", "Url": "networkview.qml",
"Parent": "org.deepin.ds.dock", "Parent": "org.deepin.ds.dock",
+1 -1
View File
@@ -340,7 +340,7 @@ AppletItem {
// 网卡名 + IP 地址卡片背景 // 网卡名 + IP 地址卡片背景
Rectangle { Rectangle {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: 180 Layout.preferredWidth: 300
// 有 IPv6 时增高以容纳第三行;无 IPv6 时保持原 40px // 有 IPv6 时增高以容纳第三行;无 IPv6 时保持原 40px
Layout.preferredHeight: root.ipv6Address ? 54 : 40 Layout.preferredHeight: root.ipv6Address ? 54 : 40
color: root.cardBackground color: root.cardBackground