Set colours of tabs correctly.
This commit is contained in:
parent
4edcab1542
commit
74028fadf7
@ -1054,14 +1054,17 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
if self.current_track.playlist_tab != self.next_track.playlist_tab:
|
if self.current_track.playlist_tab != self.next_track.playlist_tab:
|
||||||
self.set_tab_colour(self.current_track.playlist_tab,
|
self.set_tab_colour(self.current_track.playlist_tab,
|
||||||
QColor(Config.COLOUR_NORMAL_TAB))
|
QColor(Config.COLOUR_NORMAL_TAB))
|
||||||
# Set current track playlist_tab colour
|
|
||||||
self.set_tab_colour(self.current_track.playlist_tab,
|
|
||||||
QColor(Config.COLOUR_CURRENT_TAB))
|
|
||||||
|
|
||||||
# Move next track to current track.
|
# Move next track to current track.
|
||||||
|
# stop_playing() above has called end_of_track_actions()
|
||||||
|
# which will have populated self.previous_track
|
||||||
self.current_track = self.next_track
|
self.current_track = self.next_track
|
||||||
self.next_track = PlaylistTrack()
|
self.next_track = PlaylistTrack()
|
||||||
|
|
||||||
|
# Set current track playlist_tab colour
|
||||||
|
self.set_tab_colour(self.current_track.playlist_tab,
|
||||||
|
QColor(Config.COLOUR_CURRENT_TAB))
|
||||||
|
|
||||||
# Restore volume if -3dB active
|
# Restore volume if -3dB active
|
||||||
if self.btnDrop3db.isChecked():
|
if self.btnDrop3db.isChecked():
|
||||||
self.btnDrop3db.setChecked(False)
|
self.btnDrop3db.setChecked(False)
|
||||||
@ -1232,7 +1235,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
"""Scroll to show current track"""
|
"""Scroll to show current track"""
|
||||||
|
|
||||||
if self.current_track.playlist_tab != self.visible_playlist_tab():
|
if self.current_track.playlist_tab != self.visible_playlist_tab():
|
||||||
self.tabPlaylist.setCurrentWidget(self.current.track_playlist_tab)
|
self.tabPlaylist.setCurrentWidget(self.current_track.playlist_tab)
|
||||||
self.tabPlaylist.currentWidget().scroll_current_to_top()
|
self.tabPlaylist.currentWidget().scroll_current_to_top()
|
||||||
|
|
||||||
def show_next(self) -> None:
|
def show_next(self) -> None:
|
||||||
@ -1320,16 +1323,36 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Clear next track if on another tab
|
if plr.track_id is None:
|
||||||
if self.next_track.playlist_tab and (
|
return
|
||||||
self.next_track.playlist_tab != playlist_tab):
|
|
||||||
# Repaint ex-next track playlist to remove highlighting
|
# Clean up if we are replacing an existing "next track"
|
||||||
self.next_track.playlist_tab.update_display(session)
|
original_next_track_playlist_tab = None
|
||||||
|
if (
|
||||||
|
# If we already have a next tab lined up and it's neither
|
||||||
|
# the "new" next tab nor the current track tab then we need
|
||||||
|
# to reset the tab colour.
|
||||||
|
self.next_track.playlist_tab and
|
||||||
|
self.next_track.playlist_tab != playlist_tab and
|
||||||
|
self.next_track.playlist_tab != self.current_track.playlist_tab
|
||||||
|
):
|
||||||
|
original_next_track_playlist_tab = self.next_track.playlist_tab
|
||||||
|
self.set_tab_colour(self.next_track.playlist_tab,
|
||||||
|
QColor(Config.COLOUR_NORMAL_TAB))
|
||||||
|
|
||||||
# Discard now-incorrect next_track PlaylistTrack
|
# Discard now-incorrect next_track PlaylistTrack
|
||||||
self.next_track = PlaylistTrack()
|
self.next_track = PlaylistTrack()
|
||||||
|
|
||||||
self.next_track.set_plr(session, plr, playlist_tab)
|
self.next_track.set_plr(session, plr, playlist_tab)
|
||||||
self.next_track.playlist_tab.update_display(session)
|
self.next_track.playlist_tab.update_display(session)
|
||||||
|
if self.current_track.playlist_tab != self.next_track.playlist_tab:
|
||||||
|
self.set_tab_colour(self.next_track.playlist_tab,
|
||||||
|
QColor(Config.COLOUR_NEXT_TAB))
|
||||||
|
|
||||||
|
# If we've changed playlist tabs for next track, refresh old one
|
||||||
|
# to remove highligting of next track
|
||||||
|
if original_next_track_playlist_tab:
|
||||||
|
original_next_track_playlist_tab.update_display(session)
|
||||||
|
|
||||||
# Populate footer if we're not currently playing
|
# Populate footer if we're not currently playing
|
||||||
if not self.playing and self.next_track.track_id:
|
if not self.playing and self.next_track.track_id:
|
||||||
|
|||||||
@ -938,6 +938,8 @@ class PlaylistTab(QTableWidget):
|
|||||||
# Set row heights
|
# Set row heights
|
||||||
self.resizeRowsToContents()
|
self.resizeRowsToContents()
|
||||||
self.setColumnWidth(len(columns) - 1, 0)
|
self.setColumnWidth(len(columns) - 1, 0)
|
||||||
|
with Session() as session:
|
||||||
|
self.update_display(session)
|
||||||
|
|
||||||
def update_display(self, session: Session) -> None:
|
def update_display(self, session: Session) -> None:
|
||||||
"""
|
"""
|
||||||
@ -1299,12 +1301,24 @@ class PlaylistTab(QTableWidget):
|
|||||||
def _get_current_track_row_number(self) -> Optional[int]:
|
def _get_current_track_row_number(self) -> Optional[int]:
|
||||||
"""Return current track row or None"""
|
"""Return current track row or None"""
|
||||||
|
|
||||||
return self.musicmuster.current_track.row_number
|
current_track = self.musicmuster.current_track
|
||||||
|
if not current_track.track_id:
|
||||||
|
return None
|
||||||
|
if current_track.playlist_tab == self:
|
||||||
|
return current_track.row_number
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def _get_next_track_row_number(self) -> Optional[int]:
|
def _get_next_track_row_number(self) -> Optional[int]:
|
||||||
"""Return next track row or None"""
|
"""Return next track row or None"""
|
||||||
|
|
||||||
return self.musicmuster.next_track.row_number
|
next_track = self.musicmuster.next_track
|
||||||
|
if not next_track.track_id:
|
||||||
|
return None
|
||||||
|
if next_track.playlist_tab == self:
|
||||||
|
return next_track.row_number
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_note_text_time(text: str) -> Optional[datetime]:
|
def _get_note_text_time(text: str) -> Optional[datetime]:
|
||||||
@ -1501,19 +1515,6 @@ class PlaylistTab(QTableWidget):
|
|||||||
)
|
)
|
||||||
raise AttributeError(f"Multiple '{metadata}' metadata {matches}")
|
raise AttributeError(f"Multiple '{metadata}' metadata {matches}")
|
||||||
|
|
||||||
def _meta_set_attribute(self, row: int, attribute: int) -> None:
|
|
||||||
"""Set row metadata"""
|
|
||||||
|
|
||||||
if row is None:
|
|
||||||
raise ValueError(f"_meta_set_attribute({row=}, {attribute=})")
|
|
||||||
|
|
||||||
current_metadata: int = self._meta_get(row)
|
|
||||||
if not current_metadata:
|
|
||||||
new_metadata: int = (1 << attribute)
|
|
||||||
else:
|
|
||||||
new_metadata = self._meta_get(row) | (1 << attribute)
|
|
||||||
self.item(row, USERDATA).setData(self.ROW_FLAGS, new_metadata)
|
|
||||||
|
|
||||||
def _move_row(self, session: Session, plr: PlaylistRows,
|
def _move_row(self, session: Session, plr: PlaylistRows,
|
||||||
new_row_number: int) -> None:
|
new_row_number: int) -> None:
|
||||||
"""Move playlist row to new_row_number using parent copy/paste"""
|
"""Move playlist row to new_row_number using parent copy/paste"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user