From 2b4323eca801638f0a305ff29afe815a45e103b1 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Tue, 4 Jan 2022 17:55:00 +0100 Subject: Added current value to notification system, fixed Qt hack --- solo_tool.py | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'solo_tool.py') diff --git a/solo_tool.py b/solo_tool.py index fee7e4a..4ea081d 100644 --- a/solo_tool.py +++ b/solo_tool.py @@ -30,22 +30,25 @@ class SoloTool: self._sessionManager.addSong(path) def setSong(self, index): - changed = index != self._playlist.getCurrentSongIndex() + previous = self._playlist.getCurrentSongIndex() self._playlist.setCurrentSong(index) - if changed: - self._notifier.notify(Notifier.CURRENT_SONG_EVENT) + new = self._playlist.getCurrentSongIndex() + if previous != new: + self._notifier.notify(Notifier.CURRENT_SONG_EVENT, new) def nextSong(self): previous = self._playlist.getCurrentSongIndex() self._playlist.nextSong() - if previous != self._playlist.getCurrentSongIndex(): - self._notifier.notify(Notifier.CURRENT_SONG_EVENT) + new = self._playlist.getCurrentSongIndex() + if previous != new: + self._notifier.notify(Notifier.CURRENT_SONG_EVENT, new) def previousSong(self): previous = self._playlist.getCurrentSongIndex() self._playlist.previousSong() - if previous != self._playlist.getCurrentSongIndex(): - self._notifier.notify(Notifier.CURRENT_SONG_EVENT) + new = self._playlist.getCurrentSongIndex() + if previous != new: + self._notifier.notify(Notifier.CURRENT_SONG_EVENT, new) def getSongs(self): return self._playlist.getSongs() @@ -54,10 +57,11 @@ class SoloTool: self._abController.storeLimits(aLimit, bLimit) def loadAbLimits(self, index): - changed = index != self._abController.getLoadedIndex() + previous = self._abController.getLoadedIndex() self._abController.loadLimits(index) - if changed: - self._notifier.notify(Notifier.CURRENT_AB_EVENT) + new = self._abController.getLoadedIndex() + if previous != new: + self._notifier.notify(Notifier.CURRENT_AB_EVENT, new) def setAbLimits(self, aLimit, bLimit): self._abController.setLimits(aLimit, bLimit) @@ -75,14 +79,16 @@ class SoloTool: def nextStoredAbLimits(self): previous = self._abController.getLoadedIndex() self._abController.nextStoredAbLimits() - if previous != self._abController.getLoadedIndex(): - self._notifier.notify(Notifier.CURRENT_AB_EVENT) + new = self._abController.getLoadedIndex() + if previous != new: + self._notifier.notify(Notifier.CURRENT_AB_EVENT, new) def previousStoredAbLimits(self): previous = self._abController.getLoadedIndex() self._abController.previousStoredAbLimits() - if previous != self._abController.getLoadedIndex(): - self._notifier.notify(Notifier.CURRENT_AB_EVENT) + new = self._abController.getLoadedIndex() + if previous != new: + self._notifier.notify(Notifier.CURRENT_AB_EVENT, new) def jumpToA(self): a = self._abController.getCurrentLimits()[0] @@ -110,10 +116,11 @@ class SoloTool: return self._player.isPlaying() def setPlaybackRate(self, rate): - previousRate = self._player.getPlaybackRate() + previous = self._player.getPlaybackRate() self._player.setPlaybackRate(rate) - if previousRate != rate: - self._notifier.notify(Notifier.PLAYBACK_RATE_EVENT) + new = self._player.getPlaybackRate() + if previous != new: + self._notifier.notify(Notifier.PLAYBACK_RATE_EVENT, new) def getPlaybackRate(self): return self._player.getPlaybackRate() -- cgit v1.2.3