Compare commits
No commits in common. "master" and "query_tabs" have entirely different histories.
master
...
query_tabs
2
.envrc
2
.envrc
@ -1,4 +1,4 @@
|
|||||||
layout uv
|
layout poetry
|
||||||
export LINE_PROFILE=1
|
export LINE_PROFILE=1
|
||||||
export MAIL_PASSWORD="ewacyay5seu2qske"
|
export MAIL_PASSWORD="ewacyay5seu2qske"
|
||||||
export MAIL_PORT=587
|
export MAIL_PORT=587
|
||||||
|
|||||||
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1 +0,0 @@
|
|||||||
*.py diff=python
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,7 +2,6 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
*.swp
|
*.swp
|
||||||
tags
|
tags
|
||||||
.venv/
|
|
||||||
venv/
|
venv/
|
||||||
Session.vim
|
Session.vim
|
||||||
*.flac
|
*.flac
|
||||||
@ -14,4 +13,3 @@ StudioPlaylist.png
|
|||||||
tmp/
|
tmp/
|
||||||
.coverage
|
.coverage
|
||||||
profile_output*
|
profile_output*
|
||||||
kae.py
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
3.13
|
musicmuster
|
||||||
|
|||||||
78
InterceptEscapeWhenEditingTableCell.py
Executable file
78
InterceptEscapeWhenEditingTableCell.py
Executable file
@ -0,0 +1,78 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from PyQt6.QtCore import Qt, QEvent, QObject
|
||||||
|
from PyQt6.QtWidgets import (
|
||||||
|
QAbstractItemView,
|
||||||
|
QApplication,
|
||||||
|
QMainWindow,
|
||||||
|
QMessageBox,
|
||||||
|
QPlainTextEdit,
|
||||||
|
QStyledItemDelegate,
|
||||||
|
QTableWidget,
|
||||||
|
QTableWidgetItem,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt6.QtGui import QKeyEvent
|
||||||
|
|
||||||
|
from typing import cast
|
||||||
|
|
||||||
|
|
||||||
|
class EscapeDelegate(QStyledItemDelegate):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
def createEditor(self, parent, option, index):
|
||||||
|
return QPlainTextEdit(parent)
|
||||||
|
|
||||||
|
def eventFilter(self, editor: QObject, event: QEvent):
|
||||||
|
"""By default, QPlainTextEdit doesn't handle enter or return"""
|
||||||
|
|
||||||
|
print("EscapeDelegate event handler")
|
||||||
|
if event.type() == QEvent.Type.KeyPress:
|
||||||
|
key_event = cast(QKeyEvent, event)
|
||||||
|
if key_event.key() == Qt.Key.Key_Return:
|
||||||
|
if key_event.modifiers() == (Qt.KeyboardModifier.ControlModifier):
|
||||||
|
print("save data")
|
||||||
|
self.commitData.emit(editor)
|
||||||
|
self.closeEditor.emit(editor)
|
||||||
|
return True
|
||||||
|
elif key_event.key() == Qt.Key.Key_Escape:
|
||||||
|
discard_edits = QMessageBox.question(
|
||||||
|
self.parent(), "Abandon edit", "Discard changes?"
|
||||||
|
)
|
||||||
|
if discard_edits == QMessageBox.StandardButton.Yes:
|
||||||
|
print("abandon edit")
|
||||||
|
self.closeEditor.emit(editor)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class MyTableWidget(QTableWidget):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setItemDelegate(EscapeDelegate(self))
|
||||||
|
# self.setEditTriggers(QAbstractItemView.EditTrigger.DoubleClicked)
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow(QMainWindow):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.table_widget = MyTableWidget(self)
|
||||||
|
self.table_widget.setRowCount(2)
|
||||||
|
self.table_widget.setColumnCount(2)
|
||||||
|
for row in range(2):
|
||||||
|
for col in range(2):
|
||||||
|
item = QTableWidgetItem()
|
||||||
|
item.setText(f"Row {row}, Col {col}")
|
||||||
|
self.table_widget.setItem(row, col, item)
|
||||||
|
self.setCentralWidget(self.table_widget)
|
||||||
|
|
||||||
|
self.table_widget.resizeColumnsToContents()
|
||||||
|
self.table_widget.resizeRowsToContents()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = QApplication([])
|
||||||
|
window = MainWindow()
|
||||||
|
window.show()
|
||||||
|
app.exec()
|
||||||
94
InterceptEscapeWhenEditingTableCellInView.py
Executable file
94
InterceptEscapeWhenEditingTableCellInView.py
Executable file
@ -0,0 +1,94 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from PyQt6.QtCore import Qt, QEvent, QObject, QVariant, QAbstractTableModel
|
||||||
|
from PyQt6.QtWidgets import (
|
||||||
|
QApplication,
|
||||||
|
QMainWindow,
|
||||||
|
QMessageBox,
|
||||||
|
QPlainTextEdit,
|
||||||
|
QStyledItemDelegate,
|
||||||
|
QTableView,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt6.QtGui import QKeyEvent
|
||||||
|
|
||||||
|
from typing import cast
|
||||||
|
|
||||||
|
|
||||||
|
class EscapeDelegate(QStyledItemDelegate):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
def createEditor(self, parent, option, index):
|
||||||
|
return QPlainTextEdit(parent)
|
||||||
|
|
||||||
|
def eventFilter(self, editor: QObject, event: QEvent):
|
||||||
|
"""By default, QPlainTextEdit doesn't handle enter or return"""
|
||||||
|
|
||||||
|
if event.type() == QEvent.Type.KeyPress:
|
||||||
|
key_event = cast(QKeyEvent, event)
|
||||||
|
print(key_event.key())
|
||||||
|
if key_event.key() == Qt.Key.Key_Return:
|
||||||
|
if key_event.modifiers() == (Qt.KeyboardModifier.ControlModifier):
|
||||||
|
print("save data")
|
||||||
|
self.commitData.emit(editor)
|
||||||
|
self.closeEditor.emit(editor)
|
||||||
|
return True
|
||||||
|
elif key_event.key() == Qt.Key.Key_Escape:
|
||||||
|
discard_edits = QMessageBox.question(
|
||||||
|
self.parent(), "Abandon edit", "Discard changes?"
|
||||||
|
)
|
||||||
|
if discard_edits == QMessageBox.StandardButton.Yes:
|
||||||
|
print("abandon edit")
|
||||||
|
self.closeEditor.emit(editor)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class MyTableWidget(QTableView):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setItemDelegate(EscapeDelegate(self))
|
||||||
|
self.setModel(MyModel())
|
||||||
|
|
||||||
|
|
||||||
|
class MyModel(QAbstractTableModel):
|
||||||
|
def columnCount(self, index):
|
||||||
|
return 2
|
||||||
|
|
||||||
|
def rowCount(self, index):
|
||||||
|
return 2
|
||||||
|
|
||||||
|
def data(self, index, role):
|
||||||
|
if not index.isValid() or not (0 <= index.row() < 2):
|
||||||
|
return QVariant()
|
||||||
|
|
||||||
|
row = index.row()
|
||||||
|
column = index.column()
|
||||||
|
if role == Qt.ItemDataRole.DisplayRole:
|
||||||
|
return QVariant(f"Row {row}, Col {column}")
|
||||||
|
return QVariant()
|
||||||
|
|
||||||
|
def flags(self, index):
|
||||||
|
return (
|
||||||
|
Qt.ItemFlag.ItemIsEnabled
|
||||||
|
| Qt.ItemFlag.ItemIsSelectable
|
||||||
|
| Qt.ItemFlag.ItemIsEditable
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow(QMainWindow):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.table_widget = MyTableWidget(self)
|
||||||
|
self.setCentralWidget(self.table_widget)
|
||||||
|
|
||||||
|
self.table_widget.resizeColumnsToContents()
|
||||||
|
self.table_widget.resizeRowsToContents()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = QApplication([])
|
||||||
|
window = MainWindow()
|
||||||
|
window.show()
|
||||||
|
app.exec()
|
||||||
@ -69,8 +69,7 @@ class AudacityController:
|
|||||||
select_status = self._send_command("SelectAll")
|
select_status = self._send_command("SelectAll")
|
||||||
log.debug(f"{select_status=}")
|
log.debug(f"{select_status=}")
|
||||||
|
|
||||||
# Escape any double quotes in filename
|
export_cmd = f'Export2: Filename="{self.path}" NumChannels=2'
|
||||||
export_cmd = f'Export2: Filename="{self.path.replace('"', '\\"')}" NumChannels=2'
|
|
||||||
export_status = self._send_command(export_cmd)
|
export_status = self._send_command(export_cmd)
|
||||||
log.debug(f"{export_status=}")
|
log.debug(f"{export_status=}")
|
||||||
self.path = ""
|
self.path = ""
|
||||||
|
|||||||
@ -5,7 +5,7 @@ from dataclasses import dataclass
|
|||||||
from enum import auto, Enum
|
from enum import auto, Enum
|
||||||
import functools
|
import functools
|
||||||
import threading
|
import threading
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple, Optional
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
|
|
||||||
@ -97,7 +97,10 @@ class MusicMusterSignals(QObject):
|
|||||||
"""
|
"""
|
||||||
Class for all MusicMuster signals. See:
|
Class for all MusicMuster signals. See:
|
||||||
- https://zetcode.com/gui/pyqt5/eventssignals/
|
- https://zetcode.com/gui/pyqt5/eventssignals/
|
||||||
- https://stackoverflow.com/questions/62654525/emit-a-signal-from-another-class-to-main-class
|
- https://stackoverflow.com/questions/62654525/
|
||||||
|
emit-a-signal-from-another-class-to-main-class
|
||||||
|
and Singleton class at
|
||||||
|
https://refactoring.guru/design-patterns/singleton/python/example#example-0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
begin_reset_model_signal = pyqtSignal(int)
|
begin_reset_model_signal = pyqtSignal(int)
|
||||||
|
|||||||
@ -123,23 +123,23 @@ class Config(object):
|
|||||||
ROWS_FROM_ZERO = True
|
ROWS_FROM_ZERO = True
|
||||||
SCROLL_TOP_MARGIN = 3
|
SCROLL_TOP_MARGIN = 3
|
||||||
SECTION_ENDINGS = ("-", "+-", "-+")
|
SECTION_ENDINGS = ("-", "+-", "-+")
|
||||||
SECTION_HEADER = "[Section header]"
|
|
||||||
SECTION_STARTS = ("+", "+-", "-+")
|
SECTION_STARTS = ("+", "+-", "-+")
|
||||||
SONGFACTS_ON_NEXT = False
|
SONGFACTS_ON_NEXT = False
|
||||||
START_GAP_WARNING_THRESHOLD = 300
|
START_GAP_WARNING_THRESHOLD = 300
|
||||||
SUBTOTAL_ON_ROW_ZERO = "[No subtotal on first row]"
|
SUBTOTAL_ON_ROW_ZERO = "[No subtotal on first row]"
|
||||||
|
TEXT_NO_TRACK_NO_NOTE = "[Section header]"
|
||||||
TOD_TIME_FORMAT = "%H:%M:%S"
|
TOD_TIME_FORMAT = "%H:%M:%S"
|
||||||
TRACK_TIME_FORMAT = "%H:%M:%S"
|
TRACK_TIME_FORMAT = "%H:%M:%S"
|
||||||
VLC_MAIN_PLAYER_NAME = "MusicMuster Main Player"
|
VLC_MAIN_PLAYER_NAME = "MusicMuster Main Player"
|
||||||
VLC_PREVIEW_PLAYER_NAME = "MusicMuster Preview Player"
|
VLC_PREVIEW_PLAYER_NAME = "MusicMuster Preview Player"
|
||||||
VLC_VOLUME_DEFAULT = 100
|
VLC_VOLUME_DEFAULT = 75
|
||||||
VLC_VOLUME_DROP3db = 70
|
VLC_VOLUME_DROP3db = 65
|
||||||
WARNING_MS_BEFORE_FADE = 5500
|
WARNING_MS_BEFORE_FADE = 5500
|
||||||
WARNING_MS_BEFORE_SILENCE = 5500
|
WARNING_MS_BEFORE_SILENCE = 5500
|
||||||
WEB_ZOOM_FACTOR = 1.2
|
WEB_ZOOM_FACTOR = 1.2
|
||||||
WIKIPEDIA_ON_NEXT = False
|
WIKIPEDIA_ON_NEXT = False
|
||||||
|
|
||||||
# These rely on earlier definitions
|
# These rely on earlier definitions
|
||||||
HIDE_PLAYED_MODE = HIDE_PLAYED_MODE_TRACKS
|
HIDE_PLAYED_MODE = HIDE_PLAYED_MODE_SECTIONS
|
||||||
IMPORT_DESTINATION = os.path.join(ROOT, "Singles")
|
IMPORT_DESTINATION = os.path.join(ROOT, "Singles")
|
||||||
REPLACE_FILES_DEFAULT_DESTINATION = os.path.dirname(REPLACE_FILES_DEFAULT_SOURCE)
|
REPLACE_FILES_DEFAULT_DESTINATION = os.path.dirname(REPLACE_FILES_DEFAULT_SOURCE)
|
||||||
|
|||||||
@ -53,7 +53,7 @@ class NoteColoursTable(Model):
|
|||||||
__tablename__ = "notecolours"
|
__tablename__ = "notecolours"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||||
substring: Mapped[str] = mapped_column(String(256), index=True, unique=True)
|
substring: Mapped[str] = mapped_column(String(256), index=True)
|
||||||
colour: Mapped[str] = mapped_column(String(21), index=False)
|
colour: Mapped[str] = mapped_column(String(21), index=False)
|
||||||
enabled: Mapped[bool] = mapped_column(default=True, index=True)
|
enabled: Mapped[bool] = mapped_column(default=True, index=True)
|
||||||
foreground: Mapped[Optional[str]] = mapped_column(String(21), index=False)
|
foreground: Mapped[Optional[str]] = mapped_column(String(21), index=False)
|
||||||
|
|||||||
@ -35,7 +35,6 @@ from classes import (
|
|||||||
)
|
)
|
||||||
from config import Config
|
from config import Config
|
||||||
from helpers import (
|
from helpers import (
|
||||||
audio_file_extension,
|
|
||||||
file_is_unreadable,
|
file_is_unreadable,
|
||||||
get_tags,
|
get_tags,
|
||||||
show_OK,
|
show_OK,
|
||||||
@ -105,14 +104,16 @@ class FileImporter:
|
|||||||
# variable or an instance variable are effectively the same thing.
|
# variable or an instance variable are effectively the same thing.
|
||||||
workers: dict[str, DoTrackImport] = {}
|
workers: dict[str, DoTrackImport] = {}
|
||||||
|
|
||||||
def __init__(self, base_model: PlaylistModel, row_number: int) -> None:
|
def __init__(
|
||||||
|
self, base_model: PlaylistModel, row_number: Optional[int] = None
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Initialise the FileImporter singleton instance.
|
Initialise the FileImporter singleton instance.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
log.debug(f"FileImporter.__init__({base_model=}, {row_number=})")
|
|
||||||
|
|
||||||
# Create ModelData
|
# Create ModelData
|
||||||
|
if not row_number:
|
||||||
|
row_number = base_model.rowCount()
|
||||||
self.model_data = ThreadData(base_model=base_model, row_number=row_number)
|
self.model_data = ThreadData(base_model=base_model, row_number=row_number)
|
||||||
|
|
||||||
# Data structure to track files to import
|
# Data structure to track files to import
|
||||||
@ -201,9 +202,8 @@ class FileImporter:
|
|||||||
self.sort_track_match_data(tfd)
|
self.sort_track_match_data(tfd)
|
||||||
selection = self.get_user_choices(tfd)
|
selection = self.get_user_choices(tfd)
|
||||||
if self.process_selection(tfd, selection):
|
if self.process_selection(tfd, selection):
|
||||||
if self.extension_check(tfd):
|
if self.validate_file_data(tfd):
|
||||||
if self.validate_file_data(tfd):
|
tfd.import_this_file = True
|
||||||
tfd.import_this_file = True
|
|
||||||
|
|
||||||
return tfd
|
return tfd
|
||||||
|
|
||||||
@ -237,26 +237,6 @@ class FileImporter:
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def extension_check(self, tfd: TrackFileData) -> bool:
|
|
||||||
"""
|
|
||||||
If we are replacing an existing file, check that the correct file
|
|
||||||
extension of the replacement file matches the existing file
|
|
||||||
extension and return True if it does (or if there is no exsting
|
|
||||||
file), else False.
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not tfd.file_path_to_remove:
|
|
||||||
return True
|
|
||||||
|
|
||||||
if tfd.file_path_to_remove.endswith(audio_file_extension(tfd.source_path)):
|
|
||||||
return True
|
|
||||||
|
|
||||||
tfd.error = (
|
|
||||||
f"Existing file ({tfd.file_path_to_remove}) has a different "
|
|
||||||
f"extension to replacement file ({tfd.source_path})"
|
|
||||||
)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def find_similar(self, tfd: TrackFileData) -> None:
|
def find_similar(self, tfd: TrackFileData) -> None:
|
||||||
"""
|
"""
|
||||||
- Search title in existing tracks
|
- Search title in existing tracks
|
||||||
@ -465,8 +445,7 @@ class FileImporter:
|
|||||||
if tfd.track_id == 0 and tfd.destination_path != tfd.file_path_to_remove:
|
if tfd.track_id == 0 and tfd.destination_path != tfd.file_path_to_remove:
|
||||||
while os.path.exists(tfd.destination_path):
|
while os.path.exists(tfd.destination_path):
|
||||||
msg = (
|
msg = (
|
||||||
"New import requested but default destination path"
|
f"New import requested but default destination path ({tfd.destination_path})"
|
||||||
f" ({tfd.destination_path})"
|
|
||||||
" already exists. Click OK and choose where to save this track"
|
" already exists. Click OK and choose where to save this track"
|
||||||
)
|
)
|
||||||
show_OK(title="Desintation path exists", msg=msg, parent=None)
|
show_OK(title="Desintation path exists", msg=msg, parent=None)
|
||||||
@ -648,8 +627,7 @@ class DoTrackImport(QThread):
|
|||||||
f"Importing {os.path.basename(self.import_file_path)}", 5000
|
f"Importing {os.path.basename(self.import_file_path)}", 5000
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get audio metadata in this thread rather than calling
|
# Get audio metadata in this thread rather than calling function to save interactive time
|
||||||
# function to save interactive time
|
|
||||||
self.audio_metadata = helpers.get_audio_metadata(self.import_file_path)
|
self.audio_metadata = helpers.get_audio_metadata(self.import_file_path)
|
||||||
|
|
||||||
# Remove old file if so requested
|
# Remove old file if so requested
|
||||||
|
|||||||
@ -13,7 +13,6 @@ import tempfile
|
|||||||
from PyQt6.QtWidgets import QInputDialog, QMainWindow, QMessageBox, QWidget
|
from PyQt6.QtWidgets import QInputDialog, QMainWindow, QMessageBox, QWidget
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
import filetype
|
|
||||||
from mutagen.flac import FLAC # type: ignore
|
from mutagen.flac import FLAC # type: ignore
|
||||||
from mutagen.mp3 import MP3 # type: ignore
|
from mutagen.mp3 import MP3 # type: ignore
|
||||||
from pydub import AudioSegment, effects
|
from pydub import AudioSegment, effects
|
||||||
@ -51,14 +50,6 @@ def ask_yes_no(
|
|||||||
return button == QMessageBox.StandardButton.Yes
|
return button == QMessageBox.StandardButton.Yes
|
||||||
|
|
||||||
|
|
||||||
def audio_file_extension(fpath: str) -> str | None:
|
|
||||||
"""
|
|
||||||
Return the correct extension for this type of file.
|
|
||||||
"""
|
|
||||||
|
|
||||||
return filetype.guess(fpath).extension
|
|
||||||
|
|
||||||
|
|
||||||
def fade_point(
|
def fade_point(
|
||||||
audio_segment: AudioSegment,
|
audio_segment: AudioSegment,
|
||||||
fade_threshold: float = 0.0,
|
fade_threshold: float = 0.0,
|
||||||
@ -81,7 +72,7 @@ def fade_point(
|
|||||||
fade_threshold = max_vol
|
fade_threshold = max_vol
|
||||||
|
|
||||||
while (
|
while (
|
||||||
audio_segment[trim_ms: trim_ms + chunk_size].dBFS < fade_threshold
|
audio_segment[trim_ms : trim_ms + chunk_size].dBFS < fade_threshold
|
||||||
and trim_ms > 0
|
and trim_ms > 0
|
||||||
): # noqa W503
|
): # noqa W503
|
||||||
trim_ms -= chunk_size
|
trim_ms -= chunk_size
|
||||||
@ -103,9 +94,6 @@ def file_is_unreadable(path: Optional[str]) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def get_audio_segment(path: str) -> Optional[AudioSegment]:
|
def get_audio_segment(path: str) -> Optional[AudioSegment]:
|
||||||
if not path.endswith(audio_file_extension(path)):
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if path.endswith(".mp3"):
|
if path.endswith(".mp3"):
|
||||||
return AudioSegment.from_mp3(path)
|
return AudioSegment.from_mp3(path)
|
||||||
|
|||||||
@ -1,56 +0,0 @@
|
|||||||
from PyQt6.QtCore import QObject, QTimer, QElapsedTimer
|
|
||||||
import logging
|
|
||||||
import time
|
|
||||||
|
|
||||||
from config import Config
|
|
||||||
|
|
||||||
class EventLoopJitterMonitor(QObject):
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
parent=None,
|
|
||||||
interval_ms: int = 20,
|
|
||||||
jitter_threshold_ms: int = 100,
|
|
||||||
log_cooldown_s: float = 1.0,
|
|
||||||
):
|
|
||||||
super().__init__(parent)
|
|
||||||
self._interval = interval_ms
|
|
||||||
self._jitter_threshold = jitter_threshold_ms
|
|
||||||
self._log_cooldown_s = log_cooldown_s
|
|
||||||
|
|
||||||
self._timer = QTimer(self)
|
|
||||||
self._timer.setInterval(self._interval)
|
|
||||||
self._timer.timeout.connect(self._on_timeout)
|
|
||||||
|
|
||||||
self._elapsed = QElapsedTimer()
|
|
||||||
self._elapsed.start()
|
|
||||||
self._last = self._elapsed.elapsed()
|
|
||||||
|
|
||||||
# child logger: e.g. "musicmuster.jitter"
|
|
||||||
self._log = logging.getLogger(f"{Config.LOG_NAME}.jitter")
|
|
||||||
self._last_log_time = 0.0
|
|
||||||
|
|
||||||
def start(self) -> None:
|
|
||||||
self._timer.start()
|
|
||||||
|
|
||||||
def _on_timeout(self) -> None:
|
|
||||||
now_ms = self._elapsed.elapsed()
|
|
||||||
delta = now_ms - self._last
|
|
||||||
self._last = now_ms
|
|
||||||
|
|
||||||
if delta > (self._interval + self._jitter_threshold):
|
|
||||||
self._log_jitter(now_ms, delta)
|
|
||||||
|
|
||||||
def _log_jitter(self, now_ms: int, gap_ms: int) -> None:
|
|
||||||
now = time.monotonic()
|
|
||||||
|
|
||||||
# simple rate limit: only one log every log_cooldown_s
|
|
||||||
if now - self._last_log_time < self._log_cooldown_s:
|
|
||||||
return
|
|
||||||
self._last_log_time = now
|
|
||||||
|
|
||||||
self._log.warning(
|
|
||||||
"Event loop gap detected: t=%d ms, gap=%d ms (interval=%d ms)",
|
|
||||||
now_ms,
|
|
||||||
gap_ms,
|
|
||||||
self._interval,
|
|
||||||
)
|
|
||||||
79
app/log.py
79
app/log.py
@ -1,24 +1,21 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# Standard library imports
|
# Standard library imports
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from functools import wraps
|
|
||||||
import logging
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
from traceback import print_exception
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
# PyQt imports
|
# PyQt imports
|
||||||
from PyQt6.QtWidgets import QApplication, QMessageBox
|
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
import stackprinter # type: ignore
|
import stackprinter # type: ignore
|
||||||
|
|
||||||
# App imports
|
# App imports
|
||||||
from config import Config
|
from config import Config
|
||||||
from classes import ApplicationError
|
|
||||||
|
|
||||||
|
|
||||||
class FunctionFilter(logging.Filter):
|
class FunctionFilter(logging.Filter):
|
||||||
@ -79,60 +76,26 @@ with open("app/logging.yaml", "r") as f:
|
|||||||
log = logging.getLogger(Config.LOG_NAME)
|
log = logging.getLogger(Config.LOG_NAME)
|
||||||
|
|
||||||
|
|
||||||
def handle_exception(exc_type, exc_value, exc_traceback):
|
def log_uncaught_exceptions(type_, value, traceback):
|
||||||
error = str(exc_value)
|
from helpers import send_mail
|
||||||
if issubclass(exc_type, ApplicationError):
|
|
||||||
log.error(error)
|
|
||||||
else:
|
|
||||||
# Handle unexpected errors (log and display)
|
|
||||||
error_msg = "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
|
|
||||||
|
|
||||||
print(stackprinter.format(exc_value, suppressed_paths=['/.venv'], style='darkbg'))
|
print("\033[1;31;47m")
|
||||||
|
print_exception(type_, value, traceback)
|
||||||
msg = stackprinter.format(exc_value)
|
print("\033[1;37;40m")
|
||||||
log.error(msg)
|
print(
|
||||||
log.error(error_msg)
|
stackprinter.format(
|
||||||
print("Critical error:", error_msg) # Consider logging instead of print
|
value, suppressed_paths=["/pypoetry/virtualenvs/"], style="darkbg"
|
||||||
|
)
|
||||||
if os.environ["MM_ENV"] == "PRODUCTION":
|
)
|
||||||
from helpers import send_mail
|
if os.environ["MM_ENV"] == "PRODUCTION":
|
||||||
|
msg = stackprinter.format(value)
|
||||||
send_mail(
|
send_mail(
|
||||||
Config.ERRORS_TO,
|
Config.ERRORS_TO,
|
||||||
Config.ERRORS_FROM,
|
Config.ERRORS_FROM,
|
||||||
"Exception (log_uncaught_exceptions) from musicmuster",
|
"Exception (log_uncaught_exceptions) from musicmuster",
|
||||||
msg,
|
msg,
|
||||||
)
|
)
|
||||||
if QApplication.instance() is not None:
|
log.debug(msg)
|
||||||
fname = os.path.split(exc_traceback.tb_frame.f_code.co_filename)[1]
|
|
||||||
msg = f"ApplicationError: {error}\nat {fname}:{exc_traceback.tb_lineno}"
|
|
||||||
QMessageBox.critical(None, "Application Error", msg)
|
|
||||||
|
|
||||||
|
|
||||||
def truncate_large(obj, limit=5):
|
sys.excepthook = log_uncaught_exceptions
|
||||||
"""Helper to truncate large lists or other iterables."""
|
|
||||||
if isinstance(obj, (list, tuple, set)):
|
|
||||||
if len(obj) > limit:
|
|
||||||
return f"{type(obj).__name__}(len={len(obj)}, items={list(obj)[:limit]}...)"
|
|
||||||
|
|
||||||
return repr(obj)
|
|
||||||
|
|
||||||
|
|
||||||
def log_call(func):
|
|
||||||
@wraps(func)
|
|
||||||
def wrapper(*args, **kwargs):
|
|
||||||
args_repr = [truncate_large(a) for a in args]
|
|
||||||
kwargs_repr = [f"{k}={truncate_large(v)}" for k, v in kwargs.items()]
|
|
||||||
params_repr = ", ".join(args_repr + kwargs_repr)
|
|
||||||
log.debug(f"call {func.__name__}({params_repr})")
|
|
||||||
try:
|
|
||||||
result = func(*args, **kwargs)
|
|
||||||
log.debug(f"return {func.__name__}: {truncate_large(result)}")
|
|
||||||
return result
|
|
||||||
except Exception as e:
|
|
||||||
log.debug(f"exception in {func.__name__}: {e}")
|
|
||||||
raise
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
|
|
||||||
sys.excepthook = handle_exception
|
|
||||||
|
|||||||
@ -23,8 +23,8 @@ filters:
|
|||||||
# - function-name-1
|
# - function-name-1
|
||||||
# - function-name-2
|
# - function-name-2
|
||||||
musicmuster:
|
musicmuster:
|
||||||
|
- update_clocks
|
||||||
- play_next
|
- play_next
|
||||||
jittermonitor: []
|
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
stderr:
|
stderr:
|
||||||
|
|||||||
@ -10,8 +10,6 @@ import sys
|
|||||||
# PyQt imports
|
# PyQt imports
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
from dogpile.cache import make_region
|
|
||||||
from dogpile.cache.api import NO_VALUE
|
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
bindparam,
|
bindparam,
|
||||||
delete,
|
delete,
|
||||||
@ -22,7 +20,7 @@ from sqlalchemy import (
|
|||||||
)
|
)
|
||||||
from sqlalchemy.exc import IntegrityError, ProgrammingError
|
from sqlalchemy.exc import IntegrityError, ProgrammingError
|
||||||
from sqlalchemy.orm.exc import NoResultFound
|
from sqlalchemy.orm.exc import NoResultFound
|
||||||
from sqlalchemy.orm import joinedload, selectinload
|
from sqlalchemy.orm import joinedload
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
from sqlalchemy.engine.row import RowMapping
|
from sqlalchemy.engine.row import RowMapping
|
||||||
|
|
||||||
@ -42,12 +40,6 @@ if "unittest" in sys.modules and "sqlite" not in DATABASE_URL:
|
|||||||
raise ValueError("Unit tests running on non-Sqlite database")
|
raise ValueError("Unit tests running on non-Sqlite database")
|
||||||
db = DatabaseManager.get_instance(DATABASE_URL, engine_options=Config.ENGINE_OPTIONS).db
|
db = DatabaseManager.get_instance(DATABASE_URL, engine_options=Config.ENGINE_OPTIONS).db
|
||||||
|
|
||||||
# Configure the cache region
|
|
||||||
cache_region = make_region().configure(
|
|
||||||
'dogpile.cache.memory', # Use in-memory caching for now (switch to Redis if needed)
|
|
||||||
expiration_time=600 # Cache expires after 10 minutes
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def run_sql(session: Session, sql: str) -> Sequence[RowMapping]:
|
def run_sql(session: Session, sql: str) -> Sequence[RowMapping]:
|
||||||
"""
|
"""
|
||||||
@ -62,7 +54,6 @@ def run_sql(session: Session, sql: str) -> Sequence[RowMapping]:
|
|||||||
|
|
||||||
# Database classes
|
# Database classes
|
||||||
class NoteColours(dbtables.NoteColoursTable):
|
class NoteColours(dbtables.NoteColoursTable):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
session: Session,
|
session: Session,
|
||||||
@ -89,28 +80,13 @@ class NoteColours(dbtables.NoteColoursTable):
|
|||||||
Return all records
|
Return all records
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cache_key = "note_colours_all"
|
result = session.scalars(select(cls)).all()
|
||||||
cached_result = cache_region.get(cache_key)
|
|
||||||
|
|
||||||
if cached_result is not NO_VALUE:
|
|
||||||
return cached_result
|
|
||||||
|
|
||||||
# Query the database
|
|
||||||
result = session.scalars(
|
|
||||||
select(cls)
|
|
||||||
.where(
|
|
||||||
cls.enabled.is_(True),
|
|
||||||
)
|
|
||||||
.order_by(cls.order)
|
|
||||||
).all()
|
|
||||||
cache_region.set(cache_key, result)
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_colour(
|
def get_colour(
|
||||||
session: Session, text: str, foreground: bool = False
|
session: Session, text: str, foreground: bool = False
|
||||||
) -> str:
|
) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
Parse text and return background (foreground if foreground==True) colour
|
Parse text and return background (foreground if foreground==True) colour
|
||||||
string if matched, else None
|
string if matched, else None
|
||||||
@ -118,10 +94,16 @@ class NoteColours(dbtables.NoteColoursTable):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if not text:
|
if not text:
|
||||||
return ""
|
return None
|
||||||
|
|
||||||
match = False
|
match = False
|
||||||
for rec in NoteColours.get_all(session):
|
for rec in session.scalars(
|
||||||
|
select(NoteColours)
|
||||||
|
.where(
|
||||||
|
NoteColours.enabled.is_(True),
|
||||||
|
)
|
||||||
|
.order_by(NoteColours.order)
|
||||||
|
).all():
|
||||||
if rec.is_regex:
|
if rec.is_regex:
|
||||||
flags = re.UNICODE
|
flags = re.UNICODE
|
||||||
if not rec.is_casesensitive:
|
if not rec.is_casesensitive:
|
||||||
@ -139,16 +121,10 @@ class NoteColours(dbtables.NoteColoursTable):
|
|||||||
|
|
||||||
if match:
|
if match:
|
||||||
if foreground:
|
if foreground:
|
||||||
return rec.foreground or ""
|
return rec.foreground
|
||||||
else:
|
else:
|
||||||
return rec.colour
|
return rec.colour
|
||||||
return ""
|
return None
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def invalidate_cache() -> None:
|
|
||||||
"""Invalidate dogpile cache"""
|
|
||||||
|
|
||||||
cache_region.delete("note_colours_all")
|
|
||||||
|
|
||||||
|
|
||||||
class Playdates(dbtables.PlaydatesTable):
|
class Playdates(dbtables.PlaydatesTable):
|
||||||
@ -520,13 +496,9 @@ class PlaylistRows(dbtables.PlaylistRowsTable):
|
|||||||
For passed playlist, return a list of rows.
|
For passed playlist, return a list of rows.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
stmt = (
|
plrs = session.scalars(
|
||||||
select(cls)
|
select(cls).where(cls.playlist_id == playlist_id).order_by(cls.row_number)
|
||||||
.where(cls.playlist_id == playlist_id)
|
).all()
|
||||||
.options(selectinload(cls.track))
|
|
||||||
.order_by(cls.row_number)
|
|
||||||
)
|
|
||||||
plrs = session.execute(stmt).scalars().all()
|
|
||||||
|
|
||||||
return plrs
|
return plrs
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ from time import sleep
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
# import line_profiler
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pyqtgraph as pg # type: ignore
|
import pyqtgraph as pg # type: ignore
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
@ -30,7 +29,6 @@ from log import log
|
|||||||
from models import PlaylistRows
|
from models import PlaylistRows
|
||||||
from vlcmanager import VLCManager
|
from vlcmanager import VLCManager
|
||||||
|
|
||||||
|
|
||||||
# Define the VLC callback function type
|
# Define the VLC callback function type
|
||||||
# import ctypes
|
# import ctypes
|
||||||
# import platform
|
# import platform
|
||||||
@ -354,6 +352,21 @@ class _Music:
|
|||||||
self.player.set_position(position)
|
self.player.set_position(position)
|
||||||
self.start_dt = start_time
|
self.start_dt = start_time
|
||||||
|
|
||||||
|
# For as-yet unknown reasons. sometimes the volume gets
|
||||||
|
# reset to zero within 200mS or so of starting play. This
|
||||||
|
# only happened since moving to Debian 12, which uses
|
||||||
|
# Pipewire for sound (which may be irrelevant).
|
||||||
|
# It has been known for the volume to need correcting more
|
||||||
|
# than once in the first 200mS.
|
||||||
|
# Update August 2024: This no longer seems to be an issue
|
||||||
|
# for _ in range(3):
|
||||||
|
# if self.player:
|
||||||
|
# volume = self.player.audio_get_volume()
|
||||||
|
# if volume < Config.VLC_VOLUME_DEFAULT:
|
||||||
|
# self.set_volume(Config.VLC_VOLUME_DEFAULT)
|
||||||
|
# log.error(f"Reset from {volume=}")
|
||||||
|
# sleep(0.1)
|
||||||
|
|
||||||
def set_position(self, position: float) -> None:
|
def set_position(self, position: float) -> None:
|
||||||
"""
|
"""
|
||||||
Set player position
|
Set player position
|
||||||
@ -377,6 +390,17 @@ class _Music:
|
|||||||
volume = Config.VLC_VOLUME_DEFAULT
|
volume = Config.VLC_VOLUME_DEFAULT
|
||||||
|
|
||||||
self.player.audio_set_volume(volume)
|
self.player.audio_set_volume(volume)
|
||||||
|
# Ensure volume correct
|
||||||
|
# For as-yet unknown reasons. sometimes the volume gets
|
||||||
|
# reset to zero within 200mS or so of starting play. This
|
||||||
|
# only happened since moving to Debian 12, which uses
|
||||||
|
# Pipewire for sound (which may be irrelevant).
|
||||||
|
for _ in range(3):
|
||||||
|
current_volume = self.player.audio_get_volume()
|
||||||
|
if current_volume < volume:
|
||||||
|
self.player.audio_set_volume(volume)
|
||||||
|
log.debug(f"Reset from {volume=}")
|
||||||
|
sleep(0.1)
|
||||||
|
|
||||||
def stop(self) -> None:
|
def stop(self) -> None:
|
||||||
"""Immediately stop playing"""
|
"""Immediately stop playing"""
|
||||||
@ -415,12 +439,6 @@ class RowAndTrack:
|
|||||||
self.row_number = playlist_row.row_number
|
self.row_number = playlist_row.row_number
|
||||||
self.track_id = playlist_row.track_id
|
self.track_id = playlist_row.track_id
|
||||||
|
|
||||||
# Playlist display data
|
|
||||||
self.row_fg: Optional[str] = None
|
|
||||||
self.row_bg: Optional[str] = None
|
|
||||||
self.note_fg: Optional[str] = None
|
|
||||||
self.note_bg: Optional[str] = None
|
|
||||||
|
|
||||||
# Collect track data if there's a track
|
# Collect track data if there's a track
|
||||||
if playlist_row.track_id:
|
if playlist_row.track_id:
|
||||||
self.artist = playlist_row.track.artist
|
self.artist = playlist_row.track.artist
|
||||||
@ -440,7 +458,7 @@ class RowAndTrack:
|
|||||||
self.title = playlist_row.track.title
|
self.title = playlist_row.track.title
|
||||||
else:
|
else:
|
||||||
self.artist = ""
|
self.artist = ""
|
||||||
self.bitrate = 0
|
self.bitrate = None
|
||||||
self.duration = 0
|
self.duration = 0
|
||||||
self.fade_at = 0
|
self.fade_at = 0
|
||||||
self.intro = None
|
self.intro = None
|
||||||
|
|||||||
@ -57,13 +57,11 @@ from PyQt6.QtWidgets import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
# import line_profiler
|
|
||||||
from pygame import mixer
|
from pygame import mixer
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
import stackprinter # type: ignore
|
import stackprinter # type: ignore
|
||||||
|
|
||||||
# App imports
|
# App imports
|
||||||
from audacity_controller import AudacityController
|
|
||||||
from classes import (
|
from classes import (
|
||||||
ApplicationError,
|
ApplicationError,
|
||||||
Filter,
|
Filter,
|
||||||
@ -73,8 +71,8 @@ from classes import (
|
|||||||
from config import Config
|
from config import Config
|
||||||
from dialogs import TrackSelectDialog
|
from dialogs import TrackSelectDialog
|
||||||
from file_importer import FileImporter
|
from file_importer import FileImporter
|
||||||
from log import log, log_call
|
from helpers import file_is_unreadable, get_name
|
||||||
from helpers import ask_yes_no, file_is_unreadable, get_name, show_warning
|
from log import log
|
||||||
from models import db, Playdates, PlaylistRows, Playlists, Queries, Settings, Tracks
|
from models import db, Playdates, PlaylistRows, Playlists, Queries, Settings, Tracks
|
||||||
from music_manager import RowAndTrack, track_sequence
|
from music_manager import RowAndTrack, track_sequence
|
||||||
from playlistmodel import PlaylistModel, PlaylistProxyModel
|
from playlistmodel import PlaylistModel, PlaylistProxyModel
|
||||||
@ -90,7 +88,6 @@ from ui.main_window_footer_ui import Ui_FooterSection # type: ignore
|
|||||||
from utilities import check_db, update_bitrates
|
from utilities import check_db, update_bitrates
|
||||||
import helpers
|
import helpers
|
||||||
|
|
||||||
from jittermonitor import EventLoopJitterMonitor
|
|
||||||
|
|
||||||
class Current:
|
class Current:
|
||||||
base_model: PlaylistModel
|
base_model: PlaylistModel
|
||||||
@ -770,14 +767,22 @@ class PreviewManager:
|
|||||||
|
|
||||||
self.intro = ms
|
self.intro = ms
|
||||||
|
|
||||||
def set_track_info(self, track_id: int, track_intro: int, track_path: str) -> None:
|
def set_track_info(self, info: TrackInfo) -> None:
|
||||||
self.track_id = track_id
|
self.track_id = info.track_id
|
||||||
self.intro = track_intro
|
self.row_number = info.row_number
|
||||||
self.path = track_path
|
|
||||||
|
with db.Session() as session:
|
||||||
|
track = session.get(Tracks, self.track_id)
|
||||||
|
if not track:
|
||||||
|
raise ValueError(
|
||||||
|
f"PreviewManager: unable to retreive track {self.track_id=}"
|
||||||
|
)
|
||||||
|
self.intro = track.intro
|
||||||
|
self.path = track.path
|
||||||
|
|
||||||
# Check file readable
|
# Check file readable
|
||||||
if file_is_unreadable(self.path):
|
if file_is_unreadable(self.path):
|
||||||
raise ValueError(f"PreviewManager.__init__: {track_path=} unreadable")
|
raise ValueError(f"PreviewManager.__init__: {track.path=} unreadable")
|
||||||
|
|
||||||
mixer.music.load(self.path)
|
mixer.music.load(self.path)
|
||||||
|
|
||||||
@ -785,6 +790,7 @@ class PreviewManager:
|
|||||||
mixer.music.stop()
|
mixer.music.stop()
|
||||||
mixer.music.unload()
|
mixer.music.unload()
|
||||||
self.path = ""
|
self.path = ""
|
||||||
|
self.row_number = None
|
||||||
self.track_id = 0
|
self.track_id = 0
|
||||||
self.start_time = None
|
self.start_time = None
|
||||||
|
|
||||||
@ -1207,26 +1213,9 @@ class Window(QMainWindow):
|
|||||||
self.action_quicklog = QShortcut(QKeySequence("Ctrl+L"), self)
|
self.action_quicklog = QShortcut(QKeySequence("Ctrl+L"), self)
|
||||||
self.action_quicklog.activated.connect(self.quicklog)
|
self.action_quicklog.activated.connect(self.quicklog)
|
||||||
|
|
||||||
|
|
||||||
# Jitter monitor - log delays in main event loop
|
|
||||||
self.jitter_monitor = EventLoopJitterMonitor(
|
|
||||||
parent=self,
|
|
||||||
interval_ms=20,
|
|
||||||
jitter_threshold_ms=100, # only care about >~100 ms
|
|
||||||
log_cooldown_s=1.0, # at most 1 warning per second
|
|
||||||
)
|
|
||||||
self.jitter_monitor.start()
|
|
||||||
|
|
||||||
self.load_last_playlists()
|
self.load_last_playlists()
|
||||||
self.stop_autoplay = False
|
self.stop_autoplay = False
|
||||||
|
|
||||||
# Set up for Audacity
|
|
||||||
try:
|
|
||||||
self.ac: Optional[AudacityController] = AudacityController()
|
|
||||||
except ApplicationError as e:
|
|
||||||
self.ac = None
|
|
||||||
show_warning(self, "Audacity error", str(e))
|
|
||||||
|
|
||||||
# # # # # # # # # # Overrides # # # # # # # # # #
|
# # # # # # # # # # Overrides # # # # # # # # # #
|
||||||
|
|
||||||
def closeEvent(self, event: Optional[QCloseEvent]) -> None:
|
def closeEvent(self, event: Optional[QCloseEvent]) -> None:
|
||||||
@ -1450,27 +1439,7 @@ class Window(QMainWindow):
|
|||||||
|
|
||||||
# Keep a reference else it will be gc'd
|
# Keep a reference else it will be gc'd
|
||||||
self.query_dialog = QueryDialog(session, query_id)
|
self.query_dialog = QueryDialog(session, query_id)
|
||||||
if self.query_dialog.exec():
|
self.query_dialog.exec()
|
||||||
new_row_number = self.current_row_or_end()
|
|
||||||
base_model = self.current.base_model
|
|
||||||
for track_id in self.query_dialog.selected_tracks:
|
|
||||||
# Check whether track is already in playlist
|
|
||||||
move_existing = False
|
|
||||||
existing_prd = base_model.is_track_in_playlist(track_id)
|
|
||||||
if existing_prd is not None:
|
|
||||||
if ask_yes_no(
|
|
||||||
"Duplicate row",
|
|
||||||
"Track already in playlist. " "Move to new location?",
|
|
||||||
default_yes=True,
|
|
||||||
):
|
|
||||||
move_existing = True
|
|
||||||
|
|
||||||
if move_existing and existing_prd:
|
|
||||||
base_model.move_track_add_note(new_row_number, existing_prd, note="")
|
|
||||||
else:
|
|
||||||
base_model.insert_row(new_row_number, track_id)
|
|
||||||
|
|
||||||
new_row_number += 1
|
|
||||||
|
|
||||||
# # # # # # # # # # Playlist management functions # # # # # # # # # #
|
# # # # # # # # # # Playlist management functions # # # # # # # # # #
|
||||||
|
|
||||||
@ -1486,7 +1455,6 @@ class Window(QMainWindow):
|
|||||||
|
|
||||||
return Playlists(session, name, template_id)
|
return Playlists(session, name, template_id)
|
||||||
|
|
||||||
@log_call
|
|
||||||
def _open_playlist(self, playlist: Playlists, is_template: bool = False) -> int:
|
def _open_playlist(self, playlist: Playlists, is_template: bool = False) -> int:
|
||||||
"""
|
"""
|
||||||
With passed playlist:
|
With passed playlist:
|
||||||
@ -2009,7 +1977,6 @@ class Window(QMainWindow):
|
|||||||
dlg.exec()
|
dlg.exec()
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
@log_call
|
|
||||||
def load_last_playlists(self) -> None:
|
def load_last_playlists(self) -> None:
|
||||||
"""Load the playlists that were open when the last session closed"""
|
"""Load the playlists that were open when the last session closed"""
|
||||||
|
|
||||||
@ -2156,7 +2123,7 @@ class Window(QMainWindow):
|
|||||||
|
|
||||||
webbrowser.get("browser").open_new_tab(url)
|
webbrowser.get("browser").open_new_tab(url)
|
||||||
|
|
||||||
def paste_rows(self, dummy_for_profiling: int | None = None) -> None:
|
def paste_rows(self) -> None:
|
||||||
"""
|
"""
|
||||||
Paste earlier cut rows.
|
Paste earlier cut rows.
|
||||||
"""
|
"""
|
||||||
@ -2217,6 +2184,14 @@ class Window(QMainWindow):
|
|||||||
if self.return_pressed_in_error():
|
if self.return_pressed_in_error():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Issue #223 concerns a very short pause (maybe 0.1s) sometimes
|
||||||
|
# when starting to play at track. Resolution appears to be to
|
||||||
|
# disable timer10 for a short time. Timer is re-enabled in
|
||||||
|
# update_clocks.
|
||||||
|
|
||||||
|
self.timer10.stop()
|
||||||
|
log.debug("issue223: play_next: 10ms timer disabled")
|
||||||
|
|
||||||
# If there's currently a track playing, fade it.
|
# If there's currently a track playing, fade it.
|
||||||
if track_sequence.current:
|
if track_sequence.current:
|
||||||
track_sequence.current.fade()
|
track_sequence.current.fade()
|
||||||
@ -2288,33 +2263,15 @@ class Window(QMainWindow):
|
|||||||
return
|
return
|
||||||
if not track_info:
|
if not track_info:
|
||||||
return
|
return
|
||||||
self.preview_manager.row_number = track_info.row_number
|
self.preview_manager.set_track_info(track_info)
|
||||||
with db.Session() as session:
|
self.preview_manager.play()
|
||||||
track = session.get(Tracks, track_info.track_id)
|
|
||||||
if not track:
|
|
||||||
raise ApplicationError(
|
|
||||||
f"musicmuster.preview: unable to retreive track {track_info.track_id=}"
|
|
||||||
)
|
|
||||||
self.preview_manager.set_track_info(
|
|
||||||
track_id=track.id,
|
|
||||||
track_path=track.path,
|
|
||||||
track_intro=track.intro
|
|
||||||
)
|
|
||||||
self.preview_manager.play()
|
|
||||||
self.show_status_message(
|
|
||||||
f"Preview: {track.title} / {track.artist} (row {track_info.row_number})",
|
|
||||||
0
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self.preview_manager.stop()
|
self.preview_manager.stop()
|
||||||
self.show_status_message("", 0)
|
|
||||||
|
|
||||||
def preview_arm(self):
|
def preview_arm(self):
|
||||||
"""Manager arm button for setting intro length"""
|
"""Manager arm button for setting intro length"""
|
||||||
|
|
||||||
self.footer_section.btnPreviewMark.setEnabled(
|
self.footer_section.btnPreviewMark.setEnabled(self.btnPreviewArm.isChecked())
|
||||||
self.footer_section.btnPreviewArm.isChecked()
|
|
||||||
)
|
|
||||||
|
|
||||||
def preview_back(self) -> None:
|
def preview_back(self) -> None:
|
||||||
"""Wind back preview file"""
|
"""Wind back preview file"""
|
||||||
@ -2351,10 +2308,7 @@ class Window(QMainWindow):
|
|||||||
session.commit()
|
session.commit()
|
||||||
self.preview_manager.set_intro(intro)
|
self.preview_manager.set_intro(intro)
|
||||||
self.current.base_model.refresh_row(session, row_number)
|
self.current.base_model.refresh_row(session, row_number)
|
||||||
roles = [
|
self.current.base_model.invalidate_row(row_number)
|
||||||
Qt.ItemDataRole.DisplayRole,
|
|
||||||
]
|
|
||||||
self.current.base_model.invalidate_row(row_number, roles)
|
|
||||||
|
|
||||||
def preview_start(self) -> None:
|
def preview_start(self) -> None:
|
||||||
"""Restart preview"""
|
"""Restart preview"""
|
||||||
@ -2574,14 +2528,10 @@ class Window(QMainWindow):
|
|||||||
def show_status_message(self, message: str, timing: int) -> None:
|
def show_status_message(self, message: str, timing: int) -> None:
|
||||||
"""
|
"""
|
||||||
Show status message in status bar for timing milliseconds
|
Show status message in status bar for timing milliseconds
|
||||||
Clear message if message is null string
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.statusbar:
|
if self.statusbar:
|
||||||
if message:
|
self.statusbar.showMessage(message, timing)
|
||||||
self.statusbar.showMessage(message, timing)
|
|
||||||
else:
|
|
||||||
self.statusbar.clearMessage()
|
|
||||||
|
|
||||||
def show_track(self, playlist_track: RowAndTrack) -> None:
|
def show_track(self, playlist_track: RowAndTrack) -> None:
|
||||||
"""Scroll to show track in plt"""
|
"""Scroll to show track in plt"""
|
||||||
@ -2728,7 +2678,8 @@ class Window(QMainWindow):
|
|||||||
|
|
||||||
# WARNING_MS_BEFORE_FADE milliseconds before fade starts, set
|
# WARNING_MS_BEFORE_FADE milliseconds before fade starts, set
|
||||||
# warning colour on time to silence box and enable play
|
# warning colour on time to silence box and enable play
|
||||||
# controls.
|
# controls. This is also a good time to re-enable the 10ms
|
||||||
|
# timer (see play_next() and issue #223).
|
||||||
|
|
||||||
elif time_to_fade <= Config.WARNING_MS_BEFORE_FADE:
|
elif time_to_fade <= Config.WARNING_MS_BEFORE_FADE:
|
||||||
self.footer_section.frame_fade.setStyleSheet(
|
self.footer_section.frame_fade.setStyleSheet(
|
||||||
@ -2736,6 +2687,10 @@ class Window(QMainWindow):
|
|||||||
)
|
)
|
||||||
self.catch_return_key = False
|
self.catch_return_key = False
|
||||||
self.show_status_message("Play controls: Enabled", 0)
|
self.show_status_message("Play controls: Enabled", 0)
|
||||||
|
# Re-enable 10ms timer (see above)
|
||||||
|
if not self.timer10.isActive():
|
||||||
|
self.timer10.start(10)
|
||||||
|
log.debug("issue223: update_clocks: 10ms timer enabled")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.footer_section.frame_silent.setStyleSheet("")
|
self.footer_section.frame_silent.setStyleSheet("")
|
||||||
@ -2856,8 +2811,8 @@ if __name__ == "__main__":
|
|||||||
with db.Session() as session:
|
with db.Session() as session:
|
||||||
update_bitrates(session)
|
update_bitrates(session)
|
||||||
else:
|
else:
|
||||||
app = QApplication(sys.argv)
|
|
||||||
try:
|
try:
|
||||||
|
app = QApplication(sys.argv)
|
||||||
# PyQt6 defaults to a grey for labels
|
# PyQt6 defaults to a grey for labels
|
||||||
palette = app.palette()
|
palette = app.palette()
|
||||||
palette.setColor(
|
palette.setColor(
|
||||||
@ -2875,7 +2830,6 @@ if __name__ == "__main__":
|
|||||||
win.show()
|
win.show()
|
||||||
status = app.exec()
|
status = app.exec()
|
||||||
sys.exit(status)
|
sys.exit(status)
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if os.environ["MM_ENV"] == "PRODUCTION":
|
if os.environ["MM_ENV"] == "PRODUCTION":
|
||||||
from helpers import send_mail
|
from helpers import send_mail
|
||||||
@ -2889,8 +2843,10 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
log.debug(msg)
|
log.debug(msg)
|
||||||
else:
|
else:
|
||||||
|
print("\033[1;31;47mUnhandled exception starts")
|
||||||
print(
|
print(
|
||||||
stackprinter.format(
|
stackprinter.format(
|
||||||
exc, suppressed_paths=["/pypoetry/virtualenvs/"], style="darkbg"
|
exc, suppressed_paths=["/pypoetry/virtualenvs/"], style="darkbg"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
print("Unhandled exception ends\033[1;37;40m")
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
# Standard library imports
|
# Standard library imports
|
||||||
|
# Allow forward reference to PlaylistModel
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
@ -11,6 +12,7 @@ import re
|
|||||||
from PyQt6.QtCore import (
|
from PyQt6.QtCore import (
|
||||||
QAbstractTableModel,
|
QAbstractTableModel,
|
||||||
QModelIndex,
|
QModelIndex,
|
||||||
|
QObject,
|
||||||
QRegularExpression,
|
QRegularExpression,
|
||||||
QSortFilterProxyModel,
|
QSortFilterProxyModel,
|
||||||
Qt,
|
Qt,
|
||||||
@ -24,7 +26,6 @@ from PyQt6.QtGui import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
# import line_profiler
|
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
import obswebsocket # type: ignore
|
import obswebsocket # type: ignore
|
||||||
|
|
||||||
@ -46,12 +47,12 @@ from helpers import (
|
|||||||
remove_substring_case_insensitive,
|
remove_substring_case_insensitive,
|
||||||
set_track_metadata,
|
set_track_metadata,
|
||||||
)
|
)
|
||||||
from log import log, log_call
|
from log import log
|
||||||
from models import db, NoteColours, Playdates, PlaylistRows, Tracks
|
from models import db, NoteColours, Playdates, PlaylistRows, Tracks
|
||||||
from music_manager import RowAndTrack, track_sequence
|
from music_manager import RowAndTrack, track_sequence
|
||||||
|
|
||||||
|
|
||||||
HEADER_NOTES_COLUMN = 0
|
HEADER_NOTES_COLUMN = 1
|
||||||
scene_change_re = re.compile(r"SetScene=\[([^[\]]*)\]")
|
scene_change_re = re.compile(r"SetScene=\[([^[\]]*)\]")
|
||||||
|
|
||||||
|
|
||||||
@ -75,13 +76,14 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self,
|
self,
|
||||||
playlist_id: int,
|
playlist_id: int,
|
||||||
is_template: bool,
|
is_template: bool,
|
||||||
|
*args: Optional[QObject],
|
||||||
|
**kwargs: Optional[QObject],
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
log.debug("PlaylistModel.__init__()")
|
log.debug("PlaylistModel.__init__()")
|
||||||
|
|
||||||
self.playlist_id = playlist_id
|
self.playlist_id = playlist_id
|
||||||
self.is_template = is_template
|
self.is_template = is_template
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.playlist_rows: dict[int, RowAndTrack] = {}
|
self.playlist_rows: dict[int, RowAndTrack] = {}
|
||||||
self.signals = MusicMusterSignals()
|
self.signals = MusicMusterSignals()
|
||||||
@ -99,17 +101,13 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return (
|
return (
|
||||||
f"<PlaylistModel: playlist_id={self.playlist_id}, "
|
f"<PlaylistModel: playlist_id={self.playlist_id}, {self.rowCount()} rows>"
|
||||||
f"is_template={self.is_template}, "
|
|
||||||
f"{self.rowCount()} rows>"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def active_section_header(self) -> int:
|
def active_section_header(self) -> int:
|
||||||
"""
|
"""
|
||||||
Return the row number of the first header that has any of the following below it:
|
Return the row number of the first header that has either unplayed tracks
|
||||||
- unplayed tracks
|
or currently being played track below it.
|
||||||
- the currently being played track
|
|
||||||
- the track marked as next to play
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
header_row = 0
|
header_row = 0
|
||||||
@ -121,20 +119,23 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
if not self.is_played_row(row_number):
|
if not self.is_played_row(row_number):
|
||||||
break
|
break
|
||||||
|
|
||||||
# Here means that row_number points to a played track. The
|
# If track is played, we need to check it's not the current
|
||||||
# current track will be marked as played when we start
|
# next or previous track because we don't want to scroll them
|
||||||
# playing it. It's also possible that the track marked as
|
# out of view
|
||||||
# next has already been played. Check for either of those.
|
|
||||||
|
|
||||||
for ts in [track_sequence.next, track_sequence.current]:
|
for ts in [
|
||||||
|
track_sequence.next,
|
||||||
|
track_sequence.current,
|
||||||
|
]:
|
||||||
if (
|
if (
|
||||||
ts
|
ts
|
||||||
and ts.row_number == row_number
|
and ts.row_number == row_number
|
||||||
and ts.playlist_id == self.playlist_id
|
and ts.playlist_id == self.playlist_id
|
||||||
):
|
):
|
||||||
# We've found the current or next track, so return
|
break
|
||||||
# the last-found header row
|
else:
|
||||||
return header_row
|
continue # continue iterating over playlist_rows
|
||||||
|
break # current row is in one of the track sequences
|
||||||
|
|
||||||
return header_row
|
return header_row
|
||||||
|
|
||||||
@ -151,54 +152,44 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
try:
|
try:
|
||||||
rat = self.playlist_rows[row_number]
|
rat = self.playlist_rows[row_number]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise ApplicationError(
|
log.error(
|
||||||
f"{self}: KeyError in add_track_to_header ({row_number=}, {track_id=})"
|
f"{self}: KeyError in add_track_to_header ({row_number=}, {track_id=})"
|
||||||
)
|
)
|
||||||
|
return
|
||||||
if rat.path:
|
if rat.path:
|
||||||
raise ApplicationError(
|
log.error(
|
||||||
f"{self}: Header row already has track associated ({rat=}, {track_id=})"
|
f"{self}: Header row already has track associated ({rat=}, {track_id=})"
|
||||||
)
|
)
|
||||||
|
return
|
||||||
with db.Session() as session:
|
with db.Session() as session:
|
||||||
playlistrow = session.get(PlaylistRows, rat.playlistrow_id)
|
playlistrow = session.get(PlaylistRows, rat.playlistrow_id)
|
||||||
if not playlistrow:
|
if playlistrow:
|
||||||
raise ApplicationError(
|
# Add track to PlaylistRows
|
||||||
f"{self}: Failed to retrieve playlist row ({rat.playlistrow_id=}"
|
playlistrow.track_id = track_id
|
||||||
)
|
# Add any further note (header will already have a note)
|
||||||
# Add track to PlaylistRows
|
if note:
|
||||||
playlistrow.track_id = track_id
|
playlistrow.note += "\n" + note
|
||||||
# Add any further note (header will already have a note)
|
# Update local copy
|
||||||
if note:
|
self.refresh_row(session, row_number)
|
||||||
playlistrow.note += " " + note
|
# Repaint row
|
||||||
session.commit()
|
self.invalidate_row(row_number)
|
||||||
|
session.commit()
|
||||||
# Update local copy
|
|
||||||
self.refresh_row(session, row_number)
|
|
||||||
# Repaint row
|
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.BackgroundRole,
|
|
||||||
Qt.ItemDataRole.DisplayRole,
|
|
||||||
Qt.ItemDataRole.FontRole,
|
|
||||||
Qt.ItemDataRole.ForegroundRole,
|
|
||||||
]
|
|
||||||
# only invalidate required roles
|
|
||||||
self.invalidate_row(row_number, roles)
|
|
||||||
|
|
||||||
self.signals.resize_rows_signal.emit(self.playlist_id)
|
self.signals.resize_rows_signal.emit(self.playlist_id)
|
||||||
|
|
||||||
def _background_role(self, row: int, column: int, rat: RowAndTrack) -> QBrush:
|
def background_role(self, row: int, column: int, rat: RowAndTrack) -> QBrush:
|
||||||
"""Return background setting"""
|
"""Return background setting"""
|
||||||
|
|
||||||
# Handle entire row colouring
|
# Handle entire row colouring
|
||||||
# Header row
|
# Header row
|
||||||
if self.is_header_row(row):
|
if self.is_header_row(row):
|
||||||
# Check for specific header colouring
|
# Check for specific header colouring
|
||||||
if rat.row_bg is None:
|
with db.Session() as session:
|
||||||
with db.Session() as session:
|
note_background = NoteColours.get_colour(session, rat.note)
|
||||||
rat.row_bg = NoteColours.get_colour(session, rat.note)
|
if note_background:
|
||||||
if rat.row_bg:
|
return QBrush(QColor(note_background))
|
||||||
return QBrush(QColor(rat.row_bg))
|
else:
|
||||||
else:
|
return QBrush(QColor(Config.COLOUR_NOTES_PLAYLIST))
|
||||||
return QBrush(QColor(Config.COLOUR_NOTES_PLAYLIST))
|
|
||||||
# Unreadable track file
|
# Unreadable track file
|
||||||
if file_is_unreadable(rat.path):
|
if file_is_unreadable(rat.path):
|
||||||
return QBrush(QColor(Config.COLOUR_UNREADABLE))
|
return QBrush(QColor(Config.COLOUR_UNREADABLE))
|
||||||
@ -230,11 +221,10 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
return QBrush(QColor(Config.COLOUR_BITRATE_OK))
|
return QBrush(QColor(Config.COLOUR_BITRATE_OK))
|
||||||
if column == Col.NOTE.value:
|
if column == Col.NOTE.value:
|
||||||
if rat.note:
|
if rat.note:
|
||||||
if rat.note_bg is None:
|
with db.Session() as session:
|
||||||
with db.Session() as session:
|
note_background = NoteColours.get_colour(session, rat.note)
|
||||||
rat.note_bg = NoteColours.get_colour(session, rat.note)
|
if note_background:
|
||||||
if rat.note_bg:
|
return QBrush(QColor(note_background))
|
||||||
return QBrush(QColor(rat.note_bg))
|
|
||||||
|
|
||||||
return QBrush()
|
return QBrush()
|
||||||
|
|
||||||
@ -267,27 +257,26 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
- update track times
|
- update track times
|
||||||
"""
|
"""
|
||||||
|
|
||||||
log.debug(f"{self}: current_track_started()")
|
|
||||||
|
|
||||||
if not track_sequence.current:
|
if not track_sequence.current:
|
||||||
return
|
return
|
||||||
|
|
||||||
row_number = track_sequence.current.row_number
|
row_number = track_sequence.current.row_number
|
||||||
|
|
||||||
# Check for OBS scene change
|
# Check for OBS scene change
|
||||||
|
log.debug(f"{self}: Call OBS scene change")
|
||||||
self.obs_scene_change(row_number)
|
self.obs_scene_change(row_number)
|
||||||
|
|
||||||
# Sanity check that we have a track_id
|
# Sanity check that we have a track_id
|
||||||
track_id = track_sequence.current.track_id
|
if not track_sequence.current.track_id:
|
||||||
if not track_id:
|
log.error(
|
||||||
raise ApplicationError(
|
f"{self}: current_track_started() called with {track_sequence.current.track_id=}"
|
||||||
f"{self}: current_track_started() called with {track_id=}"
|
|
||||||
)
|
)
|
||||||
|
return
|
||||||
|
|
||||||
with db.Session() as session:
|
with db.Session() as session:
|
||||||
# Update Playdates in database
|
# Update Playdates in database
|
||||||
log.debug(f"{self}: update playdates {track_id=}")
|
log.debug(f"{self}: update playdates")
|
||||||
Playdates(session, track_id)
|
Playdates(session, track_sequence.current.track_id)
|
||||||
|
|
||||||
# Mark track as played in playlist
|
# Mark track as played in playlist
|
||||||
log.debug(f"{self}: Mark track as played")
|
log.debug(f"{self}: Mark track as played")
|
||||||
@ -297,62 +286,43 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.refresh_row(session, plr.row_number)
|
self.refresh_row(session, plr.row_number)
|
||||||
else:
|
else:
|
||||||
log.error(
|
log.error(
|
||||||
f"{self}: Can't retrieve plr, "
|
f"{self}: Can't retrieve plr, {track_sequence.current.playlistrow_id=}"
|
||||||
f"{track_sequence.current.playlistrow_id=}"
|
|
||||||
)
|
)
|
||||||
session.commit()
|
|
||||||
|
|
||||||
# Update colour and times for current row
|
# Update colour and times for current row
|
||||||
# only invalidate required roles
|
self.invalidate_row(row_number)
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.DisplayRole
|
|
||||||
]
|
|
||||||
self.invalidate_row(row_number, roles)
|
|
||||||
|
|
||||||
# Update previous row in case we're hiding played rows
|
# Update previous row in case we're hiding played rows
|
||||||
if track_sequence.previous and track_sequence.previous.row_number:
|
if track_sequence.previous and track_sequence.previous.row_number:
|
||||||
# only invalidate required roles
|
self.invalidate_row(track_sequence.previous.row_number)
|
||||||
self.invalidate_row(track_sequence.previous.row_number, roles)
|
|
||||||
|
|
||||||
# Find next track
|
# Update all other track times
|
||||||
next_row = None
|
|
||||||
unplayed_rows = [
|
|
||||||
a
|
|
||||||
for a in self.get_unplayed_rows()
|
|
||||||
if not self.is_header_row(a)
|
|
||||||
and not file_is_unreadable(self.playlist_rows[a].path)
|
|
||||||
]
|
|
||||||
if unplayed_rows:
|
|
||||||
try:
|
|
||||||
next_row = min([a for a in unplayed_rows if a > row_number])
|
|
||||||
except ValueError:
|
|
||||||
next_row = min(unplayed_rows)
|
|
||||||
if next_row is not None:
|
|
||||||
self.set_next_row(next_row)
|
|
||||||
else:
|
|
||||||
# set_next_row() calls update_track_times(); else we call it
|
|
||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
|
|
||||||
|
# Find next track
|
||||||
|
next_row = None
|
||||||
|
unplayed_rows = [
|
||||||
|
a
|
||||||
|
for a in self.get_unplayed_rows()
|
||||||
|
if not self.is_header_row(a)
|
||||||
|
and not file_is_unreadable(self.playlist_rows[a].path)
|
||||||
|
]
|
||||||
|
if unplayed_rows:
|
||||||
|
try:
|
||||||
|
next_row = min([a for a in unplayed_rows if a > row_number])
|
||||||
|
except ValueError:
|
||||||
|
next_row = min(unplayed_rows)
|
||||||
|
if next_row is not None:
|
||||||
|
self.set_next_row(next_row)
|
||||||
|
|
||||||
|
session.commit()
|
||||||
|
|
||||||
def data(
|
def data(
|
||||||
self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole
|
self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole
|
||||||
) -> QVariant | QFont | QBrush | str | int:
|
) -> QVariant:
|
||||||
"""Return data to view"""
|
"""Return data to view"""
|
||||||
|
|
||||||
if (
|
if not index.isValid() or not (0 <= index.row() < len(self.playlist_rows)):
|
||||||
not index.isValid()
|
|
||||||
or not (0 <= index.row() < len(self.playlist_rows))
|
|
||||||
or role
|
|
||||||
in [
|
|
||||||
Qt.ItemDataRole.DecorationRole,
|
|
||||||
Qt.ItemDataRole.StatusTipRole,
|
|
||||||
Qt.ItemDataRole.WhatsThisRole,
|
|
||||||
Qt.ItemDataRole.SizeHintRole,
|
|
||||||
Qt.ItemDataRole.TextAlignmentRole,
|
|
||||||
Qt.ItemDataRole.CheckStateRole,
|
|
||||||
Qt.ItemDataRole.InitialSortOrderRole,
|
|
||||||
]
|
|
||||||
):
|
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
row = index.row()
|
row = index.row()
|
||||||
@ -360,21 +330,32 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# rat for playlist row data as it's used a lot
|
# rat for playlist row data as it's used a lot
|
||||||
rat = self.playlist_rows[row]
|
rat = self.playlist_rows[row]
|
||||||
|
|
||||||
# These are ordered in approximately the frequency with which
|
# Dispatch to role-specific functions
|
||||||
# they are called
|
dispatch_table = {
|
||||||
if role == Qt.ItemDataRole.BackgroundRole:
|
int(Qt.ItemDataRole.BackgroundRole): self.background_role,
|
||||||
return self._background_role(row, column, rat)
|
int(Qt.ItemDataRole.DisplayRole): self.display_role,
|
||||||
elif role == Qt.ItemDataRole.DisplayRole:
|
int(Qt.ItemDataRole.EditRole): self.edit_role,
|
||||||
return self._display_role(row, column, rat)
|
int(Qt.ItemDataRole.FontRole): self.font_role,
|
||||||
elif role == Qt.ItemDataRole.EditRole:
|
int(Qt.ItemDataRole.ForegroundRole): self.foreground_role,
|
||||||
return self._edit_role(row, column, rat)
|
int(Qt.ItemDataRole.ToolTipRole): self.tooltip_role,
|
||||||
elif role == Qt.ItemDataRole.FontRole:
|
}
|
||||||
return self._font_role(row, column, rat)
|
|
||||||
elif role == Qt.ItemDataRole.ForegroundRole:
|
|
||||||
return self._foreground_role(row, column, rat)
|
|
||||||
elif role == Qt.ItemDataRole.ToolTipRole:
|
|
||||||
return self._tooltip_role(row, column, rat)
|
|
||||||
|
|
||||||
|
if role in dispatch_table:
|
||||||
|
return QVariant(dispatch_table[role](row, column, rat))
|
||||||
|
|
||||||
|
# Document other roles but don't use them
|
||||||
|
if role in [
|
||||||
|
Qt.ItemDataRole.DecorationRole,
|
||||||
|
Qt.ItemDataRole.StatusTipRole,
|
||||||
|
Qt.ItemDataRole.WhatsThisRole,
|
||||||
|
Qt.ItemDataRole.SizeHintRole,
|
||||||
|
Qt.ItemDataRole.TextAlignmentRole,
|
||||||
|
Qt.ItemDataRole.CheckStateRole,
|
||||||
|
Qt.ItemDataRole.InitialSortOrderRole,
|
||||||
|
]:
|
||||||
|
return QVariant()
|
||||||
|
|
||||||
|
# Fall through to no-op
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
def delete_rows(self, row_numbers: list[int]) -> None:
|
def delete_rows(self, row_numbers: list[int]) -> None:
|
||||||
@ -404,9 +385,8 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
super().endRemoveRows()
|
super().endRemoveRows()
|
||||||
|
|
||||||
self.reset_track_sequence_row_numbers()
|
self.reset_track_sequence_row_numbers()
|
||||||
self.update_track_times()
|
|
||||||
|
|
||||||
def _display_role(self, row: int, column: int, rat: RowAndTrack) -> str:
|
def display_role(self, row: int, column: int, rat: RowAndTrack) -> QVariant:
|
||||||
"""
|
"""
|
||||||
Return text for display
|
Return text for display
|
||||||
"""
|
"""
|
||||||
@ -417,7 +397,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
if column == HEADER_NOTES_COLUMN:
|
if column == HEADER_NOTES_COLUMN:
|
||||||
column_span = 1
|
column_span = 1
|
||||||
if header_row:
|
if header_row:
|
||||||
column_span = self.columnCount() - HEADER_NOTES_COLUMN
|
column_span = self.columnCount() - 1
|
||||||
self.signals.span_cells_signal.emit(
|
self.signals.span_cells_signal.emit(
|
||||||
self.playlist_id, row, HEADER_NOTES_COLUMN, 1, column_span
|
self.playlist_id, row, HEADER_NOTES_COLUMN, 1, column_span
|
||||||
)
|
)
|
||||||
@ -426,45 +406,45 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
if column == HEADER_NOTES_COLUMN:
|
if column == HEADER_NOTES_COLUMN:
|
||||||
header_text = self.header_text(rat)
|
header_text = self.header_text(rat)
|
||||||
if not header_text:
|
if not header_text:
|
||||||
return Config.SECTION_HEADER
|
return QVariant(Config.TEXT_NO_TRACK_NO_NOTE)
|
||||||
else:
|
else:
|
||||||
formatted_header = self.header_text(rat)
|
formatted_header = self.header_text(rat)
|
||||||
trimmed_header = self.remove_section_timer_markers(formatted_header)
|
trimmed_header = self.remove_section_timer_markers(formatted_header)
|
||||||
return trimmed_header
|
return QVariant(trimmed_header)
|
||||||
else:
|
else:
|
||||||
return ""
|
return QVariant("")
|
||||||
|
|
||||||
if column == Col.START_TIME.value:
|
if column == Col.START_TIME.value:
|
||||||
start_time = rat.forecast_start_time
|
start_time = rat.forecast_start_time
|
||||||
if start_time:
|
if start_time:
|
||||||
return start_time.strftime(Config.TRACK_TIME_FORMAT)
|
return QVariant(start_time.strftime(Config.TRACK_TIME_FORMAT))
|
||||||
return ""
|
return QVariant()
|
||||||
|
|
||||||
if column == Col.END_TIME.value:
|
if column == Col.END_TIME.value:
|
||||||
end_time = rat.forecast_end_time
|
end_time = rat.forecast_end_time
|
||||||
if end_time:
|
if end_time:
|
||||||
return end_time.strftime(Config.TRACK_TIME_FORMAT)
|
return QVariant(end_time.strftime(Config.TRACK_TIME_FORMAT))
|
||||||
return ""
|
return QVariant()
|
||||||
|
|
||||||
if column == Col.INTRO.value:
|
if column == Col.INTRO.value:
|
||||||
if rat.intro:
|
if rat.intro:
|
||||||
return f"{rat.intro / 1000:{Config.INTRO_SECONDS_FORMAT}}"
|
return QVariant(f"{rat.intro / 1000:{Config.INTRO_SECONDS_FORMAT}}")
|
||||||
else:
|
else:
|
||||||
return ""
|
return QVariant("")
|
||||||
|
|
||||||
dispatch_table: dict[int, str] = {
|
dispatch_table = {
|
||||||
Col.ARTIST.value: rat.artist,
|
Col.ARTIST.value: QVariant(rat.artist),
|
||||||
Col.BITRATE.value: str(rat.bitrate),
|
Col.BITRATE.value: QVariant(rat.bitrate),
|
||||||
Col.DURATION.value: ms_to_mmss(rat.duration),
|
Col.DURATION.value: QVariant(ms_to_mmss(rat.duration)),
|
||||||
Col.LAST_PLAYED.value: get_relative_date(rat.lastplayed),
|
Col.LAST_PLAYED.value: QVariant(get_relative_date(rat.lastplayed)),
|
||||||
Col.NOTE.value: rat.note,
|
Col.NOTE.value: QVariant(rat.note),
|
||||||
Col.START_GAP.value: str(rat.start_gap),
|
Col.START_GAP.value: QVariant(rat.start_gap),
|
||||||
Col.TITLE.value: rat.title,
|
Col.TITLE.value: QVariant(rat.title),
|
||||||
}
|
}
|
||||||
if column in dispatch_table:
|
if column in dispatch_table:
|
||||||
return dispatch_table[column]
|
return dispatch_table[column]
|
||||||
|
|
||||||
return ""
|
return QVariant()
|
||||||
|
|
||||||
def end_reset_model(self, playlist_id: int) -> None:
|
def end_reset_model(self, playlist_id: int) -> None:
|
||||||
"""
|
"""
|
||||||
@ -481,38 +461,37 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
super().endResetModel()
|
super().endResetModel()
|
||||||
self.reset_track_sequence_row_numbers()
|
self.reset_track_sequence_row_numbers()
|
||||||
|
|
||||||
def _edit_role(self, row: int, column: int, rat: RowAndTrack) -> str | int:
|
def edit_role(self, row: int, column: int, rat: RowAndTrack) -> QVariant:
|
||||||
"""
|
"""
|
||||||
Return value for editing
|
Return text for editing
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# If this is a header row and we're being asked for the
|
# If this is a header row and we're being asked for the
|
||||||
# HEADER_NOTES_COLUMN, return the note value
|
# HEADER_NOTES_COLUMN, return the note value
|
||||||
if self.is_header_row(row) and column == HEADER_NOTES_COLUMN:
|
if self.is_header_row(row) and column == HEADER_NOTES_COLUMN:
|
||||||
return rat.note
|
return QVariant(rat.note)
|
||||||
|
|
||||||
if column == Col.INTRO.value:
|
if column == Col.INTRO.value:
|
||||||
return rat.intro or 0
|
return QVariant(rat.intro)
|
||||||
if column == Col.TITLE.value:
|
if column == Col.TITLE.value:
|
||||||
return rat.title
|
return QVariant(rat.title)
|
||||||
if column == Col.ARTIST.value:
|
if column == Col.ARTIST.value:
|
||||||
return rat.artist
|
return QVariant(rat.artist)
|
||||||
if column == Col.NOTE.value:
|
if column == Col.NOTE.value:
|
||||||
return rat.note
|
return QVariant(rat.note)
|
||||||
|
|
||||||
return ""
|
return QVariant()
|
||||||
|
|
||||||
def _foreground_role(self, row: int, column: int, rat: RowAndTrack) -> QBrush:
|
def foreground_role(self, row: int, column: int, rat: RowAndTrack) -> QBrush:
|
||||||
"""Return header foreground colour or QBrush() if none"""
|
"""Return header foreground colour or QBrush() if none"""
|
||||||
|
|
||||||
if self.is_header_row(row):
|
if self.is_header_row(row):
|
||||||
if rat.row_fg is None:
|
with db.Session() as session:
|
||||||
with db.Session() as session:
|
note_foreground = NoteColours.get_colour(
|
||||||
rat.row_fg = NoteColours.get_colour(
|
session, rat.note, foreground=True
|
||||||
session, rat.note, foreground=True
|
)
|
||||||
)
|
if note_foreground:
|
||||||
if rat.row_fg:
|
return QBrush(QColor(note_foreground))
|
||||||
return QBrush(QColor(rat.row_fg))
|
|
||||||
|
|
||||||
return QBrush()
|
return QBrush()
|
||||||
|
|
||||||
@ -534,24 +513,24 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
Col.ARTIST.value,
|
Col.ARTIST.value,
|
||||||
Col.NOTE.value,
|
Col.NOTE.value,
|
||||||
Col.INTRO.value,
|
Col.INTRO.value,
|
||||||
] or self.is_header_row(index.row()) and index.column() == HEADER_NOTES_COLUMN:
|
]:
|
||||||
return default | Qt.ItemFlag.ItemIsEditable
|
return default | Qt.ItemFlag.ItemIsEditable
|
||||||
|
|
||||||
return default
|
return default
|
||||||
|
|
||||||
def _font_role(self, row: int, column: int, rat: RowAndTrack) -> QFont:
|
def font_role(self, row: int, column: int, rat: RowAndTrack) -> QVariant:
|
||||||
"""
|
"""
|
||||||
Return font
|
Return font
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Notes column is never bold
|
# Notes column is never bold
|
||||||
if column == Col.NOTE.value:
|
if column == Col.NOTE.value:
|
||||||
return QFont()
|
return QVariant()
|
||||||
|
|
||||||
boldfont = QFont()
|
boldfont = QFont()
|
||||||
boldfont.setBold(not self.playlist_rows[row].played)
|
boldfont.setBold(not self.playlist_rows[row].played)
|
||||||
|
|
||||||
return boldfont
|
return QVariant(boldfont)
|
||||||
|
|
||||||
def get_duplicate_rows(self) -> list[int]:
|
def get_duplicate_rows(self) -> list[int]:
|
||||||
"""
|
"""
|
||||||
@ -640,6 +619,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
for a in self.playlist_rows.values()
|
for a in self.playlist_rows.values()
|
||||||
if not a.played and a.track_id is not None
|
if not a.played and a.track_id is not None
|
||||||
]
|
]
|
||||||
|
# log.debug(f"{self}: get_unplayed_rows() returned: {result=}")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def headerData(
|
def headerData(
|
||||||
@ -647,22 +627,22 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
section: int,
|
section: int,
|
||||||
orientation: Qt.Orientation,
|
orientation: Qt.Orientation,
|
||||||
role: int = Qt.ItemDataRole.DisplayRole,
|
role: int = Qt.ItemDataRole.DisplayRole,
|
||||||
) -> str | int | QFont | QVariant:
|
) -> QVariant:
|
||||||
"""
|
"""
|
||||||
Return text for headers
|
Return text for headers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
display_dispatch_table = {
|
display_dispatch_table = {
|
||||||
Col.START_GAP.value: Config.HEADER_START_GAP,
|
Col.START_GAP.value: QVariant(Config.HEADER_START_GAP),
|
||||||
Col.INTRO.value: Config.HEADER_INTRO,
|
Col.INTRO.value: QVariant(Config.HEADER_INTRO),
|
||||||
Col.TITLE.value: Config.HEADER_TITLE,
|
Col.TITLE.value: QVariant(Config.HEADER_TITLE),
|
||||||
Col.ARTIST.value: Config.HEADER_ARTIST,
|
Col.ARTIST.value: QVariant(Config.HEADER_ARTIST),
|
||||||
Col.DURATION.value: Config.HEADER_DURATION,
|
Col.DURATION.value: QVariant(Config.HEADER_DURATION),
|
||||||
Col.START_TIME.value: Config.HEADER_START_TIME,
|
Col.START_TIME.value: QVariant(Config.HEADER_START_TIME),
|
||||||
Col.END_TIME.value: Config.HEADER_END_TIME,
|
Col.END_TIME.value: QVariant(Config.HEADER_END_TIME),
|
||||||
Col.LAST_PLAYED.value: Config.HEADER_LAST_PLAYED,
|
Col.LAST_PLAYED.value: QVariant(Config.HEADER_LAST_PLAYED),
|
||||||
Col.BITRATE.value: Config.HEADER_BITRATE,
|
Col.BITRATE.value: QVariant(Config.HEADER_BITRATE),
|
||||||
Col.NOTE.value: Config.HEADER_NOTE,
|
Col.NOTE.value: QVariant(Config.HEADER_NOTE),
|
||||||
}
|
}
|
||||||
|
|
||||||
if role == Qt.ItemDataRole.DisplayRole:
|
if role == Qt.ItemDataRole.DisplayRole:
|
||||||
@ -670,14 +650,14 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
return display_dispatch_table[section]
|
return display_dispatch_table[section]
|
||||||
else:
|
else:
|
||||||
if Config.ROWS_FROM_ZERO:
|
if Config.ROWS_FROM_ZERO:
|
||||||
return section
|
return QVariant(str(section))
|
||||||
else:
|
else:
|
||||||
return section + 1
|
return QVariant(str(section + 1))
|
||||||
|
|
||||||
elif role == Qt.ItemDataRole.FontRole:
|
elif role == Qt.ItemDataRole.FontRole:
|
||||||
boldfont = QFont()
|
boldfont = QFont()
|
||||||
boldfont.setBold(True)
|
boldfont.setBold(True)
|
||||||
return boldfont
|
return QVariant(boldfont)
|
||||||
|
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
@ -715,11 +695,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.played_tracks_hidden = hide
|
self.played_tracks_hidden = hide
|
||||||
for row_number in range(len(self.playlist_rows)):
|
for row_number in range(len(self.playlist_rows)):
|
||||||
if self.is_played_row(row_number):
|
if self.is_played_row(row_number):
|
||||||
# only invalidate required roles
|
self.invalidate_row(row_number)
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.DisplayRole,
|
|
||||||
]
|
|
||||||
self.invalidate_row(row_number, roles)
|
|
||||||
|
|
||||||
def insert_row(
|
def insert_row(
|
||||||
self,
|
self,
|
||||||
@ -751,16 +727,9 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
self.signals.resize_rows_signal.emit(self.playlist_id)
|
self.signals.resize_rows_signal.emit(self.playlist_id)
|
||||||
self.reset_track_sequence_row_numbers()
|
self.reset_track_sequence_row_numbers()
|
||||||
# only invalidate required roles
|
self.invalidate_rows(list(range(new_row_number, len(self.playlist_rows))))
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.BackgroundRole,
|
|
||||||
Qt.ItemDataRole.DisplayRole,
|
|
||||||
Qt.ItemDataRole.FontRole,
|
|
||||||
Qt.ItemDataRole.ForegroundRole,
|
|
||||||
]
|
|
||||||
self.invalidate_rows(list(range(new_row_number, len(self.playlist_rows))), roles)
|
|
||||||
|
|
||||||
def invalidate_row(self, modified_row: int, roles: list[Qt.ItemDataRole]) -> None:
|
def invalidate_row(self, modified_row: int) -> None:
|
||||||
"""
|
"""
|
||||||
Signal to view to refresh invalidated row
|
Signal to view to refresh invalidated row
|
||||||
"""
|
"""
|
||||||
@ -768,17 +737,15 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.dataChanged.emit(
|
self.dataChanged.emit(
|
||||||
self.index(modified_row, 0),
|
self.index(modified_row, 0),
|
||||||
self.index(modified_row, self.columnCount() - 1),
|
self.index(modified_row, self.columnCount() - 1),
|
||||||
roles
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def invalidate_rows(self, modified_rows: list[int], roles: list[Qt.ItemDataRole]) -> None:
|
def invalidate_rows(self, modified_rows: list[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Signal to view to refresh invlidated rows
|
Signal to view to refresh invlidated rows
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for modified_row in modified_rows:
|
for modified_row in modified_rows:
|
||||||
# only invalidate required roles
|
self.invalidate_row(modified_row)
|
||||||
self.invalidate_row(modified_row, roles)
|
|
||||||
|
|
||||||
def is_header_row(self, row_number: int) -> bool:
|
def is_header_row(self, row_number: int) -> bool:
|
||||||
"""
|
"""
|
||||||
@ -853,11 +820,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.refresh_row(session, row_number)
|
self.refresh_row(session, row_number)
|
||||||
|
|
||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
# only invalidate required roles
|
self.invalidate_rows(row_numbers)
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.FontRole,
|
|
||||||
]
|
|
||||||
self.invalidate_rows(row_numbers, roles)
|
|
||||||
|
|
||||||
def move_rows(self, from_rows: list[int], to_row_number: int) -> None:
|
def move_rows(self, from_rows: list[int], to_row_number: int) -> None:
|
||||||
"""
|
"""
|
||||||
@ -922,11 +885,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# Update display
|
# Update display
|
||||||
self.reset_track_sequence_row_numbers()
|
self.reset_track_sequence_row_numbers()
|
||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
# only invalidate required roles
|
self.invalidate_rows(list(row_map.keys()))
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.DisplayRole,
|
|
||||||
]
|
|
||||||
self.invalidate_rows(list(row_map.keys()), roles)
|
|
||||||
|
|
||||||
def move_rows_between_playlists(
|
def move_rows_between_playlists(
|
||||||
self,
|
self,
|
||||||
@ -1103,11 +1062,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Update display
|
# Update display
|
||||||
# only invalidate required roles
|
self.invalidate_row(track_sequence.previous.row_number)
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.BackgroundRole,
|
|
||||||
]
|
|
||||||
self.invalidate_row(track_sequence.previous.row_number, roles)
|
|
||||||
|
|
||||||
def refresh_data(self, session: Session) -> None:
|
def refresh_data(self, session: Session) -> None:
|
||||||
"""
|
"""
|
||||||
@ -1160,11 +1115,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
playlist_row.track_id = None
|
playlist_row.track_id = None
|
||||||
session.commit()
|
session.commit()
|
||||||
self.refresh_row(session, row_number)
|
self.refresh_row(session, row_number)
|
||||||
# only invalidate required roles
|
self.invalidate_row(row_number)
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.DisplayRole,
|
|
||||||
]
|
|
||||||
self.invalidate_row(row_number, roles)
|
|
||||||
|
|
||||||
def rescan_track(self, row_number: int) -> None:
|
def rescan_track(self, row_number: int) -> None:
|
||||||
"""
|
"""
|
||||||
@ -1178,12 +1129,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
set_track_metadata(track)
|
set_track_metadata(track)
|
||||||
self.refresh_row(session, row_number)
|
self.refresh_row(session, row_number)
|
||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
roles = [
|
self.invalidate_row(row_number)
|
||||||
Qt.ItemDataRole.BackgroundRole,
|
|
||||||
Qt.ItemDataRole.DisplayRole,
|
|
||||||
]
|
|
||||||
# only invalidate required roles
|
|
||||||
self.invalidate_row(row_number, roles)
|
|
||||||
self.signals.resize_rows_signal.emit(self.playlist_id)
|
self.signals.resize_rows_signal.emit(self.playlist_id)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
@ -1197,6 +1143,8 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
looking up the playlistrow_id and retrieving the row number from the database.
|
looking up the playlistrow_id and retrieving the row number from the database.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
log.debug(f"{self}: reset_track_sequence_row_numbers()")
|
||||||
|
|
||||||
# Check the track_sequence.next, current and previous plrs and
|
# Check the track_sequence.next, current and previous plrs and
|
||||||
# update the row number
|
# update the row number
|
||||||
with db.Session() as session:
|
with db.Session() as session:
|
||||||
@ -1241,13 +1189,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# self.playlist_rows directly.
|
# self.playlist_rows directly.
|
||||||
self.playlist_rows[row_number].note = ""
|
self.playlist_rows[row_number].note = ""
|
||||||
session.commit()
|
session.commit()
|
||||||
# only invalidate required roles
|
self.invalidate_rows(row_numbers)
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.BackgroundRole,
|
|
||||||
Qt.ItemDataRole.DisplayRole,
|
|
||||||
Qt.ItemDataRole.ForegroundRole,
|
|
||||||
]
|
|
||||||
self.invalidate_rows(row_numbers, roles)
|
|
||||||
|
|
||||||
def _reversed_contiguous_row_groups(
|
def _reversed_contiguous_row_groups(
|
||||||
self, row_numbers: list[int]
|
self, row_numbers: list[int]
|
||||||
@ -1456,14 +1398,9 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
self.signals.search_songfacts_signal.emit(
|
self.signals.search_songfacts_signal.emit(
|
||||||
self.playlist_rows[row_number].title
|
self.playlist_rows[row_number].title
|
||||||
)
|
)
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.BackgroundRole,
|
|
||||||
]
|
|
||||||
if old_next_row is not None:
|
if old_next_row is not None:
|
||||||
# only invalidate required roles
|
self.invalidate_row(old_next_row)
|
||||||
self.invalidate_row(old_next_row, roles)
|
self.invalidate_row(row_number)
|
||||||
# only invalidate required roles
|
|
||||||
self.invalidate_row(row_number, roles)
|
|
||||||
|
|
||||||
self.signals.next_track_changed_signal.emit()
|
self.signals.next_track_changed_signal.emit()
|
||||||
self.update_track_times()
|
self.update_track_times()
|
||||||
@ -1613,23 +1550,25 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
def supportedDropActions(self) -> Qt.DropAction:
|
def supportedDropActions(self) -> Qt.DropAction:
|
||||||
return Qt.DropAction.MoveAction | Qt.DropAction.CopyAction
|
return Qt.DropAction.MoveAction | Qt.DropAction.CopyAction
|
||||||
|
|
||||||
def _tooltip_role(self, row: int, column: int, rat: RowAndTrack) -> str:
|
def tooltip_role(self, row: int, column: int, rat: RowAndTrack) -> QVariant:
|
||||||
"""
|
"""
|
||||||
Return tooltip. Currently only used for last_played column.
|
Return tooltip. Currently only used for last_played column.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if column != Col.LAST_PLAYED.value:
|
if column != Col.LAST_PLAYED.value:
|
||||||
return ""
|
return QVariant()
|
||||||
with db.Session() as session:
|
with db.Session() as session:
|
||||||
track_id = self.playlist_rows[row].track_id
|
track_id = self.playlist_rows[row].track_id
|
||||||
if not track_id:
|
if not track_id:
|
||||||
return ""
|
return QVariant()
|
||||||
playdates = Playdates.last_playdates(session, track_id)
|
playdates = Playdates.last_playdates(session, track_id)
|
||||||
return "<br>".join(
|
return QVariant(
|
||||||
[
|
"<br>".join(
|
||||||
a.lastplayed.strftime(Config.LAST_PLAYED_TOOLTIP_DATE_FORMAT)
|
[
|
||||||
for a in playdates
|
a.lastplayed.strftime(Config.LAST_PLAYED_TOOLTIP_DATE_FORMAT)
|
||||||
]
|
for a in playdates
|
||||||
|
]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def update_or_insert(self, track_id: int, row_number: int) -> None:
|
def update_or_insert(self, track_id: int, row_number: int) -> None:
|
||||||
@ -1645,14 +1584,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
with db.Session() as session:
|
with db.Session() as session:
|
||||||
for row in track_rows:
|
for row in track_rows:
|
||||||
self.refresh_row(session, row)
|
self.refresh_row(session, row)
|
||||||
# only invalidate required roles
|
self.invalidate_rows(track_rows)
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.BackgroundRole,
|
|
||||||
Qt.ItemDataRole.DisplayRole,
|
|
||||||
Qt.ItemDataRole.FontRole,
|
|
||||||
Qt.ItemDataRole.ForegroundRole,
|
|
||||||
]
|
|
||||||
self.invalidate_rows(track_rows, roles)
|
|
||||||
else:
|
else:
|
||||||
self.insert_row(proposed_row_number=row_number, track_id=track_id)
|
self.insert_row(proposed_row_number=row_number, track_id=track_id)
|
||||||
|
|
||||||
@ -1661,6 +1593,8 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
Update track start/end times in self.playlist_rows
|
Update track start/end times in self.playlist_rows
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
log.debug(f"{self}: update_track_times()")
|
||||||
|
|
||||||
next_start_time: Optional[dt.datetime] = None
|
next_start_time: Optional[dt.datetime] = None
|
||||||
update_rows: list[int] = []
|
update_rows: list[int] = []
|
||||||
row_count = len(self.playlist_rows)
|
row_count = len(self.playlist_rows)
|
||||||
@ -1799,13 +1733,9 @@ class PlaylistProxyModel(QSortFilterProxyModel):
|
|||||||
# milliseconds so that it hides then. We add
|
# milliseconds so that it hides then. We add
|
||||||
# 100mS on so that the if clause above is
|
# 100mS on so that the if clause above is
|
||||||
# true next time through.
|
# true next time through.
|
||||||
# only invalidate required roles
|
|
||||||
roles = [
|
|
||||||
Qt.ItemDataRole.DisplayRole,
|
|
||||||
]
|
|
||||||
QTimer.singleShot(
|
QTimer.singleShot(
|
||||||
Config.HIDE_AFTER_PLAYING_OFFSET + 100,
|
Config.HIDE_AFTER_PLAYING_OFFSET + 100,
|
||||||
lambda: self.sourceModel().invalidate_row(source_row, roles),
|
lambda: self.sourceModel().invalidate_row(source_row),
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
# Next track not playing yet so don't hide previous
|
# Next track not playing yet so don't hide previous
|
||||||
|
|||||||
@ -31,9 +31,9 @@ from PyQt6.QtWidgets import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
# import line_profiler
|
|
||||||
|
|
||||||
# App imports
|
# App imports
|
||||||
|
from audacity_controller import AudacityController
|
||||||
from classes import ApplicationError, Col, MusicMusterSignals, PlaylistStyle, TrackInfo
|
from classes import ApplicationError, Col, MusicMusterSignals, PlaylistStyle, TrackInfo
|
||||||
from config import Config
|
from config import Config
|
||||||
from dialogs import TrackSelectDialog
|
from dialogs import TrackSelectDialog
|
||||||
@ -43,7 +43,7 @@ from helpers import (
|
|||||||
show_OK,
|
show_OK,
|
||||||
show_warning,
|
show_warning,
|
||||||
)
|
)
|
||||||
from log import log, log_call
|
from log import log
|
||||||
from models import db, Settings
|
from models import db, Settings
|
||||||
from music_manager import track_sequence
|
from music_manager import track_sequence
|
||||||
from playlistmodel import PlaylistModel, PlaylistProxyModel
|
from playlistmodel import PlaylistModel, PlaylistProxyModel
|
||||||
@ -183,11 +183,11 @@ class PlaylistDelegate(QStyledItemDelegate):
|
|||||||
data_modified = False
|
data_modified = False
|
||||||
if isinstance(editor, QTextEdit):
|
if isinstance(editor, QTextEdit):
|
||||||
data_modified = (
|
data_modified = (
|
||||||
self.original_model_data != editor.toPlainText()
|
self.original_model_data.value() != editor.toPlainText()
|
||||||
)
|
)
|
||||||
elif isinstance(editor, QDoubleSpinBox):
|
elif isinstance(editor, QDoubleSpinBox):
|
||||||
data_modified = (
|
data_modified = (
|
||||||
self.original_model_data != int(editor.value()) * 1000
|
self.original_model_data.value() != int(editor.value()) * 1000
|
||||||
)
|
)
|
||||||
if not data_modified:
|
if not data_modified:
|
||||||
self.closeEditor.emit(editor)
|
self.closeEditor.emit(editor)
|
||||||
@ -246,10 +246,10 @@ class PlaylistDelegate(QStyledItemDelegate):
|
|||||||
edit_index, Qt.ItemDataRole.EditRole
|
edit_index, Qt.ItemDataRole.EditRole
|
||||||
)
|
)
|
||||||
if index.column() == Col.INTRO.value:
|
if index.column() == Col.INTRO.value:
|
||||||
if self.original_model_data:
|
if self.original_model_data.value():
|
||||||
editor.setValue(self.original_model_data / 1000)
|
editor.setValue(self.original_model_data.value() / 1000)
|
||||||
else:
|
else:
|
||||||
editor.setPlainText(self.original_model_data)
|
editor.setPlainText(self.original_model_data.value())
|
||||||
|
|
||||||
def setModelData(self, editor, model, index):
|
def setModelData(self, editor, model, index):
|
||||||
proxy_model = index.model()
|
proxy_model = index.model()
|
||||||
@ -307,6 +307,13 @@ class PlaylistTab(QTableView):
|
|||||||
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||||
self.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
|
self.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
|
||||||
|
|
||||||
|
# Set up for Audacity
|
||||||
|
try:
|
||||||
|
self.ac: Optional[AudacityController] = AudacityController()
|
||||||
|
except ApplicationError as e:
|
||||||
|
self.ac = None
|
||||||
|
show_warning(self.musicmuster, "Audacity error", str(e))
|
||||||
|
|
||||||
# Load model, set column widths
|
# Load model, set column widths
|
||||||
self.setModel(model)
|
self.setModel(model)
|
||||||
self._set_column_widths()
|
self._set_column_widths()
|
||||||
@ -350,7 +357,7 @@ class PlaylistTab(QTableView):
|
|||||||
# Deselect edited line
|
# Deselect edited line
|
||||||
self.clear_selection()
|
self.clear_selection()
|
||||||
|
|
||||||
def dropEvent(self, event: Optional[QDropEvent], dummy: int | None = None) -> None:
|
def dropEvent(self, event: Optional[QDropEvent]) -> None:
|
||||||
"""
|
"""
|
||||||
Move dropped rows
|
Move dropped rows
|
||||||
"""
|
"""
|
||||||
@ -538,8 +545,8 @@ class PlaylistTab(QTableView):
|
|||||||
track_path = base_model.get_row_info(model_row_number).path
|
track_path = base_model.get_row_info(model_row_number).path
|
||||||
|
|
||||||
# Open/import in/from Audacity
|
# Open/import in/from Audacity
|
||||||
if track_row and not this_is_current_row and self.musicmuster.ac:
|
if track_row and not this_is_current_row:
|
||||||
if track_path == self.musicmuster.ac.path:
|
if self.ac and track_path == self.ac.path:
|
||||||
# This track was opened in Audacity
|
# This track was opened in Audacity
|
||||||
self._add_context_menu(
|
self._add_context_menu(
|
||||||
"Update from Audacity",
|
"Update from Audacity",
|
||||||
@ -649,8 +656,8 @@ class PlaylistTab(QTableView):
|
|||||||
that we have an edit open.
|
that we have an edit open.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.musicmuster.ac:
|
if self.ac:
|
||||||
self.musicmuster.ac.path = None
|
self.ac.path = None
|
||||||
|
|
||||||
def clear_selection(self) -> None:
|
def clear_selection(self) -> None:
|
||||||
"""Unselect all tracks and reset drag mode"""
|
"""Unselect all tracks and reset drag mode"""
|
||||||
@ -746,29 +753,14 @@ class PlaylistTab(QTableView):
|
|||||||
if row_count < 1:
|
if row_count < 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Don't delete current or next tracks
|
|
||||||
selected_row_numbers = self.selected_model_row_numbers()
|
|
||||||
for ts in [
|
|
||||||
track_sequence.next,
|
|
||||||
track_sequence.current,
|
|
||||||
]:
|
|
||||||
if ts:
|
|
||||||
if (
|
|
||||||
ts.playlist_id == self.playlist_id
|
|
||||||
and ts.row_number in selected_row_numbers
|
|
||||||
):
|
|
||||||
self.musicmuster.show_warning(
|
|
||||||
"Delete not allowed", "Can't delete current or next track"
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
# Get confirmation
|
# Get confirmation
|
||||||
plural = "s" if row_count > 1 else ""
|
plural = "s" if row_count > 1 else ""
|
||||||
if not ask_yes_no("Delete rows", f"Really delete {row_count} row{plural}?"):
|
if not ask_yes_no("Delete rows", f"Really delete {row_count} row{plural}?"):
|
||||||
return
|
return
|
||||||
|
|
||||||
base_model = self.get_base_model()
|
base_model = self.get_base_model()
|
||||||
base_model.delete_rows(selected_row_numbers)
|
|
||||||
|
base_model.delete_rows(self.selected_model_row_numbers())
|
||||||
self.clear_selection()
|
self.clear_selection()
|
||||||
|
|
||||||
def get_base_model(self) -> PlaylistModel:
|
def get_base_model(self) -> PlaylistModel:
|
||||||
@ -817,12 +809,14 @@ class PlaylistTab(QTableView):
|
|||||||
|
|
||||||
# Use a set to deduplicate result (a selected row will have all
|
# Use a set to deduplicate result (a selected row will have all
|
||||||
# items in that row selected)
|
# items in that row selected)
|
||||||
selected_indexes = self.selectedIndexes()
|
result = sorted(
|
||||||
|
list(
|
||||||
|
set([self.model().mapToSource(a).row() for a in self.selectedIndexes()])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if not selected_indexes:
|
log.debug(f"get_selected_rows() returned: {result=}")
|
||||||
return []
|
return result
|
||||||
|
|
||||||
return sorted(list(set([self.model().mapToSource(a).row() for a in selected_indexes])))
|
|
||||||
|
|
||||||
def get_top_visible_row(self) -> int:
|
def get_top_visible_row(self) -> int:
|
||||||
"""
|
"""
|
||||||
@ -852,10 +846,10 @@ class PlaylistTab(QTableView):
|
|||||||
Import current Audacity track to passed row
|
Import current Audacity track to passed row
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not self.musicmuster.ac:
|
if not self.ac:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self.musicmuster.ac.export()
|
self.ac.export()
|
||||||
self._rescan(row_number)
|
self._rescan(row_number)
|
||||||
except ApplicationError as e:
|
except ApplicationError as e:
|
||||||
show_warning(self.musicmuster, "Audacity error", str(e))
|
show_warning(self.musicmuster, "Audacity error", str(e))
|
||||||
@ -912,16 +906,15 @@ class PlaylistTab(QTableView):
|
|||||||
Open track in passed row in Audacity
|
Open track in passed row in Audacity
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not self.musicmuster.ac:
|
|
||||||
return
|
|
||||||
|
|
||||||
path = self.get_base_model().get_row_track_path(row_number)
|
path = self.get_base_model().get_row_track_path(row_number)
|
||||||
if not path:
|
if not path:
|
||||||
log.error(f"_open_in_audacity: can't get path for {row_number=}")
|
log.error(f"_open_in_audacity: can't get path for {row_number=}")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.musicmuster.ac.open(path)
|
if not self.ac:
|
||||||
|
self.ac = AudacityController()
|
||||||
|
self.ac.open(path)
|
||||||
except ApplicationError as e:
|
except ApplicationError as e:
|
||||||
show_warning(self.musicmuster, "Audacity error", str(e))
|
show_warning(self.musicmuster, "Audacity error", str(e))
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,6 @@ from PyQt6.QtCore import (
|
|||||||
QVariant,
|
QVariant,
|
||||||
)
|
)
|
||||||
from PyQt6.QtGui import (
|
from PyQt6.QtGui import (
|
||||||
QBrush,
|
|
||||||
QColor,
|
QColor,
|
||||||
QFont,
|
QFont,
|
||||||
)
|
)
|
||||||
@ -83,27 +82,27 @@ class QuerylistModel(QAbstractTableModel):
|
|||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"<QuerylistModel: filter={self.filter}, {self.rowCount()} rows>"
|
return f"<QuerylistModel: filter={self.filter}, {self.rowCount()} rows>"
|
||||||
|
|
||||||
def _background_role(self, row: int, column: int, qrow: QueryRow) -> QBrush:
|
def background_role(self, row: int, column: int, qrow: QueryRow) -> QVariant:
|
||||||
"""Return background setting"""
|
"""Return background setting"""
|
||||||
|
|
||||||
# Unreadable track file
|
# Unreadable track file
|
||||||
if file_is_unreadable(qrow.path):
|
if file_is_unreadable(qrow.path):
|
||||||
return QBrush(QColor(Config.COLOUR_UNREADABLE))
|
return QVariant(QColor(Config.COLOUR_UNREADABLE))
|
||||||
|
|
||||||
# Selected row
|
# Selected row
|
||||||
if row in self._selected_rows:
|
if row in self._selected_rows:
|
||||||
return QBrush(QColor(Config.COLOUR_QUERYLIST_SELECTED))
|
return QVariant(QColor(Config.COLOUR_QUERYLIST_SELECTED))
|
||||||
|
|
||||||
# Individual cell colouring
|
# Individual cell colouring
|
||||||
if column == QueryCol.BITRATE.value:
|
if column == QueryCol.BITRATE.value:
|
||||||
if not qrow.bitrate or qrow.bitrate < Config.BITRATE_LOW_THRESHOLD:
|
if not qrow.bitrate or qrow.bitrate < Config.BITRATE_LOW_THRESHOLD:
|
||||||
return QBrush(QColor(Config.COLOUR_BITRATE_LOW))
|
return QVariant(QColor(Config.COLOUR_BITRATE_LOW))
|
||||||
elif qrow.bitrate < Config.BITRATE_OK_THRESHOLD:
|
elif qrow.bitrate < Config.BITRATE_OK_THRESHOLD:
|
||||||
return QBrush(QColor(Config.COLOUR_BITRATE_MEDIUM))
|
return QVariant(QColor(Config.COLOUR_BITRATE_MEDIUM))
|
||||||
else:
|
else:
|
||||||
return QBrush(QColor(Config.COLOUR_BITRATE_OK))
|
return QVariant(QColor(Config.COLOUR_BITRATE_OK))
|
||||||
|
|
||||||
return QBrush()
|
return QVariant()
|
||||||
|
|
||||||
def columnCount(self, parent: QModelIndex = QModelIndex()) -> int:
|
def columnCount(self, parent: QModelIndex = QModelIndex()) -> int:
|
||||||
"""Standard function for view"""
|
"""Standard function for view"""
|
||||||
@ -115,23 +114,7 @@ class QuerylistModel(QAbstractTableModel):
|
|||||||
) -> QVariant:
|
) -> QVariant:
|
||||||
"""Return data to view"""
|
"""Return data to view"""
|
||||||
|
|
||||||
if (
|
if not index.isValid() or not (0 <= index.row() < len(self.querylist_rows)):
|
||||||
not index.isValid()
|
|
||||||
or not (0 <= index.row() < len(self.querylist_rows))
|
|
||||||
or role
|
|
||||||
in [
|
|
||||||
Qt.ItemDataRole.CheckStateRole,
|
|
||||||
Qt.ItemDataRole.DecorationRole,
|
|
||||||
Qt.ItemDataRole.EditRole,
|
|
||||||
Qt.ItemDataRole.FontRole,
|
|
||||||
Qt.ItemDataRole.ForegroundRole,
|
|
||||||
Qt.ItemDataRole.InitialSortOrderRole,
|
|
||||||
Qt.ItemDataRole.SizeHintRole,
|
|
||||||
Qt.ItemDataRole.StatusTipRole,
|
|
||||||
Qt.ItemDataRole.TextAlignmentRole,
|
|
||||||
Qt.ItemDataRole.WhatsThisRole,
|
|
||||||
]
|
|
||||||
):
|
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
row = index.row()
|
row = index.row()
|
||||||
@ -141,33 +124,48 @@ class QuerylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
# Dispatch to role-specific functions
|
# Dispatch to role-specific functions
|
||||||
dispatch_table: dict[int, Callable] = {
|
dispatch_table: dict[int, Callable] = {
|
||||||
int(Qt.ItemDataRole.BackgroundRole): self._background_role,
|
int(Qt.ItemDataRole.BackgroundRole): self.background_role,
|
||||||
int(Qt.ItemDataRole.DisplayRole): self._display_role,
|
int(Qt.ItemDataRole.DisplayRole): self.display_role,
|
||||||
int(Qt.ItemDataRole.ToolTipRole): self._tooltip_role,
|
int(Qt.ItemDataRole.ToolTipRole): self.tooltip_role,
|
||||||
}
|
}
|
||||||
|
|
||||||
if role in dispatch_table:
|
if role in dispatch_table:
|
||||||
return QVariant(dispatch_table[role](row, column, qrow))
|
return QVariant(dispatch_table[role](row, column, qrow))
|
||||||
|
|
||||||
|
# Document other roles but don't use them
|
||||||
|
if role in [
|
||||||
|
Qt.ItemDataRole.DecorationRole,
|
||||||
|
Qt.ItemDataRole.EditRole,
|
||||||
|
Qt.ItemDataRole.FontRole,
|
||||||
|
Qt.ItemDataRole.ForegroundRole,
|
||||||
|
Qt.ItemDataRole.InitialSortOrderRole,
|
||||||
|
Qt.ItemDataRole.SizeHintRole,
|
||||||
|
Qt.ItemDataRole.StatusTipRole,
|
||||||
|
Qt.ItemDataRole.TextAlignmentRole,
|
||||||
|
Qt.ItemDataRole.ToolTipRole,
|
||||||
|
Qt.ItemDataRole.WhatsThisRole,
|
||||||
|
]:
|
||||||
|
return QVariant()
|
||||||
|
|
||||||
# Fall through to no-op
|
# Fall through to no-op
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
def _display_role(self, row: int, column: int, qrow: QueryRow) -> str:
|
def display_role(self, row: int, column: int, qrow: QueryRow) -> QVariant:
|
||||||
"""
|
"""
|
||||||
Return text for display
|
Return text for display
|
||||||
"""
|
"""
|
||||||
|
|
||||||
dispatch_table = {
|
dispatch_table = {
|
||||||
QueryCol.ARTIST.value: qrow.artist,
|
QueryCol.ARTIST.value: QVariant(qrow.artist),
|
||||||
QueryCol.BITRATE.value: str(qrow.bitrate),
|
QueryCol.BITRATE.value: QVariant(qrow.bitrate),
|
||||||
QueryCol.DURATION.value: ms_to_mmss(qrow.duration),
|
QueryCol.DURATION.value: QVariant(ms_to_mmss(qrow.duration)),
|
||||||
QueryCol.LAST_PLAYED.value: get_relative_date(qrow.lastplayed),
|
QueryCol.LAST_PLAYED.value: QVariant(get_relative_date(qrow.lastplayed)),
|
||||||
QueryCol.TITLE.value: qrow.title,
|
QueryCol.TITLE.value: QVariant(qrow.title),
|
||||||
}
|
}
|
||||||
if column in dispatch_table:
|
if column in dispatch_table:
|
||||||
return dispatch_table[column]
|
return dispatch_table[column]
|
||||||
|
|
||||||
return ""
|
return QVariant()
|
||||||
|
|
||||||
def flags(self, index: QModelIndex) -> Qt.ItemFlag:
|
def flags(self, index: QModelIndex) -> Qt.ItemFlag:
|
||||||
"""
|
"""
|
||||||
@ -268,7 +266,7 @@ class QuerylistModel(QAbstractTableModel):
|
|||||||
bottom_right = self.index(row, self.columnCount() - 1)
|
bottom_right = self.index(row, self.columnCount() - 1)
|
||||||
self.dataChanged.emit(top_left, bottom_right, [Qt.ItemDataRole.BackgroundRole])
|
self.dataChanged.emit(top_left, bottom_right, [Qt.ItemDataRole.BackgroundRole])
|
||||||
|
|
||||||
def _tooltip_role(self, row: int, column: int, rat: RowAndTrack) -> str | QVariant:
|
def tooltip_role(self, row: int, column: int, rat: RowAndTrack) -> QVariant:
|
||||||
"""
|
"""
|
||||||
Return tooltip. Currently only used for last_played column.
|
Return tooltip. Currently only used for last_played column.
|
||||||
"""
|
"""
|
||||||
@ -280,7 +278,7 @@ class QuerylistModel(QAbstractTableModel):
|
|||||||
if not track_id:
|
if not track_id:
|
||||||
return QVariant()
|
return QVariant()
|
||||||
playdates = Playdates.last_playdates(session, track_id)
|
playdates = Playdates.last_playdates(session, track_id)
|
||||||
return (
|
return QVariant(
|
||||||
"<br>".join(
|
"<br>".join(
|
||||||
[
|
[
|
||||||
a.lastplayed.strftime(Config.LAST_PLAYED_TOOLTIP_DATE_FORMAT)
|
a.lastplayed.strftime(Config.LAST_PLAYED_TOOLTIP_DATE_FORMAT)
|
||||||
|
|||||||
850
app/ui/main_window_ui.py
Normal file
850
app/ui/main_window_ui.py
Normal file
@ -0,0 +1,850 @@
|
|||||||
|
# Form implementation generated from reading ui file 'app/ui/main_window.ui'
|
||||||
|
#
|
||||||
|
# Created by: PyQt6 UI code generator 6.8.1
|
||||||
|
#
|
||||||
|
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
|
||||||
|
# run again. Do not edit this file unless you know what you are doing.
|
||||||
|
|
||||||
|
|
||||||
|
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
|
|
||||||
|
class Ui_MainWindow(object):
|
||||||
|
def setupUi(self, MainWindow):
|
||||||
|
MainWindow.setObjectName("MainWindow")
|
||||||
|
MainWindow.resize(1280, 857)
|
||||||
|
MainWindow.setMinimumSize(QtCore.QSize(1280, 0))
|
||||||
|
icon = QtGui.QIcon()
|
||||||
|
icon.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/musicmuster"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
MainWindow.setWindowIcon(icon)
|
||||||
|
MainWindow.setStyleSheet("")
|
||||||
|
self.centralwidget = QtWidgets.QWidget(parent=MainWindow)
|
||||||
|
self.centralwidget.setObjectName("centralwidget")
|
||||||
|
self.gridLayout_4 = QtWidgets.QGridLayout(self.centralwidget)
|
||||||
|
self.gridLayout_4.setObjectName("gridLayout_4")
|
||||||
|
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
|
||||||
|
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
|
||||||
|
self.verticalLayout_3 = QtWidgets.QVBoxLayout()
|
||||||
|
self.verticalLayout_3.setObjectName("verticalLayout_3")
|
||||||
|
self.previous_track_2 = QtWidgets.QLabel(parent=self.centralwidget)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(
|
||||||
|
self.previous_track_2.sizePolicy().hasHeightForWidth()
|
||||||
|
)
|
||||||
|
self.previous_track_2.setSizePolicy(sizePolicy)
|
||||||
|
self.previous_track_2.setMaximumSize(QtCore.QSize(230, 16777215))
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setFamily("Sans")
|
||||||
|
font.setPointSize(20)
|
||||||
|
self.previous_track_2.setFont(font)
|
||||||
|
self.previous_track_2.setStyleSheet(
|
||||||
|
"background-color: #f8d7da;\n" "border: 1px solid rgb(85, 87, 83);"
|
||||||
|
)
|
||||||
|
self.previous_track_2.setAlignment(
|
||||||
|
QtCore.Qt.AlignmentFlag.AlignRight
|
||||||
|
| QtCore.Qt.AlignmentFlag.AlignTrailing
|
||||||
|
| QtCore.Qt.AlignmentFlag.AlignVCenter
|
||||||
|
)
|
||||||
|
self.previous_track_2.setObjectName("previous_track_2")
|
||||||
|
self.verticalLayout_3.addWidget(self.previous_track_2)
|
||||||
|
self.current_track_2 = QtWidgets.QLabel(parent=self.centralwidget)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(
|
||||||
|
self.current_track_2.sizePolicy().hasHeightForWidth()
|
||||||
|
)
|
||||||
|
self.current_track_2.setSizePolicy(sizePolicy)
|
||||||
|
self.current_track_2.setMaximumSize(QtCore.QSize(230, 16777215))
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setFamily("Sans")
|
||||||
|
font.setPointSize(20)
|
||||||
|
self.current_track_2.setFont(font)
|
||||||
|
self.current_track_2.setStyleSheet(
|
||||||
|
"background-color: #d4edda;\n" "border: 1px solid rgb(85, 87, 83);"
|
||||||
|
)
|
||||||
|
self.current_track_2.setAlignment(
|
||||||
|
QtCore.Qt.AlignmentFlag.AlignRight
|
||||||
|
| QtCore.Qt.AlignmentFlag.AlignTrailing
|
||||||
|
| QtCore.Qt.AlignmentFlag.AlignVCenter
|
||||||
|
)
|
||||||
|
self.current_track_2.setObjectName("current_track_2")
|
||||||
|
self.verticalLayout_3.addWidget(self.current_track_2)
|
||||||
|
self.next_track_2 = QtWidgets.QLabel(parent=self.centralwidget)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.next_track_2.sizePolicy().hasHeightForWidth())
|
||||||
|
self.next_track_2.setSizePolicy(sizePolicy)
|
||||||
|
self.next_track_2.setMaximumSize(QtCore.QSize(230, 16777215))
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setFamily("Sans")
|
||||||
|
font.setPointSize(20)
|
||||||
|
self.next_track_2.setFont(font)
|
||||||
|
self.next_track_2.setStyleSheet(
|
||||||
|
"background-color: #fff3cd;\n" "border: 1px solid rgb(85, 87, 83);"
|
||||||
|
)
|
||||||
|
self.next_track_2.setAlignment(
|
||||||
|
QtCore.Qt.AlignmentFlag.AlignRight
|
||||||
|
| QtCore.Qt.AlignmentFlag.AlignTrailing
|
||||||
|
| QtCore.Qt.AlignmentFlag.AlignVCenter
|
||||||
|
)
|
||||||
|
self.next_track_2.setObjectName("next_track_2")
|
||||||
|
self.verticalLayout_3.addWidget(self.next_track_2)
|
||||||
|
self.horizontalLayout_3.addLayout(self.verticalLayout_3)
|
||||||
|
self.verticalLayout = QtWidgets.QVBoxLayout()
|
||||||
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
|
self.hdrPreviousTrack = QtWidgets.QLabel(parent=self.centralwidget)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(
|
||||||
|
self.hdrPreviousTrack.sizePolicy().hasHeightForWidth()
|
||||||
|
)
|
||||||
|
self.hdrPreviousTrack.setSizePolicy(sizePolicy)
|
||||||
|
self.hdrPreviousTrack.setMinimumSize(QtCore.QSize(0, 0))
|
||||||
|
self.hdrPreviousTrack.setMaximumSize(QtCore.QSize(16777215, 16777215))
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setFamily("Sans")
|
||||||
|
font.setPointSize(20)
|
||||||
|
self.hdrPreviousTrack.setFont(font)
|
||||||
|
self.hdrPreviousTrack.setStyleSheet(
|
||||||
|
"background-color: #f8d7da;\n" "border: 1px solid rgb(85, 87, 83);"
|
||||||
|
)
|
||||||
|
self.hdrPreviousTrack.setText("")
|
||||||
|
self.hdrPreviousTrack.setWordWrap(False)
|
||||||
|
self.hdrPreviousTrack.setObjectName("hdrPreviousTrack")
|
||||||
|
self.verticalLayout.addWidget(self.hdrPreviousTrack)
|
||||||
|
self.hdrCurrentTrack = QtWidgets.QPushButton(parent=self.centralwidget)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(
|
||||||
|
self.hdrCurrentTrack.sizePolicy().hasHeightForWidth()
|
||||||
|
)
|
||||||
|
self.hdrCurrentTrack.setSizePolicy(sizePolicy)
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setPointSize(20)
|
||||||
|
self.hdrCurrentTrack.setFont(font)
|
||||||
|
self.hdrCurrentTrack.setStyleSheet(
|
||||||
|
"background-color: #d4edda;\n"
|
||||||
|
"border: 1px solid rgb(85, 87, 83);\n"
|
||||||
|
"text-align: left;\n"
|
||||||
|
"padding-left: 8px;\n"
|
||||||
|
""
|
||||||
|
)
|
||||||
|
self.hdrCurrentTrack.setText("")
|
||||||
|
self.hdrCurrentTrack.setFlat(True)
|
||||||
|
self.hdrCurrentTrack.setObjectName("hdrCurrentTrack")
|
||||||
|
self.verticalLayout.addWidget(self.hdrCurrentTrack)
|
||||||
|
self.hdrNextTrack = QtWidgets.QPushButton(parent=self.centralwidget)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.hdrNextTrack.sizePolicy().hasHeightForWidth())
|
||||||
|
self.hdrNextTrack.setSizePolicy(sizePolicy)
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setPointSize(20)
|
||||||
|
self.hdrNextTrack.setFont(font)
|
||||||
|
self.hdrNextTrack.setStyleSheet(
|
||||||
|
"background-color: #fff3cd;\n"
|
||||||
|
"border: 1px solid rgb(85, 87, 83);\n"
|
||||||
|
"text-align: left;\n"
|
||||||
|
"padding-left: 8px;"
|
||||||
|
)
|
||||||
|
self.hdrNextTrack.setText("")
|
||||||
|
self.hdrNextTrack.setFlat(True)
|
||||||
|
self.hdrNextTrack.setObjectName("hdrNextTrack")
|
||||||
|
self.verticalLayout.addWidget(self.hdrNextTrack)
|
||||||
|
self.horizontalLayout_3.addLayout(self.verticalLayout)
|
||||||
|
self.frame_2 = QtWidgets.QFrame(parent=self.centralwidget)
|
||||||
|
self.frame_2.setMinimumSize(QtCore.QSize(0, 131))
|
||||||
|
self.frame_2.setMaximumSize(QtCore.QSize(230, 131))
|
||||||
|
self.frame_2.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||||
|
self.frame_2.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||||
|
self.frame_2.setObjectName("frame_2")
|
||||||
|
self.verticalLayout_10 = QtWidgets.QVBoxLayout(self.frame_2)
|
||||||
|
self.verticalLayout_10.setObjectName("verticalLayout_10")
|
||||||
|
self.lblTOD = QtWidgets.QLabel(parent=self.frame_2)
|
||||||
|
self.lblTOD.setMinimumSize(QtCore.QSize(208, 0))
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setPointSize(35)
|
||||||
|
self.lblTOD.setFont(font)
|
||||||
|
self.lblTOD.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.lblTOD.setObjectName("lblTOD")
|
||||||
|
self.verticalLayout_10.addWidget(self.lblTOD)
|
||||||
|
self.label_elapsed_timer = QtWidgets.QLabel(parent=self.frame_2)
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setFamily("FreeSans")
|
||||||
|
font.setPointSize(18)
|
||||||
|
font.setBold(False)
|
||||||
|
font.setWeight(50)
|
||||||
|
self.label_elapsed_timer.setFont(font)
|
||||||
|
self.label_elapsed_timer.setStyleSheet("color: black;")
|
||||||
|
self.label_elapsed_timer.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.label_elapsed_timer.setObjectName("label_elapsed_timer")
|
||||||
|
self.verticalLayout_10.addWidget(self.label_elapsed_timer)
|
||||||
|
self.horizontalLayout_3.addWidget(self.frame_2)
|
||||||
|
self.gridLayout_4.addLayout(self.horizontalLayout_3, 0, 0, 1, 1)
|
||||||
|
self.frame_4 = QtWidgets.QFrame(parent=self.centralwidget)
|
||||||
|
self.frame_4.setMinimumSize(QtCore.QSize(0, 16))
|
||||||
|
self.frame_4.setAutoFillBackground(False)
|
||||||
|
self.frame_4.setStyleSheet("background-color: rgb(154, 153, 150)")
|
||||||
|
self.frame_4.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||||
|
self.frame_4.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||||
|
self.frame_4.setObjectName("frame_4")
|
||||||
|
self.gridLayout_4.addWidget(self.frame_4, 1, 0, 1, 1)
|
||||||
|
self.cartsWidget = QtWidgets.QWidget(parent=self.centralwidget)
|
||||||
|
self.cartsWidget.setObjectName("cartsWidget")
|
||||||
|
self.horizontalLayout_Carts = QtWidgets.QHBoxLayout(self.cartsWidget)
|
||||||
|
self.horizontalLayout_Carts.setObjectName("horizontalLayout_Carts")
|
||||||
|
spacerItem = QtWidgets.QSpacerItem(
|
||||||
|
40,
|
||||||
|
20,
|
||||||
|
QtWidgets.QSizePolicy.Policy.Expanding,
|
||||||
|
QtWidgets.QSizePolicy.Policy.Minimum,
|
||||||
|
)
|
||||||
|
self.horizontalLayout_Carts.addItem(spacerItem)
|
||||||
|
self.gridLayout_4.addWidget(self.cartsWidget, 2, 0, 1, 1)
|
||||||
|
self.frame_6 = QtWidgets.QFrame(parent=self.centralwidget)
|
||||||
|
self.frame_6.setMinimumSize(QtCore.QSize(0, 16))
|
||||||
|
self.frame_6.setAutoFillBackground(False)
|
||||||
|
self.frame_6.setStyleSheet("background-color: rgb(154, 153, 150)")
|
||||||
|
self.frame_6.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||||
|
self.frame_6.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||||
|
self.frame_6.setObjectName("frame_6")
|
||||||
|
self.gridLayout_4.addWidget(self.frame_6, 3, 0, 1, 1)
|
||||||
|
self.splitter = QtWidgets.QSplitter(parent=self.centralwidget)
|
||||||
|
self.splitter.setOrientation(QtCore.Qt.Orientation.Vertical)
|
||||||
|
self.splitter.setObjectName("splitter")
|
||||||
|
self.tabPlaylist = QtWidgets.QTabWidget(parent=self.splitter)
|
||||||
|
self.tabPlaylist.setDocumentMode(False)
|
||||||
|
self.tabPlaylist.setTabsClosable(True)
|
||||||
|
self.tabPlaylist.setMovable(True)
|
||||||
|
self.tabPlaylist.setObjectName("tabPlaylist")
|
||||||
|
self.tabInfolist = InfoTabs(parent=self.splitter)
|
||||||
|
self.tabInfolist.setDocumentMode(False)
|
||||||
|
self.tabInfolist.setTabsClosable(True)
|
||||||
|
self.tabInfolist.setMovable(True)
|
||||||
|
self.tabInfolist.setTabBarAutoHide(False)
|
||||||
|
self.tabInfolist.setObjectName("tabInfolist")
|
||||||
|
self.gridLayout_4.addWidget(self.splitter, 4, 0, 1, 1)
|
||||||
|
self.InfoFooterFrame = QtWidgets.QFrame(parent=self.centralwidget)
|
||||||
|
self.InfoFooterFrame.setMaximumSize(QtCore.QSize(16777215, 16777215))
|
||||||
|
self.InfoFooterFrame.setStyleSheet("background-color: rgb(192, 191, 188)")
|
||||||
|
self.InfoFooterFrame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||||
|
self.InfoFooterFrame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||||
|
self.InfoFooterFrame.setObjectName("InfoFooterFrame")
|
||||||
|
self.horizontalLayout = QtWidgets.QHBoxLayout(self.InfoFooterFrame)
|
||||||
|
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||||
|
self.FadeStopInfoFrame = QtWidgets.QFrame(parent=self.InfoFooterFrame)
|
||||||
|
self.FadeStopInfoFrame.setMinimumSize(QtCore.QSize(152, 112))
|
||||||
|
self.FadeStopInfoFrame.setMaximumSize(QtCore.QSize(184, 16777215))
|
||||||
|
self.FadeStopInfoFrame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||||
|
self.FadeStopInfoFrame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||||
|
self.FadeStopInfoFrame.setObjectName("FadeStopInfoFrame")
|
||||||
|
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.FadeStopInfoFrame)
|
||||||
|
self.verticalLayout_4.setObjectName("verticalLayout_4")
|
||||||
|
self.btnPreview = QtWidgets.QPushButton(parent=self.FadeStopInfoFrame)
|
||||||
|
self.btnPreview.setMinimumSize(QtCore.QSize(132, 41))
|
||||||
|
icon1 = QtGui.QIcon()
|
||||||
|
icon1.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/headphones"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.btnPreview.setIcon(icon1)
|
||||||
|
self.btnPreview.setIconSize(QtCore.QSize(30, 30))
|
||||||
|
self.btnPreview.setCheckable(True)
|
||||||
|
self.btnPreview.setObjectName("btnPreview")
|
||||||
|
self.verticalLayout_4.addWidget(self.btnPreview)
|
||||||
|
self.groupBoxIntroControls = QtWidgets.QGroupBox(parent=self.FadeStopInfoFrame)
|
||||||
|
self.groupBoxIntroControls.setMinimumSize(QtCore.QSize(132, 46))
|
||||||
|
self.groupBoxIntroControls.setMaximumSize(QtCore.QSize(132, 46))
|
||||||
|
self.groupBoxIntroControls.setTitle("")
|
||||||
|
self.groupBoxIntroControls.setObjectName("groupBoxIntroControls")
|
||||||
|
self.btnPreviewStart = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
|
||||||
|
self.btnPreviewStart.setGeometry(QtCore.QRect(0, 0, 44, 23))
|
||||||
|
self.btnPreviewStart.setMinimumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewStart.setMaximumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewStart.setObjectName("btnPreviewStart")
|
||||||
|
self.btnPreviewArm = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
|
||||||
|
self.btnPreviewArm.setGeometry(QtCore.QRect(44, 0, 44, 23))
|
||||||
|
self.btnPreviewArm.setMinimumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewArm.setMaximumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewArm.setText("")
|
||||||
|
icon2 = QtGui.QIcon()
|
||||||
|
icon2.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/record-button.png"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
icon2.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/record-red-button.png"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.On,
|
||||||
|
)
|
||||||
|
self.btnPreviewArm.setIcon(icon2)
|
||||||
|
self.btnPreviewArm.setCheckable(True)
|
||||||
|
self.btnPreviewArm.setObjectName("btnPreviewArm")
|
||||||
|
self.btnPreviewEnd = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
|
||||||
|
self.btnPreviewEnd.setGeometry(QtCore.QRect(88, 0, 44, 23))
|
||||||
|
self.btnPreviewEnd.setMinimumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewEnd.setMaximumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewEnd.setObjectName("btnPreviewEnd")
|
||||||
|
self.btnPreviewBack = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
|
||||||
|
self.btnPreviewBack.setGeometry(QtCore.QRect(0, 23, 44, 23))
|
||||||
|
self.btnPreviewBack.setMinimumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewBack.setMaximumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewBack.setObjectName("btnPreviewBack")
|
||||||
|
self.btnPreviewMark = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
|
||||||
|
self.btnPreviewMark.setEnabled(False)
|
||||||
|
self.btnPreviewMark.setGeometry(QtCore.QRect(44, 23, 44, 23))
|
||||||
|
self.btnPreviewMark.setMinimumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewMark.setMaximumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewMark.setText("")
|
||||||
|
icon3 = QtGui.QIcon()
|
||||||
|
icon3.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/star.png"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.On,
|
||||||
|
)
|
||||||
|
icon3.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/star_empty.png"),
|
||||||
|
QtGui.QIcon.Mode.Disabled,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.btnPreviewMark.setIcon(icon3)
|
||||||
|
self.btnPreviewMark.setObjectName("btnPreviewMark")
|
||||||
|
self.btnPreviewFwd = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
|
||||||
|
self.btnPreviewFwd.setGeometry(QtCore.QRect(88, 23, 44, 23))
|
||||||
|
self.btnPreviewFwd.setMinimumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewFwd.setMaximumSize(QtCore.QSize(44, 23))
|
||||||
|
self.btnPreviewFwd.setObjectName("btnPreviewFwd")
|
||||||
|
self.verticalLayout_4.addWidget(self.groupBoxIntroControls)
|
||||||
|
self.horizontalLayout.addWidget(self.FadeStopInfoFrame)
|
||||||
|
self.frame_intro = QtWidgets.QFrame(parent=self.InfoFooterFrame)
|
||||||
|
self.frame_intro.setMinimumSize(QtCore.QSize(152, 112))
|
||||||
|
self.frame_intro.setStyleSheet("")
|
||||||
|
self.frame_intro.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||||
|
self.frame_intro.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||||
|
self.frame_intro.setObjectName("frame_intro")
|
||||||
|
self.verticalLayout_9 = QtWidgets.QVBoxLayout(self.frame_intro)
|
||||||
|
self.verticalLayout_9.setObjectName("verticalLayout_9")
|
||||||
|
self.label_7 = QtWidgets.QLabel(parent=self.frame_intro)
|
||||||
|
self.label_7.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.label_7.setObjectName("label_7")
|
||||||
|
self.verticalLayout_9.addWidget(self.label_7)
|
||||||
|
self.label_intro_timer = QtWidgets.QLabel(parent=self.frame_intro)
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setFamily("FreeSans")
|
||||||
|
font.setPointSize(40)
|
||||||
|
font.setBold(False)
|
||||||
|
font.setWeight(50)
|
||||||
|
self.label_intro_timer.setFont(font)
|
||||||
|
self.label_intro_timer.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.label_intro_timer.setObjectName("label_intro_timer")
|
||||||
|
self.verticalLayout_9.addWidget(self.label_intro_timer)
|
||||||
|
self.horizontalLayout.addWidget(self.frame_intro)
|
||||||
|
self.frame_toggleplayed_3db = QtWidgets.QFrame(parent=self.InfoFooterFrame)
|
||||||
|
self.frame_toggleplayed_3db.setMinimumSize(QtCore.QSize(152, 112))
|
||||||
|
self.frame_toggleplayed_3db.setMaximumSize(QtCore.QSize(184, 16777215))
|
||||||
|
self.frame_toggleplayed_3db.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||||
|
self.frame_toggleplayed_3db.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||||
|
self.frame_toggleplayed_3db.setObjectName("frame_toggleplayed_3db")
|
||||||
|
self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.frame_toggleplayed_3db)
|
||||||
|
self.verticalLayout_6.setObjectName("verticalLayout_6")
|
||||||
|
self.btnDrop3db = QtWidgets.QPushButton(parent=self.frame_toggleplayed_3db)
|
||||||
|
self.btnDrop3db.setMinimumSize(QtCore.QSize(132, 41))
|
||||||
|
self.btnDrop3db.setMaximumSize(QtCore.QSize(164, 16777215))
|
||||||
|
self.btnDrop3db.setCheckable(True)
|
||||||
|
self.btnDrop3db.setObjectName("btnDrop3db")
|
||||||
|
self.verticalLayout_6.addWidget(self.btnDrop3db)
|
||||||
|
self.btnHidePlayed = QtWidgets.QPushButton(parent=self.frame_toggleplayed_3db)
|
||||||
|
self.btnHidePlayed.setMinimumSize(QtCore.QSize(132, 41))
|
||||||
|
self.btnHidePlayed.setMaximumSize(QtCore.QSize(164, 16777215))
|
||||||
|
self.btnHidePlayed.setCheckable(True)
|
||||||
|
self.btnHidePlayed.setObjectName("btnHidePlayed")
|
||||||
|
self.verticalLayout_6.addWidget(self.btnHidePlayed)
|
||||||
|
self.horizontalLayout.addWidget(self.frame_toggleplayed_3db)
|
||||||
|
self.frame_fade = QtWidgets.QFrame(parent=self.InfoFooterFrame)
|
||||||
|
self.frame_fade.setMinimumSize(QtCore.QSize(152, 112))
|
||||||
|
self.frame_fade.setStyleSheet("")
|
||||||
|
self.frame_fade.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||||
|
self.frame_fade.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||||
|
self.frame_fade.setObjectName("frame_fade")
|
||||||
|
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.frame_fade)
|
||||||
|
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||||
|
self.label_4 = QtWidgets.QLabel(parent=self.frame_fade)
|
||||||
|
self.label_4.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.label_4.setObjectName("label_4")
|
||||||
|
self.verticalLayout_2.addWidget(self.label_4)
|
||||||
|
self.label_fade_timer = QtWidgets.QLabel(parent=self.frame_fade)
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setFamily("FreeSans")
|
||||||
|
font.setPointSize(40)
|
||||||
|
font.setBold(False)
|
||||||
|
font.setWeight(50)
|
||||||
|
self.label_fade_timer.setFont(font)
|
||||||
|
self.label_fade_timer.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.label_fade_timer.setObjectName("label_fade_timer")
|
||||||
|
self.verticalLayout_2.addWidget(self.label_fade_timer)
|
||||||
|
self.horizontalLayout.addWidget(self.frame_fade)
|
||||||
|
self.frame_silent = QtWidgets.QFrame(parent=self.InfoFooterFrame)
|
||||||
|
self.frame_silent.setMinimumSize(QtCore.QSize(152, 112))
|
||||||
|
self.frame_silent.setStyleSheet("")
|
||||||
|
self.frame_silent.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||||
|
self.frame_silent.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||||
|
self.frame_silent.setObjectName("frame_silent")
|
||||||
|
self.verticalLayout_7 = QtWidgets.QVBoxLayout(self.frame_silent)
|
||||||
|
self.verticalLayout_7.setObjectName("verticalLayout_7")
|
||||||
|
self.label_5 = QtWidgets.QLabel(parent=self.frame_silent)
|
||||||
|
self.label_5.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.label_5.setObjectName("label_5")
|
||||||
|
self.verticalLayout_7.addWidget(self.label_5)
|
||||||
|
self.label_silent_timer = QtWidgets.QLabel(parent=self.frame_silent)
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setFamily("FreeSans")
|
||||||
|
font.setPointSize(40)
|
||||||
|
font.setBold(False)
|
||||||
|
font.setWeight(50)
|
||||||
|
self.label_silent_timer.setFont(font)
|
||||||
|
self.label_silent_timer.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.label_silent_timer.setObjectName("label_silent_timer")
|
||||||
|
self.verticalLayout_7.addWidget(self.label_silent_timer)
|
||||||
|
self.horizontalLayout.addWidget(self.frame_silent)
|
||||||
|
self.widgetFadeVolume = PlotWidget(parent=self.InfoFooterFrame)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
QtWidgets.QSizePolicy.Policy.Preferred,
|
||||||
|
)
|
||||||
|
sizePolicy.setHorizontalStretch(1)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(
|
||||||
|
self.widgetFadeVolume.sizePolicy().hasHeightForWidth()
|
||||||
|
)
|
||||||
|
self.widgetFadeVolume.setSizePolicy(sizePolicy)
|
||||||
|
self.widgetFadeVolume.setMinimumSize(QtCore.QSize(0, 0))
|
||||||
|
self.widgetFadeVolume.setObjectName("widgetFadeVolume")
|
||||||
|
self.horizontalLayout.addWidget(self.widgetFadeVolume)
|
||||||
|
self.frame = QtWidgets.QFrame(parent=self.InfoFooterFrame)
|
||||||
|
self.frame.setMinimumSize(QtCore.QSize(151, 0))
|
||||||
|
self.frame.setMaximumSize(QtCore.QSize(151, 112))
|
||||||
|
self.frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||||
|
self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||||
|
self.frame.setObjectName("frame")
|
||||||
|
self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.frame)
|
||||||
|
self.verticalLayout_5.setObjectName("verticalLayout_5")
|
||||||
|
self.btnFade = QtWidgets.QPushButton(parent=self.frame)
|
||||||
|
self.btnFade.setMinimumSize(QtCore.QSize(132, 32))
|
||||||
|
self.btnFade.setMaximumSize(QtCore.QSize(164, 16777215))
|
||||||
|
icon4 = QtGui.QIcon()
|
||||||
|
icon4.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/fade"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.btnFade.setIcon(icon4)
|
||||||
|
self.btnFade.setIconSize(QtCore.QSize(30, 30))
|
||||||
|
self.btnFade.setObjectName("btnFade")
|
||||||
|
self.verticalLayout_5.addWidget(self.btnFade)
|
||||||
|
self.btnStop = QtWidgets.QPushButton(parent=self.frame)
|
||||||
|
self.btnStop.setMinimumSize(QtCore.QSize(0, 36))
|
||||||
|
icon5 = QtGui.QIcon()
|
||||||
|
icon5.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/stopsign"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.btnStop.setIcon(icon5)
|
||||||
|
self.btnStop.setObjectName("btnStop")
|
||||||
|
self.verticalLayout_5.addWidget(self.btnStop)
|
||||||
|
self.horizontalLayout.addWidget(self.frame)
|
||||||
|
self.gridLayout_4.addWidget(self.InfoFooterFrame, 5, 0, 1, 1)
|
||||||
|
MainWindow.setCentralWidget(self.centralwidget)
|
||||||
|
self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
|
||||||
|
self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 29))
|
||||||
|
self.menubar.setObjectName("menubar")
|
||||||
|
self.menuFile = QtWidgets.QMenu(parent=self.menubar)
|
||||||
|
self.menuFile.setObjectName("menuFile")
|
||||||
|
self.menuPlaylist = QtWidgets.QMenu(parent=self.menubar)
|
||||||
|
self.menuPlaylist.setObjectName("menuPlaylist")
|
||||||
|
self.menuSearc_h = QtWidgets.QMenu(parent=self.menubar)
|
||||||
|
self.menuSearc_h.setObjectName("menuSearc_h")
|
||||||
|
self.menuHelp = QtWidgets.QMenu(parent=self.menubar)
|
||||||
|
self.menuHelp.setObjectName("menuHelp")
|
||||||
|
MainWindow.setMenuBar(self.menubar)
|
||||||
|
self.statusbar = QtWidgets.QStatusBar(parent=MainWindow)
|
||||||
|
self.statusbar.setEnabled(True)
|
||||||
|
self.statusbar.setStyleSheet("background-color: rgb(211, 215, 207);")
|
||||||
|
self.statusbar.setObjectName("statusbar")
|
||||||
|
MainWindow.setStatusBar(self.statusbar)
|
||||||
|
self.actionPlay_next = QtGui.QAction(parent=MainWindow)
|
||||||
|
icon6 = QtGui.QIcon()
|
||||||
|
icon6.addPixmap(
|
||||||
|
QtGui.QPixmap("app/ui/../../../../../../.designer/backup/icon-play.png"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.actionPlay_next.setIcon(icon6)
|
||||||
|
self.actionPlay_next.setObjectName("actionPlay_next")
|
||||||
|
self.actionSkipToNext = QtGui.QAction(parent=MainWindow)
|
||||||
|
icon7 = QtGui.QIcon()
|
||||||
|
icon7.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/next"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.actionSkipToNext.setIcon(icon7)
|
||||||
|
self.actionSkipToNext.setObjectName("actionSkipToNext")
|
||||||
|
self.actionInsertTrack = QtGui.QAction(parent=MainWindow)
|
||||||
|
icon8 = QtGui.QIcon()
|
||||||
|
icon8.addPixmap(
|
||||||
|
QtGui.QPixmap(
|
||||||
|
"app/ui/../../../../../../.designer/backup/icon_search_database.png"
|
||||||
|
),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.actionInsertTrack.setIcon(icon8)
|
||||||
|
self.actionInsertTrack.setObjectName("actionInsertTrack")
|
||||||
|
self.actionAdd_file = QtGui.QAction(parent=MainWindow)
|
||||||
|
icon9 = QtGui.QIcon()
|
||||||
|
icon9.addPixmap(
|
||||||
|
QtGui.QPixmap(
|
||||||
|
"app/ui/../../../../../../.designer/backup/icon_open_file.png"
|
||||||
|
),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.actionAdd_file.setIcon(icon9)
|
||||||
|
self.actionAdd_file.setObjectName("actionAdd_file")
|
||||||
|
self.actionFade = QtGui.QAction(parent=MainWindow)
|
||||||
|
icon10 = QtGui.QIcon()
|
||||||
|
icon10.addPixmap(
|
||||||
|
QtGui.QPixmap("app/ui/../../../../../../.designer/backup/icon-fade.png"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.actionFade.setIcon(icon10)
|
||||||
|
self.actionFade.setObjectName("actionFade")
|
||||||
|
self.actionStop = QtGui.QAction(parent=MainWindow)
|
||||||
|
icon11 = QtGui.QIcon()
|
||||||
|
icon11.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/stop"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.actionStop.setIcon(icon11)
|
||||||
|
self.actionStop.setObjectName("actionStop")
|
||||||
|
self.action_Clear_selection = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.action_Clear_selection.setObjectName("action_Clear_selection")
|
||||||
|
self.action_Resume_previous = QtGui.QAction(parent=MainWindow)
|
||||||
|
icon12 = QtGui.QIcon()
|
||||||
|
icon12.addPixmap(
|
||||||
|
QtGui.QPixmap(":/icons/previous"),
|
||||||
|
QtGui.QIcon.Mode.Normal,
|
||||||
|
QtGui.QIcon.State.Off,
|
||||||
|
)
|
||||||
|
self.action_Resume_previous.setIcon(icon12)
|
||||||
|
self.action_Resume_previous.setObjectName("action_Resume_previous")
|
||||||
|
self.actionE_xit = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionE_xit.setObjectName("actionE_xit")
|
||||||
|
self.actionTest = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionTest.setObjectName("actionTest")
|
||||||
|
self.actionOpenPlaylist = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionOpenPlaylist.setObjectName("actionOpenPlaylist")
|
||||||
|
self.actionNewPlaylist = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionNewPlaylist.setObjectName("actionNewPlaylist")
|
||||||
|
self.actionTestFunction = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionTestFunction.setObjectName("actionTestFunction")
|
||||||
|
self.actionSkipToFade = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSkipToFade.setObjectName("actionSkipToFade")
|
||||||
|
self.actionSkipToEnd = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSkipToEnd.setObjectName("actionSkipToEnd")
|
||||||
|
self.actionClosePlaylist = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionClosePlaylist.setEnabled(True)
|
||||||
|
self.actionClosePlaylist.setObjectName("actionClosePlaylist")
|
||||||
|
self.actionRenamePlaylist = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionRenamePlaylist.setEnabled(True)
|
||||||
|
self.actionRenamePlaylist.setObjectName("actionRenamePlaylist")
|
||||||
|
self.actionDeletePlaylist = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionDeletePlaylist.setEnabled(True)
|
||||||
|
self.actionDeletePlaylist.setObjectName("actionDeletePlaylist")
|
||||||
|
self.actionMoveSelected = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionMoveSelected.setObjectName("actionMoveSelected")
|
||||||
|
self.actionExport_playlist = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionExport_playlist.setObjectName("actionExport_playlist")
|
||||||
|
self.actionSetNext = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSetNext.setObjectName("actionSetNext")
|
||||||
|
self.actionSelect_next_track = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSelect_next_track.setObjectName("actionSelect_next_track")
|
||||||
|
self.actionSelect_previous_track = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSelect_previous_track.setObjectName("actionSelect_previous_track")
|
||||||
|
self.actionSelect_played_tracks = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSelect_played_tracks.setObjectName("actionSelect_played_tracks")
|
||||||
|
self.actionMoveUnplayed = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionMoveUnplayed.setObjectName("actionMoveUnplayed")
|
||||||
|
self.actionAdd_note = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionAdd_note.setObjectName("actionAdd_note")
|
||||||
|
self.actionEnable_controls = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionEnable_controls.setObjectName("actionEnable_controls")
|
||||||
|
self.actionImport = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionImport.setObjectName("actionImport")
|
||||||
|
self.actionDownload_CSV_of_played_tracks = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionDownload_CSV_of_played_tracks.setObjectName(
|
||||||
|
"actionDownload_CSV_of_played_tracks"
|
||||||
|
)
|
||||||
|
self.actionSearch = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSearch.setObjectName("actionSearch")
|
||||||
|
self.actionInsertSectionHeader = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionInsertSectionHeader.setObjectName("actionInsertSectionHeader")
|
||||||
|
self.actionRemove = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionRemove.setObjectName("actionRemove")
|
||||||
|
self.actionFind_next = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionFind_next.setObjectName("actionFind_next")
|
||||||
|
self.actionFind_previous = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionFind_previous.setObjectName("actionFind_previous")
|
||||||
|
self.action_About = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.action_About.setObjectName("action_About")
|
||||||
|
self.actionSave_as_template = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSave_as_template.setObjectName("actionSave_as_template")
|
||||||
|
self.actionManage_templates = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionManage_templates.setObjectName("actionManage_templates")
|
||||||
|
self.actionDebug = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionDebug.setObjectName("actionDebug")
|
||||||
|
self.actionAdd_cart = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionAdd_cart.setObjectName("actionAdd_cart")
|
||||||
|
self.actionMark_for_moving = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionMark_for_moving.setObjectName("actionMark_for_moving")
|
||||||
|
self.actionPaste = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionPaste.setObjectName("actionPaste")
|
||||||
|
self.actionResume = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionResume.setObjectName("actionResume")
|
||||||
|
self.actionSearch_title_in_Wikipedia = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSearch_title_in_Wikipedia.setObjectName(
|
||||||
|
"actionSearch_title_in_Wikipedia"
|
||||||
|
)
|
||||||
|
self.actionSearch_title_in_Songfacts = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSearch_title_in_Songfacts.setObjectName(
|
||||||
|
"actionSearch_title_in_Songfacts"
|
||||||
|
)
|
||||||
|
self.actionSelect_duplicate_rows = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionSelect_duplicate_rows.setObjectName("actionSelect_duplicate_rows")
|
||||||
|
self.actionImport_files = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionImport_files.setObjectName("actionImport_files")
|
||||||
|
self.actionOpenQuerylist = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionOpenQuerylist.setObjectName("actionOpenQuerylist")
|
||||||
|
self.actionManage_querylists = QtGui.QAction(parent=MainWindow)
|
||||||
|
self.actionManage_querylists.setObjectName("actionManage_querylists")
|
||||||
|
self.menuFile.addSeparator()
|
||||||
|
self.menuFile.addAction(self.actionInsertTrack)
|
||||||
|
self.menuFile.addAction(self.actionRemove)
|
||||||
|
self.menuFile.addAction(self.actionInsertSectionHeader)
|
||||||
|
self.menuFile.addSeparator()
|
||||||
|
self.menuFile.addAction(self.actionMark_for_moving)
|
||||||
|
self.menuFile.addAction(self.actionPaste)
|
||||||
|
self.menuFile.addSeparator()
|
||||||
|
self.menuFile.addAction(self.actionExport_playlist)
|
||||||
|
self.menuFile.addAction(self.actionDownload_CSV_of_played_tracks)
|
||||||
|
self.menuFile.addSeparator()
|
||||||
|
self.menuFile.addAction(self.actionSelect_duplicate_rows)
|
||||||
|
self.menuFile.addAction(self.actionMoveSelected)
|
||||||
|
self.menuFile.addAction(self.actionMoveUnplayed)
|
||||||
|
self.menuFile.addAction(self.action_Clear_selection)
|
||||||
|
self.menuPlaylist.addSeparator()
|
||||||
|
self.menuPlaylist.addSeparator()
|
||||||
|
self.menuPlaylist.addAction(self.actionOpenPlaylist)
|
||||||
|
self.menuPlaylist.addAction(self.actionNewPlaylist)
|
||||||
|
self.menuPlaylist.addAction(self.actionClosePlaylist)
|
||||||
|
self.menuPlaylist.addAction(self.actionRenamePlaylist)
|
||||||
|
self.menuPlaylist.addAction(self.actionDeletePlaylist)
|
||||||
|
self.menuPlaylist.addSeparator()
|
||||||
|
self.menuPlaylist.addAction(self.actionOpenQuerylist)
|
||||||
|
self.menuPlaylist.addAction(self.actionManage_querylists)
|
||||||
|
self.menuPlaylist.addSeparator()
|
||||||
|
self.menuPlaylist.addAction(self.actionSave_as_template)
|
||||||
|
self.menuPlaylist.addAction(self.actionManage_templates)
|
||||||
|
self.menuPlaylist.addSeparator()
|
||||||
|
self.menuPlaylist.addAction(self.actionImport_files)
|
||||||
|
self.menuPlaylist.addSeparator()
|
||||||
|
self.menuPlaylist.addAction(self.actionE_xit)
|
||||||
|
self.menuSearc_h.addAction(self.actionSetNext)
|
||||||
|
self.menuSearc_h.addAction(self.actionPlay_next)
|
||||||
|
self.menuSearc_h.addAction(self.actionFade)
|
||||||
|
self.menuSearc_h.addAction(self.actionStop)
|
||||||
|
self.menuSearc_h.addAction(self.actionResume)
|
||||||
|
self.menuSearc_h.addAction(self.actionSkipToNext)
|
||||||
|
self.menuSearc_h.addSeparator()
|
||||||
|
self.menuSearc_h.addAction(self.actionSearch)
|
||||||
|
self.menuSearc_h.addAction(self.actionSearch_title_in_Wikipedia)
|
||||||
|
self.menuSearc_h.addAction(self.actionSearch_title_in_Songfacts)
|
||||||
|
self.menuHelp.addAction(self.action_About)
|
||||||
|
self.menuHelp.addAction(self.actionDebug)
|
||||||
|
self.menubar.addAction(self.menuPlaylist.menuAction())
|
||||||
|
self.menubar.addAction(self.menuFile.menuAction())
|
||||||
|
self.menubar.addAction(self.menuSearc_h.menuAction())
|
||||||
|
self.menubar.addAction(self.menuHelp.menuAction())
|
||||||
|
|
||||||
|
self.retranslateUi(MainWindow)
|
||||||
|
self.tabPlaylist.setCurrentIndex(-1)
|
||||||
|
self.tabInfolist.setCurrentIndex(-1)
|
||||||
|
self.actionE_xit.triggered.connect(MainWindow.close) # type: ignore
|
||||||
|
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||||
|
|
||||||
|
def retranslateUi(self, MainWindow):
|
||||||
|
_translate = QtCore.QCoreApplication.translate
|
||||||
|
MainWindow.setWindowTitle(_translate("MainWindow", "Music Muster"))
|
||||||
|
self.previous_track_2.setText(_translate("MainWindow", "Last track:"))
|
||||||
|
self.current_track_2.setText(_translate("MainWindow", "Current track:"))
|
||||||
|
self.next_track_2.setText(_translate("MainWindow", "Next track:"))
|
||||||
|
self.lblTOD.setText(_translate("MainWindow", "00:00:00"))
|
||||||
|
self.label_elapsed_timer.setText(_translate("MainWindow", "00:00 / 00:00"))
|
||||||
|
self.btnPreview.setText(_translate("MainWindow", " Preview"))
|
||||||
|
self.btnPreviewStart.setText(_translate("MainWindow", "<<"))
|
||||||
|
self.btnPreviewEnd.setText(_translate("MainWindow", ">>"))
|
||||||
|
self.btnPreviewBack.setText(_translate("MainWindow", "<"))
|
||||||
|
self.btnPreviewFwd.setText(_translate("MainWindow", ">"))
|
||||||
|
self.label_7.setText(_translate("MainWindow", "Intro"))
|
||||||
|
self.label_intro_timer.setText(_translate("MainWindow", "0:0"))
|
||||||
|
self.btnDrop3db.setText(_translate("MainWindow", "-3dB to talk"))
|
||||||
|
self.btnHidePlayed.setText(_translate("MainWindow", "Hide played"))
|
||||||
|
self.label_4.setText(_translate("MainWindow", "Fade"))
|
||||||
|
self.label_fade_timer.setText(_translate("MainWindow", "00:00"))
|
||||||
|
self.label_5.setText(_translate("MainWindow", "Silent"))
|
||||||
|
self.label_silent_timer.setText(_translate("MainWindow", "00:00"))
|
||||||
|
self.btnFade.setText(_translate("MainWindow", " Fade"))
|
||||||
|
self.btnStop.setText(_translate("MainWindow", " Stop"))
|
||||||
|
self.menuFile.setTitle(_translate("MainWindow", "&Playlist"))
|
||||||
|
self.menuPlaylist.setTitle(_translate("MainWindow", "&File"))
|
||||||
|
self.menuSearc_h.setTitle(_translate("MainWindow", "&Music"))
|
||||||
|
self.menuHelp.setTitle(_translate("MainWindow", "Help"))
|
||||||
|
self.actionPlay_next.setText(_translate("MainWindow", "&Play next"))
|
||||||
|
self.actionPlay_next.setShortcut(_translate("MainWindow", "Return"))
|
||||||
|
self.actionSkipToNext.setText(_translate("MainWindow", "Skip to &next"))
|
||||||
|
self.actionSkipToNext.setShortcut(_translate("MainWindow", "Ctrl+Alt+Return"))
|
||||||
|
self.actionInsertTrack.setText(_translate("MainWindow", "Insert &track..."))
|
||||||
|
self.actionInsertTrack.setShortcut(_translate("MainWindow", "Ctrl+T"))
|
||||||
|
self.actionAdd_file.setText(_translate("MainWindow", "Add &file"))
|
||||||
|
self.actionAdd_file.setShortcut(_translate("MainWindow", "Ctrl+F"))
|
||||||
|
self.actionFade.setText(_translate("MainWindow", "F&ade"))
|
||||||
|
self.actionFade.setShortcut(_translate("MainWindow", "Ctrl+Z"))
|
||||||
|
self.actionStop.setText(_translate("MainWindow", "S&top"))
|
||||||
|
self.actionStop.setShortcut(_translate("MainWindow", "Ctrl+Alt+S"))
|
||||||
|
self.action_Clear_selection.setText(
|
||||||
|
_translate("MainWindow", "Clear &selection")
|
||||||
|
)
|
||||||
|
self.action_Clear_selection.setShortcut(_translate("MainWindow", "Esc"))
|
||||||
|
self.action_Resume_previous.setText(
|
||||||
|
_translate("MainWindow", "&Resume previous")
|
||||||
|
)
|
||||||
|
self.actionE_xit.setText(_translate("MainWindow", "E&xit"))
|
||||||
|
self.actionTest.setText(_translate("MainWindow", "&Test"))
|
||||||
|
self.actionOpenPlaylist.setText(_translate("MainWindow", "O&pen..."))
|
||||||
|
self.actionNewPlaylist.setText(_translate("MainWindow", "&New..."))
|
||||||
|
self.actionTestFunction.setText(_translate("MainWindow", "&Test function"))
|
||||||
|
self.actionSkipToFade.setText(
|
||||||
|
_translate("MainWindow", "&Skip to start of fade")
|
||||||
|
)
|
||||||
|
self.actionSkipToEnd.setText(_translate("MainWindow", "Skip to &end of track"))
|
||||||
|
self.actionClosePlaylist.setText(_translate("MainWindow", "&Close"))
|
||||||
|
self.actionRenamePlaylist.setText(_translate("MainWindow", "&Rename..."))
|
||||||
|
self.actionDeletePlaylist.setText(_translate("MainWindow", "Dele&te..."))
|
||||||
|
self.actionMoveSelected.setText(
|
||||||
|
_translate("MainWindow", "Mo&ve selected tracks to...")
|
||||||
|
)
|
||||||
|
self.actionExport_playlist.setText(_translate("MainWindow", "E&xport..."))
|
||||||
|
self.actionSetNext.setText(_translate("MainWindow", "Set &next"))
|
||||||
|
self.actionSetNext.setShortcut(_translate("MainWindow", "Ctrl+N"))
|
||||||
|
self.actionSelect_next_track.setText(
|
||||||
|
_translate("MainWindow", "Select next track")
|
||||||
|
)
|
||||||
|
self.actionSelect_next_track.setShortcut(_translate("MainWindow", "J"))
|
||||||
|
self.actionSelect_previous_track.setText(
|
||||||
|
_translate("MainWindow", "Select previous track")
|
||||||
|
)
|
||||||
|
self.actionSelect_previous_track.setShortcut(_translate("MainWindow", "K"))
|
||||||
|
self.actionSelect_played_tracks.setText(
|
||||||
|
_translate("MainWindow", "Select played tracks")
|
||||||
|
)
|
||||||
|
self.actionMoveUnplayed.setText(
|
||||||
|
_translate("MainWindow", "Move &unplayed tracks to...")
|
||||||
|
)
|
||||||
|
self.actionAdd_note.setText(_translate("MainWindow", "Add note..."))
|
||||||
|
self.actionAdd_note.setShortcut(_translate("MainWindow", "Ctrl+T"))
|
||||||
|
self.actionEnable_controls.setText(_translate("MainWindow", "Enable controls"))
|
||||||
|
self.actionImport.setText(_translate("MainWindow", "Import track..."))
|
||||||
|
self.actionImport.setShortcut(_translate("MainWindow", "Ctrl+Shift+I"))
|
||||||
|
self.actionDownload_CSV_of_played_tracks.setText(
|
||||||
|
_translate("MainWindow", "Download CSV of played tracks...")
|
||||||
|
)
|
||||||
|
self.actionSearch.setText(_translate("MainWindow", "Search..."))
|
||||||
|
self.actionSearch.setShortcut(_translate("MainWindow", "/"))
|
||||||
|
self.actionInsertSectionHeader.setText(
|
||||||
|
_translate("MainWindow", "Insert §ion header...")
|
||||||
|
)
|
||||||
|
self.actionInsertSectionHeader.setShortcut(_translate("MainWindow", "Ctrl+H"))
|
||||||
|
self.actionRemove.setText(_translate("MainWindow", "&Remove track"))
|
||||||
|
self.actionFind_next.setText(_translate("MainWindow", "Find next"))
|
||||||
|
self.actionFind_next.setShortcut(_translate("MainWindow", "N"))
|
||||||
|
self.actionFind_previous.setText(_translate("MainWindow", "Find previous"))
|
||||||
|
self.actionFind_previous.setShortcut(_translate("MainWindow", "P"))
|
||||||
|
self.action_About.setText(_translate("MainWindow", "&About"))
|
||||||
|
self.actionSave_as_template.setText(
|
||||||
|
_translate("MainWindow", "Save as template...")
|
||||||
|
)
|
||||||
|
self.actionManage_templates.setText(
|
||||||
|
_translate("MainWindow", "Manage templates...")
|
||||||
|
)
|
||||||
|
self.actionDebug.setText(_translate("MainWindow", "Debug"))
|
||||||
|
self.actionAdd_cart.setText(_translate("MainWindow", "Edit cart &1..."))
|
||||||
|
self.actionMark_for_moving.setText(_translate("MainWindow", "Mark for moving"))
|
||||||
|
self.actionMark_for_moving.setShortcut(_translate("MainWindow", "Ctrl+C"))
|
||||||
|
self.actionPaste.setText(_translate("MainWindow", "Paste"))
|
||||||
|
self.actionPaste.setShortcut(_translate("MainWindow", "Ctrl+V"))
|
||||||
|
self.actionResume.setText(_translate("MainWindow", "Resume"))
|
||||||
|
self.actionResume.setShortcut(_translate("MainWindow", "Ctrl+R"))
|
||||||
|
self.actionSearch_title_in_Wikipedia.setText(
|
||||||
|
_translate("MainWindow", "Search title in Wikipedia")
|
||||||
|
)
|
||||||
|
self.actionSearch_title_in_Wikipedia.setShortcut(
|
||||||
|
_translate("MainWindow", "Ctrl+W")
|
||||||
|
)
|
||||||
|
self.actionSearch_title_in_Songfacts.setText(
|
||||||
|
_translate("MainWindow", "Search title in Songfacts")
|
||||||
|
)
|
||||||
|
self.actionSearch_title_in_Songfacts.setShortcut(
|
||||||
|
_translate("MainWindow", "Ctrl+S")
|
||||||
|
)
|
||||||
|
self.actionSelect_duplicate_rows.setText(
|
||||||
|
_translate("MainWindow", "Select duplicate rows...")
|
||||||
|
)
|
||||||
|
self.actionImport_files.setText(_translate("MainWindow", "Import files..."))
|
||||||
|
|
||||||
|
|
||||||
|
from infotabs import InfoTabs
|
||||||
|
from pyqtgraph import PlotWidget # type: ignore
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
73
audacity_tester.py
Executable file
73
audacity_tester.py
Executable file
@ -0,0 +1,73 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Tests the audacity pipe.
|
||||||
|
Keep pipe_test.py short!!
|
||||||
|
You can make more complicated longer tests to test other functionality
|
||||||
|
or to generate screenshots etc in other scripts.
|
||||||
|
Make sure Audacity is running first and that mod-script-pipe is enabled
|
||||||
|
before running this script.
|
||||||
|
Requires Python 2.7 or later. Python 3 is strongly recommended.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
print("pipe-test.py, running on windows")
|
||||||
|
TONAME = '\\\\.\\pipe\\ToSrvPipe'
|
||||||
|
FROMNAME = '\\\\.\\pipe\\FromSrvPipe'
|
||||||
|
EOL = '\r\n\0'
|
||||||
|
else:
|
||||||
|
print("pipe-test.py, running on linux or mac")
|
||||||
|
TONAME = '/tmp/audacity_script_pipe.to.' + str(os.getuid())
|
||||||
|
FROMNAME = '/tmp/audacity_script_pipe.from.' + str(os.getuid())
|
||||||
|
EOL = '\n'
|
||||||
|
|
||||||
|
print("Write to \"" + TONAME + "\"")
|
||||||
|
if not os.path.exists(TONAME):
|
||||||
|
print(" does not exist. Ensure Audacity is running with mod-script-pipe.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
print("Read from \"" + FROMNAME + "\"")
|
||||||
|
if not os.path.exists(FROMNAME):
|
||||||
|
print(" does not exist. Ensure Audacity is running with mod-script-pipe.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
print("-- Both pipes exist. Good.")
|
||||||
|
|
||||||
|
TOFILE = open(TONAME, 'w')
|
||||||
|
print("-- File to write to has been opened")
|
||||||
|
FROMFILE = open(FROMNAME, 'rt')
|
||||||
|
print("-- File to read from has now been opened too\r\n")
|
||||||
|
|
||||||
|
|
||||||
|
def send_command(command):
|
||||||
|
"""Send a single command."""
|
||||||
|
print("Send: >>> \n"+command)
|
||||||
|
TOFILE.write(command + EOL)
|
||||||
|
TOFILE.flush()
|
||||||
|
|
||||||
|
|
||||||
|
def get_response():
|
||||||
|
"""Return the command response."""
|
||||||
|
result = ''
|
||||||
|
line = ''
|
||||||
|
while True:
|
||||||
|
result += line
|
||||||
|
line = FROMFILE.readline()
|
||||||
|
if line == '\n' and len(result) > 0:
|
||||||
|
break
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def do_command(command):
|
||||||
|
"""Send one command, and return the response."""
|
||||||
|
send_command(command)
|
||||||
|
response = get_response()
|
||||||
|
print("Rcvd: <<< \n" + response)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
do_command('Import2: Filename=/home/kae/git/musicmuster/archive/boot.flac')
|
||||||
1
devnotes.txt
Normal file
1
devnotes.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Run Flake8 and Black
|
||||||
6
mmimport
Executable file
6
mmimport
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# cd /home/kae/mm
|
||||||
|
# MYSQL_CONNECT="mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_prod" ROOT="/home/kae/music" direnv exec .
|
||||||
|
for file in "$@"; do
|
||||||
|
app/songdb.py -i "$file"
|
||||||
|
done
|
||||||
2048
poetry.lock
generated
Normal file
2048
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,9 +2,11 @@
|
|||||||
name = "musicmuster"
|
name = "musicmuster"
|
||||||
version = "4.1.10"
|
version = "4.1.10"
|
||||||
description = "Music player for internet radio"
|
description = "Music player for internet radio"
|
||||||
authors = [{ name = "Keith Edmunds", email = "kae@midnighthax.com" }]
|
authors = [
|
||||||
requires-python = ">=3.13,<4"
|
{ name = "Keith Edmunds", email = "kae@midnighthax.com" }
|
||||||
|
]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.11,<4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alchemical>=1.0.2",
|
"alchemical>=1.0.2",
|
||||||
"alembic>=1.14.0",
|
"alembic>=1.14.0",
|
||||||
@ -29,35 +31,27 @@ dependencies = [
|
|||||||
"tinytag>=1.10.1",
|
"tinytag>=1.10.1",
|
||||||
"types-psutil>=6.0.0.20240621",
|
"types-psutil>=6.0.0.20240621",
|
||||||
"pyyaml (>=6.0.2,<7.0.0)",
|
"pyyaml (>=6.0.2,<7.0.0)",
|
||||||
"audioop-lts>=0.2.1",
|
|
||||||
"types-pyyaml>=6.0.12.20241230",
|
|
||||||
"dogpile-cache>=1.3.4",
|
|
||||||
"pdbpp>=0.10.3",
|
|
||||||
"filetype>=1.2.0",
|
|
||||||
"black>=25.1.0",
|
|
||||||
"slugify>=0.0.1",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependency-groups]
|
|
||||||
dev = [
|
|
||||||
"flakehell>=0.9.0,<0.10",
|
|
||||||
"ipdb>=0.13.9,<0.14",
|
|
||||||
"line-profiler>=4.2.0,<5",
|
|
||||||
"mypy>=1.15.0,<2",
|
|
||||||
"pudb",
|
|
||||||
"pydub-stubs>=0.25.1,<0.26",
|
|
||||||
"pytest>=8.3.4,<9",
|
|
||||||
"pytest-qt>=4.4.0,<5",
|
|
||||||
"black>=25.1.0,<26",
|
|
||||||
"pytest-cov>=6.0.0,<7",
|
|
||||||
]
|
|
||||||
|
|
||||||
[tool.uv]
|
[tool.poetry]
|
||||||
package = false
|
package-mode = false
|
||||||
|
|
||||||
|
[tool.poetry.group.dev.dependencies]
|
||||||
|
flakehell = "^0.9.0"
|
||||||
|
ipdb = "^0.13.9"
|
||||||
|
line-profiler = "^4.2.0"
|
||||||
|
mypy = "^1.15.0"
|
||||||
|
pudb = "*"
|
||||||
|
pydub-stubs = "^0.25.1"
|
||||||
|
pytest = "^8.3.4"
|
||||||
|
pytest-qt = "^4.4.0"
|
||||||
|
black = "^25.1.0"
|
||||||
|
pytest-cov = "^6.0.0"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["hatchling"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
build-backend = "hatchling.build"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
mypy_path = "/home/kae/git/musicmuster/app"
|
mypy_path = "/home/kae/git/musicmuster/app"
|
||||||
@ -66,9 +60,6 @@ python_version = 3.11
|
|||||||
warn_unused_configs = true
|
warn_unused_configs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
|
||||||
[tool.pylsp.plugins.pycodestyle]
|
|
||||||
maxLineLength = 88
|
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
addopts = "--exitfirst --showlocals --capture=no"
|
addopts = "--exitfirst --showlocals --capture=no"
|
||||||
pythonpath = [".", "app"]
|
pythonpath = [".", "app"]
|
||||||
|
|||||||
@ -21,9 +21,7 @@ from app.models import (
|
|||||||
|
|
||||||
class TestMMModels(unittest.TestCase):
|
class TestMMModels(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Runs before each test"""
|
|
||||||
db.create_all()
|
db.create_all()
|
||||||
NoteColours.invalidate_cache()
|
|
||||||
|
|
||||||
with db.Session() as session:
|
with db.Session() as session:
|
||||||
track1_path = "testdata/isa.mp3"
|
track1_path = "testdata/isa.mp3"
|
||||||
@ -33,7 +31,6 @@ class TestMMModels(unittest.TestCase):
|
|||||||
self.track2 = Tracks(session, **helpers.get_all_track_metadata(track2_path))
|
self.track2 = Tracks(session, **helpers.get_all_track_metadata(track2_path))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""Runs after each test"""
|
|
||||||
db.drop_all()
|
db.drop_all()
|
||||||
|
|
||||||
def test_track_repr(self):
|
def test_track_repr(self):
|
||||||
@ -73,7 +70,7 @@ class TestMMModels(unittest.TestCase):
|
|||||||
NoteColours(session, substring="substring", colour=note_colour)
|
NoteColours(session, substring="substring", colour=note_colour)
|
||||||
|
|
||||||
result = NoteColours.get_colour(session, "xyz")
|
result = NoteColours.get_colour(session, "xyz")
|
||||||
assert result == ""
|
assert result is None
|
||||||
|
|
||||||
def test_notecolours_get_colour_match(self):
|
def test_notecolours_get_colour_match(self):
|
||||||
note_colour = "#4bcdef"
|
note_colour = "#4bcdef"
|
||||||
@ -203,7 +200,7 @@ class TestMMModels(unittest.TestCase):
|
|||||||
nc = NoteColours(session, substring="x", colour="x")
|
nc = NoteColours(session, substring="x", colour="x")
|
||||||
_ = str(nc)
|
_ = str(nc)
|
||||||
|
|
||||||
def test_get_colour_1(self):
|
def test_get_colour(self):
|
||||||
"""Test for errors in execution"""
|
"""Test for errors in execution"""
|
||||||
|
|
||||||
GOOD_STRING = "cantelope"
|
GOOD_STRING = "cantelope"
|
||||||
@ -216,42 +213,22 @@ class TestMMModels(unittest.TestCase):
|
|||||||
session, substring=SUBSTR, colour=COLOUR, is_casesensitive=True
|
session, substring=SUBSTR, colour=COLOUR, is_casesensitive=True
|
||||||
)
|
)
|
||||||
|
|
||||||
session.commit()
|
|
||||||
_ = nc1.get_colour(session, "")
|
_ = nc1.get_colour(session, "")
|
||||||
colour = nc1.get_colour(session, GOOD_STRING)
|
colour = nc1.get_colour(session, GOOD_STRING)
|
||||||
assert colour == COLOUR
|
assert colour == COLOUR
|
||||||
|
|
||||||
colour = nc1.get_colour(session, BAD_STRING)
|
colour = nc1.get_colour(session, BAD_STRING)
|
||||||
assert colour == ""
|
assert colour is None
|
||||||
|
|
||||||
def test_get_colour_2(self):
|
|
||||||
"""Test for errors in execution"""
|
|
||||||
|
|
||||||
GOOD_STRING = "cantelope"
|
|
||||||
BAD_STRING = "ericTheBee"
|
|
||||||
SUBSTR = "ant"
|
|
||||||
COLOUR = "blue"
|
|
||||||
|
|
||||||
with db.Session() as session:
|
|
||||||
nc2 = NoteColours(
|
nc2 = NoteColours(
|
||||||
session, substring=".*" + SUBSTR, colour=COLOUR, is_regex=True
|
session, substring=".*" + SUBSTR, colour=COLOUR, is_regex=True
|
||||||
)
|
)
|
||||||
session.commit()
|
|
||||||
colour = nc2.get_colour(session, GOOD_STRING)
|
colour = nc2.get_colour(session, GOOD_STRING)
|
||||||
assert colour == COLOUR
|
assert colour == COLOUR
|
||||||
|
|
||||||
colour = nc2.get_colour(session, BAD_STRING)
|
colour = nc2.get_colour(session, BAD_STRING)
|
||||||
assert colour == ""
|
assert colour is None
|
||||||
|
|
||||||
def test_get_colour_3(self):
|
|
||||||
"""Test for errors in execution"""
|
|
||||||
|
|
||||||
GOOD_STRING = "cantelope"
|
|
||||||
BAD_STRING = "ericTheBee"
|
|
||||||
SUBSTR = "ant"
|
|
||||||
COLOUR = "blue"
|
|
||||||
|
|
||||||
with db.Session() as session:
|
|
||||||
nc3 = NoteColours(
|
nc3 = NoteColours(
|
||||||
session,
|
session,
|
||||||
substring=".*" + SUBSTR,
|
substring=".*" + SUBSTR,
|
||||||
@ -259,13 +236,12 @@ class TestMMModels(unittest.TestCase):
|
|||||||
is_regex=True,
|
is_regex=True,
|
||||||
is_casesensitive=True,
|
is_casesensitive=True,
|
||||||
)
|
)
|
||||||
session.commit()
|
|
||||||
|
|
||||||
colour = nc3.get_colour(session, GOOD_STRING)
|
colour = nc3.get_colour(session, GOOD_STRING)
|
||||||
assert colour == COLOUR
|
assert colour == COLOUR
|
||||||
|
|
||||||
colour = nc3.get_colour(session, BAD_STRING)
|
colour = nc3.get_colour(session, BAD_STRING)
|
||||||
assert colour == ""
|
assert colour is None
|
||||||
|
|
||||||
def test_name_available(self):
|
def test_name_available(self):
|
||||||
PLAYLIST_NAME = "a name"
|
PLAYLIST_NAME = "a name"
|
||||||
|
|||||||
@ -66,10 +66,10 @@ class TestMMMiscTracks(unittest.TestCase):
|
|||||||
self.model.insert_row(proposed_row_number=END_ROW, note="-")
|
self.model.insert_row(proposed_row_number=END_ROW, note="-")
|
||||||
|
|
||||||
prd = self.model.playlist_rows[START_ROW]
|
prd = self.model.playlist_rows[START_ROW]
|
||||||
qv_value = self.model._display_role(
|
qv_value = self.model.display_role(
|
||||||
START_ROW, playlistmodel.HEADER_NOTES_COLUMN, prd
|
START_ROW, playlistmodel.HEADER_NOTES_COLUMN, prd
|
||||||
)
|
)
|
||||||
assert qv_value == "start [1 tracks, 4:23 unplayed]"
|
assert qv_value.value() == "start [1 tracks, 4:23 unplayed]"
|
||||||
|
|
||||||
|
|
||||||
class TestMMMiscNoPlaylist(unittest.TestCase):
|
class TestMMMiscNoPlaylist(unittest.TestCase):
|
||||||
@ -109,7 +109,7 @@ class TestMMMiscNoPlaylist(unittest.TestCase):
|
|||||||
_ = str(prd)
|
_ = str(prd)
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
model._edit_role(
|
model.edit_role(
|
||||||
model.rowCount() - 1, playlistmodel.Col.TITLE.value, prd
|
model.rowCount() - 1, playlistmodel.Col.TITLE.value, prd
|
||||||
)
|
)
|
||||||
== metadata["title"]
|
== metadata["title"]
|
||||||
@ -262,7 +262,7 @@ class TestMMMiscRowMove(unittest.TestCase):
|
|||||||
# Test against edit_role because display_role for headers is
|
# Test against edit_role because display_role for headers is
|
||||||
# handled differently (sets up row span)
|
# handled differently (sets up row span)
|
||||||
assert (
|
assert (
|
||||||
self.model._edit_role(
|
self.model.edit_role(
|
||||||
self.model.rowCount() - 1, playlistmodel.Col.NOTE.value, prd
|
self.model.rowCount() - 1, playlistmodel.Col.NOTE.value, prd
|
||||||
)
|
)
|
||||||
== note_text
|
== note_text
|
||||||
@ -280,7 +280,7 @@ class TestMMMiscRowMove(unittest.TestCase):
|
|||||||
# Test against edit_role because display_role for headers is
|
# Test against edit_role because display_role for headers is
|
||||||
# handled differently (sets up row span)
|
# handled differently (sets up row span)
|
||||||
assert (
|
assert (
|
||||||
self.model._edit_role(
|
self.model.edit_role(
|
||||||
self.model.rowCount() - 1, playlistmodel.Col.NOTE.value, prd
|
self.model.rowCount() - 1, playlistmodel.Col.NOTE.value, prd
|
||||||
)
|
)
|
||||||
== note_text
|
== note_text
|
||||||
@ -353,7 +353,7 @@ class TestMMMiscRowMove(unittest.TestCase):
|
|||||||
index = model_dst.index(
|
index = model_dst.index(
|
||||||
row_number, playlistmodel.Col.TITLE.value, QModelIndex()
|
row_number, playlistmodel.Col.TITLE.value, QModelIndex()
|
||||||
)
|
)
|
||||||
row_notes.append(model_dst.data(index, Qt.ItemDataRole.EditRole))
|
row_notes.append(model_dst.data(index, Qt.ItemDataRole.EditRole).value())
|
||||||
|
|
||||||
assert len(model_src.playlist_rows) == self.ROWS_TO_CREATE - len(from_rows)
|
assert len(model_src.playlist_rows) == self.ROWS_TO_CREATE - len(from_rows)
|
||||||
assert len(model_dst.playlist_rows) == self.ROWS_TO_CREATE + len(from_rows)
|
assert len(model_dst.playlist_rows) == self.ROWS_TO_CREATE + len(from_rows)
|
||||||
@ -380,7 +380,7 @@ class TestMMMiscRowMove(unittest.TestCase):
|
|||||||
index = model_dst.index(
|
index = model_dst.index(
|
||||||
row_number, playlistmodel.Col.TITLE.value, QModelIndex()
|
row_number, playlistmodel.Col.TITLE.value, QModelIndex()
|
||||||
)
|
)
|
||||||
row_notes.append(model_dst.data(index, Qt.ItemDataRole.EditRole))
|
row_notes.append(model_dst.data(index, Qt.ItemDataRole.EditRole).value())
|
||||||
|
|
||||||
assert len(model_src.playlist_rows) == self.ROWS_TO_CREATE - len(from_rows)
|
assert len(model_src.playlist_rows) == self.ROWS_TO_CREATE - len(from_rows)
|
||||||
assert len(model_dst.playlist_rows) == self.ROWS_TO_CREATE + len(from_rows)
|
assert len(model_dst.playlist_rows) == self.ROWS_TO_CREATE + len(from_rows)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user