Compare commits

...

7 Commits

Author SHA1 Message Date
Keith Edmunds
c9cdbe2eb2 Remove commented code 2022-08-17 21:30:04 +01:00
Keith Edmunds
dfcdc0b9e8 Only resize track rows that have notes 2022-08-17 21:28:32 +01:00
Keith Edmunds
957450c0f6 Use QPlainTextEdit to edit cells 2022-08-17 21:28:15 +01:00
Keith Edmunds
20e9880a03 Set alternate row colous using App.setPalette 2022-08-17 21:12:21 +01:00
Keith Edmunds
d267b32c0d WIP trying things 2022-08-17 13:30:45 +01:00
Keith Edmunds
7b2b7fada5 WIP: replace notes TableWidgetItem with TextEdit 2022-08-17 12:52:09 +01:00
Keith Edmunds
4fad05db6b QTextEdit WIP 2022-08-16 12:30:03 +01:00
3 changed files with 31 additions and 17 deletions

View File

@ -11,12 +11,14 @@ 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 from PyQt5.QtGui import QColor, QPalette
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QApplication, QApplication,
QDialog, QDialog,
@ -74,6 +74,13 @@ 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,12 +6,18 @@ 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 QEvent, QModelIndex, Qt, pyqtSignal from PyQt5.QtCore import (
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,
@ -20,10 +26,12 @@ from PyQt5.QtWidgets import (
QLineEdit, QLineEdit,
QMainWindow, QMainWindow,
QMenu, QMenu,
QStyledItemDelegate,
QMessageBox, QMessageBox,
QPlainTextEdit,
QStyledItemDelegate,
QTableWidget, QTableWidget,
QTableWidgetItem, QTableWidgetItem,
QTextEdit,
QWidget QWidget
) )
@ -74,21 +82,18 @@ 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):
editor = super().createEditor(parent, option, index) if isinstance(index.data(), str):
if isinstance(editor, QLineEdit): return QPlainTextEdit(parent)
def deselect(): return super().createEditor(parent, option, index)
# 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
@ -986,6 +991,9 @@ 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
@ -1091,9 +1099,6 @@ 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