refactor: 移除refresh()的Q_INVOKABLE标记
refresh() 是 m_refreshTimer 每秒回调,QML 从不直接调用。 移除 Q_INVOKABLE 防止 QML 误调用打破定时间隔。函数本身保留。
This commit is contained in:
@@ -63,8 +63,9 @@
|
|||||||
~~`networkview.qml` 绑定了 `interfaceStats` 属性但从未读取,C++ 侧的 `interfaceStats()` 函数和 `Q_PROPERTY` 也是死代码。~~
|
~~`networkview.qml` 绑定了 `interfaceStats` 属性但从未读取,C++ 侧的 `interfaceStats()` 函数和 `Q_PROPERTY` 也是死代码。~~
|
||||||
已删除 `Q_PROPERTY`、`interfaceStats()` 实现、`statsChanged` 信号、QML 属性绑定。
|
已删除 `Q_PROPERTY`、`interfaceStats()` 实现、`statsChanged` 信号、QML 属性绑定。
|
||||||
|
|
||||||
**13. 死代码:`refresh()` Q_INVOKABLE 从未被 QML 调用**
|
**13. ~~死代码:`refresh()` Q_INVOKABLE 从未被 QML 调用~~ ✅ 已修复**
|
||||||
注释(networkview.qml:276)说明此前 QML 调 `applet.refresh()` 导致问题后已移除调用,但 C++ 侧的 `Q_INVOKABLE void refresh()` 仍保留。若确无外部调用方,可删除或标注保留原因。
|
~~C++ 侧的 `Q_INVOKABLE void refresh()` 从未被 QML 调用。~~
|
||||||
|
已移除 `Q_INVOKABLE` 标记。`refresh()` 函数本身保留(是 `m_refreshTimer` 每秒回调),仅不再暴露给 QML。
|
||||||
|
|
||||||
**14. ~~`interfaceStats` 暴露的数据不完整~~ ✅ 随 #12 一并解决**
|
**14. ~~`interfaceStats` 暴露的数据不完整~~ ✅ 随 #12 一并解决**
|
||||||
~~`NetworkInterface` 结构体解析了 `rxErrors`/`txErrors`/`rxDropped`/`txDropped`,但 `interfaceStats()` 输出时丢弃了这些字段。~~
|
~~`NetworkInterface` 结构体解析了 `rxErrors`/`txErrors`/`rxDropped`/`txDropped`,但 `interfaceStats()` 输出时丢弃了这些字段。~~
|
||||||
|
|||||||
@@ -233,8 +233,7 @@ AppletItem {
|
|||||||
// C++ 后端 NetworkMonitorApplet::init() 已启动 1 秒间隔的 m_refreshTimer,
|
// C++ 后端 NetworkMonitorApplet::init() 已启动 1 秒间隔的 m_refreshTimer,
|
||||||
// 持续调用 refresh()->readNetworkStats()->calculateSpeed() 更新速度属性。
|
// 持续调用 refresh()->readNetworkStats()->calculateSpeed() 更新速度属性。
|
||||||
// QML 通过属性绑定自动获取最新值,无需主动触发 refresh。
|
// QML 通过属性绑定自动获取最新值,无需主动触发 refresh。
|
||||||
// 此前 QML 额外调用 applet.refresh() 会打破 1 秒定时间隔,
|
// refresh() 已移除 Q_INVOKABLE 标记,防止 QML 误调用打破定时间隔。
|
||||||
// 导致 calculateSpeed() 基于不固定间隔计算字节差,速度显示接近 0。
|
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: toolTipShowTimer
|
id: toolTipShowTimer
|
||||||
|
|||||||
@@ -95,7 +95,9 @@ public:
|
|||||||
// 设置任务栏网速字体颜色,空串表示跟随系统主题
|
// 设置任务栏网速字体颜色,空串表示跟随系统主题
|
||||||
void setTextColor(const QString &color);
|
void setTextColor(const QString &color);
|
||||||
|
|
||||||
Q_INVOKABLE void refresh();
|
// 定时器回调,由 m_refreshTimer 每秒调用。非 Q_INVOKABLE(QML 不应直接调用,
|
||||||
|
// 否则会打破 1 秒定时间隔导致速度计算失真)
|
||||||
|
void refresh();
|
||||||
Q_INVOKABLE void setActiveInterface(const QString &interface);
|
Q_INVOKABLE void setActiveInterface(const QString &interface);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
Reference in New Issue
Block a user