Compare commits
No commits in common. "bf67866f8a21f4f8943ef6dd076256298547dda6" and "3528b5817446894c750cd0179ccdb77eb03046c3" have entirely different histories.
bf67866f8a
...
3528b58174
@ -260,7 +260,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
def debug(self):
|
||||
"""Invoke debugger"""
|
||||
|
||||
import ipdb # type: ignore
|
||||
import ipdb
|
||||
ipdb.set_trace()
|
||||
|
||||
def disable_play_next_controls(self) -> None:
|
||||
@ -834,7 +834,6 @@ 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()
|
||||
@ -842,7 +841,6 @@ 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()
|
||||
|
||||
@ -415,7 +415,7 @@ class PlaylistTab(QTableWidget):
|
||||
|
||||
# Determin cell type changed
|
||||
with Session() as session:
|
||||
if self.edit_cell_type == ROW_NOTES:
|
||||
if self.edit_cell_type == "row_notes":
|
||||
# Get playlistrow object
|
||||
plr_id = self._get_playlistrow_id(row)
|
||||
plr_item = session.get(PlaylistRows, plr_id)
|
||||
@ -434,10 +434,9 @@ class PlaylistTab(QTableWidget):
|
||||
if track:
|
||||
update_current = row == self._get_current_track_row()
|
||||
update_next = row == self._get_next_track_row()
|
||||
if self.edit_cell_type == TITLE:
|
||||
log.debug(f"KAE: _cell_changed:438, {new_text=}")
|
||||
if self.edit_cell_type == "title":
|
||||
track.title = new_text
|
||||
elif self.edit_cell_type == ARTIST:
|
||||
elif self.edit_cell_type == "artist":
|
||||
track.artist = new_text
|
||||
if update_current:
|
||||
self.musicmuster.update_current_track(track)
|
||||
@ -488,21 +487,25 @@ class PlaylistTab(QTableWidget):
|
||||
# If a track row, we only allow editing of title, artist and
|
||||
# note. Check that this column is one of those.
|
||||
self.edit_cell_type = None
|
||||
if column in [TITLE, ARTIST, ROW_NOTES]:
|
||||
self.edit_cell_type = column
|
||||
if column == TITLE:
|
||||
self.edit_cell_type = "title"
|
||||
elif column == ARTIST:
|
||||
self.edit_cell_type = "artist"
|
||||
elif column == ROW_NOTES:
|
||||
self.edit_cell_type = "row_notes"
|
||||
else:
|
||||
# Can't edit other columns
|
||||
return False
|
||||
|
||||
# Check whether we're editing a notes row for later
|
||||
if self.edit_cell_type == ROW_NOTES:
|
||||
if self.edit_cell_type == "row_notes":
|
||||
note_column = ROW_NOTES
|
||||
else:
|
||||
# This is a section header.
|
||||
if column != HEADER_NOTES_COLUMN:
|
||||
return False
|
||||
note_column = HEADER_NOTES_COLUMN
|
||||
self.edit_cell_type = ROW_NOTES
|
||||
self.edit_cell_type = "row_notes"
|
||||
|
||||
# Disable play controls so that keyboard input doesn't
|
||||
# disturb playing
|
||||
@ -612,7 +615,6 @@ class PlaylistTab(QTableWidget):
|
||||
self.setItem(row, START_GAP, start_gap_item)
|
||||
|
||||
title_item = QTableWidgetItem(row_data.track.title)
|
||||
log.debug(f"KAE: insert_row:615, {title_item.text()=}")
|
||||
self.setItem(row, TITLE, title_item)
|
||||
|
||||
artist_item = QTableWidgetItem(row_data.track.artist)
|
||||
@ -821,17 +823,13 @@ 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:
|
||||
@ -1955,7 +1953,6 @@ class PlaylistTab(QTableWidget):
|
||||
item_startgap.setBackground(QColor("white"))
|
||||
|
||||
item_title = self.item(row, TITLE)
|
||||
log.debug(f"KAE: _update_row:1958, {track.title=}")
|
||||
item_title.setText(track.title)
|
||||
|
||||
item_artist = self.item(row, ARTIST)
|
||||
|
||||
@ -134,15 +134,9 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="hdrPreviousTrack">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<width>16</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -166,18 +160,12 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="hdrCurrentTrack">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
@ -186,9 +174,7 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: #d4edda;
|
||||
border: 1px solid rgb(85, 87, 83);
|
||||
text-align: left;
|
||||
padding-left: 8px;
|
||||
</string>
|
||||
text-align: left;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
@ -200,12 +186,6 @@ padding-left: 8px;
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="hdrNextTrack">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
@ -214,8 +194,7 @@ padding-left: 8px;
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: #fff3cd;
|
||||
border: 1px solid rgb(85, 87, 83);
|
||||
text-align: left;
|
||||
padding-left: 8px;</string>
|
||||
text-align: left;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
|
||||
@ -80,12 +80,7 @@ class Ui_MainWindow(object):
|
||||
self.verticalLayout = QtWidgets.QVBoxLayout()
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
self.hdrPreviousTrack = QtWidgets.QLabel(self.centralwidget)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.hdrPreviousTrack.sizePolicy().hasHeightForWidth())
|
||||
self.hdrPreviousTrack.setSizePolicy(sizePolicy)
|
||||
self.hdrPreviousTrack.setMinimumSize(QtCore.QSize(0, 0))
|
||||
self.hdrPreviousTrack.setMinimumSize(QtCore.QSize(16, 0))
|
||||
self.hdrPreviousTrack.setMaximumSize(QtCore.QSize(16777215, 16777215))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Sans")
|
||||
@ -94,40 +89,27 @@ class Ui_MainWindow(object):
|
||||
self.hdrPreviousTrack.setStyleSheet("background-color: #f8d7da;\n"
|
||||
"border: 1px solid rgb(85, 87, 83);")
|
||||
self.hdrPreviousTrack.setText("")
|
||||
self.hdrPreviousTrack.setWordWrap(False)
|
||||
self.hdrPreviousTrack.setWordWrap(True)
|
||||
self.hdrPreviousTrack.setObjectName("hdrPreviousTrack")
|
||||
self.verticalLayout.addWidget(self.hdrPreviousTrack)
|
||||
self.hdrCurrentTrack = QtWidgets.QPushButton(self.centralwidget)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.hdrCurrentTrack.sizePolicy().hasHeightForWidth())
|
||||
self.hdrCurrentTrack.setSizePolicy(sizePolicy)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(20)
|
||||
self.hdrCurrentTrack.setFont(font)
|
||||
self.hdrCurrentTrack.setStyleSheet("background-color: #d4edda;\n"
|
||||
"border: 1px solid rgb(85, 87, 83);\n"
|
||||
"text-align: left;\n"
|
||||
"padding-left: 8px;\n"
|
||||
"")
|
||||
"text-align: left;")
|
||||
self.hdrCurrentTrack.setText("")
|
||||
self.hdrCurrentTrack.setFlat(True)
|
||||
self.hdrCurrentTrack.setObjectName("hdrCurrentTrack")
|
||||
self.verticalLayout.addWidget(self.hdrCurrentTrack)
|
||||
self.hdrNextTrack = QtWidgets.QPushButton(self.centralwidget)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.hdrNextTrack.sizePolicy().hasHeightForWidth())
|
||||
self.hdrNextTrack.setSizePolicy(sizePolicy)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(20)
|
||||
self.hdrNextTrack.setFont(font)
|
||||
self.hdrNextTrack.setStyleSheet("background-color: #fff3cd;\n"
|
||||
"border: 1px solid rgb(85, 87, 83);\n"
|
||||
"text-align: left;\n"
|
||||
"padding-left: 8px;")
|
||||
"text-align: left;")
|
||||
self.hdrNextTrack.setText("")
|
||||
self.hdrNextTrack.setFlat(True)
|
||||
self.hdrNextTrack.setObjectName("hdrNextTrack")
|
||||
|
||||
30
test.py
30
test.py
@ -1,30 +0,0 @@
|
||||
#!/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_())
|
||||
Loading…
Reference in New Issue
Block a user