Compare commits

..

2 Commits

Author SHA1 Message Date
Keith Edmunds
9ccff3db20 Specify colour of cart progress bars 2022-10-23 22:37:06 +01:00
Keith Edmunds
ef9b1e7ce5 Remove redundant debug logging 2022-10-23 16:29:38 +01:00
3 changed files with 24 additions and 8 deletions

View File

@ -16,6 +16,7 @@ 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,6 +7,7 @@ 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
@ -58,6 +59,9 @@ 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
@ -72,9 +76,13 @@ 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(100)
self.pgb.setMaximum(1)
self.pgb.setValue(0)
def __repr__(self) -> str:
@ -184,6 +192,9 @@ 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")
@ -240,6 +251,16 @@ 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"""
@ -248,11 +269,7 @@ class Window(QMainWindow, Ui_MainWindow):
if not btn:
continue
if btn.is_playing:
if btn.player.is_playing():
# Update progress bar
position = btn.player.get_position()
btn.pgb.setValue(int(position * 100))
else:
if not btn.player.is_playing():
# Cart has finished playing
btn.is_playing = False
# Setting to position 0 doesn't seem to work

View File

@ -823,7 +823,6 @@ 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)
@ -831,7 +830,6 @@ 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)