WIP V3: search wikipedia/songfacts from menu
This commit is contained in:
parent
4ca5eb24c3
commit
88e638a56e
@ -481,12 +481,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.actionRenamePlaylist.triggered.connect(self.rename_playlist)
|
||||
self.actionResume.triggered.connect(self.resume)
|
||||
self.actionSave_as_template.triggered.connect(self.save_as_template)
|
||||
self.actionSearch_title_in_Songfacts.triggered.connect(
|
||||
lambda: self.tabPlaylist.currentWidget().lookup_row_in_songfacts()
|
||||
)
|
||||
self.actionSearch_title_in_Wikipedia.triggered.connect(
|
||||
lambda: self.tabPlaylist.currentWidget().lookup_row_in_wikipedia()
|
||||
)
|
||||
self.actionSearch_title_in_Songfacts.triggered.connect(self.lookup_row_in_songfacts)
|
||||
self.actionSearch_title_in_Wikipedia.triggered.connect(self.lookup_row_in_wikipedia)
|
||||
self.actionSearch.triggered.connect(self.search_playlist)
|
||||
self.actionSelect_duplicate_rows.triggered.connect(
|
||||
lambda: self.active_tab().select_duplicate_rows()
|
||||
@ -839,6 +835,48 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
if record.f_int and record.f_int >= 0:
|
||||
self.tabPlaylist.setCurrentIndex(record.f_int)
|
||||
|
||||
def lookup_row_in_songfacts(self) -> None:
|
||||
"""
|
||||
Display songfacts page for title in highlighted row
|
||||
"""
|
||||
|
||||
row_number = self.active_tab().get_selected_row_number()
|
||||
if row_number is None:
|
||||
return
|
||||
|
||||
track_info = self.active_model().get_row_info(row_number)
|
||||
if track_info is None:
|
||||
return
|
||||
|
||||
# Populate infotab in a thread as it's slow
|
||||
QTimer.singleShot(
|
||||
0,
|
||||
lambda: self.tabInfolist.open_in_songfacts(
|
||||
track_info.title
|
||||
),
|
||||
)
|
||||
|
||||
def lookup_row_in_wikipedia(self) -> None:
|
||||
"""
|
||||
Display Wikipedia page for title in highlighted row
|
||||
"""
|
||||
|
||||
row_number = self.active_tab().get_selected_row_number()
|
||||
if row_number is None:
|
||||
return
|
||||
|
||||
track_info = self.active_model().get_row_info(row_number)
|
||||
if track_info is None:
|
||||
return
|
||||
|
||||
# Populate infotab in a thread as it's slow
|
||||
QTimer.singleShot(
|
||||
0,
|
||||
lambda: self.tabInfolist.open_in_wikipedia(
|
||||
track_info.title
|
||||
),
|
||||
)
|
||||
|
||||
def move_playlist_rows(
|
||||
self, session: scoped_session, playlistrows: Sequence[PlaylistRows]
|
||||
) -> None:
|
||||
|
||||
@ -472,7 +472,7 @@ class PlaylistTab(QTableView):
|
||||
Set selected row as next track
|
||||
"""
|
||||
|
||||
selected_row = self._get_selected_row()
|
||||
selected_row = self.get_selected_row_number()
|
||||
if selected_row is None:
|
||||
return
|
||||
model = cast(PlaylistModel, self.model())
|
||||
@ -663,18 +663,6 @@ class PlaylistTab(QTableView):
|
||||
model = cast(PlaylistModel, self.model())
|
||||
model.delete_rows(self._get_selected_rows())
|
||||
|
||||
def _get_selected_row(self) -> Optional[int]:
|
||||
"""
|
||||
Return row_number number of first selected row,
|
||||
or None if none selected
|
||||
"""
|
||||
|
||||
sm = self.selectionModel()
|
||||
if sm:
|
||||
if sm.hasSelection():
|
||||
return sm.selectedIndexes()[0].row()
|
||||
return None
|
||||
|
||||
def _get_selected_rows(self) -> List[int]:
|
||||
"""Return a list of selected row numbers sorted by row"""
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user