From 34dde803cec37e86e6b88af373c636a28f7da6de Mon Sep 17 00:00:00 2001 From: "billy@pom" Date: Thu, 22 Jan 2026 07:04:47 -0500 Subject: [PATCH] more better modals --- components/CreatePlaylistWindow.py | 7 +++---- components/EditPlaylistOptionsWindow.py | 16 +++++++++++++--- components/PlaylistsPane.py | 5 +++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/components/CreatePlaylistWindow.py b/components/CreatePlaylistWindow.py index 04c62e4..0e53ff2 100644 --- a/components/CreatePlaylistWindow.py +++ b/components/CreatePlaylistWindow.py @@ -4,8 +4,8 @@ import DBA class CreatePlaylistWindow(QDialog): - def __init__(self, playlistCreatedSignal): - super(CreatePlaylistWindow, self).__init__() + def __init__(self, playlistCreatedSignal, parent=None): + super().__init__(parent) self.playlistCreatedSignal = playlistCreatedSignal self.setWindowTitle("Create new playlist") layout = QVBoxLayout() @@ -16,10 +16,9 @@ class CreatePlaylistWindow(QDialog): ok_button = QPushButton("OK") ok_button.clicked.connect(self.save) - button_layout.addWidget(ok_button) - cancel_button = QPushButton("Cancel") cancel_button.clicked.connect(self.cancel) + button_layout.addWidget(ok_button) button_layout.addWidget(cancel_button) layout.addLayout(button_layout) diff --git a/components/EditPlaylistOptionsWindow.py b/components/EditPlaylistOptionsWindow.py index 3226797..f20d6a1 100644 --- a/components/EditPlaylistOptionsWindow.py +++ b/components/EditPlaylistOptionsWindow.py @@ -12,10 +12,11 @@ from PyQt5.QtGui import QFont class EditPlaylistOptionsWindow(QDialog): - def __init__(self, playlist_id): - super(EditPlaylistOptionsWindow, self).__init__() + def __init__(self, playlist_id, parent=None): + # super(EditPlaylistOptionsWindow, self).__init__() + super().__init__(parent) self.setWindowTitle("Playlist options") - self.setMinimumSize(800, 200) + # self.setMinimumSize(800, 200) self.playlist_id = playlist_id # self.playlist_path_prefix: str = self.config.get( # "settings", "playlist_path_prefix" @@ -27,6 +28,15 @@ class EditPlaylistOptionsWindow(QDialog): self.setLayout(layout) self.show() + def resizeEvent(self, a0): + """ + Adjust maximum size with parent resize + """ + parent = self.parentWidget() + if parent: + self.setMaximumSize(parent.size()) + super().resizeEvent(a0) + def setup_ui(self): layout = QVBoxLayout() diff --git a/components/PlaylistsPane.py b/components/PlaylistsPane.py index 88af444..23447ec 100644 --- a/components/PlaylistsPane.py +++ b/components/PlaylistsPane.py @@ -34,6 +34,7 @@ class PlaylistsPane(QTreeWidget): def __init__(self: QTreeWidget, parent=None): super().__init__(parent) + self.parent = parent self._library_root = QTreeWidgetItem(["Library"]) self._playlists_root: QTreeWidgetItem = QTreeWidgetItem(["Playlists"]) self.addTopLevelItem(self._library_root) @@ -88,12 +89,12 @@ class PlaylistsPane(QTreeWidget): def create_playlist(self): """Creates a database record for a playlist, given a name""" - window = CreatePlaylistWindow(self.playlistCreatedSignal) + window = CreatePlaylistWindow(self.playlistCreatedSignal, self.parent) window.playlistCreatedSignal.connect(self.reload_playlists) window.exec_() def options(self): - window = EditPlaylistOptionsWindow(self.playlist_db_id_choice) + window = EditPlaylistOptionsWindow(self.playlist_db_id_choice, self.parent) window.exec_() def rename_playlist(self, *args):