Compare commits

..

No commits in common. "9ccff3db2011d945e521edbc8ea615fed2855cbd" and "5e770b39754002450465abb68fc47454c18e017b" have entirely different histories.

3 changed files with 8 additions and 24 deletions

View File

@ -16,7 +16,6 @@ class Config(object):
COLOUR_BITRATE_OK = "#dcedc8"
COLOUR_CART_ERROR = "#dc3545"
COLOUR_CART_PLAYING = "#248f24"
COLOUR_CART_PROGRESSBAR = "#000000"
COLOUR_CART_READY = "#ffc107"
COLOUR_CART_UNCONFIGURED = "#f2f2f2"
COLOUR_CURRENT_HEADER = "#d4edda"

View File

@ -7,7 +7,6 @@ import sys
import threading
from datetime import datetime, timedelta
from time import sleep
from typing import List, Optional
from PyQt5.QtCore import QDate, QEvent, Qt, QSize, QTime, QTimer
@ -59,9 +58,6 @@ class CartButton(QPushButton):
super().__init__(parent)
self.parent = parent
self.cart_id = cart.id
if cart.path and cart.enabled and not cart.duration:
tags = helpers.get_tags(cart.path)
cart.duration = tags['duration']
self.duration = cart.duration
self.path = cart.path
self.player = None
@ -76,13 +72,9 @@ class CartButton(QPushButton):
self.pgb = QProgressBar(self, textVisible=False)
self.pgb.setVisible(False)
palette = self.pgb.palette()
palette.setColor(QPalette.Highlight,
QColor(Config.COLOUR_CART_PROGRESSBAR))
self.pgb.setPalette(palette)
self.pgb.setGeometry(0, 0, self.width(), 10)
self.pgb.setMinimum(0)
self.pgb.setMaximum(1)
self.pgb.setMaximum(100)
self.pgb.setValue(0)
def __repr__(self) -> str:
@ -192,9 +184,6 @@ class Window(QMainWindow, Ui_MainWindow):
btn.player.play()
btn.is_playing = True
colour = Config.COLOUR_CART_PLAYING
thread = threading.Thread(target=self.cart_progressbar,
args=(btn,))
thread.start()
else:
colour = Config.COLOUR_CART_ERROR
btn.setStyleSheet("background-color: " + colour + ";\n")
@ -251,16 +240,6 @@ class Window(QMainWindow, Ui_MainWindow):
# Configure button
self.cart_configure(cart, btn)
def cart_progressbar(self, btn: CartButton) -> None:
"""Manage progress bar"""
ms = 0
btn.pgb.setMaximum(btn.duration)
while ms <= btn.duration:
btn.pgb.setValue(ms)
ms += 100
sleep(0.1)
def cart_tick(self) -> None:
"""Cart clock actions"""
@ -269,7 +248,11 @@ class Window(QMainWindow, Ui_MainWindow):
if not btn:
continue
if btn.is_playing:
if not btn.player.is_playing():
if btn.player.is_playing():
# Update progress bar
position = btn.player.get_position()
btn.pgb.setValue(int(position * 100))
else:
# Cart has finished playing
btn.is_playing = False
# Setting to position 0 doesn't seem to work

View File

@ -823,6 +823,7 @@ class PlaylistTab(QTableWidget):
def scroll_current_to_top(self) -> None:
"""Scroll currently-playing row to top"""
log.debug("KAE: playlists.scroll_current_to_top()")
current_row = self._get_current_track_row()
log.debug(f"KAE: playlists.scroll_current_to_top(), {current_row=}")
self._scroll_to_top(current_row)
@ -830,6 +831,7 @@ class PlaylistTab(QTableWidget):
def scroll_next_to_top(self) -> None:
"""Scroll nextly-playing row to top"""
log.debug("KAE: playlists.scroll_next_to_top()")
next_row = self._get_next_track_row()
log.debug(f"KAE: playlists.scroll_next_to_top(), {next_row=}")
self._scroll_to_top(next_row)