Compare commits
4 Commits
af6e0f69be
...
5d95748640
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d95748640 | ||
|
|
c511bf053e | ||
|
|
468ecda450 | ||
|
|
42676789c1 |
@ -226,12 +226,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.move_source_rows: Optional[List[int]] = None
|
self.move_source_rows: Optional[List[int]] = None
|
||||||
self.move_source_model: Optional[PlaylistProxyModel] = None
|
self.move_source_model: Optional[PlaylistProxyModel] = None
|
||||||
self.audacity_file_path: Optional[str] = None
|
self.audacity_file_path: Optional[str] = None
|
||||||
# Initialise Audacity access
|
self.audacity_client: Optional[pipeclient.PipeClient] = None
|
||||||
try:
|
self.initialise_audacity()
|
||||||
self.audacity_client = pipeclient.PipeClient()
|
|
||||||
log.info(f"{hex(id(self.audacity_client))=}")
|
|
||||||
except RuntimeError as e:
|
|
||||||
log.error(f"Unable to initialise Audacity: {str(e)}")
|
|
||||||
|
|
||||||
if Config.CARTS_HIDE:
|
if Config.CARTS_HIDE:
|
||||||
self.cartsWidget.hide()
|
self.cartsWidget.hide()
|
||||||
@ -865,6 +861,17 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.import_thread.finished.connect(self.import_thread.deleteLater)
|
self.import_thread.finished.connect(self.import_thread.deleteLater)
|
||||||
self.import_thread.start()
|
self.import_thread.start()
|
||||||
|
|
||||||
|
def initialise_audacity(self) -> None:
|
||||||
|
"""
|
||||||
|
Initialise access to audacity
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.audacity_client = pipeclient.PipeClient()
|
||||||
|
log.info(f"{hex(id(self.audacity_client))=}")
|
||||||
|
except RuntimeError as e:
|
||||||
|
log.error(f"Unable to initialise Audacity: {str(e)}")
|
||||||
|
|
||||||
def insert_header(self) -> None:
|
def insert_header(self) -> None:
|
||||||
"""Show dialog box to enter header text and add to playlist"""
|
"""Show dialog box to enter header text and add to playlist"""
|
||||||
|
|
||||||
|
|||||||
@ -370,11 +370,15 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
with Session() as session:
|
with Session() as session:
|
||||||
for row_number in row_numbers:
|
for row_number in row_numbers:
|
||||||
super().beginRemoveRows(QModelIndex(), row_number, row_number)
|
super().beginRemoveRows(QModelIndex(), row_number, row_number)
|
||||||
|
# We need to remove data from the underlying data store,
|
||||||
|
# which is the database, but we cache in
|
||||||
|
# self.playlist_rows, which is what calls to data()
|
||||||
|
# reads, so fixup that too.
|
||||||
PlaylistRows.delete_row(session, self.playlist_id, row_number)
|
PlaylistRows.delete_row(session, self.playlist_id, row_number)
|
||||||
super().endRemoveRows()
|
|
||||||
|
|
||||||
PlaylistRows.fixup_rownumbers(session, self.playlist_id)
|
PlaylistRows.fixup_rownumbers(session, self.playlist_id)
|
||||||
self.refresh_data(session)
|
self.refresh_data(session)
|
||||||
|
super().endRemoveRows()
|
||||||
|
|
||||||
self.reset_track_sequence_row_numbers()
|
self.reset_track_sequence_row_numbers()
|
||||||
|
|
||||||
def display_role(self, row: int, column: int, prd: PlaylistRowData) -> QVariant:
|
def display_role(self, row: int, column: int, prd: PlaylistRowData) -> QVariant:
|
||||||
@ -570,7 +574,11 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
Return a list of unplayed row numbers
|
Return a list of unplayed row numbers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result = [a.plr_rownum for a in self.playlist_rows.values() if not a.played]
|
result = [
|
||||||
|
a.plr_rownum
|
||||||
|
for a in self.playlist_rows.values()
|
||||||
|
if not a.played and a.track_id is not None
|
||||||
|
]
|
||||||
log.info(f"get_unplayed_rows() returned: {result=}")
|
log.info(f"get_unplayed_rows() returned: {result=}")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -1418,7 +1426,7 @@ class PlaylistProxyModel(QSortFilterProxyModel):
|
|||||||
self.setFilterKeyColumn(-1)
|
self.setFilterKeyColumn(-1)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return (f"<PlaylistProxyModel: source_model={self.source_model}>")
|
return f"<PlaylistProxyModel: source_model={self.source_model}>"
|
||||||
|
|
||||||
def filterAcceptsRow(self, source_row: int, source_parent: QModelIndex) -> bool:
|
def filterAcceptsRow(self, source_row: int, source_parent: QModelIndex) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -209,10 +209,6 @@ class PlaylistTab(QTableView):
|
|||||||
h_header.sectionResized.connect(self._column_resize)
|
h_header.sectionResized.connect(self._column_resize)
|
||||||
h_header.setStretchLastSection(True)
|
h_header.setStretchLastSection(True)
|
||||||
# Setting ResizeToContents causes screen flash on load
|
# Setting ResizeToContents causes screen flash on load
|
||||||
# v_header = self.verticalHeader()
|
|
||||||
# if v_header:
|
|
||||||
# print("HEADER")
|
|
||||||
# v_header.setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
|
|
||||||
QTimer.singleShot(300, self.resizeRowsToContents)
|
QTimer.singleShot(300, self.resizeRowsToContents)
|
||||||
|
|
||||||
# ########## Overridden class functions ##########
|
# ########## Overridden class functions ##########
|
||||||
@ -362,6 +358,12 @@ class PlaylistTab(QTableView):
|
|||||||
show_warning(self.musicmuster, "Audacity", "Audacity is not running")
|
show_warning(self.musicmuster, "Audacity", "Audacity is not running")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if not self.musicmuster.audacity_client:
|
||||||
|
self.musicmuster.initialise_audacity()
|
||||||
|
if not self.musicmuster.audacity_client:
|
||||||
|
log.error("Unable to access Audacity client")
|
||||||
|
return False
|
||||||
|
|
||||||
self.musicmuster.audacity_client.write(cmd, timer=True)
|
self.musicmuster.audacity_client.write(cmd, timer=True)
|
||||||
|
|
||||||
reply = ""
|
reply = ""
|
||||||
@ -675,15 +677,19 @@ class PlaylistTab(QTableView):
|
|||||||
Open track in passed row in Audacity
|
Open track in passed row in Audacity
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not self.musicmuster.audacity_client:
|
||||||
|
self.musicmuster.initialise_audacity()
|
||||||
|
|
||||||
path = self.source_model.get_row_track_path(row_number)
|
path = self.source_model.get_row_track_path(row_number)
|
||||||
if not path:
|
if not path:
|
||||||
log.error(f"_open_in_audacity: can't get path for {row_number=}")
|
log.error(f"_open_in_audacity: can't get path for {row_number=}")
|
||||||
return
|
return
|
||||||
|
|
||||||
self.musicmuster.audacity_file_path = path
|
|
||||||
escaped_path = path.replace('"', '\\"')
|
escaped_path = path.replace('"', '\\"')
|
||||||
cmd = f'Import2: Filename="{escaped_path}"'
|
cmd = f'Import2: Filename="{escaped_path}"'
|
||||||
status = self._audactity_command(cmd)
|
status = self._audactity_command(cmd)
|
||||||
|
if status:
|
||||||
|
self.musicmuster.audacity_file_path = path
|
||||||
|
|
||||||
log.info(f"_open_in_audacity {path=}, {status=}")
|
log.info(f"_open_in_audacity {path=}, {status=}")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user