WIP V3: info popup implemented
This commit is contained in:
parent
f4a374f68c
commit
4f4408400f
@ -507,6 +507,13 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return duration
|
return duration
|
||||||
|
|
||||||
|
def get_row_info(self, row_number: int) -> PlaylistRowData:
|
||||||
|
"""
|
||||||
|
Return info about passed row
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self.playlist_rows[row_number]
|
||||||
|
|
||||||
def headerData(
|
def headerData(
|
||||||
self,
|
self,
|
||||||
section: int,
|
section: int,
|
||||||
|
|||||||
@ -576,9 +576,9 @@ class PlaylistTab(QTableView):
|
|||||||
parent_menu=sort_menu,
|
parent_menu=sort_menu,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Info TODO
|
# Info
|
||||||
if track_row:
|
if track_row:
|
||||||
self._add_context_menu("Info", lambda: print("Track info"))
|
self._add_context_menu("Info", lambda: self._info_row(row_number))
|
||||||
|
|
||||||
# Track path TODO
|
# Track path TODO
|
||||||
if track_row:
|
if track_row:
|
||||||
@ -682,25 +682,23 @@ class PlaylistTab(QTableView):
|
|||||||
# items in that row selected)
|
# items in that row selected)
|
||||||
return sorted(list(set([a.row() for a in self.selectedIndexes()])))
|
return sorted(list(set([a.row() for a in self.selectedIndexes()])))
|
||||||
|
|
||||||
def _info_row(self, track_id: int) -> None:
|
def _info_row(self, row_number: int) -> None:
|
||||||
"""Display popup with info re row"""
|
"""Display popup with info re row"""
|
||||||
|
|
||||||
with Session() as session:
|
model = cast(PlaylistModel, self.model())
|
||||||
track = session.get(Tracks, track_id)
|
prd = model.get_row_info(row_number)
|
||||||
if track:
|
if prd:
|
||||||
txt = (
|
txt = (
|
||||||
f"Title: {track.title}\n"
|
f"Title: {prd.title}\n"
|
||||||
f"Artist: {track.artist}\n"
|
f"Artist: {prd.artist}\n"
|
||||||
f"Track ID: {track.id}\n"
|
f"Track ID: {prd.track_id}\n"
|
||||||
f"Track duration: {ms_to_mmss(track.duration)}\n"
|
f"Track duration: {ms_to_mmss(prd.duration)}\n"
|
||||||
f"Track bitrate: {track.bitrate}\n"
|
f"Track bitrate: {prd.bitrate}\n"
|
||||||
f"Track fade at: {ms_to_mmss(track.fade_at)}\n"
|
|
||||||
f"Track silence at: {ms_to_mmss(track.silence_at)}"
|
|
||||||
"\n\n"
|
"\n\n"
|
||||||
f"Path: {track.path}\n"
|
f"Path: {prd.path}\n"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
txt = f"Can't find {track_id=}"
|
txt = f"Can't find info about row{row_number}"
|
||||||
|
|
||||||
info: QMessageBox = QMessageBox(self)
|
info: QMessageBox = QMessageBox(self)
|
||||||
info.setIcon(QMessageBox.Icon.Information)
|
info.setIcon(QMessageBox.Icon.Information)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user