From 199dada24660cf98482e04742b91015085749ac9 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 3 Jul 2021 10:15:39 +0100 Subject: [PATCH] Save playlist column widths correctly --- app/playlists.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/playlists.py b/app/playlists.py index a03f600..02d5514 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -91,19 +91,6 @@ class PlaylistTab(QTableWidget): # ########## Events ########## - def closeEvent(self, event): - "Save column widths" - - for column in range(self.columnCount()): - width = self.columnWidth(column) - name = f"playlist_col_{str(column)}_width" - with Session() as session: - record = Settings.get_int(session, name) - if record.f_int != self.columnWidth(column): - record.update(session, {'f_int': width}) - - event.accept() - def dropEvent(self, event: QDropEvent): if not event.isAccepted() and event.source() == self: drop_row = self._drop_on(event) @@ -170,6 +157,16 @@ class PlaylistTab(QTableWidget): # ########## Externally called functions ########## + def close(self, session): + "Save column widths" + + for column in range(self.columnCount()): + width = self.columnWidth(column) + name = f"playlist_col_{str(column)}_width" + record = Settings.get_int(session, name) + if record.f_int != self.columnWidth(column): + record.update(session, {'f_int': width}) + def insert_note(self, session, note, repaint=True): """ Add note to playlist