Compare commits

...

5 Commits

Author SHA1 Message Date
Keith Edmunds
25add4239d Limit matching tracks on import to five 2022-11-10 10:11:42 +00:00
Keith Edmunds
04f1fba581 Ignore directories for replace_files 2022-11-10 10:11:20 +00:00
Keith Edmunds
9af20c29d3 Fix scroll to current/next with hidden rows 2022-11-06 16:18:51 +00:00
Keith Edmunds
2b4e003caf Speed up marking track as next 2022-10-28 13:22:00 +01:00
Keith Edmunds
52776fcf8d Workaround to crash when playing cart with next track selected 2022-10-26 14:20:34 +01:00
3 changed files with 41 additions and 16 deletions

View File

@ -195,9 +195,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")
@ -666,11 +666,15 @@ class Window(QMainWindow, Ui_MainWindow):
artist = tags['artist'] artist = tags['artist']
possible_matches = Tracks.search_titles(session, title) possible_matches = Tracks.search_titles(session, title)
if possible_matches: if possible_matches:
txt += 'Similar to new track ' if len(possible_matches) > 5:
txt += f'"{title}" by "{artist} ({fname})":\n\n' txt = "More than five tracks look similar to "
for track in possible_matches: txt += f'"{title}" by "{artist} ({fname})":\n\n'
txt += f' "{track.title}" by {track.artist}' else:
txt += f' ({track.path})\n\n' 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'
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?"
@ -1027,7 +1031,7 @@ class Window(QMainWindow, Ui_MainWindow):
"""Scroll to show current track""" """Scroll to show current track"""
log.debug(f"KAE: musicmuster.show_current()") log.debug(f"KAE: musicmuster.show_current()")
if self.current_track_playlist_tab != self.visible_playlist_tab: if self.current_track_playlist_tab != self.visible_playlist_tab():
self.tabPlaylist.setCurrentWidget(self.current_track_playlist_tab) self.tabPlaylist.setCurrentWidget(self.current_track_playlist_tab)
self.tabPlaylist.currentWidget().scroll_current_to_top() self.tabPlaylist.currentWidget().scroll_current_to_top()
@ -1035,7 +1039,7 @@ class Window(QMainWindow, Ui_MainWindow):
"""Scroll to show next track""" """Scroll to show next track"""
log.debug(f"KAE: musicmuster.show_next()") log.debug(f"KAE: musicmuster.show_next()")
if self.next_track_playlist_tab != self.visible_playlist_tab: if self.next_track_playlist_tab != self.visible_playlist_tab():
self.tabPlaylist.setCurrentWidget(self.next_track_playlist_tab) self.tabPlaylist.setCurrentWidget(self.next_track_playlist_tab)
self.tabPlaylist.currentWidget().scroll_next_to_top() self.tabPlaylist.currentWidget().scroll_next_to_top()
@ -1147,8 +1151,12 @@ class Window(QMainWindow, Ui_MainWindow):
# Update headers # Update headers
self.update_headers() self.update_headers()
# Populate 'info' tabs with Wikipedia info # Populate 'info' tabs with Wikipedia info, but queue it because
self.tabInfolist.open_in_wikipedia(track.title) # it isn't quick
track_title = track.title
QTimer.singleShot(
1, lambda: self.tabInfolist.open_in_wikipedia(track_title)
)
def tick(self) -> None: def tick(self) -> None:
""" """

View File

@ -1727,10 +1727,25 @@ class PlaylistTab(QTableWidget):
top. top.
""" """
if row is not None: padding_required = Config.SCROLL_TOP_MARGIN
top_row = max(0, row - Config.SCROLL_TOP_MARGIN + 1) top_row = row
scroll_item = self.item(top_row, 0)
self.scrollToItem(scroll_item, QAbstractItemView.PositionAtTop) if row > Config.SCROLL_TOP_MARGIN:
# We can't scroll to a hidden row. Calculate target_row as the
# one that is ideal to be at the top. Then count upwards from
# passed row until we either reach the target, pass it or reach
# row 0.
# target_row = max(0, row - Config.SCROLL_TOP_MARGIN + 1)
for i in range(row - 1, -1, -1):
if padding_required == 0:
break
if self.isRowHidden(i):
continue
top_row = i
padding_required -= 1
scroll_item = self.item(top_row, 0)
self.scrollToItem(scroll_item, QAbstractItemView.PositionAtTop)
def _select_event(self) -> None: def _select_event(self) -> None:
""" """

View File

@ -87,6 +87,8 @@ def main():
for new_fname in os.listdir(source_dir): for new_fname in os.listdir(source_dir):
new_path = os.path.join(source_dir, new_fname) new_path = os.path.join(source_dir, new_fname)
if not os.path.isfile(new_path):
continue
new_tags = get_tags(new_path) new_tags = get_tags(new_path)
new_title = new_tags['title'] new_title = new_tags['title']
new_artist = new_tags['artist'] new_artist = new_tags['artist']