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