V3 hide played tracks
Don't hide previous track until delay after playing next track.
This commit is contained in:
parent
3179c6f5de
commit
95aadb867a
@ -13,6 +13,7 @@ from PyQt6.QtCore import (
|
|||||||
QRegularExpression,
|
QRegularExpression,
|
||||||
QSortFilterProxyModel,
|
QSortFilterProxyModel,
|
||||||
Qt,
|
Qt,
|
||||||
|
QTimer,
|
||||||
QVariant,
|
QVariant,
|
||||||
)
|
)
|
||||||
from PyQt6.QtGui import (
|
from PyQt6.QtGui import (
|
||||||
@ -278,6 +279,11 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
# Update colour and times for current row
|
# Update colour and times for current row
|
||||||
self.invalidate_row(row_number)
|
self.invalidate_row(row_number)
|
||||||
|
|
||||||
|
# Update previous row in case we're hiding played rows
|
||||||
|
if track_sequence.previous.plr_rownum:
|
||||||
|
self.invalidate_row(track_sequence.previous.plr_rownum)
|
||||||
|
|
||||||
# Update all other track times
|
# Update all other track times
|
||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
|
|
||||||
@ -1365,9 +1371,46 @@ class PlaylistProxyModel(QSortFilterProxyModel):
|
|||||||
if (
|
if (
|
||||||
now_plr
|
now_plr
|
||||||
and now_plr.plr_rownum == source_row
|
and now_plr.plr_rownum == source_row
|
||||||
and now_plr.playlist_id == self.playlist_model.playlist_id
|
and now_plr.playlist_id == self.data_model.playlist_id
|
||||||
):
|
):
|
||||||
return True
|
return True
|
||||||
|
# Don't hide previous track until
|
||||||
|
# HIDE_AFTER_PLAYING_OFFSET milliseconds after
|
||||||
|
# current track has started
|
||||||
|
if track_sequence.previous.plr_id:
|
||||||
|
previous_plr = session.get(
|
||||||
|
PlaylistRows, track_sequence.previous.plr_id
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
previous_plr
|
||||||
|
and previous_plr.plr_rownum == source_row
|
||||||
|
and previous_plr.playlist_id == self.data_model.playlist_id
|
||||||
|
):
|
||||||
|
print("Checking previous track")
|
||||||
|
if track_sequence.now.start_time:
|
||||||
|
if datetime.now() > (
|
||||||
|
track_sequence.now.start_time
|
||||||
|
+ timedelta(
|
||||||
|
milliseconds=Config.HIDE_AFTER_PLAYING_OFFSET
|
||||||
|
)
|
||||||
|
):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
# Invalidate this row in
|
||||||
|
# HIDE_AFTER_PLAYING_OFFSET and a
|
||||||
|
# bit milliseconds
|
||||||
|
# so that it hides then - add 100mS
|
||||||
|
# on so that it if clause above it
|
||||||
|
# true next time through.
|
||||||
|
print("queuing singleshot")
|
||||||
|
QTimer.singleShot(
|
||||||
|
Config.HIDE_AFTER_PLAYING_OFFSET + 100,
|
||||||
|
lambda: self.data_model.invalidate_row(source_row),
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
return super().filterAcceptsRow(source_row, source_parent)
|
return super().filterAcceptsRow(source_row, source_parent)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user