diff --git a/app/config.py b/app/config.py index 749919b..64a67cc 100644 --- a/app/config.py +++ b/app/config.py @@ -79,7 +79,6 @@ class Config(object): SCROLL_TOP_MARGIN = 3 TEXT_NO_TRACK_NO_NOTE = "[Section header]" TOD_TIME_FORMAT = "%H:%M:%S" - TIMER_MS = 10 TRACK_TIME_FORMAT = "%H:%M:%S" VOLUME_VLC_DEFAULT = 75 VOLUME_VLC_DROP3db = 65 diff --git a/app/musicmuster.py b/app/musicmuster.py index b9fbf1e..bbec707 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -319,8 +319,9 @@ class Window(QMainWindow, Ui_MainWindow): super().__init__(*args, **kwargs) self.setupUi(self) - self.timer: QTimer = QTimer() - self.clock_counter: int = 0 + self.timer10: QTimer = QTimer() + self.timer500: QTimer = QTimer() + self.timer1000: QTimer = QTimer() self.music: music.Music = music.Music() self.playing: bool = False @@ -360,7 +361,9 @@ class Window(QMainWindow, Ui_MainWindow): self.carts_init() self.enable_play_next_controls() self.clock_counter = 0 - self.timer.start(Config.TIMER_MS) + self.timer10.start(10) + self.timer500.start(500) + self.timer1000.start(1000) self.connect_signals_slots() def about(self) -> None: @@ -671,7 +674,9 @@ class Window(QMainWindow, Ui_MainWindow): self.tabBar.tabMoved.connect(self.move_tab) self.txtSearch.returnPressed.connect(self.search_playlist_return) - self.timer.timeout.connect(self.tick) + self.timer10.timeout.connect(self.tick_10ms) + self.timer500.timeout.connect(self.tick_500ms) + self.timer1000.timeout.connect(self.tick_1000ms) def create_playlist( self, session: scoped_session, playlist_name: Optional[str] = None @@ -812,8 +817,8 @@ class Window(QMainWindow, Ui_MainWindow): - Enable controls """ - # Set flag to say we're not playing a track so that tick() - # doesn't see player=None and kick off end-of-track actions + # Set flag to say we're not playing a track so that timer ticks + # don't see player=None and kick off end-of-track actions self.playing = False # Tell playlist_tab track has finished @@ -831,8 +836,7 @@ class Window(QMainWindow, Ui_MainWindow): # Reset clocks self.frame_fade.setStyleSheet("") self.frame_silent.setStyleSheet("") - self.label_elapsed_timer.setText("00:00") - self.label_end_timer.setText("00:00") + self.label_elapsed_timer.setText("00:00 / 00:00") self.label_fade_timer.setText("00:00") self.label_silent_timer.setText("00:00") @@ -1668,24 +1672,6 @@ class Window(QMainWindow, Ui_MainWindow): self.next_track.playlist_tab, QColor(Config.COLOUR_NEXT_TAB) ) - def tick(self) -> None: - """ - Called every Config.TIMER_MS milliseconds. Call periodic functions - as required. - """ - - # Get current number of milliseconds - self.clock_counter += Config.TIMER_MS - self.clock_counter %= 1000 - - # Call periodic functions - if self.clock_counter % 10 == 0: - self.tick_10ms() - if self.clock_counter % 500 == 0: - self.tick_500ms() - if self.clock_counter == 0: - self.tick_1000ms() - def tick_10ms(self) -> None: """ Called every 10ms