more cleanup, less linting errors pls

This commit is contained in:
tsi-billypom 2025-04-04 11:47:48 -04:00
parent 1cf9ea57f4
commit ecc9800ade
2 changed files with 32 additions and 31 deletions

View File

@ -25,7 +25,9 @@ class AlbumArtGraphicsView(QGraphicsView):
Displays the album art of the currently playing song Displays the album art of the currently playing song
""" """
# drag&drop / copy&paste will update album art for selected songs
albumArtDropped = pyqtSignal(str) albumArtDropped = pyqtSignal(str)
# delete will only delete album art for current song
albumArtDeleted = pyqtSignal() albumArtDeleted = pyqtSignal()
def __init__(self, parent=None): def __init__(self, parent=None):
@ -124,17 +126,23 @@ class AlbumArtGraphicsView(QGraphicsView):
def copy_album_art_to_clipboard(self): def copy_album_art_to_clipboard(self):
"""Copies album art to the clipboard""" """Copies album art to the clipboard"""
if not self.scene().items(): scene = self.scene()
if scene is None:
return
if not scene.items():
return # dont care if no pic return # dont care if no pic
clipboard = self.qapp.clipboard clipboard = self.qapp.clipboard
pixmap_item = self.scene().items()[0] pixmap_item = scene.items()[0]
if hasattr(pixmap_item, "pixmap"): if hasattr(pixmap_item, "pixmap"):
clipboard.setPixmap(pixmap_item.pixmap()) clipboard.setPixmap(pixmap_item.pixmap())
def paste_album_art_from_clipboard(self): def paste_album_art_from_clipboard(self):
"""Handles pasting album art into a song via system clipboard""" """Handles pasting album art into a song via system clipboard"""
clipboard = self.qapp.clipboard clipboard = self.qapp.clipboard
scene = self.scene()
if scene is None:
return
mime_data = clipboard.mimeData() mime_data = clipboard.mimeData()
# Check if clipboard data is raw data or filepath # Check if clipboard data is raw data or filepath
pixmap = None pixmap = None
@ -151,7 +159,7 @@ class AlbumArtGraphicsView(QGraphicsView):
# self.scene().clear() # self.scene().clear()
# except Exception: # except Exception:
# pass # pass
self.scene().addPixmap(pixmap) scene.addPixmap(pixmap)
# Create temp file for pic # Create temp file for pic
temp_file, file_path = tempfile.mkstemp(suffix=".jpg") temp_file, file_path = tempfile.mkstemp(suffix=".jpg")
os.close(temp_file) # close the file os.close(temp_file) # close the file

45
main.py
View File

@ -253,12 +253,8 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
## CONNECTIONS ## CONNECTIONS
# tableView # tableView
self.tableView.doubleClicked.connect( self.tableView.doubleClicked.connect(self.play_audio_file)
self.play_audio_file self.tableView.enterKey.connect(self.play_audio_file)
) # Listens for the double click event, then plays the song
self.tableView.enterKey.connect(
self.play_audio_file
) # Listens for the enter key event, then plays the song
self.tableView.playPauseSignal.connect( self.tableView.playPauseSignal.connect(
self.on_play_clicked self.on_play_clicked
) # Spacebar toggle play/pause signal ) # Spacebar toggle play/pause signal
@ -456,12 +452,8 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
def update_audio_visualization(self) -> None: def update_audio_visualization(self) -> None:
"""Handles updating points on the pyqtgraph visual""" """Handles updating points on the pyqtgraph visual"""
if self.audio_visualizer.use_decibels:
# Use decibel values instead of raw amplitudes # Use decibel values instead of raw amplitudes
y = self.audio_visualizer.get_decibels() y = self.audio_visualizer.get_decibels()
else:
y = self.audio_visualizer.get_amplitudes()
if len(y) == 0: if len(y) == 0:
return return
@ -514,6 +506,21 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
"""Refreshes the playlist tree""" """Refreshes the playlist tree"""
self.playlistTreeView.add_latest_playlist_to_tree() self.playlistTreeView.add_latest_playlist_to_tree()
def handle_progress(self, data):
"""
updates the status bar when progress is emitted
"""
self.show_status_bar_message(data)
# ____________________
# | |
# | |
# | menubar verbs |
# | |
# |____________________|
# File
def open_files(self) -> None: def open_files(self) -> None:
""" """
Opens the open files window Opens the open files window
@ -532,21 +539,6 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
worker.signals.signal_progress.connect(self.handle_progress) worker.signals.signal_progress.connect(self.handle_progress)
self.threadpool.start(worker) self.threadpool.start(worker)
def handle_progress(self, data):
"""
updates the status bar when progress is emitted
"""
self.show_status_bar_message(data)
# ____________________
# | |
# | |
# | menubar verbs |
# | |
# |____________________|
# File
def create_playlist(self) -> None: def create_playlist(self) -> None:
"""Creates a database record for a playlist, given a name""" """Creates a database record for a playlist, given a name"""
window = CreatePlaylistWindow(self.playlistCreatedSignal) window = CreatePlaylistWindow(self.playlistCreatedSignal)
@ -558,6 +550,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
Imports a .m3u file, given a base path attempts to match playlist files to Imports a .m3u file, given a base path attempts to match playlist files to
database records that currently exist database records that currently exist
""" """
# TODO: implement this
pass pass
def export_playlist(self) -> None: def export_playlist(self) -> None:
@ -584,7 +577,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
def scan_libraries(self) -> None: def scan_libraries(self) -> None:
""" """
Scans for new files in the configured library folder Scans for new files in the configured library folder
Refreshes the datagridview then, refreshes the datagridview
""" """
scan_for_music() scan_for_music()
self.tableView.load_music_table() self.tableView.load_music_table()