fix: 修复QML不识别qint64类型的问题
- 将Q_PROPERTY类型从qint64改为double - 将QML属性类型从qint64改为real - 修复插件无法加载的问题
This commit is contained in:
@@ -0,0 +1,78 @@
|
|||||||
|
# AGENTS.md
|
||||||
|
|
||||||
|
Guidance for AI agents working in this repo. Verified against `CMakeLists.txt`,
|
||||||
|
`package/metadata.json`, and the installed macro file at
|
||||||
|
`/usr/lib/x86_64-linux-gnu/cmake/DDEShell/DDEShellPackageMacros.cmake`.
|
||||||
|
|
||||||
|
## What this is
|
||||||
|
|
||||||
|
A **pure-QML dde-shell applet** (deepin desktop shell panel widget). There is no
|
||||||
|
C++ and no `.so` plugin — the entire applet is `package/main.qml` +
|
||||||
|
`package/metadata.json`, installed as a data package via dde-shell's CMake macros.
|
||||||
|
|
||||||
|
- Applet ID: `space.jokul.JNetApplet`.
|
||||||
|
- Root element of `main.qml` must be `AppletItem` from `import org.deepin.ds 1.0`.
|
||||||
|
|
||||||
|
## Build & install
|
||||||
|
|
||||||
|
Requires the `DDEShell` CMake package (from the `dde-shell` dev package) at configure
|
||||||
|
time. Standard flow:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake -B build
|
||||||
|
cmake --build build
|
||||||
|
sudo cmake --install build # -> /usr/share/dde-shell/space.jokul.JNetApplet/
|
||||||
|
```
|
||||||
|
|
||||||
|
`cmake --install` needs `sudo` because the default `DDE_SHELL_PACKAGE_INSTALL_DIR`
|
||||||
|
is `/usr/share/dde-shell` (a CMake CACHE variable on this system). For a user-local
|
||||||
|
install instead:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cmake -B build -DCMAKE_INSTALL_PREFIX=$HOME/.local
|
||||||
|
cmake --build build && cmake --install build # -> ~/.local/share/dde-shell/space.jokul.JNetApplet/
|
||||||
|
```
|
||||||
|
|
||||||
|
There is no test, lint, typecheck, or CI target. Verification is manual: install,
|
||||||
|
then restart `dde-shell` (it discovers applets by scanning the install dir for
|
||||||
|
`metadata.json`). The build also stages a copy at `build/packages/space.jokul.JNetApplet/`
|
||||||
|
for previewing the QML without installing.
|
||||||
|
|
||||||
|
## Identifier correspondence (keep in sync when renaming)
|
||||||
|
|
||||||
|
| Where | Field | Value |
|
||||||
|
|---|---|---|
|
||||||
|
| `CMakeLists.txt` | `ds_install_package(PACKAGE …)` | `space.jokul.JNetApplet` |
|
||||||
|
| `package/metadata.json` | `Plugin.Id` | `space.jokul.JNetApplet` |
|
||||||
|
|
||||||
|
The CMake `PACKAGE` becomes the install subdirectory name; `Plugin.Id` is the runtime
|
||||||
|
identifier. They don't technically have to match, but every official dde-shell applet
|
||||||
|
keeps them identical — treat them as required to match.
|
||||||
|
|
||||||
|
`Plugin.Url` (`main.qml`) is a path **relative to `package/`**, not an identifier.
|
||||||
|
Keep it pointing at the entry QML.
|
||||||
|
|
||||||
|
## Required metadata fields (QML applet)
|
||||||
|
|
||||||
|
`metadata.json` must contain `Plugin.Version`, `Plugin.Id`, and `Plugin.Url`. The
|
||||||
|
current file is complete — don't drop any. (`Plugin.Url` is omitted only for
|
||||||
|
widget-based, non-QML plugins.)
|
||||||
|
|
||||||
|
## Package layout is fixed by the macro
|
||||||
|
|
||||||
|
`ds_install_package` reads `package/` relative to `CMAKE_CURRENT_SOURCE_DIR` by
|
||||||
|
default (overridable via `PACKAGE_ROOT_DIR`, not used here). Keep the directory named
|
||||||
|
`package/` with `metadata.json` at its root.
|
||||||
|
|
||||||
|
## Adding translations (not yet set up)
|
||||||
|
|
||||||
|
If i18n is needed, use the `ds_handle_package(PACKAGE <id>)` macro from the same
|
||||||
|
DDEShell package. It expects `.ts` files at `translations/<id>_<lang>.ts` and
|
||||||
|
installs compiled `.qm` to `${DDE_SHELL_TRANSLATION_INSTALL_DIR}/<id>/translations/`.
|
||||||
|
Do not invent a different translation workflow.
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
- QML files carry SPDX headers (`SPDX-FileCopyrightText` +
|
||||||
|
`SPDX-License-Identifier: LGPL-3.0-or-later`). Preserve on new/edited QML files.
|
||||||
|
- Default branch is `master` (not `main`).
|
||||||
@@ -51,24 +51,24 @@ bool NetworkMonitorApplet::init()
|
|||||||
return DApplet::init();
|
return DApplet::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 NetworkMonitorApplet::downloadSpeed() const
|
double NetworkMonitorApplet::downloadSpeed() const
|
||||||
{
|
{
|
||||||
return m_downloadSpeed;
|
return static_cast<double>(m_downloadSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 NetworkMonitorApplet::uploadSpeed() const
|
double NetworkMonitorApplet::uploadSpeed() const
|
||||||
{
|
{
|
||||||
return m_uploadSpeed;
|
return static_cast<double>(m_uploadSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 NetworkMonitorApplet::totalDownload() const
|
double NetworkMonitorApplet::totalDownload() const
|
||||||
{
|
{
|
||||||
return m_totalDownload;
|
return static_cast<double>(m_totalDownload);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 NetworkMonitorApplet::totalUpload() const
|
double NetworkMonitorApplet::totalUpload() const
|
||||||
{
|
{
|
||||||
return m_totalUpload;
|
return static_cast<double>(m_totalUpload);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList NetworkMonitorApplet::networkInterfaces() const
|
QStringList NetworkMonitorApplet::networkInterfaces() const
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ class NetworkMonitorApplet : public DApplet
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(qint64 downloadSpeed READ downloadSpeed NOTIFY speedChanged)
|
Q_PROPERTY(double downloadSpeed READ downloadSpeed NOTIFY speedChanged)
|
||||||
Q_PROPERTY(qint64 uploadSpeed READ uploadSpeed NOTIFY speedChanged)
|
Q_PROPERTY(double uploadSpeed READ uploadSpeed NOTIFY speedChanged)
|
||||||
Q_PROPERTY(qint64 totalDownload READ totalDownload NOTIFY totalChanged)
|
Q_PROPERTY(double totalDownload READ totalDownload NOTIFY totalChanged)
|
||||||
Q_PROPERTY(qint64 totalUpload READ totalUpload NOTIFY totalChanged)
|
Q_PROPERTY(double totalUpload READ totalUpload NOTIFY totalChanged)
|
||||||
Q_PROPERTY(QStringList networkInterfaces READ networkInterfaces NOTIFY interfacesChanged)
|
Q_PROPERTY(QStringList networkInterfaces READ networkInterfaces NOTIFY interfacesChanged)
|
||||||
Q_PROPERTY(QStringList interfaceStats READ interfaceStats NOTIFY statsChanged)
|
Q_PROPERTY(QStringList interfaceStats READ interfaceStats NOTIFY statsChanged)
|
||||||
Q_PROPERTY(bool ready READ ready NOTIFY readyChanged)
|
Q_PROPERTY(bool ready READ ready NOTIFY readyChanged)
|
||||||
@@ -46,10 +46,10 @@ public:
|
|||||||
virtual bool load() override;
|
virtual bool load() override;
|
||||||
virtual bool init() override;
|
virtual bool init() override;
|
||||||
|
|
||||||
qint64 downloadSpeed() const;
|
double downloadSpeed() const;
|
||||||
qint64 uploadSpeed() const;
|
double uploadSpeed() const;
|
||||||
qint64 totalDownload() const;
|
double totalDownload() const;
|
||||||
qint64 totalUpload() const;
|
double totalUpload() const;
|
||||||
QStringList networkInterfaces() const;
|
QStringList networkInterfaces() const;
|
||||||
QStringList interfaceStats() const;
|
QStringList interfaceStats() const;
|
||||||
bool ready() const;
|
bool ready() const;
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ AppletItem {
|
|||||||
|
|
||||||
readonly property var applet: Applet
|
readonly property var applet: Applet
|
||||||
readonly property bool ready: applet ? applet.ready : false
|
readonly property bool ready: applet ? applet.ready : false
|
||||||
readonly property qint64 downloadSpeed: applet ? applet.downloadSpeed : 0
|
readonly property real downloadSpeed: applet ? applet.downloadSpeed : 0
|
||||||
readonly property qint64 uploadSpeed: applet ? applet.uploadSpeed : 0
|
readonly property real uploadSpeed: applet ? applet.uploadSpeed : 0
|
||||||
readonly property qint64 totalDownload: applet ? applet.totalDownload : 0
|
readonly property real totalDownload: applet ? applet.totalDownload : 0
|
||||||
readonly property qint64 totalUpload: applet ? applet.totalUpload : 0
|
readonly property real totalUpload: applet ? applet.totalUpload : 0
|
||||||
readonly property string activeInterface: applet ? (applet.activeInterface || "") : ""
|
readonly property string activeInterface: applet ? (applet.activeInterface || "") : ""
|
||||||
readonly property var networkInterfaces: applet ? (applet.networkInterfaces || []) : []
|
readonly property var networkInterfaces: applet ? (applet.networkInterfaces || []) : []
|
||||||
readonly property var interfaceStats: applet ? (applet.interfaceStats || []) : []
|
readonly property var interfaceStats: applet ? (applet.interfaceStats || []) : []
|
||||||
|
|||||||
Reference in New Issue
Block a user