Pull in recent V3 updates
This commit is contained in:
parent
e4a9520908
commit
2e8fae99ed
@ -183,14 +183,19 @@ class PlaylistTrack:
|
|||||||
Called when track starts playing
|
Called when track starts playing
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.start_time = dt.datetime.now()
|
now = dt.datetime.now()
|
||||||
|
self.start_time = now
|
||||||
if self.duration:
|
if self.duration:
|
||||||
self.end_time = self.start_time + dt.timedelta(milliseconds=self.duration)
|
self.end_time = self.start_time + dt.timedelta(milliseconds=self.duration)
|
||||||
|
|
||||||
# Calculate time fade_graph should start updating
|
# Calculate time fade_graph should start updating
|
||||||
if self.fade_at:
|
if self.fade_at:
|
||||||
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 + 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
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AddFadeCurve(QObject):
|
class AddFadeCurve(QObject):
|
||||||
|
|||||||
@ -1,17 +1,15 @@
|
|||||||
# Standard library imports
|
# Standard library imports
|
||||||
|
|
||||||
# PyQt imports
|
|
||||||
|
|
||||||
# Third party imports
|
|
||||||
|
|
||||||
# App imports
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
# PyQt imports
|
||||||
from PyQt6.QtCore import QEvent, Qt
|
from PyQt6.QtCore import QEvent, Qt
|
||||||
from PyQt6.QtWidgets import QDialog, QListWidgetItem
|
from PyQt6.QtWidgets import QDialog, QListWidgetItem
|
||||||
|
|
||||||
|
# Third party imports
|
||||||
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
|
# App imports
|
||||||
from classes import MusicMusterSignals
|
from classes import MusicMusterSignals
|
||||||
from sqlalchemy.orm import scoped_session
|
|
||||||
from helpers import (
|
from helpers import (
|
||||||
ask_yes_no,
|
ask_yes_no,
|
||||||
get_relative_date,
|
get_relative_date,
|
||||||
@ -28,7 +26,7 @@ class TrackSelectDialog(QDialog):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
session: scoped_session,
|
session: Session,
|
||||||
new_row_number: int,
|
new_row_number: int,
|
||||||
source_model: PlaylistModel,
|
source_model: PlaylistModel,
|
||||||
add_to_header: Optional[bool] = False,
|
add_to_header: Optional[bool] = False,
|
||||||
|
|||||||
@ -48,7 +48,7 @@ from PyQt6.QtWidgets import (
|
|||||||
# Third party imports
|
# Third party imports
|
||||||
from pygame import mixer
|
from pygame import mixer
|
||||||
import pipeclient
|
import pipeclient
|
||||||
from sqlalchemy.orm import scoped_session
|
from sqlalchemy.orm.session import Session
|
||||||
import stackprinter # type: ignore
|
import stackprinter # type: ignore
|
||||||
|
|
||||||
# App imports
|
# App imports
|
||||||
@ -562,7 +562,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.timer1000.timeout.connect(self.tick_1000ms)
|
self.timer1000.timeout.connect(self.tick_1000ms)
|
||||||
|
|
||||||
def create_playlist(
|
def create_playlist(
|
||||||
self, session: scoped_session, playlist_name: Optional[str] = None
|
self, session: Session, playlist_name: Optional[str] = None
|
||||||
) -> Optional[Playlists]:
|
) -> Optional[Playlists]:
|
||||||
"""Create new playlist"""
|
"""Create new playlist"""
|
||||||
|
|
||||||
@ -1405,7 +1405,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.tabPlaylist.currentWidget().scroll_to_top(display_row)
|
self.tabPlaylist.currentWidget().scroll_to_top(display_row)
|
||||||
|
|
||||||
def solicit_playlist_name(
|
def solicit_playlist_name(
|
||||||
self, session: scoped_session, default: str = ""
|
self, session: Session, default: str = ""
|
||||||
) -> Optional[str]:
|
) -> Optional[str]:
|
||||||
"""Get name of new playlist from user"""
|
"""Get name of new playlist from user"""
|
||||||
|
|
||||||
@ -1508,7 +1508,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# Update volume fade curve
|
# Update volume fade curve
|
||||||
if (
|
if (
|
||||||
track_sequence.now.fade_graph_start_updates is None
|
track_sequence.now.fade_graph_start_updates is None
|
||||||
or track_sequence.now.fade_graph_start_updates > datetime.now()
|
or track_sequence.now.fade_graph_start_updates > dt.datetime.now()
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1640,7 +1640,7 @@ class CartDialog(QDialog):
|
|||||||
"""Edit cart details"""
|
"""Edit cart details"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, musicmuster: Window, session: scoped_session, cart: Carts, *args, **kwargs
|
self, musicmuster: Window, session: Session, cart: Carts, *args, **kwargs
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Manage carts
|
Manage carts
|
||||||
|
|||||||
@ -160,7 +160,7 @@ class PipeClient:
|
|||||||
|
|
||||||
def _write_pipe_open(self) -> None:
|
def _write_pipe_open(self) -> None:
|
||||||
"""Open _write_pipe."""
|
"""Open _write_pipe."""
|
||||||
self._write_pipe = open(WRITE_NAME, 'w')
|
self._write_pipe = open(WRITE_NAME, "w")
|
||||||
|
|
||||||
def _read_thread_start(self) -> None:
|
def _read_thread_start(self) -> None:
|
||||||
"""Start read_pipe thread."""
|
"""Start read_pipe thread."""
|
||||||
@ -204,8 +204,8 @@ class PipeClient:
|
|||||||
"""Read FIFO in worker thread."""
|
"""Read FIFO in worker thread."""
|
||||||
# Thread will wait at this read until it connects.
|
# Thread will wait at this read until it connects.
|
||||||
# Connection should occur as soon as _write_pipe has connected.
|
# Connection should occur as soon as _write_pipe has connected.
|
||||||
with open(READ_NAME, 'r') as read_pipe:
|
with open(READ_NAME, "r") as read_pipe:
|
||||||
message = ''
|
message = ""
|
||||||
pipe_ok = True
|
pipe_ok = True
|
||||||
while pipe_ok:
|
while pipe_ok:
|
||||||
line = read_pipe.readline()
|
line = read_pipe.readline()
|
||||||
|
|||||||
@ -1569,7 +1569,7 @@ class PlaylistProxyModel(QSortFilterProxyModel):
|
|||||||
self,
|
self,
|
||||||
proposed_row_number: Optional[int],
|
proposed_row_number: Optional[int],
|
||||||
track_id: Optional[int] = None,
|
track_id: Optional[int] = None,
|
||||||
note: Optional[str] = None,
|
note: str = "",
|
||||||
) -> None:
|
) -> None:
|
||||||
return self.source_model.insert_row(proposed_row_number, track_id, note)
|
return self.source_model.insert_row(proposed_row_number, track_id, note)
|
||||||
|
|
||||||
|
|||||||
@ -79,12 +79,13 @@ class TestMMMiscTracks(unittest.TestCase):
|
|||||||
self.model.insert_row(proposed_row_number=END_ROW, note="-")
|
self.model.insert_row(proposed_row_number=END_ROW, note="-")
|
||||||
|
|
||||||
prd = self.model.playlist_rows[START_ROW]
|
prd = self.model.playlist_rows[START_ROW]
|
||||||
qv_value = self.model.display_role(START_ROW, playlistmodel.HEADER_NOTES_COLUMN, prd)
|
qv_value = self.model.display_role(
|
||||||
|
START_ROW, playlistmodel.HEADER_NOTES_COLUMN, prd
|
||||||
|
)
|
||||||
assert qv_value.value() == "start [1 tracks, 4:23 unplayed]"
|
assert qv_value.value() == "start [1 tracks, 4:23 unplayed]"
|
||||||
|
|
||||||
|
|
||||||
class TestMMMiscNoPlaylist(unittest.TestCase):
|
class TestMMMiscNoPlaylist(unittest.TestCase):
|
||||||
|
|
||||||
PLAYLIST_NAME = "tracks playlist"
|
PLAYLIST_NAME = "tracks playlist"
|
||||||
test_tracks = [
|
test_tracks = [
|
||||||
"testdata/isa.mp3",
|
"testdata/isa.mp3",
|
||||||
@ -121,10 +122,13 @@ class TestMMMiscNoPlaylist(unittest.TestCase):
|
|||||||
_ = str(prd)
|
_ = str(prd)
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
model.edit_role(model.rowCount() - 1, playlistmodel.Col.TITLE.value, prd)
|
model.edit_role(
|
||||||
|
model.rowCount() - 1, playlistmodel.Col.TITLE.value, prd
|
||||||
|
)
|
||||||
== metadata["title"]
|
== metadata["title"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestMMMiscRowMove(unittest.TestCase):
|
class TestMMMiscRowMove(unittest.TestCase):
|
||||||
PLAYLIST_NAME = "rowmove playlist"
|
PLAYLIST_NAME = "rowmove playlist"
|
||||||
ROWS_TO_CREATE = 11
|
ROWS_TO_CREATE = 11
|
||||||
@ -292,7 +296,6 @@ class TestMMMiscRowMove(unittest.TestCase):
|
|||||||
self.model.add_track_to_header(insert_row, prd.track_id)
|
self.model.add_track_to_header(insert_row, prd.track_id)
|
||||||
|
|
||||||
def test_reverse_row_groups_one_row(self):
|
def test_reverse_row_groups_one_row(self):
|
||||||
|
|
||||||
rows_to_move = [3]
|
rows_to_move = [3]
|
||||||
|
|
||||||
result = self.model._reversed_contiguous_row_groups(rows_to_move)
|
result = self.model._reversed_contiguous_row_groups(rows_to_move)
|
||||||
@ -301,7 +304,6 @@ class TestMMMiscRowMove(unittest.TestCase):
|
|||||||
assert result[0] == [3]
|
assert result[0] == [3]
|
||||||
|
|
||||||
def test_reverse_row_groups_multiple_row(self):
|
def test_reverse_row_groups_multiple_row(self):
|
||||||
|
|
||||||
rows_to_move = [2, 3, 4, 5, 7, 9, 10, 13, 17, 20, 21]
|
rows_to_move = [2, 3, 4, 5, 7, 9, 10, 13, 17, 20, 21]
|
||||||
|
|
||||||
result = self.model._reversed_contiguous_row_groups(rows_to_move)
|
result = self.model._reversed_contiguous_row_groups(rows_to_move)
|
||||||
@ -357,7 +359,6 @@ class TestMMMiscRowMove(unittest.TestCase):
|
|||||||
assert [int(a) for a in row_notes] == [0, 1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
assert [int(a) for a in row_notes] == [0, 1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||||
|
|
||||||
def test_move_multiple_rows_between_playlists_to_end(self):
|
def test_move_multiple_rows_between_playlists_to_end(self):
|
||||||
|
|
||||||
from_rows = [1, 3, 4]
|
from_rows = [1, 3, 4]
|
||||||
to_row = 2
|
to_row = 2
|
||||||
destination_playlist = "destination"
|
destination_playlist = "destination"
|
||||||
@ -382,7 +383,22 @@ class TestMMMiscRowMove(unittest.TestCase):
|
|||||||
|
|
||||||
assert len(model_src.playlist_rows) == self.ROWS_TO_CREATE - len(from_rows)
|
assert len(model_src.playlist_rows) == self.ROWS_TO_CREATE - len(from_rows)
|
||||||
assert len(model_dst.playlist_rows) == self.ROWS_TO_CREATE + len(from_rows)
|
assert len(model_dst.playlist_rows) == self.ROWS_TO_CREATE + len(from_rows)
|
||||||
assert [int(a) for a in row_notes] == [0, 1, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
assert [int(a) for a in row_notes] == [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
# # def test_edit_header(monkeypatch, session): # edit header row in middle of playlist
|
# # def test_edit_header(monkeypatch, session): # edit header row in middle of playlist
|
||||||
|
|||||||
@ -41,13 +41,14 @@ def qtbot_adapter(qapp, request):
|
|||||||
# Wrapper to handle setup/teardown operations
|
# Wrapper to handle setup/teardown operations
|
||||||
def with_updown(function):
|
def with_updown(function):
|
||||||
def test_wrapper(self, *args, **kwargs):
|
def test_wrapper(self, *args, **kwargs):
|
||||||
if callable(getattr(self, 'up', None)):
|
if callable(getattr(self, "up", None)):
|
||||||
self.up()
|
self.up()
|
||||||
try:
|
try:
|
||||||
function(self, *args, **kwargs)
|
function(self, *args, **kwargs)
|
||||||
finally:
|
finally:
|
||||||
if callable(getattr(self, 'down', None)):
|
if callable(getattr(self, "down", None)):
|
||||||
self.down()
|
self.down()
|
||||||
|
|
||||||
test_wrapper.__doc__ = function.__doc__
|
test_wrapper.__doc__ = function.__doc__
|
||||||
return test_wrapper
|
return test_wrapper
|
||||||
|
|
||||||
@ -103,12 +104,11 @@ class MyTestCase(unittest.TestCase):
|
|||||||
# },
|
# },
|
||||||
# ]
|
# ]
|
||||||
|
|
||||||
# for track in tracks:
|
# for track in tracks:
|
||||||
# db_track = models.Tracks(session=session, **track)
|
# db_track = models.Tracks(session=session, **track)
|
||||||
# session.add(db_track)
|
# session.add(db_track)
|
||||||
|
|
||||||
# session.commit()
|
|
||||||
|
|
||||||
|
# session.commit()
|
||||||
|
|
||||||
|
|
||||||
# def test_save_and_restore(qtbot, session):
|
# def test_save_and_restore(qtbot, session):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user