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.active_proxy_model = lambda: self.tabPlaylist.currentWidget().model()
|
||||||
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
|
||||||
|
|
||||||
if Config.CARTS_HIDE:
|
if Config.CARTS_HIDE:
|
||||||
self.cartsWidget.hide()
|
self.cartsWidget.hide()
|
||||||
|
|||||||
@ -346,11 +346,18 @@ class PlaylistTab(QTableView):
|
|||||||
track_row = not header_row
|
track_row = not header_row
|
||||||
current_row = model_row_number == track_sequence.now.plr_rownum
|
current_row = model_row_number == track_sequence.now.plr_rownum
|
||||||
next_row = model_row_number == track_sequence.next.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:
|
if track_row and not current_row:
|
||||||
|
if track_path == self.musicmuster.audacity_file_path:
|
||||||
|
# This track was opened in Audacity
|
||||||
self._add_context_menu(
|
self._add_context_menu(
|
||||||
"Open in Audacity", lambda: self.open_in_audacity(model_row_number)
|
"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
|
# Rescan
|
||||||
@ -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:
|
def _info_row(self, row_number: int) -> None:
|
||||||
"""Display popup with info re row"""
|
"""Display popup with info re row"""
|
||||||
|
|
||||||
@ -561,7 +586,7 @@ class PlaylistTab(QTableView):
|
|||||||
self.source_model.mark_unplayed(row_numbers)
|
self.source_model.mark_unplayed(row_numbers)
|
||||||
self.clear_selection()
|
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
|
Open track in passed row in Audacity
|
||||||
"""
|
"""
|
||||||
@ -575,15 +600,9 @@ class PlaylistTab(QTableView):
|
|||||||
if not path:
|
if not path:
|
||||||
return
|
return
|
||||||
|
|
||||||
audacity = AudacityManager()
|
self.musicmuster.audacity_file_path = path
|
||||||
audacity.open_file(path)
|
self.audacity = AudacityManager()
|
||||||
if ask_yes_no(
|
self.audacity.open_file(path)
|
||||||
"Export file",
|
|
||||||
"Click yes to export file, no to ignore",
|
|
||||||
parent=self.musicmuster,
|
|
||||||
):
|
|
||||||
audacity.export_file()
|
|
||||||
self._rescan(row_number)
|
|
||||||
|
|
||||||
def _rescan(self, row_number: int) -> None:
|
def _rescan(self, row_number: int) -> None:
|
||||||
"""Rescan track"""
|
"""Rescan track"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user