cleanup
This commit is contained in:
parent
b2406d2cbe
commit
82c2bd470f
@ -1,6 +1,5 @@
|
||||
import logging
|
||||
from logging import error
|
||||
from PyQt5.QtWidgets import QDialog, QHBoxLayout, QLineEdit, QPushButton, QVBoxLayout
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
import DBA
|
||||
|
||||
|
||||
@ -37,7 +36,7 @@ class CreatePlaylistWindow(QDialog):
|
||||
with DBA.DBAccess() as db:
|
||||
db.execute("INSERT INTO playlist (name) VALUES (?);", (value,))
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
error(
|
||||
f"CreatePlaylistWindow.py save() | Could not create playlist: {e}"
|
||||
)
|
||||
self.playlistCreatedSignal.emit()
|
||||
|
||||
@ -2,12 +2,8 @@ from PyQt5.QtWidgets import (
|
||||
QDialog,
|
||||
QPlainTextEdit,
|
||||
QVBoxLayout,
|
||||
QLabel,
|
||||
QPushButton,
|
||||
)
|
||||
from PyQt5.QtGui import QFont
|
||||
from components.ErrorDialog import ErrorDialog
|
||||
from utils import set_id3_tag
|
||||
from pprint import pformat
|
||||
|
||||
|
||||
class DebugWindow(QDialog):
|
||||
@ -20,7 +16,7 @@ class DebugWindow(QDialog):
|
||||
layout = QVBoxLayout()
|
||||
|
||||
# Labels & input fields
|
||||
self.input_field = QPlainTextEdit(self.text)
|
||||
self.input_field = QPlainTextEdit(pformat(self.text))
|
||||
layout.addWidget(self.input_field)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
from mutagen.id3 import ID3
|
||||
from json import load as jsonload
|
||||
import DBA
|
||||
from PyQt5.QtGui import (
|
||||
QDragMoveEvent,
|
||||
@ -195,8 +196,10 @@ class MusicTable(QTableView):
|
||||
col_count = self.model2.columnCount()
|
||||
qtableview_width = self.size().width()
|
||||
sum_of_cols = self.horizontal_header.length()
|
||||
debug(f'qtable_width: {qtableview_width}')
|
||||
debug(f'sum of cols: {sum_of_cols}')
|
||||
|
||||
if sum != qtableview_width:
|
||||
if sum_of_cols <= qtableview_width:
|
||||
# if not the last header
|
||||
if logicalIndex < (col_count):
|
||||
next_header_size = self.horizontal_header.sectionSize(logicalIndex + 1)
|
||||
@ -544,12 +547,11 @@ class MusicTable(QTableView):
|
||||
self.set_current_song_filepath()
|
||||
self.playPauseSignal.emit()
|
||||
|
||||
def add_files(self, files) -> None:
|
||||
"""Thread handles adding songs to library
|
||||
def add_files(self, files: list[str]) -> None:
|
||||
"""Spawns a worker thread - adds a list of filepaths to the library
|
||||
- Drag & Drop song(s) on tableView
|
||||
- File > Open > List of song(s)
|
||||
"""
|
||||
debug(f"add files, files: {files}")
|
||||
worker = Worker(add_files_to_library, files)
|
||||
worker.signals.signal_progress.connect(self.qapp.handle_progress)
|
||||
worker.signals.signal_finished.connect(self.load_music_table)
|
||||
@ -695,6 +697,7 @@ class MusicTable(QTableView):
|
||||
|
||||
def set_current_song_filepath(self) -> None:
|
||||
"""Sets the filepath of the currently playing song"""
|
||||
# NOTE:
|
||||
# Setting the current song filepath automatically plays that song
|
||||
# self.tableView listens to this function and plays the audio file located at self.current_song_filepath
|
||||
self.current_song_filepath = (
|
||||
|
||||
@ -18,8 +18,8 @@ class PlaylistsPane(QTreeWidget):
|
||||
super().__init__(parent)
|
||||
library_root = QTreeWidgetItem(["Library"])
|
||||
self.addTopLevelItem(library_root)
|
||||
all_songs_branch = QTreeWidgetItem(["All Songs"])
|
||||
library_root.addChild(all_songs_branch)
|
||||
# all_songs_branch = QTreeWidgetItem(["All Songs"])
|
||||
# library_root.addChild(all_songs_branch)
|
||||
|
||||
self.playlists_root = QTreeWidgetItem(["Playlists"])
|
||||
self.addTopLevelItem(self.playlists_root)
|
||||
@ -36,17 +36,22 @@ class PlaylistsPane(QTreeWidget):
|
||||
self.playlist_db_id_choice: int | None = None
|
||||
|
||||
def playlist_clicked(self, item):
|
||||
"""Specific playlist index was clicked"""
|
||||
if isinstance(item, PlaylistWidgetItem):
|
||||
debug(f"ID: {item.id}, name: {item.text(0)}")
|
||||
self.playlist_db_id_choice = item.id
|
||||
self.playlistChoiceSignal.emit(int(item.id))
|
||||
elif item.text(0).lower() == "all songs":
|
||||
elif item.text(0).lower() == "library":
|
||||
self.all_songs_selected()
|
||||
|
||||
def all_songs_selected(self):
|
||||
"""Emits a signal to display all songs in the library"""
|
||||
# I have no idea why this has to be in its own function, but it does
|
||||
# or else it doesn't work
|
||||
self.allSongsSignal.emit()
|
||||
|
||||
def add_latest_playlist_to_tree(self):
|
||||
"""Adds the most recently created playlist to the pane"""
|
||||
with DBA.DBAccess() as db:
|
||||
playlist = db.query(
|
||||
"SELECT id, name FROM playlist ORDER BY date_created DESC LIMIT 1;", ()
|
||||
|
||||
@ -93,7 +93,8 @@ class PreferencesWindow(QDialog):
|
||||
child.widget().deleteLater()
|
||||
|
||||
def save_preferences(self):
|
||||
info("im saving")
|
||||
# FIXME: this isnt working? at least not for database
|
||||
|
||||
# Upcate the config fields
|
||||
for key in self.input_fields:
|
||||
for category in self.config.sections():
|
||||
|
||||
2
main.py
2
main.py
@ -492,7 +492,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
||||
def create_playlist(self) -> None:
|
||||
"""Creates a database record for a playlist, given a name"""
|
||||
window = CreatePlaylistWindow(self.playlistCreatedSignal)
|
||||
window.playlistCreatedSignal.connect(self.add_latest_playlist_to_tree)
|
||||
window.playlistCreatedSignal.connect(self.add_latest_playlist_to_tree) # type: ignore
|
||||
window.exec_()
|
||||
|
||||
def import_playlist(self) -> None:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user