Compare commits

...

4 Commits

Author SHA1 Message Date
Keith Edmunds
41379efd1b Limit number of matching tracks on import 2022-11-11 21:12:12 +00:00
Keith Edmunds
6339326947 Don't scroll to top without a row 2022-11-11 21:06:15 +00:00
Keith Edmunds
a0c1dad2f5 Merge branch 'dev' 2022-11-10 10:12:13 +00:00
Keith Edmunds
0f5edcc86c Use signal to update cart progress bar 2022-10-26 20:09:04 +01:00
3 changed files with 24 additions and 15 deletions

View File

@ -65,6 +65,7 @@ class Config(object):
MAIL_SERVER = os.environ.get('MAIL_SERVER') or "woodlands.midnighthax.com" MAIL_SERVER = os.environ.get('MAIL_SERVER') or "woodlands.midnighthax.com"
MAIL_USERNAME = os.environ.get('MAIL_USERNAME') MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
MAX_IMPORT_MATCHES = 5
MAX_INFO_TABS = 5 MAX_INFO_TABS = 5
MAX_MISSING_FILES_TO_REPORT = 10 MAX_MISSING_FILES_TO_REPORT = 10
MILLISECOND_SIGFIGS = 0 MILLISECOND_SIGFIGS = 0

View File

@ -10,7 +10,7 @@ from datetime import datetime, timedelta
from time import sleep from time import sleep
from typing import List, Optional from typing import List, Optional
from PyQt5.QtCore import QDate, QEvent, Qt, QSize, QTime, QTimer from PyQt5.QtCore import pyqtSignal, QDate, QEvent, Qt, QSize, QTime, QTimer
from PyQt5.QtGui import QColor, QFont, QPalette, QResizeEvent from PyQt5.QtGui import QColor, QFont, QPalette, QResizeEvent
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QApplication, QApplication,
@ -53,6 +53,8 @@ from utilities import check_db, update_bitrates
class CartButton(QPushButton): class CartButton(QPushButton):
"""Button for playing carts""" """Button for playing carts"""
progress = pyqtSignal(int)
def __init__(self, parent: QMainWindow, cart: Carts): def __init__(self, parent: QMainWindow, cart: Carts):
"""Create a cart pushbutton and set it disabled""" """Create a cart pushbutton and set it disabled"""
@ -85,6 +87,8 @@ class CartButton(QPushButton):
self.pgb.setMaximum(1) self.pgb.setMaximum(1)
self.pgb.setValue(0) self.pgb.setValue(0)
self.progress.connect(self.pgb.setValue)
def __repr__(self) -> str: def __repr__(self) -> str:
return ( return (
f"<CartButton(cart_id={self.cart_id} " f"<CartButton(cart_id={self.cart_id} "
@ -195,9 +199,9 @@ class Window(QMainWindow, Ui_MainWindow):
btn.player.play() btn.player.play()
btn.is_playing = True btn.is_playing = True
colour = Config.COLOUR_CART_PLAYING colour = Config.COLOUR_CART_PLAYING
# thread = threading.Thread(target=self.cart_progressbar, thread = threading.Thread(target=self.cart_progressbar,
# args=(btn,)) args=(btn,))
# thread.start() thread.start()
else: else:
colour = Config.COLOUR_CART_ERROR colour = Config.COLOUR_CART_ERROR
btn.setStyleSheet("background-color: " + colour + ";\n") btn.setStyleSheet("background-color: " + colour + ";\n")
@ -260,7 +264,7 @@ class Window(QMainWindow, Ui_MainWindow):
ms = 0 ms = 0
btn.pgb.setMaximum(btn.duration) btn.pgb.setMaximum(btn.duration)
while ms <= btn.duration: while ms <= btn.duration:
btn.pgb.setValue(ms) btn.progress.emit(ms)
ms += 100 ms += 100
sleep(0.1) sleep(0.1)
@ -664,17 +668,18 @@ class Window(QMainWindow, Ui_MainWindow):
new_tracks.append((fname, tags)) new_tracks.append((fname, tags))
title = tags['title'] title = tags['title']
artist = tags['artist'] artist = tags['artist']
count = 0
possible_matches = Tracks.search_titles(session, title) possible_matches = Tracks.search_titles(session, title)
if possible_matches: if possible_matches:
if len(possible_matches) > 5:
txt = "More than five tracks look similar to "
txt += f'"{title}" by "{artist} ({fname})":\n\n'
else:
txt += 'Similar to new track ' txt += 'Similar to new track '
txt += f'"{title}" by "{artist} ({fname})":\n\n' txt += f'"{title}" by "{artist} ({fname})":\n\n'
for track in possible_matches: for track in possible_matches:
txt += f' "{track.title}" by {track.artist}' txt += f' "{track.title}" by {track.artist}'
txt += f' ({track.path})\n\n' txt += f' ({track.path})\n\n'
count += 1
if count >= Config.MAX_IMPORT_MATCHES:
txt += "\nThere are more similar-looking tracks"
break
txt += "\n" txt += "\n"
# Check whether to proceed if there were potential matches # Check whether to proceed if there were potential matches
txt += "Proceed with import?" txt += "Proceed with import?"

View File

@ -1727,6 +1727,9 @@ class PlaylistTab(QTableWidget):
top. top.
""" """
if row is None:
return
padding_required = Config.SCROLL_TOP_MARGIN padding_required = Config.SCROLL_TOP_MARGIN
top_row = row top_row = row