diff --git a/modules/Backlight.qml b/modules/Backlight.qml index 0973603..8d7c5d3 100644 --- a/modules/Backlight.qml +++ b/modules/Backlight.qml @@ -12,9 +12,12 @@ M.BarSection { property int percent: 0 property bool _osdActive: false + property bool _ready: false readonly property bool _showPanel: root._hovered || hoverPanel.panelHovered || _osdActive - onPercentChanged: if (percent > 0) + Component.onCompleted: _ready = true + + onPercentChanged: if (_ready && percent > 0) _flashPanel() function _flashPanel() { diff --git a/modules/NotifItem.qml b/modules/NotifItem.qml index e24941f..1f5199f 100644 --- a/modules/NotifItem.qml +++ b/modules/NotifItem.qml @@ -29,29 +29,17 @@ QtObject { } } - // Relative time string - property string timeStr: "now" - readonly property Timer _timeStrTimer: Timer { - running: root.state !== "dismissed" - repeat: true - interval: 5000 - onTriggered: root._updateTimeStr() - } - - function _updateTimeStr() { - const diff = Date.now() - time; + // Relative time string — recomputed whenever NotifService._now ticks (single global 5s timer) + readonly property string timeStr: { + const diff = M.NotifService._now - time; const m = Math.floor(diff / 60000); - if (m < 1) { - timeStr = "now"; - return; - } + if (m < 1) + return "now"; const h = Math.floor(m / 60); - if (h < 1) { - timeStr = m + "m"; - return; - } + if (h < 1) + return m + "m"; const d = Math.floor(h / 24); - timeStr = d > 0 ? d + "d" : h + "h"; + return d > 0 ? d + "d" : h + "h"; } function beginDismiss() { diff --git a/modules/NotifService.qml b/modules/NotifService.qml index b266f94..0591eae 100644 --- a/modules/NotifService.qml +++ b/modules/NotifService.qml @@ -124,6 +124,15 @@ QtObject { } // Persistence + // Single global tick for all NotifItem.timeStr bindings — replaces per-item 5s timers + property real _now: Date.now() + property Timer _nowTimer: Timer { + running: root.count > 0 + repeat: true + interval: 5000 + onTriggered: root._now = Date.now() + } + property Timer _saveTimer: Timer { interval: 1000 onTriggered: { diff --git a/modules/Volume.qml b/modules/Volume.qml index b091a43..2aa5524 100644 --- a/modules/Volume.qml +++ b/modules/Volume.qml @@ -39,11 +39,16 @@ M.BarSection { } property bool _osdActive: false + property bool _ready: false readonly property bool _anyHover: root._hovered || hoverPanel.panelHovered readonly property bool _showPanel: _anyHover || _osdActive - onVolumeChanged: _flashPanel() - onMutedChanged: _flashPanel() + Component.onCompleted: _ready = true + + onVolumeChanged: if (_ready) + _flashPanel() + onMutedChanged: if (_ready) + _flashPanel() function _flashPanel() { _osdActive = true;