Merge branch 'EditorClosing' into v3_play
This commit is contained in:
commit
7819e863eb
@ -10,6 +10,7 @@ from PyQt5.QtCore import (
|
||||
pyqtSignal,
|
||||
QEvent,
|
||||
QModelIndex,
|
||||
QObject,
|
||||
QSize,
|
||||
Qt,
|
||||
)
|
||||
@ -96,6 +97,16 @@ class NoSelectDelegate(QStyledItemDelegate):
|
||||
return QPlainTextEdit(parent)
|
||||
return super().createEditor(parent, option, index)
|
||||
|
||||
def eventFilter(self, editor: QObject, event: QEvent):
|
||||
"""By default, QPlainTextEdit doesn't handle enter or return"""
|
||||
|
||||
if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Return:
|
||||
if (Qt.ShiftModifier & event.modifiers()) != Qt.ShiftModifier:
|
||||
self.commitData.emit(editor)
|
||||
self.closeEditor.emit(editor)
|
||||
|
||||
return super().eventFilter(editor, event)
|
||||
|
||||
|
||||
class PlaylistTab(QTableWidget):
|
||||
# Qt.UserRoles
|
||||
@ -358,7 +369,7 @@ class PlaylistTab(QTableWidget):
|
||||
#
|
||||
# Call sequences:
|
||||
# Start editing:
|
||||
# edit() (called twice; not sure why)
|
||||
# edit()
|
||||
# _cell_edit_started()
|
||||
# End editing:
|
||||
# _cell_changed() (only if changes made)
|
||||
@ -561,7 +572,10 @@ class PlaylistTab(QTableWidget):
|
||||
|
||||
if row_data.track_id:
|
||||
# Add track details to items
|
||||
start_gap = row_data.track.start_gap
|
||||
try:
|
||||
start_gap = row_data.track.start_gap
|
||||
except:
|
||||
return
|
||||
start_gap_item = QTableWidgetItem(str(start_gap))
|
||||
if start_gap and start_gap >= 500:
|
||||
start_gap_item.setBackground(QColor(Config.COLOUR_LONG_START))
|
||||
@ -1001,8 +1015,8 @@ class PlaylistTab(QTableWidget):
|
||||
(self.item(row, columns['row_notes'].idx)
|
||||
.setBackground(QColor(note_colour)))
|
||||
|
||||
# Ensure content is visible by wrapping cells
|
||||
self.resizeRowToContents(row)
|
||||
# Ensure content is visible by wrapping cells
|
||||
self.resizeRowToContents(row)
|
||||
|
||||
# Highlight low bitrates
|
||||
if track.bitrate:
|
||||
@ -1102,11 +1116,11 @@ class PlaylistTab(QTableWidget):
|
||||
elif note_text.endswith("+"):
|
||||
section_start_plr = playlist_row
|
||||
section_time = 0
|
||||
self._set_row_colour(
|
||||
row, QColor(note_colour)
|
||||
)
|
||||
self._set_row_colour(row, QColor(note_colour))
|
||||
# Section headers are always bold
|
||||
self._set_row_bold(row)
|
||||
# Ensure content is visible by wrapping cells
|
||||
self.resizeRowToContents(row)
|
||||
continue
|
||||
|
||||
# Have we had a section start but not end?
|
||||
@ -1741,16 +1755,19 @@ class PlaylistTab(QTableWidget):
|
||||
Set or reset row background colour
|
||||
"""
|
||||
|
||||
j: int
|
||||
column: int
|
||||
|
||||
if colour:
|
||||
brush = QBrush(colour)
|
||||
else:
|
||||
brush = QBrush()
|
||||
|
||||
for j in range(1, self.columnCount()):
|
||||
if self.item(row, j):
|
||||
self.item(row, j).setBackground(brush)
|
||||
for column in range(1, self.columnCount()):
|
||||
# Don't clear colour on start gap row
|
||||
if not colour and column == columns['start_gap'].idx:
|
||||
continue
|
||||
if self.item(row, column):
|
||||
self.item(row, column).setBackground(brush)
|
||||
|
||||
def _set_row_duration(self, row: int, ms: int) -> None:
|
||||
"""Set duration of this row in row metadata"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user