From c990b0231c425743622368399aaf3b3b7231c481 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Sat, 22 Feb 2025 10:29:50 +0100 Subject: Refactor to use properties for song list and current song --- solo-tool-project/src/solo_tool/solo_tool.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 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 38e3d11..47e31ca 100644 --- a/solo-tool-project/src/solo_tool/solo_tool.py +++ b/solo-tool-project/src/solo_tool/solo_tool.py @@ -25,23 +25,26 @@ class SoloTool: position = self._player.getPlaybackPosition() self._abController.positionChanged(position) - def addSong(self, path): + @property + def songList(self) -> list[str]: + return self._playlist.getSongs() + + def addSong(self, path: str) -> None: if os.path.isfile(path): self._sessionManager.addSong(path) - def setSong(self, index): + @property + def song(self) -> int: + return self._playlist.getCurrentSongIndex() + + @song.setter + def song(self, index: int) -> None: previous = self._playlist.getCurrentSongIndex() self._playlist.setCurrentSong(index) new = self._playlist.getCurrentSongIndex() if previous != new: self._notifier.notify(Notifier.CURRENT_SONG_EVENT, new) - def getCurrentSong(self): - return self._playlist.getCurrentSongIndex() - - def getSongs(self): - return self._playlist.getSongs() - def storeAbLimits(self, aLimit, bLimit): self._abController.storeLimits(aLimit, bLimit) -- cgit v1.2.3