Reorder functions
This commit is contained in:
parent
01a9ce342a
commit
a67b295f33
@ -150,6 +150,36 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
|
def close_playlist_tab(self) -> None:
|
||||||
|
"""
|
||||||
|
Close active playlist tab, called by menu item
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.close_tab(self.tabPlaylist.currentIndex())
|
||||||
|
|
||||||
|
def close_tab(self, tab_index: int) -> None:
|
||||||
|
"""
|
||||||
|
Close active playlist tab unless it holds the curren or next track.
|
||||||
|
Called from close_playlist_tab() or by clicking close button on tab.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 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 connect_signals_slots(self) -> None:
|
def connect_signals_slots(self) -> None:
|
||||||
self.action_Clear_selection.triggered.connect(self.clear_selection)
|
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)
|
||||||
@ -188,55 +218,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
self.timer.timeout.connect(self.tick)
|
self.timer.timeout.connect(self.tick)
|
||||||
|
|
||||||
def close_playlist_tab(self) -> None:
|
|
||||||
"""
|
|
||||||
Close active playlist tab, called by menu item
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.close_tab(self.tabPlaylist.currentIndex())
|
|
||||||
|
|
||||||
def close_tab(self, tab_index: int) -> None:
|
|
||||||
"""
|
|
||||||
Close active playlist tab unless it holds the curren or next track.
|
|
||||||
Called from close_playlist_tab() or by clicking close button on tab.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# 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 insert_header(self) -> None:
|
|
||||||
"""Show dialog box to enter header text and add to playlist"""
|
|
||||||
|
|
||||||
try:
|
|
||||||
playlist_tab = self.visible_playlist_tab()
|
|
||||||
except AttributeError:
|
|
||||||
# Just return if there's no visible playlist tab
|
|
||||||
return
|
|
||||||
|
|
||||||
# Get header text
|
|
||||||
dlg: QInputDialog = QInputDialog(self)
|
|
||||||
dlg.setInputMode(QInputDialog.TextInput)
|
|
||||||
dlg.setLabelText("Header text:")
|
|
||||||
dlg.resize(500, 100)
|
|
||||||
ok = dlg.exec()
|
|
||||||
if ok:
|
|
||||||
with Session() as session:
|
|
||||||
playlist_tab.insert_header(session, dlg.textValue())
|
|
||||||
|
|
||||||
def create_playlist(self) -> None:
|
def create_playlist(self) -> None:
|
||||||
"""Create new playlist"""
|
"""Create new playlist"""
|
||||||
|
|
||||||
@ -472,6 +453,32 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
track = create_track_from_file(session, fname, tags=tags)
|
track = create_track_from_file(session, fname, tags=tags)
|
||||||
self.visible_playlist_tab().insert_track(session, track)
|
self.visible_playlist_tab().insert_track(session, track)
|
||||||
|
|
||||||
|
def insert_header(self) -> None:
|
||||||
|
"""Show dialog box to enter header text and add to playlist"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
playlist_tab = self.visible_playlist_tab()
|
||||||
|
except AttributeError:
|
||||||
|
# Just return if there's no visible playlist tab
|
||||||
|
return
|
||||||
|
|
||||||
|
# Get header text
|
||||||
|
dlg: QInputDialog = QInputDialog(self)
|
||||||
|
dlg.setInputMode(QInputDialog.TextInput)
|
||||||
|
dlg.setLabelText("Header text:")
|
||||||
|
dlg.resize(500, 100)
|
||||||
|
ok = dlg.exec()
|
||||||
|
if ok:
|
||||||
|
with Session() as session:
|
||||||
|
playlist_tab.insert_header(session, dlg.textValue())
|
||||||
|
|
||||||
|
def insert_track(self) -> None:
|
||||||
|
"""Show dialog box to select and add track from database"""
|
||||||
|
|
||||||
|
with Session() as session:
|
||||||
|
dlg = DbDialog(self, session)
|
||||||
|
dlg.exec()
|
||||||
|
|
||||||
def load_last_playlists(self) -> None:
|
def load_last_playlists(self) -> None:
|
||||||
"""Load the playlists that were open when the last session closed"""
|
"""Load the playlists that were open when the last session closed"""
|
||||||
|
|
||||||
@ -561,6 +568,19 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
session, playlist_id)
|
session, playlist_id)
|
||||||
self.move_playlist_rows(session, unplayed_playlist_rows)
|
self.move_playlist_rows(session, unplayed_playlist_rows)
|
||||||
|
|
||||||
|
def open_playlist(self):
|
||||||
|
"""Open existing playlist"""
|
||||||
|
|
||||||
|
with Session() as session:
|
||||||
|
playlists = Playlists.get_closed(session)
|
||||||
|
dlg = SelectPlaylistDialog(self, playlists=playlists,
|
||||||
|
session=session)
|
||||||
|
dlg.exec()
|
||||||
|
playlist = dlg.playlist
|
||||||
|
if playlist:
|
||||||
|
playlist.mark_open(session)
|
||||||
|
self.create_playlist_tab(session, playlist)
|
||||||
|
|
||||||
def play_next(self) -> None:
|
def play_next(self) -> None:
|
||||||
"""
|
"""
|
||||||
Play next track.
|
Play next track.
|
||||||
@ -645,13 +665,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.label_end_time.setText(
|
self.label_end_time.setText(
|
||||||
end_at.strftime(Config.TRACK_TIME_FORMAT))
|
end_at.strftime(Config.TRACK_TIME_FORMAT))
|
||||||
|
|
||||||
def insert_track(self) -> None:
|
|
||||||
"""Show dialog box to select and add track from database"""
|
|
||||||
|
|
||||||
with Session() as session:
|
|
||||||
dlg = DbDialog(self, session)
|
|
||||||
dlg.exec()
|
|
||||||
|
|
||||||
def search_playlist(self) -> None:
|
def search_playlist(self) -> None:
|
||||||
"""Show text box to search playlist"""
|
"""Show text box to search playlist"""
|
||||||
|
|
||||||
@ -678,17 +691,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.visible_playlist_tab().set_search(self.txtSearch.text())
|
self.visible_playlist_tab().set_search(self.txtSearch.text())
|
||||||
self.enable_play_next_controls()
|
self.enable_play_next_controls()
|
||||||
|
|
||||||
def open_playlist(self):
|
|
||||||
with Session() as session:
|
|
||||||
playlists = Playlists.get_closed(session)
|
|
||||||
dlg = SelectPlaylistDialog(self, playlists=playlists,
|
|
||||||
session=session)
|
|
||||||
dlg.exec()
|
|
||||||
playlist = dlg.playlist
|
|
||||||
if playlist:
|
|
||||||
playlist.mark_open(session)
|
|
||||||
self.create_playlist_tab(session, playlist)
|
|
||||||
|
|
||||||
def select_next_row(self) -> None:
|
def select_next_row(self) -> None:
|
||||||
"""Select next or first row in playlist"""
|
"""Select next or first row in playlist"""
|
||||||
|
|
||||||
|
|||||||
@ -1143,6 +1143,7 @@ class PlaylistTab(QTableWidget):
|
|||||||
record.update(session, {'f_int': width})
|
record.update(session, {'f_int': width})
|
||||||
|
|
||||||
def _context_menu(self, pos):
|
def _context_menu(self, pos):
|
||||||
|
"""Display right-click menu"""
|
||||||
|
|
||||||
assert self.menu
|
assert self.menu
|
||||||
self.menu.exec_(self.mapToGlobal(pos))
|
self.menu.exec_(self.mapToGlobal(pos))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user