diff options
| author | Eddy Pedroni <epedroni@pm.me> | 2025-02-24 21:45:50 +0100 | 
|---|---|---|
| committer | Eddy Pedroni <epedroni@pm.me> | 2025-02-24 21:45:50 +0100 | 
| commit | 4b029ddcbccb75ef9aa129fa0d726fdee24af0bb (patch) | |
| tree | 44377b7357df400a3eb969520f8992f481db1fb1 /solo-tool-project/src/solo_tool | |
| parent | b65d54e662c7f7bde6d0f1d6bb195e6e7cb96af8 (diff) | |
Improved key points notification
Diffstat (limited to 'solo-tool-project/src/solo_tool')
| -rw-r--r-- | solo-tool-project/src/solo_tool/notifier.py | 1 | ||||
| -rw-r--r-- | solo-tool-project/src/solo_tool/solo_tool.py | 8 | 
2 files changed, 7 insertions, 2 deletions
| diff --git a/solo-tool-project/src/solo_tool/notifier.py b/solo-tool-project/src/solo_tool/notifier.py index 73b84b7..dadf85c 100644 --- a/solo-tool-project/src/solo_tool/notifier.py +++ b/solo-tool-project/src/solo_tool/notifier.py @@ -4,6 +4,7 @@ class Notifier:      PLAYBACK_RATE_EVENT = 2      CURRENT_SONG_EVENT = 3      CURRENT_KEY_POINT_EVENT = 3 +    KEY_POINTS_EVENT = 4      def __init__(self, player):          self._callbacks = dict() 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) | 
