aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/src/solo_tool
diff options
context:
space:
mode:
Diffstat (limited to 'solo-tool-project/src/solo_tool')
-rw-r--r--solo-tool-project/src/solo_tool/notifier.py1
-rw-r--r--solo-tool-project/src/solo_tool/solo_tool.py8
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)