diff --git a/modules/bar/states/Network/NetworkState.qml b/modules/bar/states/Network/NetworkState.qml index 2ec75dc..1cbbe15 100644 --- a/modules/bar/states/Network/NetworkState.qml +++ b/modules/bar/states/Network/NetworkState.qml @@ -32,7 +32,7 @@ QtObject { property string _activeDevice: "" property real _prevRxBytes: 0 property real _prevTxBytes: 0 - property int _prevUpdateTime: 0 + property var _prevUpdateTime: 0 property Timer networkTimer: Timer { interval: 10000 @@ -137,13 +137,27 @@ QtObject { else if (tline.indexOf("TX_BYTES=") === 0) txBytes = parseFloat(tline.substring("TX_BYTES=".length)) } + // console.log("[Network] rxBytes:", rxBytes, "txBytes:", txBytes) + // console.log("[Network] activeDevice:", activeDevice, "| prevActiveDevice:", root._activeDevice) + // console.log("[Network] prevRxBytes:", root._prevRxBytes, "prevTxBytes:", root._prevTxBytes, "prevTime:", root._prevUpdateTime) + if (activeDevice === root._activeDevice && root._prevRxBytes > 0 && root._prevUpdateTime > 0) { - var interval = (Date.now() - root._prevUpdateTime) / 1000 + var now = Date.now() + var interval = (now - root._prevUpdateTime) / 1000 + // console.log("[Network] Same device, interval:", interval, "s") + // console.log("[Network] rxDelta:", (rxBytes - root._prevRxBytes), "txDelta:", (txBytes - root._prevTxBytes)) if (interval > 0) { - root.downloadSpeed = root.formatSpeed((rxBytes - root._prevRxBytes) / interval) - root.uploadSpeed = root.formatSpeed((txBytes - root._prevTxBytes) / interval) + var downBps = (rxBytes - root._prevRxBytes) / interval + var upBps = (txBytes - root._prevTxBytes) / interval + // console.log("[Network] downBps:", downBps, "upBps:", upBps) + root.downloadSpeed = root.formatSpeed(downBps) + root.uploadSpeed = root.formatSpeed(upBps) + // console.log("[Network] downloadSpeed:", root.downloadSpeed, "uploadSpeed:", root.uploadSpeed) + } else { + console.log("[Network] Interval zero or negative, skipping") } } else { + // console.log("[Network] First run or device changed, storing baseline") root.downloadSpeed = "" root.uploadSpeed = "" } @@ -152,6 +166,7 @@ QtObject { root._prevRxBytes = rxBytes root._prevTxBytes = txBytes root._prevUpdateTime = Date.now() + // console.log("[Network] Stored baseline: rxBytes:", root._prevRxBytes, "txBytes:", root._prevTxBytes) } // Parse WIFI section diff --git a/modules/bar/widgets/BarPopup.qml b/modules/bar/widgets/BarPopup.qml index d4bf829..0e47fd7 100644 --- a/modules/bar/widgets/BarPopup.qml +++ b/modules/bar/widgets/BarPopup.qml @@ -14,8 +14,8 @@ PopupWindow { visible: false color: "transparent" - width: popupWidth - height: background.height + // width: popupWidth + // height: background.height onAnchorHoveredChanged: popup.updateVisibility() diff --git a/modules/bar/widgets/Clock.qml b/modules/bar/widgets/Clock.qml index cd2e8b2..7a087ca 100644 --- a/modules/bar/widgets/Clock.qml +++ b/modules/bar/widgets/Clock.qml @@ -61,8 +61,8 @@ Rectangle { //workspace id: clockPopup anchorItem: clockRect anchorHovered: clockArea.containsMouse - width: Math.max(text1.width, text2.width) + (Config.spacing_fun(clockRect.height) * 3) - height: text1.height*3+(Config.spacing_fun(clockRect.height) * 5) + implicitWidth: Math.max(text1.width, text2.width) + (Config.spacing_fun(clockRect.height) * 3) + implicitHeight: text1.height*3+(Config.spacing_fun(clockRect.height) * 5) Column { width: parent.width diff --git a/modules/bar/widgets/Network.qml b/modules/bar/widgets/Network.qml index 955cdfc..8366b37 100644 --- a/modules/bar/widgets/Network.qml +++ b/modules/bar/widgets/Network.qml @@ -39,8 +39,8 @@ MouseArea { anchorItem: networkButton anchorHovered: networkButton.containsMouse property int count: 17 - width: Math.max(text1.width, text2.width, text3.width, text4.width, text5.width, text6.width) + (Config.spacing_fun(networkButton.height) * 3) - height: text1.height*count+(Config.spacing_fun(networkButton.height) * (count + 2)) + implicitWidth: Math.max(text1.width, text2.width, text3.width, text4.width, text5.width, text6.width) + (Config.spacing_fun(networkButton.height) * 3) + implicitHeight: text1.height*count+(Config.spacing_fun(networkButton.height) * (count + 2)) Column { width: parent.width