small fixes

This commit is contained in:
billypom on debian 2024-09-16 21:51:33 -04:00
parent 705407f3a3
commit b61a18ee03
6 changed files with 38 additions and 10 deletions

View File

@ -15,6 +15,10 @@ import logging
class AddToPlaylistWindow(QDialog): class AddToPlaylistWindow(QDialog):
"""
Dialog box to choose what playlist to add the selected files to
"""
def __init__(self, song_db_ids: list): def __init__(self, song_db_ids: list):
super(AddToPlaylistWindow, self).__init__() super(AddToPlaylistWindow, self).__init__()
self.song_db_ids = song_db_ids self.song_db_ids = song_db_ids

View File

@ -2,10 +2,20 @@ import os
import tempfile import tempfile
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsView, QMenu, QAction from PyQt5.QtWidgets import QGraphicsScene, QGraphicsView, QMenu, QAction
from PyQt5.QtCore import QEvent, Qt, pyqtSignal, QUrl, QPoint from PyQt5.QtCore import QEvent, Qt, pyqtSignal, QUrl, QPoint
from PyQt5.QtGui import QDragEnterEvent, QDropEvent, QClipboard, QPixmap from PyQt5.QtGui import (
QDragEnterEvent,
QDragMoveEvent,
QDropEvent,
QClipboard,
QPixmap,
)
class AlbumArtGraphicsView(QGraphicsView): class AlbumArtGraphicsView(QGraphicsView):
"""
Displays the album art of the currently playing song
"""
albumArtDropped = pyqtSignal(str) albumArtDropped = pyqtSignal(str)
albumArtDeleted = pyqtSignal(str) albumArtDeleted = pyqtSignal(str)
@ -15,21 +25,22 @@ class AlbumArtGraphicsView(QGraphicsView):
self.setContextMenuPolicy(Qt.CustomContextMenu) self.setContextMenuPolicy(Qt.CustomContextMenu)
self.scene = QGraphicsScene self.scene = QGraphicsScene
self.customContextMenuRequested.connect(self.showContextMenu) self.customContextMenuRequested.connect(self.showContextMenu)
self.qapp = None
def dragEnterEvent(self, event): def dragEnterEvent(self, event: QDragEnterEvent | None):
if not event:
return
if event.mimeData().hasUrls(): if event.mimeData().hasUrls():
event.accept() event.accept()
else: else:
event.ignore() event.ignore()
def dragMoveEvent(self, event): def dragMoveEvent(self, event: QDragMoveEvent | None):
if event.mimeData().hasUrls(): if event.mimeData().hasUrls():
event.accept() event.accept()
else: else:
event.ignore() event.ignore()
def dropEvent(self, event): def dropEvent(self, event: QDropEvent | None):
"""Handles drag and drop pic onto view to add album art to songs""" """Handles drag and drop pic onto view to add album art to songs"""
urls = event.mimeData().urls() urls = event.mimeData().urls()
if urls: if urls:

View File

@ -14,7 +14,7 @@ class PreferencesWindow(QDialog):
def __init__(self, config): def __init__(self, config):
super(PreferencesWindow, self).__init__() super(PreferencesWindow, self).__init__()
self.setWindowTitle("Preferences") self.setWindowTitle("Preferences")
self.setMinimumSize(400, 400) self.setMinimumSize(400, 800)
self.config = config self.config = config
layout = QVBoxLayout() layout = QVBoxLayout()

6
ui.py
View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'ui.ui' # Form implementation generated from reading ui file 'ui.ui'
# #
# Created by: PyQt5 UI code generator 5.15.9 # Created by: PyQt5 UI code generator 5.15.10
# #
# WARNING: Any manual changes made to this file will be lost when pyuic5 is # WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing. # run again. Do not edit this file unless you know what you are doing.
@ -120,6 +120,8 @@ class Ui_MainWindow(object):
self.hLayoutMusicTable.setStretch(0, 2) self.hLayoutMusicTable.setStretch(0, 2)
self.hLayoutMusicTable.setStretch(1, 10) self.hLayoutMusicTable.setStretch(1, 10)
self.verticalLayout.addLayout(self.hLayoutMusicTable) self.verticalLayout.addLayout(self.hLayoutMusicTable)
self.verticalLayout.setStretch(0, 1)
self.verticalLayout.setStretch(1, 10)
self.verticalLayout_3.addLayout(self.verticalLayout) self.verticalLayout_3.addLayout(self.verticalLayout)
self.hLayoutControls = QtWidgets.QHBoxLayout() self.hLayoutControls = QtWidgets.QHBoxLayout()
self.hLayoutControls.setSpacing(6) self.hLayoutControls.setSpacing(6)
@ -158,7 +160,7 @@ class Ui_MainWindow(object):
self.verticalLayout_3.setStretch(2, 1) self.verticalLayout_3.setStretch(2, 1)
MainWindow.setCentralWidget(self.centralwidget) MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1152, 21)) self.menubar.setGeometry(QtCore.QRect(0, 0, 1152, 41))
self.menubar.setObjectName("menubar") self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile") self.menuFile.setObjectName("menuFile")

4
ui.ui
View File

@ -19,7 +19,7 @@
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="10,1,1"> <layout class="QVBoxLayout" name="verticalLayout_3" stretch="10,1,1">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout" stretch="1,10">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
@ -281,7 +281,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1152</width> <width>1152</width>
<height>21</height> <height>41</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">

View File

@ -1,4 +1,5 @@
import DBA import DBA
import logging
from components.ErrorDialog import ErrorDialog from components.ErrorDialog import ErrorDialog
@ -8,6 +9,10 @@ def batch_delete_filepaths_from_database(
""" """
Handles deleting many songs from the database by filepath Handles deleting many songs from the database by filepath
Accounts for playlists and other song-linked tables Accounts for playlists and other song-linked tables
Args:
files: a list of absolute filepaths to songs
chunk_size: how many files to process at once in DB
progress_callback: emit this signal for user feedback
Returns True on success Returns True on success
False on failure/error False on failure/error
@ -20,6 +25,9 @@ def batch_delete_filepaths_from_database(
result = db.query(query, files) result = db.query(query, files)
song_ids = [item[0] for item in result] song_ids = [item[0] for item in result]
except Exception as e: except Exception as e:
logging.error(
f"batch_delete_filepaths_from_database.py | An error occurred during retrieval of song_ids: {e}"
)
dialog = ErrorDialog( dialog = ErrorDialog(
f"batch_delete_filepaths_from_database.py | An error occurred during retrieval of song_ids: {e}" f"batch_delete_filepaths_from_database.py | An error occurred during retrieval of song_ids: {e}"
) )
@ -42,6 +50,9 @@ def batch_delete_filepaths_from_database(
if progress_callback: if progress_callback:
progress_callback.emit(f"Deleting songs: {i}") progress_callback.emit(f"Deleting songs: {i}")
except Exception as e: except Exception as e:
logging.error(
f"batch_delete_filepaths_from_database.py | An error occurred during batch processing: {e}"
)
dialog = ErrorDialog( dialog = ErrorDialog(
f"batch_delete_filepaths_from_database.py | An error occurred during batch processing: {e}" f"batch_delete_filepaths_from_database.py | An error occurred during batch processing: {e}"
) )