From 4b029ddcbccb75ef9aa129fa0d726fdee24af0bb Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Mon, 24 Feb 2025 21:45:50 +0100 Subject: Improved key points notification --- solo-tool-project/src/solo_tool/solo_tool.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'solo-tool-project/src/solo_tool/solo_tool.py') diff --git a/solo-tool-project/src/solo_tool/solo_tool.py b/solo-tool-project/src/solo_tool/solo_tool.py index 0f47aef..199e2ad 100644 --- a/solo-tool-project/src/solo_tool/solo_tool.py +++ b/solo-tool-project/src/solo_tool/solo_tool.py @@ -16,8 +16,9 @@ class SoloTool: self._song = index path = self._songs[index] self._player.setCurrentSong(path) - self._notifier.notify(Notifier.CURRENT_SONG_EVENT, index) self._keyPoint = 0.0 + self._notifier.notify(Notifier.CURRENT_SONG_EVENT, index) + self._notifier.notify(Notifier.CURRENT_KEY_POINT_EVENT, index) @staticmethod def _keyPointValid(kp: float) -> bool: @@ -49,13 +50,14 @@ class SoloTool: def keyPoints(self) -> list[float]: if self._song is None: return None - return self._keyPoints[self._song] + return self._keyPoints[self._song].copy() @keyPoints.setter def keyPoints(self, new: list[float]) -> None: if new is not None and self._song is not None: sanitized = sorted(list(set([p for p in new if SoloTool._keyPointValid(p)]))) self._keyPoints[self._song] = sanitized + self._notifier.notify(Notifier.KEY_POINTS_EVENT, sanitized.copy()) @property def keyPoint(self) -> float: @@ -127,3 +129,5 @@ class SoloTool: def registerCurrentKeyPointCallback(self, callback): self._notifier.registerCallback(Notifier.CURRENT_KEY_POINT_EVENT, callback) + def registerKeyPointsCallback(self, callback): + self._notifier.registerCallback(Notifier.KEY_POINTS_EVENT, callback) -- cgit v1.2.3