Compare commits
7 Commits
c4be0b55d4
...
c9cdbe2eb2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9cdbe2eb2 | ||
|
|
dfcdc0b9e8 | ||
|
|
957450c0f6 | ||
|
|
20e9880a03 | ||
|
|
d267b32c0d | ||
|
|
7b2b7fada5 | ||
|
|
4fad05db6b |
@ -11,12 +11,14 @@ class Config(object):
|
||||
COLOUR_CURRENT_PLAYLIST = "#7eca8f"
|
||||
COLOUR_CURRENT_TAB = "#248f24"
|
||||
COLOUR_ENDING_TIMER = "#dc3545"
|
||||
COLOUR_EVEN_PLAYLIST = "#d9d9d9"
|
||||
COLOUR_LONG_START = "#dc3545"
|
||||
COLOUR_NEXT_HEADER = "#fff3cd"
|
||||
COLOUR_NEXT_PLAYLIST = "#ffc107"
|
||||
COLOUR_NEXT_TAB = "#b38600"
|
||||
COLOUR_NORMAL_TAB = "#000000"
|
||||
COLOUR_NOTES_PLAYLIST = "#b8daff"
|
||||
COLOUR_ODD_PLAYLIST = "#f2f2f2"
|
||||
COLOUR_PREVIOUS_HEADER = "#f8d7da"
|
||||
COLOUR_UNREADABLE = "#dc3545"
|
||||
COLOUR_WARNING_TIMER = "#ffc107"
|
||||
|
||||
@ -9,7 +9,7 @@ from datetime import datetime, timedelta
|
||||
from typing import List, Optional
|
||||
|
||||
from PyQt5.QtCore import QDate, QEvent, Qt, QTime, QTimer
|
||||
from PyQt5.QtGui import QColor
|
||||
from PyQt5.QtGui import QColor, QPalette
|
||||
from PyQt5.QtWidgets import (
|
||||
QApplication,
|
||||
QDialog,
|
||||
@ -74,6 +74,13 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.previous_track: Optional[TrackData] = 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.lblSumPlaytime = QLabel("")
|
||||
self.statusbar.addPermanentWidget(self.lblSumPlaytime)
|
||||
|
||||
@ -6,12 +6,18 @@ from collections import namedtuple
|
||||
from datetime import datetime, timedelta
|
||||
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 (
|
||||
QBrush,
|
||||
QColor,
|
||||
QFont,
|
||||
QDropEvent
|
||||
QDropEvent,
|
||||
)
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractItemDelegate,
|
||||
@ -20,10 +26,12 @@ from PyQt5.QtWidgets import (
|
||||
QLineEdit,
|
||||
QMainWindow,
|
||||
QMenu,
|
||||
QStyledItemDelegate,
|
||||
QMessageBox,
|
||||
QPlainTextEdit,
|
||||
QStyledItemDelegate,
|
||||
QTableWidget,
|
||||
QTableWidgetItem,
|
||||
QTextEdit,
|
||||
QWidget
|
||||
)
|
||||
|
||||
@ -74,21 +82,18 @@ columns["row_notes"] = Column(idx=8, heading=Config.COLUMN_NAME_NOTES)
|
||||
|
||||
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/
|
||||
dont-select-text-in-qtablewidget-cell-when-editing/72792962#72792962
|
||||
"""
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
editor = super().createEditor(parent, option, index)
|
||||
if isinstance(editor, QLineEdit):
|
||||
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
|
||||
|
||||
if isinstance(index.data(), str):
|
||||
return QPlainTextEdit(parent)
|
||||
return super().createEditor(parent, option, index)
|
||||
|
||||
class PlaylistTab(QTableWidget):
|
||||
# Qt.UserRoles
|
||||
@ -986,6 +991,9 @@ class PlaylistTab(QTableWidget):
|
||||
(self.item(row, columns['row_notes'].idx)
|
||||
.setBackground(QColor(note_colour)))
|
||||
|
||||
# Ensure content is visible by wrapping cells
|
||||
self.resizeRowToContents(row)
|
||||
|
||||
# Render playing track
|
||||
if row == current_row:
|
||||
# Set start time
|
||||
@ -1091,9 +1099,6 @@ class PlaylistTab(QTableWidget):
|
||||
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
|
||||
# top. Rows number from zero, so set (current_row -
|
||||
# Config.SCROLL_TOP_MARGIN + 1) row to be top row
|
||||
|
||||
Loading…
Reference in New Issue
Block a user