Compare commits

..

No commits in common. "c9cdbe2eb2b2dc37dcf879b28052bf5e265a22bf" and "c4be0b55d429ba38061be5b455554afa3d81d9d3" have entirely different histories.

3 changed files with 17 additions and 31 deletions

View File

@ -11,14 +11,12 @@ class Config(object):
COLOUR_CURRENT_PLAYLIST = "#7eca8f" COLOUR_CURRENT_PLAYLIST = "#7eca8f"
COLOUR_CURRENT_TAB = "#248f24" COLOUR_CURRENT_TAB = "#248f24"
COLOUR_ENDING_TIMER = "#dc3545" COLOUR_ENDING_TIMER = "#dc3545"
COLOUR_EVEN_PLAYLIST = "#d9d9d9"
COLOUR_LONG_START = "#dc3545" COLOUR_LONG_START = "#dc3545"
COLOUR_NEXT_HEADER = "#fff3cd" COLOUR_NEXT_HEADER = "#fff3cd"
COLOUR_NEXT_PLAYLIST = "#ffc107" COLOUR_NEXT_PLAYLIST = "#ffc107"
COLOUR_NEXT_TAB = "#b38600" COLOUR_NEXT_TAB = "#b38600"
COLOUR_NORMAL_TAB = "#000000" COLOUR_NORMAL_TAB = "#000000"
COLOUR_NOTES_PLAYLIST = "#b8daff" COLOUR_NOTES_PLAYLIST = "#b8daff"
COLOUR_ODD_PLAYLIST = "#f2f2f2"
COLOUR_PREVIOUS_HEADER = "#f8d7da" COLOUR_PREVIOUS_HEADER = "#f8d7da"
COLOUR_UNREADABLE = "#dc3545" COLOUR_UNREADABLE = "#dc3545"
COLOUR_WARNING_TIMER = "#ffc107" COLOUR_WARNING_TIMER = "#ffc107"

View File

@ -9,7 +9,7 @@ from datetime import datetime, timedelta
from typing import List, Optional from typing import List, Optional
from PyQt5.QtCore import QDate, QEvent, Qt, QTime, QTimer from PyQt5.QtCore import QDate, QEvent, Qt, QTime, QTimer
from PyQt5.QtGui import QColor, QPalette from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QApplication, QApplication,
QDialog, QDialog,
@ -74,13 +74,6 @@ class Window(QMainWindow, Ui_MainWindow):
self.previous_track: Optional[TrackData] = None self.previous_track: Optional[TrackData] = None
self.previous_track_position: Optional[int] = None self.previous_track_position: Optional[int] = None
# Set colours that will be used by playlist row stripes
palette = QPalette()
palette.setColor(QPalette.Base, QColor(Config.COLOUR_EVEN_PLAYLIST))
palette.setColor(QPalette.AlternateBase,
QColor(Config.COLOUR_ODD_PLAYLIST))
self.setPalette(palette)
self.set_main_window_size() self.set_main_window_size()
self.lblSumPlaytime = QLabel("") self.lblSumPlaytime = QLabel("")
self.statusbar.addPermanentWidget(self.lblSumPlaytime) self.statusbar.addPermanentWidget(self.lblSumPlaytime)

View File

@ -6,18 +6,12 @@ from collections import namedtuple
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import List, Optional from typing import List, Optional
from PyQt5.QtCore import ( from PyQt5.QtCore import QEvent, QModelIndex, Qt, pyqtSignal
pyqtSignal,
QEvent,
QModelIndex,
QSize,
Qt,
)
from PyQt5.QtGui import ( from PyQt5.QtGui import (
QBrush, QBrush,
QColor, QColor,
QFont, QFont,
QDropEvent, QDropEvent
) )
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QAbstractItemDelegate, QAbstractItemDelegate,
@ -26,12 +20,10 @@ from PyQt5.QtWidgets import (
QLineEdit, QLineEdit,
QMainWindow, QMainWindow,
QMenu, QMenu,
QMessageBox,
QPlainTextEdit,
QStyledItemDelegate, QStyledItemDelegate,
QMessageBox,
QTableWidget, QTableWidget,
QTableWidgetItem, QTableWidgetItem,
QTextEdit,
QWidget QWidget
) )
@ -82,18 +74,21 @@ columns["row_notes"] = Column(idx=8, heading=Config.COLUMN_NAME_NOTES)
class NoSelectDelegate(QStyledItemDelegate): class NoSelectDelegate(QStyledItemDelegate):
""" """
This originally used the following link to not select text on edit;
however, using a QPlainTextBox means a) text isn't selected anyway and
b) it provides a multiline edit.
https://stackoverflow.com/questions/72790705/ https://stackoverflow.com/questions/72790705/
dont-select-text-in-qtablewidget-cell-when-editing/72792962#72792962 dont-select-text-in-qtablewidget-cell-when-editing/72792962#72792962
""" """
def createEditor(self, parent, option, index): def createEditor(self, parent, option, index):
if isinstance(index.data(), str): editor = super().createEditor(parent, option, index)
return QPlainTextEdit(parent) if isinstance(editor, QLineEdit):
return super().createEditor(parent, option, index) def deselect():
# Important! First disconnect, otherwise editor.deselect()
# will call again this function
editor.selectionChanged.disconnect(deselect)
editor.deselect()
editor.selectionChanged.connect(deselect)
return editor
class PlaylistTab(QTableWidget): class PlaylistTab(QTableWidget):
# Qt.UserRoles # Qt.UserRoles
@ -991,9 +986,6 @@ 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
self.resizeRowToContents(row)
# Render playing track # Render playing track
if row == current_row: if row == current_row:
# Set start time # Set start time
@ -1099,6 +1091,9 @@ class PlaylistTab(QTableWidget):
self._get_section_timing_string(section_time, no_end=True) self._get_section_timing_string(section_time, no_end=True)
) )
# Ensure content is visible by wrapping cells
self.resizeRowsToContents()
# Scroll to put next track Config.SCROLL_TOP_MARGIN from the # Scroll to put next track Config.SCROLL_TOP_MARGIN from the
# top. Rows number from zero, so set (current_row - # top. Rows number from zero, so set (current_row -
# Config.SCROLL_TOP_MARGIN + 1) row to be top row # Config.SCROLL_TOP_MARGIN + 1) row to be top row