From 5783da051e8a4c09c3adf4b64eed4f4d80f58e22 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Fri, 7 Oct 2022 10:03:50 +0100 Subject: [PATCH] Add debug statements for scroll to next/current --- app/musicmuster.py | 2 ++ app/playlists.py | 4 ++++ test.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100755 test.py diff --git a/app/musicmuster.py b/app/musicmuster.py index 1eeb413..c25dde6 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -834,6 +834,7 @@ class Window(QMainWindow, Ui_MainWindow): def show_current(self) -> None: """Scroll to show current track""" + log.debug(f"musicmuster.show_current()") if self.current_track_playlist_tab != self.visible_playlist_tab: self.tabPlaylist.setCurrentWidget(self.current_track_playlist_tab) self.tabPlaylist.currentWidget().scroll_current_to_top() @@ -841,6 +842,7 @@ class Window(QMainWindow, Ui_MainWindow): def show_next(self) -> None: """Scroll to show next track""" + log.debug(f"musicmuster.show_next()") if self.next_track_playlist_tab != self.visible_playlist_tab: self.tabPlaylist.setCurrentWidget(self.next_track_playlist_tab) self.tabPlaylist.currentWidget().scroll_next_to_top() diff --git a/app/playlists.py b/app/playlists.py index bff9f72..48279d5 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -823,13 +823,17 @@ class PlaylistTab(QTableWidget): def scroll_current_to_top(self) -> None: """Scroll currently-playing row to top""" + log.debug("playlists.scroll_current_to_top()") current_row = self._get_current_track_row() + log.debug(f"playlists.scroll_current_to_top(), {current_row=}") self._scroll_to_top(current_row) def scroll_next_to_top(self) -> None: """Scroll nextly-playing row to top""" + log.debug("playlists.scroll_next_to_top()") next_row = self._get_next_track_row() + log.debug(f"playlists.scroll_next_to_top(), {next_row=}") self._scroll_to_top(next_row) def set_search(self, text: str) -> None: diff --git a/test.py b/test.py new file mode 100755 index 0000000..5840871 --- /dev/null +++ b/test.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +from PyQt5 import QtGui, QtWidgets + +class TabBar(QtWidgets.QTabWidget): + def paintEvent(self, event): + painter = QtGui.QStylePainter(self) + option = QtGui.QStyleOptionTab() + for index in range(self.count()): + self.initStyleOption(option, index) + bgcolor = QtGui.QColor(self.tabText(index)) + option.palette.setColor(QtGui.QPalette.Window, bgcolor) + painter.drawControl(QtGui.QStyle.CE_TabBarTabShape, option) + painter.drawControl(QtGui.QStyle.CE_TabBarTabLabel, option) + +class Window(QtWidgets.QTabWidget): + def __init__(self): + QtGui.QTabWidget.__init__(self) + self.setTabBar(TabBar(self)) + for color in 'tomato orange yellow lightgreen skyblue plum'.split(): + self.addTab(QtGui.QWidget(self), color) + +if __name__ == '__main__': + + import sys + app = QtGui.QApplication(sys.argv) + window = Window() + window.resize(420, 200) + window.show() + sys.exit(app.exec_())