Merge changes made to master
This commit is contained in:
commit
f2d01e003d
@ -199,8 +199,12 @@ class PlaylistTrack:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Calculate time fade_graph should start updating
|
# Calculate time fade_graph should start updating
|
||||||
update_graph_at_ms = max(0, self.fade_at - Config.FADE_CURVE_MS_BEFORE_FADE - 1)
|
update_graph_at_ms = max(
|
||||||
self.fade_graph_start_updates = now + dt.timedelta(milliseconds=update_graph_at_ms)
|
0, self.fade_at - Config.FADE_CURVE_MS_BEFORE_FADE - 1
|
||||||
|
)
|
||||||
|
self.fade_graph_start_updates = now + dt.timedelta(
|
||||||
|
milliseconds=update_graph_at_ms
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@ -84,7 +84,7 @@ class ReplaceFilesDialog(QDialog):
|
|||||||
continue
|
continue
|
||||||
rf = TrackFileData(new_file_path=new_file_path)
|
rf = TrackFileData(new_file_path=new_file_path)
|
||||||
rf.tags = get_tags(new_file_path)
|
rf.tags = get_tags(new_file_path)
|
||||||
if not rf.tags['title'] or not rf.tags['artist']:
|
if not rf.tags["title"] or not rf.tags["artist"]:
|
||||||
show_warning(
|
show_warning(
|
||||||
parent=self.main_window,
|
parent=self.main_window,
|
||||||
title="Error",
|
title="Error",
|
||||||
@ -98,11 +98,11 @@ class ReplaceFilesDialog(QDialog):
|
|||||||
|
|
||||||
# Check for same filename
|
# Check for same filename
|
||||||
match_track = self.check_by_basename(
|
match_track = self.check_by_basename(
|
||||||
session, new_file_path, rf.tags['artist'], rf.tags['title']
|
session, new_file_path, rf.tags["artist"], rf.tags["title"]
|
||||||
)
|
)
|
||||||
if not match_track:
|
if not match_track:
|
||||||
match_track = self.check_by_title(
|
match_track = self.check_by_title(
|
||||||
session, new_file_path, rf.tags['artist'], rf.tags['title']
|
session, new_file_path, rf.tags["artist"], rf.tags["title"]
|
||||||
)
|
)
|
||||||
|
|
||||||
if not match_track:
|
if not match_track:
|
||||||
@ -113,8 +113,7 @@ class ReplaceFilesDialog(QDialog):
|
|||||||
# We will store new file in the same directory as the
|
# We will store new file in the same directory as the
|
||||||
# existing file but with the new file name
|
# existing file but with the new file name
|
||||||
rf.track_path = os.path.join(
|
rf.track_path = os.path.join(
|
||||||
os.path.dirname(match_track.path),
|
os.path.dirname(match_track.path), new_file_basename
|
||||||
new_file_basename
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# We will remove existing track file
|
# We will remove existing track file
|
||||||
@ -125,27 +124,34 @@ class ReplaceFilesDialog(QDialog):
|
|||||||
if match_basename == new_file_basename:
|
if match_basename == new_file_basename:
|
||||||
path_text = " " + new_file_basename + " (no change)"
|
path_text = " " + new_file_basename + " (no change)"
|
||||||
else:
|
else:
|
||||||
path_text = f" {match_basename} →\n {new_file_basename} (replace)"
|
path_text = (
|
||||||
|
f" {match_basename} →\n {new_file_basename} (replace)"
|
||||||
|
)
|
||||||
filename_item = QTableWidgetItem(path_text)
|
filename_item = QTableWidgetItem(path_text)
|
||||||
|
|
||||||
if match_track.title == rf.tags['title']:
|
if match_track.title == rf.tags["title"]:
|
||||||
title_text = " " + rf.tags['title'] + " (no change)"
|
title_text = " " + rf.tags["title"] + " (no change)"
|
||||||
else:
|
else:
|
||||||
title_text = f" {match_track.title} →\n {rf.tags['title']} (update)"
|
title_text = (
|
||||||
|
f" {match_track.title} →\n {rf.tags['title']} (update)"
|
||||||
|
)
|
||||||
title_item = QTableWidgetItem(title_text)
|
title_item = QTableWidgetItem(title_text)
|
||||||
|
|
||||||
if match_track.artist == rf.tags['artist']:
|
if match_track.artist == rf.tags["artist"]:
|
||||||
artist_text = " " + rf.tags['artist'] + " (no change)"
|
artist_text = " " + rf.tags["artist"] + " (no change)"
|
||||||
else:
|
else:
|
||||||
artist_text = f" {match_track.artist} →\n {rf.tags['artist']} (update)"
|
artist_text = (
|
||||||
|
f" {match_track.artist} →\n {rf.tags['artist']} (update)"
|
||||||
|
)
|
||||||
artist_item = QTableWidgetItem(artist_text)
|
artist_item = QTableWidgetItem(artist_text)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
rf.track_path = os.path.join(Config.REPLACE_FILES_DEFAULT_DESTINATION,
|
rf.track_path = os.path.join(
|
||||||
new_file_basename)
|
Config.REPLACE_FILES_DEFAULT_DESTINATION, new_file_basename
|
||||||
|
)
|
||||||
filename_item = QTableWidgetItem(" " + new_file_basename + " (new)")
|
filename_item = QTableWidgetItem(" " + new_file_basename + " (new)")
|
||||||
title_item = QTableWidgetItem(" " + rf.tags['title'])
|
title_item = QTableWidgetItem(" " + rf.tags["title"])
|
||||||
artist_item = QTableWidgetItem(" " + rf.tags['artist'])
|
artist_item = QTableWidgetItem(" " + rf.tags["artist"])
|
||||||
|
|
||||||
self.replacement_files.append(rf)
|
self.replacement_files.append(rf)
|
||||||
row = self.ui.tableWidget.rowCount()
|
row = self.ui.tableWidget.rowCount()
|
||||||
|
|||||||
@ -175,7 +175,6 @@ class Music:
|
|||||||
if current_volume < volume:
|
if current_volume < volume:
|
||||||
self.player.audio_set_volume(volume)
|
self.player.audio_set_volume(volume)
|
||||||
log.debug(f"Reset from {volume=}")
|
log.debug(f"Reset from {volume=}")
|
||||||
break
|
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
|
|
||||||
def stop(self) -> float:
|
def stop(self) -> float:
|
||||||
|
|||||||
@ -1151,13 +1151,10 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# If return is pressed during first PLAY_NEXT_GUARD_MS then
|
# If return is pressed during first PLAY_NEXT_GUARD_MS then
|
||||||
# default to NOT playing the next track, else default to
|
# default to NOT playing the next track, else default to
|
||||||
# playing it.
|
# playing it.
|
||||||
default_yes: bool = (
|
default_yes: bool = track_sequence.now.start_time is not None and (
|
||||||
track_sequence.now.start_time is not None
|
(dt.datetime.now() - track_sequence.now.start_time).total_seconds()
|
||||||
and (
|
* 1000
|
||||||
(dt.datetime.now() - track_sequence.now.start_time).total_seconds()
|
> Config.PLAY_NEXT_GUARD_MS
|
||||||
* 1000
|
|
||||||
> Config.PLAY_NEXT_GUARD_MS
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
if not helpers.ask_yes_no(
|
if not helpers.ask_yes_no(
|
||||||
"Track playing",
|
"Track playing",
|
||||||
|
|||||||
@ -862,7 +862,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# otherwise rows below the destination row will end up above the
|
# otherwise rows below the destination row will end up above the
|
||||||
# moved rows.
|
# moved rows.
|
||||||
adjusted_to_row = to_row_number - len(
|
adjusted_to_row = to_row_number - len(
|
||||||
[a for a in from_rows if a <= to_row_number]
|
[a for a in from_rows if a < to_row_number]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Put the from_row row numbers into the row_map. Ultimately the
|
# Put the from_row row numbers into the row_map. Ultimately the
|
||||||
|
|||||||
@ -244,6 +244,20 @@ class TestMMMiscRowMove(unittest.TestCase):
|
|||||||
new_order.append(int(self.model.playlist_rows[row].note))
|
new_order.append(int(self.model.playlist_rows[row].note))
|
||||||
assert new_order == [0, 1, 2, 3, 4, 7, 8, 10, 5, 6, 9]
|
assert new_order == [0, 1, 2, 3, 4, 7, 8, 10, 5, 6, 9]
|
||||||
|
|
||||||
|
def test_move_rows_test9(self):
|
||||||
|
# move rows [1, 2, 3] → 0
|
||||||
|
# Replicate issue 244
|
||||||
|
|
||||||
|
self.model.move_rows([0, 1, 2, 3], 0)
|
||||||
|
|
||||||
|
# Check we have all rows and plr_rownums are correct
|
||||||
|
new_order = []
|
||||||
|
for row in range(self.model.rowCount()):
|
||||||
|
assert row in self.model.playlist_rows
|
||||||
|
assert self.model.playlist_rows[row].plr_rownum == row
|
||||||
|
new_order.append(int(self.model.playlist_rows[row].note))
|
||||||
|
assert new_order == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||||
|
|
||||||
def test_insert_header_row_end(self):
|
def test_insert_header_row_end(self):
|
||||||
# insert header row at end of playlist
|
# insert header row at end of playlist
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user