Close playlist from menubar
This commit is contained in:
parent
f1796451ae
commit
066b20a571
@ -309,12 +309,10 @@ class Playlists(Base):
|
||||
#
|
||||
# xPlaylistTracks(session, self.id, track_id, row)
|
||||
#
|
||||
# def close(self, session: Session) -> None:
|
||||
# """Record playlist as no longer loaded"""
|
||||
#
|
||||
# self.loaded = False
|
||||
# session.add(self)
|
||||
# session.flush()
|
||||
def close(self, session: Session) -> None:
|
||||
"""Mark playlist as unloaded"""
|
||||
|
||||
self.loaded = False
|
||||
|
||||
@classmethod
|
||||
def get_all(cls, session: Session) -> List["Playlists"]:
|
||||
|
||||
@ -170,7 +170,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
def connect_signals_slots(self) -> None:
|
||||
# self.actionAdd_note.triggered.connect(self.create_note)
|
||||
self.action_Clear_selection.triggered.connect(self.clear_selection)
|
||||
# self.actionClosePlaylist.triggered.connect(self.close_playlist_tab)
|
||||
self.actionClosePlaylist.triggered.connect(self.close_playlist_tab)
|
||||
# self.actionDownload_CSV_of_played_tracks.triggered.connect(
|
||||
# self.download_played_tracks)
|
||||
self.actionEnable_controls.triggered.connect(
|
||||
@ -216,32 +216,30 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
# with Session() as session:
|
||||
# playlist = Playlists(session, dlg.textValue())
|
||||
# self.create_playlist_tab(session, playlist)
|
||||
#
|
||||
# def close_playlist_tab(self) -> None:
|
||||
# """Close active playlist tab"""
|
||||
#
|
||||
# self.close_tab(self.tabPlaylist.currentIndex())
|
||||
#
|
||||
# def close_tab(self, index: int) -> None:
|
||||
# """
|
||||
# Close tab unless it holds the curren or next track
|
||||
# """
|
||||
#
|
||||
# if hasattr(self.tabPlaylist.widget(index), 'playlist_id'):
|
||||
# if self.tabPlaylist.widget(index) == (
|
||||
# self.current_track_playlist_tab):
|
||||
# self.statusbar.showMessage(
|
||||
# "Can't close current track playlist", 5000)
|
||||
# return
|
||||
# if self.tabPlaylist.widget(index) == self.next_track_playlist_tab:
|
||||
# self.statusbar.showMessage(
|
||||
# "Can't close next track playlist", 5000)
|
||||
# return
|
||||
# # It's OK to close this playlist so remove from open playlist list
|
||||
# self.tabPlaylist.widget(index).close()
|
||||
#
|
||||
# # Close regardless of tab type
|
||||
# self.tabPlaylist.removeTab(index)
|
||||
|
||||
def close_playlist_tab(self) -> None:
|
||||
"""
|
||||
Close active playlist tab unless it holds the curren or next track.
|
||||
"""
|
||||
|
||||
tab_index = self.tabPlaylist.currentIndex()
|
||||
|
||||
# Don't close current track playlist
|
||||
if self.tabPlaylist.widget(tab_index) == (
|
||||
self.current_track_playlist_tab):
|
||||
self.statusbar.showMessage(
|
||||
"Can't close current track playlist", 5000)
|
||||
return
|
||||
|
||||
# Don't close next track playlist
|
||||
if self.tabPlaylist.widget(tab_index) == self.next_track_playlist_tab:
|
||||
self.statusbar.showMessage(
|
||||
"Can't close next track playlist", 5000)
|
||||
return
|
||||
|
||||
# Close playlist and remove tab
|
||||
self.tabPlaylist.widget(tab_index).close()
|
||||
self.tabPlaylist.removeTab(tab_index)
|
||||
#
|
||||
# def create_note(self) -> None:
|
||||
# """Call playlist to create note"""
|
||||
|
||||
@ -349,23 +349,15 @@ class PlaylistTab(QTableWidget):
|
||||
|
||||
return [self._get_playlistrow_id(a) for a in self._selected_rows()]
|
||||
|
||||
# def closeEvent(self, event) -> None:
|
||||
# """Save column widths"""
|
||||
#
|
||||
# log.debug(f"playlists.closeEvent()")
|
||||
# with Session() as session:
|
||||
# for column in range(self.columnCount()):
|
||||
# width = self.columnWidth(column)
|
||||
# name = f"playlist_col_{str(column)}_width"
|
||||
# record = Settings.get_int_settings(session, name)
|
||||
# if record.f_int != self.columnWidth(column):
|
||||
# record.update(session, {'f_int': width})
|
||||
#
|
||||
# # Record playlist as closed
|
||||
# playlist = Playlists.get_by_id(session, self.playlist_id)
|
||||
# playlist.close(session)
|
||||
#
|
||||
# event.accept()
|
||||
def closeEvent(self, event) -> None:
|
||||
"""Handle closing playist tab"""
|
||||
|
||||
with Session() as session:
|
||||
# Record playlist as closed
|
||||
playlist = session.get(Playlists, self.playlist_id)
|
||||
playlist.close(session)
|
||||
|
||||
event.accept()
|
||||
|
||||
def clear_next(self, session) -> None:
|
||||
"""Clear next track marker"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user