Improve open in / import from Audacity
This commit is contained in:
parent
f228a371f2
commit
74bdbe2975
@ -219,6 +219,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.active_proxy_model = lambda: self.tabPlaylist.currentWidget().model()
|
||||
self.move_source_rows: Optional[List[int]] = None
|
||||
self.move_source_model: Optional[PlaylistProxyModel] = None
|
||||
self.audacity_file_path: Optional[str] = None
|
||||
|
||||
if Config.CARTS_HIDE:
|
||||
self.cartsWidget.hide()
|
||||
|
||||
@ -346,12 +346,19 @@ class PlaylistTab(QTableView):
|
||||
track_row = not header_row
|
||||
current_row = model_row_number == track_sequence.now.plr_rownum
|
||||
next_row = model_row_number == track_sequence.next.plr_rownum
|
||||
track_path = self.source_model.get_row_info(model_row_number).path
|
||||
|
||||
# Open in Audacity
|
||||
# Open/import in/from Audacity
|
||||
if track_row and not current_row:
|
||||
self._add_context_menu(
|
||||
"Open in Audacity", lambda: self.open_in_audacity(model_row_number)
|
||||
)
|
||||
if track_path == self.musicmuster.audacity_file_path:
|
||||
# This track was opened in Audacity
|
||||
self._add_context_menu(
|
||||
"Update from Audacity", lambda: self._import_from_audacity(model_row_number)
|
||||
)
|
||||
else:
|
||||
self._add_context_menu(
|
||||
"Open in Audacity", lambda: self._open_in_audacity(model_row_number)
|
||||
)
|
||||
|
||||
# Rescan
|
||||
if track_row and not current_row:
|
||||
@ -536,6 +543,24 @@ class PlaylistTab(QTableView):
|
||||
)
|
||||
)
|
||||
|
||||
def _import_from_audacity(self, row_number: int) -> None:
|
||||
"""
|
||||
Import current Audacity track to passed row
|
||||
"""
|
||||
|
||||
# Notify user if audacity not running
|
||||
if "audacity" not in [i.name() for i in psutil.process_iter()]:
|
||||
show_warning(self.musicmuster, "Audacity", "Audacity is not running")
|
||||
return
|
||||
|
||||
audacity = self.audacity
|
||||
if not audacity:
|
||||
return
|
||||
|
||||
audacity.export_file()
|
||||
self.musicmuster.audacity_file_path = None
|
||||
self._rescan(row_number)
|
||||
|
||||
def _info_row(self, row_number: int) -> None:
|
||||
"""Display popup with info re row"""
|
||||
|
||||
@ -561,7 +586,7 @@ class PlaylistTab(QTableView):
|
||||
self.source_model.mark_unplayed(row_numbers)
|
||||
self.clear_selection()
|
||||
|
||||
def open_in_audacity(self, row_number: int) -> None:
|
||||
def _open_in_audacity(self, row_number: int) -> None:
|
||||
"""
|
||||
Open track in passed row in Audacity
|
||||
"""
|
||||
@ -575,15 +600,9 @@ class PlaylistTab(QTableView):
|
||||
if not path:
|
||||
return
|
||||
|
||||
audacity = AudacityManager()
|
||||
audacity.open_file(path)
|
||||
if ask_yes_no(
|
||||
"Export file",
|
||||
"Click yes to export file, no to ignore",
|
||||
parent=self.musicmuster,
|
||||
):
|
||||
audacity.export_file()
|
||||
self._rescan(row_number)
|
||||
self.musicmuster.audacity_file_path = path
|
||||
self.audacity = AudacityManager()
|
||||
self.audacity.open_file(path)
|
||||
|
||||
def _rescan(self, row_number: int) -> None:
|
||||
"""Rescan track"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user