Fix notes not wrapping on startup
Ensure notes column stretches to fill width and that it wraps.
This commit is contained in:
parent
632e555bed
commit
b42ffcec69
@ -219,6 +219,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
lambda: self.tabPlaylist.currentWidget().scroll_current_to_top())
|
lambda: self.tabPlaylist.currentWidget().scroll_current_to_top())
|
||||||
self.hdrNextTrack.clicked.connect(
|
self.hdrNextTrack.clicked.connect(
|
||||||
lambda: self.tabPlaylist.currentWidget().scroll_next_to_top())
|
lambda: self.tabPlaylist.currentWidget().scroll_next_to_top())
|
||||||
|
self.tabPlaylist.currentChanged.connect(
|
||||||
|
lambda: self.tabPlaylist.currentWidget().tab_visible())
|
||||||
self.tabPlaylist.tabCloseRequested.connect(self.close_tab)
|
self.tabPlaylist.tabCloseRequested.connect(self.close_tab)
|
||||||
self.txtSearch.returnPressed.connect(self.search_playlist_return)
|
self.txtSearch.returnPressed.connect(self.search_playlist_return)
|
||||||
|
|
||||||
@ -968,7 +970,7 @@ class DbDialog(QDialog):
|
|||||||
"""
|
"""
|
||||||
Subclassed QDialog to manage track selection
|
Subclassed QDialog to manage track selection
|
||||||
|
|
||||||
If get_one_track is True, return after first track selection
|
If get_one_track is True, return after first track selection
|
||||||
with that track in ui.track. Otherwise, allow multiple tracks
|
with that track in ui.track. Otherwise, allow multiple tracks
|
||||||
to be added to the playlist.
|
to be added to the playlist.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -13,6 +13,7 @@ from PyQt5.QtCore import (
|
|||||||
QObject,
|
QObject,
|
||||||
QSize,
|
QSize,
|
||||||
Qt,
|
Qt,
|
||||||
|
QTimer,
|
||||||
)
|
)
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import (
|
||||||
QBrush,
|
QBrush,
|
||||||
@ -151,7 +152,6 @@ class PlaylistTab(QTableWidget):
|
|||||||
item: QTableWidgetItem = QTableWidgetItem()
|
item: QTableWidgetItem = QTableWidgetItem()
|
||||||
self.setHorizontalHeaderItem(idx, item)
|
self.setHorizontalHeaderItem(idx, item)
|
||||||
self.horizontalHeader().setMinimumSectionSize(0)
|
self.horizontalHeader().setMinimumSectionSize(0)
|
||||||
self._set_column_widths(session)
|
|
||||||
# Set column headings sorted by idx
|
# Set column headings sorted by idx
|
||||||
self.setHorizontalHeaderLabels(
|
self.setHorizontalHeaderLabels(
|
||||||
[a.heading for a in list(sorted(columns.values(),
|
[a.heading for a in list(sorted(columns.values(),
|
||||||
@ -748,6 +748,13 @@ class PlaylistTab(QTableWidget):
|
|||||||
scroll_to: QTableWidgetItem = self.item(0, 0)
|
scroll_to: QTableWidgetItem = self.item(0, 0)
|
||||||
self.scrollToItem(scroll_to, QAbstractItemView.PositionAtTop)
|
self.scrollToItem(scroll_to, QAbstractItemView.PositionAtTop)
|
||||||
|
|
||||||
|
# Set widths
|
||||||
|
self._set_column_widths(session)
|
||||||
|
|
||||||
|
# Needed to wrap notes column correctly - add to event queue so
|
||||||
|
# that it's processed after list populated
|
||||||
|
QTimer.singleShot(0, self.tab_visible)
|
||||||
|
|
||||||
# We possibly don't need to save the playlist here, but row
|
# We possibly don't need to save the playlist here, but row
|
||||||
# numbers may have changed during population, and it's cheap to do
|
# numbers may have changed during population, and it's cheap to do
|
||||||
# self.save_playlist(session)
|
# self.save_playlist(session)
|
||||||
@ -973,6 +980,13 @@ class PlaylistTab(QTableWidget):
|
|||||||
with Session() as session:
|
with Session() as session:
|
||||||
self._set_next(session, row)
|
self._set_next(session, row)
|
||||||
|
|
||||||
|
def tab_visible(self) -> None:
|
||||||
|
"""Called when tab becomes visible"""
|
||||||
|
|
||||||
|
# Set row heights
|
||||||
|
self.resizeRowsToContents()
|
||||||
|
self.setColumnWidth(len(columns) - 1, 0)
|
||||||
|
|
||||||
def update_display(self, session, clear_selection: bool = True) -> None:
|
def update_display(self, session, clear_selection: bool = True) -> None:
|
||||||
"""
|
"""
|
||||||
Set row colours, fonts, etc
|
Set row colours, fonts, etc
|
||||||
@ -1017,9 +1031,6 @@ class PlaylistTab(QTableWidget):
|
|||||||
# Get note colour
|
# Get note colour
|
||||||
note_colour = NoteColours.get_colour(session, note_text)
|
note_colour = NoteColours.get_colour(session, note_text)
|
||||||
|
|
||||||
# Set row height
|
|
||||||
self.resizeRowToContents(row)
|
|
||||||
|
|
||||||
# Get track if there is one
|
# Get track if there is one
|
||||||
track_id = self._get_row_track_id(row)
|
track_id = self._get_row_track_id(row)
|
||||||
track = None
|
track = None
|
||||||
@ -1151,6 +1162,10 @@ class PlaylistTab(QTableWidget):
|
|||||||
self._set_row_bold(row)
|
self._set_row_bold(row)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Set row heights
|
||||||
|
self.resizeRowsToContents()
|
||||||
|
self.setColumnWidth(len(columns) - 1, 0)
|
||||||
|
|
||||||
# Have we had a section start but not end?
|
# Have we had a section start but not end?
|
||||||
if section_start_plr is not None:
|
if section_start_plr is not None:
|
||||||
self._update_note_text(
|
self._update_note_text(
|
||||||
@ -1224,6 +1239,10 @@ class PlaylistTab(QTableWidget):
|
|||||||
with Session() as session:
|
with Session() as session:
|
||||||
for column_name, data in columns.items():
|
for column_name, data in columns.items():
|
||||||
idx = data.idx
|
idx = data.idx
|
||||||
|
if idx == len(columns) - 1:
|
||||||
|
# Don't set width of last column as it's set to
|
||||||
|
# stretch
|
||||||
|
continue
|
||||||
width = self.columnWidth(idx)
|
width = self.columnWidth(idx)
|
||||||
attribute_name = f"playlist_{column_name}_col_width"
|
attribute_name = f"playlist_{column_name}_col_width"
|
||||||
record = Settings.get_int_settings(session, attribute_name)
|
record = Settings.get_int_settings(session, attribute_name)
|
||||||
@ -1702,6 +1721,11 @@ class PlaylistTab(QTableWidget):
|
|||||||
|
|
||||||
for column_name, data in columns.items():
|
for column_name, data in columns.items():
|
||||||
idx = data.idx
|
idx = data.idx
|
||||||
|
if idx == len(columns) - 1:
|
||||||
|
# Set width of last column to zero as it's set to stretch
|
||||||
|
print(f"Set {column_name} to zero width, {self.playlist_id=}")
|
||||||
|
self.setColumnWidth(idx, 0)
|
||||||
|
continue
|
||||||
attr_name = f"playlist_{column_name}_col_width"
|
attr_name = f"playlist_{column_name}_col_width"
|
||||||
record: Settings = Settings.get_int_settings(session, attr_name)
|
record: Settings = Settings.get_int_settings(session, attr_name)
|
||||||
if record and record.f_int is not None:
|
if record and record.f_int is not None:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user