Made the main Library not be a dock.

This commit is contained in:
The Wobbler 2025-03-02 16:57:04 +01:00
parent 67f27c8a15
commit a4d1d31e0b
7 changed files with 21 additions and 27 deletions

View file

@ -23,12 +23,7 @@ class GUI:
self.popups = Popups(app, self)
self.window.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, self.app.library.main_library_dock)
self.app.library.main_library_dock.setFeatures(
QDockWidget.DockWidgetFeature.DockWidgetMovable |
QDockWidget.DockWidgetFeature.DockWidgetFloatable
)
self.window.setCentralWidget(self.app.library.main_library_widget)
if self.app.settings.window_maximized:
self.window.showMaximized()
@ -68,8 +63,8 @@ class GUI:
def on_track_change(self, previous_track, track):
self.track_control.on_track_change(previous_track, track)
for dock_id in self.app.player.current_playlist.views:
view = self.app.player.current_playlist.views[dock_id]
for library_widget_id in self.app.player.current_playlist.views:
view = self.app.player.current_playlist.views[library_widget_id]
view.on_track_change(previous_track, track)
def on_background_job_start(self, job_name: str, description: str, steps: int=0, getter: any=None):

View file

@ -3,7 +3,7 @@
import os
from PyQt6.QtWidgets import QTabWidget, QAbstractItemView
from ..player.playlist import Playlist
from ..ui.library_dock import LibraryDock
from ..ui.library import LibraryWidget
from ..ui.playlist import PlaylistView
@ -15,8 +15,8 @@ class Library:
def __init__(self, app):
self.app = app
self.main_library_dock = LibraryDock(self)
self.library_docks = [self.main_library_dock]
self.main_library_widget = LibraryWidget(self)
self.library_widgets = [self.main_library_widget]
self.playlists = []
self.temporary_playlist = None
@ -49,15 +49,15 @@ class Library:
def load_playlist_views(self):
# create views for each dock and playlist
for library_dock in self.library_docks:
playlist_tabs: QTabWidget = library_dock.library_widget.playlist_tabs
for library_widget in self.library_widgets:
playlist_tabs: QTabWidget = library_widget.playlist_tabs
# create view for each playlist
for playlist in self.playlists:
if id(library_dock) in playlist.views: # view already exists
if id(library_widget) in playlist.views: # view already exists
continue
playlist_view = PlaylistView(playlist, library_dock)
playlist_view = PlaylistView(playlist, library_widget)
playlist_tabs.addTab(playlist_view, playlist.title)
if playlist.path == self.app.settings.latest_playlist: # start with latest playlist opened and loaded
@ -83,10 +83,10 @@ class Library:
self.playlists.append(playlist)
for library_dock in self.library_docks:
playlist_tabs: QTabWidget = library_dock.library_widget.playlist_tabs
for library_widget in self.library_widgets:
playlist_tabs: QTabWidget = library_widget.playlist_tabs
playlist_view = PlaylistView(playlist, library_dock)
playlist_view = PlaylistView(playlist, library_widget)
playlist_view.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove) # enable drag n drop
playlist_tabs.addTab(playlist_view, playlist.title)

View file

@ -34,7 +34,7 @@ class Playlist:
self.tracks: list[Track] = []
self.current_track_index = 0
self.current_track: Track | None = None
self.views = {} # dict of id(LibraryDock): PlaylistView
self.views = {} # dict of id(LibraryWidget): PlaylistView
self.loaded = False
self.loading = False

View file

@ -1,11 +1,11 @@
#!/usr/bin/python3
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QToolBox, QLabel, QTabWidget, QToolButton
from PyQt6.QtWidgets import QToolBox, QLabel, QToolButton
from .playlist_tabs import PlaylistTabs
class Library(QToolBox):
class LibraryWidget(QToolBox):
def __init__(self, library, parent=None):
super().__init__(parent)

View file

@ -1,8 +1,7 @@
#!/usr/bin/python3
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QDockWidget
from .library import Library
from .library import LibraryWidget
class LibraryDock(QDockWidget):

View file

@ -13,11 +13,11 @@ class PlaylistView(QTreeWidget):
playing_mark = QIcon.fromTheme(QIcon.ThemeIcon.MediaPlaybackStart)
def __init__(self, playlist, dock, parent=None):
def __init__(self, playlist, library_widget, parent=None):
super().__init__(parent)
self.playlist = playlist
self.library_dock = dock
self.library_widget = library_widget
self.app = playlist.app
@ -25,7 +25,7 @@ class PlaylistView(QTreeWidget):
self.header.setSectionsClickable(True)
self.header.setSortIndicatorShown(True)
playlist.views[id(dock)] = self # let the playlist know that this view exists
playlist.views[id(self.library_widget)] = self # let the playlist know that this view exists
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)

View file

@ -1,6 +1,6 @@
#!/usr/bin/python3
from PyQt6.QtCore import pyqtSignal
from PyQt6.QtCore import Qt, pyqtSignal
from PyQt6.QtWidgets import QWidget, QDockWidget, QScrollArea, QVBoxLayout
from .process import BackgroundProcess