Add total time of selected tracks to status bar
This commit is contained in:
parent
7ed7730574
commit
762a41bec6
@ -71,6 +71,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
self.menuTest.menuAction().setVisible(Config.TESTMODE)
|
self.menuTest.menuAction().setVisible(Config.TESTMODE)
|
||||||
self.set_main_window_size()
|
self.set_main_window_size()
|
||||||
|
self.lblSumPlaytime = QLabel("")
|
||||||
|
self.statusbar.addPermanentWidget(self.lblSumPlaytime)
|
||||||
|
|
||||||
self.visible_playlist_tab = self.tabPlaylist.currentWidget
|
self.visible_playlist_tab = self.tabPlaylist.currentWidget
|
||||||
|
|
||||||
|
|||||||
@ -89,6 +89,8 @@ class PlaylistTab(QTableWidget):
|
|||||||
self.customContextMenuRequested.connect(self._context_menu)
|
self.customContextMenuRequested.connect(self._context_menu)
|
||||||
self.viewport().installEventFilter(self)
|
self.viewport().installEventFilter(self)
|
||||||
|
|
||||||
|
self.itemSelectionChanged.connect(self._select_event)
|
||||||
|
|
||||||
self.current_track_start_time = None
|
self.current_track_start_time = None
|
||||||
self.played_tracks = []
|
self.played_tracks = []
|
||||||
|
|
||||||
@ -1001,8 +1003,29 @@ class PlaylistTab(QTableWidget):
|
|||||||
PlaylistTracks.add_track(
|
PlaylistTracks.add_track(
|
||||||
session, self.id, self._get_row_id(row), row)
|
session, self.id, self._get_row_id(row), row)
|
||||||
|
|
||||||
def _set_column_widths(self):
|
def _select_event(self):
|
||||||
|
"""
|
||||||
|
Called when item selection changes.
|
||||||
|
If multiple rows are selected, display sum of durations in status bar.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Clear label
|
||||||
|
self.master_process.lblSumPlaytime.setText("")
|
||||||
|
|
||||||
|
rows = set([item.row() for item in self.selectedItems()])
|
||||||
|
notes = self._meta_get_notes()
|
||||||
|
ms = 0
|
||||||
|
with Session() as session:
|
||||||
|
for row in rows:
|
||||||
|
if row in notes:
|
||||||
|
continue
|
||||||
|
ms += Tracks.get_duration(session, self._get_row_id(row))
|
||||||
|
# Only paint message if there are selected track rows
|
||||||
|
if ms > 0:
|
||||||
|
self.master_process.lblSumPlaytime.setText(
|
||||||
|
f"Selected duration: {helpers.ms_to_mmss(ms)}")
|
||||||
|
|
||||||
|
def _set_column_widths(self):
|
||||||
# Column widths from settings
|
# Column widths from settings
|
||||||
with Session() as session:
|
with Session() as session:
|
||||||
for column in range(self.columnCount()):
|
for column in range(self.columnCount()):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user