Compare commits
No commits in common. "06efaf2ba2e5abc3343852fad0f13a1e628acdda" and "e7004688d0faeaa209bc9d2574afb83cd0482a9c" have entirely different histories.
06efaf2ba2
...
e7004688d0
@ -54,7 +54,6 @@ class Config(object):
|
||||
NORMALISE_ON_IMPORT = True
|
||||
NOTE_TIME_FORMAT = "%H:%M:%S"
|
||||
ROOT = os.environ.get('ROOT') or "/home/kae/music"
|
||||
SCROLL_TOP_MARGIN = 3
|
||||
TESTMODE = True
|
||||
TOD_TIME_FORMAT = "%H:%M:%S"
|
||||
TIMER_MS = 500
|
||||
|
||||
@ -338,7 +338,6 @@ class Playlists(Base):
|
||||
|
||||
self.loaded = True
|
||||
self.last_used = datetime.now()
|
||||
session.commit()
|
||||
|
||||
def remove_all_tracks(self, session: Session) -> None:
|
||||
"""
|
||||
|
||||
@ -235,7 +235,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
"Can't close next track playlist", 5000)
|
||||
return
|
||||
# It's OK to close this playlist so remove from open playlist list
|
||||
self.tabPlaylist.widget(index).close()
|
||||
with Session() as session:
|
||||
self.tabPlaylist.widget(index).playlist.close(session)
|
||||
|
||||
# Close regardless of tab type
|
||||
self.tabPlaylist.removeTab(index)
|
||||
@ -515,10 +516,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.current_track = self.next_track
|
||||
self.next_track = None
|
||||
|
||||
# Ensure track is in session
|
||||
if self.current_track not in session:
|
||||
session.add(self.current_track)
|
||||
|
||||
# If current track on different playlist_tab to last, reset
|
||||
# last track playlist_tab colour
|
||||
# Set current track playlist_tab colour
|
||||
|
||||
@ -220,9 +220,8 @@ class PlaylistTab(QTableWidget):
|
||||
if row not in self._get_notes_rows():
|
||||
if not current and not next_row:
|
||||
act_setnext = self.menu.addAction("Set next")
|
||||
with Session() as session:
|
||||
act_setnext.triggered.connect(
|
||||
lambda: self._set_next(row, session))
|
||||
lambda: self._set_next(row))
|
||||
act_copypath = self.menu.addAction("Copy track path")
|
||||
act_copypath.triggered.connect(
|
||||
lambda: self._copy_path(row))
|
||||
@ -398,7 +397,7 @@ class PlaylistTab(QTableWidget):
|
||||
- Note start time
|
||||
- Mark next-track row as current
|
||||
- Mark current row as played
|
||||
- Scroll to put current track as required
|
||||
- Scroll to put current track in middle
|
||||
- Set next track
|
||||
- Update display
|
||||
"""
|
||||
@ -415,20 +414,15 @@ class PlaylistTab(QTableWidget):
|
||||
# Mark current row as played
|
||||
self._set_played_row(current_row)
|
||||
|
||||
# Scroll to put current track as requiredin middle We want this
|
||||
# row to be Config.SCROLL_TOP_MARGIN from the top. Rows number
|
||||
# from zero, so set (current_row - Config.SCROLL_TOP_MARGIN + 1)
|
||||
# row to be top row
|
||||
|
||||
top_row = max(0, current_row - Config.SCROLL_TOP_MARGIN + 1)
|
||||
scroll_item = self.item(top_row, self.COL_MSS)
|
||||
self.scrollToItem(scroll_item, QAbstractItemView.PositionAtTop)
|
||||
# Scroll to put current track in middle
|
||||
scroll_to = self.item(current_row, self.COL_MSS)
|
||||
self.scrollToItem(scroll_to, QAbstractItemView.PositionAtCenter)
|
||||
|
||||
# Set next track
|
||||
search_from = current_row + 1
|
||||
next_row = self._find_next_track_row(search_from)
|
||||
if next_row:
|
||||
self._set_next(next_row, session)
|
||||
self._set_next(next_row)
|
||||
|
||||
# Update display
|
||||
self.update_display(session)
|
||||
@ -642,8 +636,7 @@ class PlaylistTab(QTableWidget):
|
||||
if row is None:
|
||||
return None
|
||||
|
||||
with Session() as session:
|
||||
self._set_next(row, session)
|
||||
self._set_next(row)
|
||||
|
||||
def update_display(self, session, clear_selection: bool = True) -> None:
|
||||
"""
|
||||
@ -1405,7 +1398,7 @@ class PlaylistTab(QTableWidget):
|
||||
else:
|
||||
self.setColumnWidth(column, Config.DEFAULT_COLUMN_WIDTH)
|
||||
|
||||
def _set_next(self, row: int, session: Session) -> None:
|
||||
def _set_next(self, row: int) -> None:
|
||||
"""
|
||||
Set passed row as next track to play.
|
||||
|
||||
@ -1419,6 +1412,7 @@ class PlaylistTab(QTableWidget):
|
||||
|
||||
DEBUG(f"_set_next({row=})")
|
||||
|
||||
with Session() as session:
|
||||
# Check row is a track row
|
||||
if row in self._get_notes_rows():
|
||||
return None
|
||||
|
||||
@ -9,7 +9,7 @@ def test_init(qtbot, session):
|
||||
"""Just check we can create a playlist_tab"""
|
||||
|
||||
playlist = Playlists(session, "my playlist")
|
||||
playlist_tab = PlaylistTab(None, session, playlist.id)
|
||||
playlist_tab = PlaylistTab(None, session, playlist)
|
||||
assert playlist_tab
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ def test_save_and_restore(qtbot, session):
|
||||
|
||||
# Create playlist
|
||||
playlist = Playlists(session, "my playlist")
|
||||
playlist_tab = PlaylistTab(None, session, playlist.id)
|
||||
playlist_tab = PlaylistTab(None, session, playlist)
|
||||
|
||||
# Insert a note
|
||||
note_text = "my note"
|
||||
@ -46,7 +46,7 @@ def test_meta_all_clear(qtbot, session):
|
||||
|
||||
# Create playlist
|
||||
playlist = Playlists(session, "my playlist")
|
||||
playlist_tab = PlaylistTab(None, session, playlist.id)
|
||||
playlist_tab = PlaylistTab(None, session, playlist)
|
||||
|
||||
# Add some tracks
|
||||
track1_path = "/a/b/c"
|
||||
@ -70,7 +70,7 @@ def test_meta(qtbot, session):
|
||||
|
||||
# Create playlist
|
||||
playlist = Playlists(session, "my playlist")
|
||||
playlist_tab = PlaylistTab(None, session, playlist.id)
|
||||
playlist_tab = PlaylistTab(None, session, playlist)
|
||||
|
||||
# Add some tracks
|
||||
track1_path = "/a/b/c"
|
||||
@ -148,7 +148,7 @@ def test_meta(qtbot, session):
|
||||
def test_clear_next(qtbot, session):
|
||||
# Create playlist
|
||||
playlist = Playlists(session, "my playlist")
|
||||
playlist_tab = PlaylistTab(None, session, playlist.id)
|
||||
playlist_tab = PlaylistTab(None, session, playlist)
|
||||
|
||||
# Add some tracks
|
||||
track1_path = "/a/b/c"
|
||||
@ -169,7 +169,7 @@ def test_get_selected_row(qtbot, session):
|
||||
|
||||
# Create playlist
|
||||
playlist = Playlists(session, "my playlist")
|
||||
playlist_tab = PlaylistTab(None, session, playlist.id)
|
||||
playlist_tab = PlaylistTab(None, session, playlist)
|
||||
|
||||
# Add some tracks
|
||||
track1_path = "/a/b/c"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user