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_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
MAX_IMPORT_MATCHES = 5
MAX_INFO_TABS = 5
MAX_MISSING_FILES_TO_REPORT = 10
MILLISECOND_SIGFIGS = 0

View File

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

View File

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