Compare commits
No commits in common. "c93f24970f7caa8054e8365dfa3a33c43e6b7b7b" and "2a6dfc8b636d8e50ea6a970a1cc6e2cd3f98db46" have entirely different histories.
c93f24970f
...
2a6dfc8b63
@ -249,14 +249,6 @@ class Playlists(Base):
|
|||||||
|
|
||||||
return playlist
|
return playlist
|
||||||
|
|
||||||
def delete(self, session: scoped_session) -> None:
|
|
||||||
"""
|
|
||||||
Mark as deleted
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.deleted = True
|
|
||||||
session.flush()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_all(cls, session: scoped_session) -> List["Playlists"]:
|
def get_all(cls, session: scoped_session) -> List["Playlists"]:
|
||||||
"""Returns a list of all playlists ordered by last use"""
|
"""Returns a list of all playlists ordered by last use"""
|
||||||
@ -294,8 +286,7 @@ class Playlists(Base):
|
|||||||
select(cls)
|
select(cls)
|
||||||
.filter(
|
.filter(
|
||||||
cls.tab.is_(None),
|
cls.tab.is_(None),
|
||||||
cls.is_template.is_(False),
|
cls.is_template.is_(False)
|
||||||
cls.deleted.is_(False)
|
|
||||||
)
|
)
|
||||||
.order_by(cls.last_used.desc())
|
.order_by(cls.last_used.desc())
|
||||||
)
|
)
|
||||||
@ -345,14 +336,6 @@ class Playlists(Base):
|
|||||||
row_to.tab = frm
|
row_to.tab = frm
|
||||||
row_frm.tab = to
|
row_frm.tab = to
|
||||||
|
|
||||||
def rename(self, session: scoped_session, new_name: str) -> None:
|
|
||||||
"""
|
|
||||||
Rename playlist
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.name = new_name
|
|
||||||
session.flush()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def save_as_template(session: scoped_session,
|
def save_as_template(session: scoped_session,
|
||||||
playlist_id: int, template_name: str) -> None:
|
playlist_id: int, template_name: str) -> None:
|
||||||
|
|||||||
@ -491,19 +491,17 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
def close_playlist_tab(self) -> bool:
|
def close_playlist_tab(self) -> None:
|
||||||
"""
|
"""
|
||||||
Close active playlist tab, called by menu item
|
Close active playlist tab, called by menu item
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self.close_tab(self.tabPlaylist.currentIndex())
|
self.close_tab(self.tabPlaylist.currentIndex())
|
||||||
|
|
||||||
def close_tab(self, tab_index: int) -> bool:
|
def close_tab(self, tab_index: int) -> None:
|
||||||
"""
|
"""
|
||||||
Close playlist tab unless it holds the current or next track.
|
Close playlist tab unless it holds the current or next track.
|
||||||
Called from close_playlist_tab() or by clicking close button on tab.
|
Called from close_playlist_tab() or by clicking close button on tab.
|
||||||
|
|
||||||
Return True if tab closed else False.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Don't close current track playlist
|
# Don't close current track playlist
|
||||||
@ -511,13 +509,13 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.current_track.playlist_tab):
|
self.current_track.playlist_tab):
|
||||||
self.statusbar.showMessage(
|
self.statusbar.showMessage(
|
||||||
"Can't close current track playlist", 5000)
|
"Can't close current track playlist", 5000)
|
||||||
return False
|
return
|
||||||
|
|
||||||
# Don't close next track playlist
|
# Don't close next track playlist
|
||||||
if self.tabPlaylist.widget(tab_index) == self.next_track.playlist_tab:
|
if self.tabPlaylist.widget(tab_index) == self.next_track.playlist_tab:
|
||||||
self.statusbar.showMessage(
|
self.statusbar.showMessage(
|
||||||
"Can't close next track playlist", 5000)
|
"Can't close next track playlist", 5000)
|
||||||
return False
|
return
|
||||||
|
|
||||||
# Record playlist as closed and update remaining playlist tabs
|
# Record playlist as closed and update remaining playlist tabs
|
||||||
with Session() as session:
|
with Session() as session:
|
||||||
@ -530,14 +528,11 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.tabPlaylist.widget(tab_index).close()
|
self.tabPlaylist.widget(tab_index).close()
|
||||||
self.tabPlaylist.removeTab(tab_index)
|
self.tabPlaylist.removeTab(tab_index)
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def connect_signals_slots(self) -> None:
|
def connect_signals_slots(self) -> None:
|
||||||
self.action_About.triggered.connect(self.about)
|
self.action_About.triggered.connect(self.about)
|
||||||
self.action_Clear_selection.triggered.connect(self.clear_selection)
|
self.action_Clear_selection.triggered.connect(self.clear_selection)
|
||||||
self.actionDebug.triggered.connect(self.debug)
|
self.actionDebug.triggered.connect(self.debug)
|
||||||
self.actionClosePlaylist.triggered.connect(self.close_playlist_tab)
|
self.actionClosePlaylist.triggered.connect(self.close_playlist_tab)
|
||||||
self.actionDeletePlaylist.triggered.connect(self.delete_playlist)
|
|
||||||
self.actionDownload_CSV_of_played_tracks.triggered.connect(
|
self.actionDownload_CSV_of_played_tracks.triggered.connect(
|
||||||
self.download_played_tracks)
|
self.download_played_tracks)
|
||||||
self.actionEnable_controls.triggered.connect(
|
self.actionEnable_controls.triggered.connect(
|
||||||
@ -558,7 +553,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.actionOpenPlaylist.triggered.connect(self.open_playlist)
|
self.actionOpenPlaylist.triggered.connect(self.open_playlist)
|
||||||
self.actionPaste.triggered.connect(self.paste_rows)
|
self.actionPaste.triggered.connect(self.paste_rows)
|
||||||
self.actionPlay_next.triggered.connect(self.play_next)
|
self.actionPlay_next.triggered.connect(self.play_next)
|
||||||
self.actionRenamePlaylist.triggered.connect(self.rename_playlist)
|
|
||||||
self.actionResume.triggered.connect(self.resume)
|
self.actionResume.triggered.connect(self.resume)
|
||||||
self.actionSave_as_template.triggered.connect(self.save_as_template)
|
self.actionSave_as_template.triggered.connect(self.save_as_template)
|
||||||
self.actionSearch.triggered.connect(self.search_playlist)
|
self.actionSearch.triggered.connect(self.search_playlist)
|
||||||
@ -636,22 +630,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
import ipdb # type: ignore
|
import ipdb # type: ignore
|
||||||
ipdb.set_trace()
|
ipdb.set_trace()
|
||||||
|
|
||||||
def delete_playlist(self) -> None:
|
|
||||||
"""
|
|
||||||
Delete current playlist
|
|
||||||
"""
|
|
||||||
|
|
||||||
with Session() as session:
|
|
||||||
playlist_id = self.visible_playlist_tab().playlist_id
|
|
||||||
playlist = session.get(Playlists, playlist_id)
|
|
||||||
if playlist:
|
|
||||||
if helpers.ask_yes_no("Delete playlist",
|
|
||||||
f"Delete playlist '{playlist.name}': "
|
|
||||||
"Are you sure?"
|
|
||||||
):
|
|
||||||
if self.close_playlist_tab():
|
|
||||||
playlist.delete(session)
|
|
||||||
|
|
||||||
def disable_play_next_controls(self) -> None:
|
def disable_play_next_controls(self) -> None:
|
||||||
"""
|
"""
|
||||||
Disable "play next" keyboard controls
|
Disable "play next" keyboard controls
|
||||||
@ -915,7 +893,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.worker.importing.connect(
|
self.worker.importing.connect(
|
||||||
lambda msg: self.statusbar.showMessage(msg, 5000)
|
lambda msg: self.statusbar.showMessage("Importing " + msg, 5000)
|
||||||
)
|
)
|
||||||
self.worker.finished.connect(self.import_complete)
|
self.worker.finished.connect(self.import_complete)
|
||||||
self.import_thread.start()
|
self.import_thread.start()
|
||||||
@ -1045,12 +1023,12 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
Move selected rows to another playlist
|
Move selected rows to another playlist
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with Session() as session:
|
selected_plrs = self.visible_playlist_tab().get_selected_playlistrows(
|
||||||
selected_plrs = (
|
session)
|
||||||
self.visible_playlist_tab().get_selected_playlistrows(session))
|
if not selected_plrs:
|
||||||
if not selected_plrs:
|
return
|
||||||
return
|
|
||||||
|
|
||||||
|
with Session() as session:
|
||||||
self.move_playlist_rows(session, selected_plrs)
|
self.move_playlist_rows(session, selected_plrs)
|
||||||
|
|
||||||
def move_tab(self, frm: int, to: int) -> None:
|
def move_tab(self, frm: int, to: int) -> None:
|
||||||
@ -1275,21 +1253,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.current_track.end_time.strftime(
|
self.current_track.end_time.strftime(
|
||||||
Config.TRACK_TIME_FORMAT))
|
Config.TRACK_TIME_FORMAT))
|
||||||
|
|
||||||
def rename_playlist(self) -> None:
|
|
||||||
"""
|
|
||||||
Rename current playlist
|
|
||||||
"""
|
|
||||||
|
|
||||||
with Session() as session:
|
|
||||||
playlist_id = self.visible_playlist_tab().playlist_id
|
|
||||||
playlist = session.get(Playlists, playlist_id)
|
|
||||||
if playlist:
|
|
||||||
new_name = self.solicit_playlist_name(playlist.name)
|
|
||||||
if new_name:
|
|
||||||
playlist.rename(session, new_name)
|
|
||||||
idx = self.tabBar.currentIndex()
|
|
||||||
self.tabBar.setTabText(idx, new_name)
|
|
||||||
|
|
||||||
def resume(self) -> None:
|
def resume(self) -> None:
|
||||||
"""
|
"""
|
||||||
Resume playing stopped track
|
Resume playing stopped track
|
||||||
@ -1437,15 +1400,12 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.tabPlaylist.setCurrentWidget(self.next_track.playlist_tab)
|
self.tabPlaylist.setCurrentWidget(self.next_track.playlist_tab)
|
||||||
self.tabPlaylist.currentWidget().scroll_next_to_top()
|
self.tabPlaylist.currentWidget().scroll_next_to_top()
|
||||||
|
|
||||||
def solicit_playlist_name(self,
|
def solicit_playlist_name(self) -> Optional[str]:
|
||||||
default: Optional[str] = "") -> Optional[str]:
|
|
||||||
"""Get name of playlist from user"""
|
"""Get name of playlist from user"""
|
||||||
|
|
||||||
dlg = QInputDialog(self)
|
dlg = QInputDialog(self)
|
||||||
dlg.setInputMode(QInputDialog.TextInput)
|
dlg.setInputMode(QInputDialog.TextInput)
|
||||||
dlg.setLabelText("Playlist name:")
|
dlg.setLabelText("Playlist name:")
|
||||||
if default:
|
|
||||||
dlg.setTextValue(default)
|
|
||||||
dlg.resize(500, 100)
|
dlg.resize(500, 100)
|
||||||
ok = dlg.exec()
|
ok = dlg.exec()
|
||||||
if ok:
|
if ok:
|
||||||
|
|||||||
@ -831,17 +831,18 @@ padding-left: 8px;</string>
|
|||||||
<string>&Playlists</string>
|
<string>&Playlists</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionNewPlaylist"/>
|
<addaction name="actionNewPlaylist"/>
|
||||||
<addaction name="actionNew_from_template"/>
|
|
||||||
<addaction name="actionOpenPlaylist"/>
|
<addaction name="actionOpenPlaylist"/>
|
||||||
<addaction name="actionClosePlaylist"/>
|
<addaction name="actionClosePlaylist"/>
|
||||||
<addaction name="actionRenamePlaylist"/>
|
<addaction name="actionRenamePlaylist"/>
|
||||||
<addaction name="actionDeletePlaylist"/>
|
|
||||||
<addaction name="actionExport_playlist"/>
|
<addaction name="actionExport_playlist"/>
|
||||||
|
<addaction name="actionDeletePlaylist"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionNew_from_template"/>
|
||||||
|
<addaction name="actionSave_as_template"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionMoveSelected"/>
|
<addaction name="actionMoveSelected"/>
|
||||||
<addaction name="actionMoveUnplayed"/>
|
<addaction name="actionMoveUnplayed"/>
|
||||||
<addaction name="actionDownload_CSV_of_played_tracks"/>
|
<addaction name="actionDownload_CSV_of_played_tracks"/>
|
||||||
<addaction name="actionSave_as_template"/>
|
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionE_xit"/>
|
<addaction name="actionE_xit"/>
|
||||||
</widget>
|
</widget>
|
||||||
@ -1035,7 +1036,7 @@ padding-left: 8px;</string>
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionRenamePlaylist">
|
<action name="actionRenamePlaylist">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Rename...</string>
|
<string>&Rename...</string>
|
||||||
@ -1043,7 +1044,7 @@ padding-left: 8px;</string>
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionDeletePlaylist">
|
<action name="actionDeletePlaylist">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Dele&te...</string>
|
<string>Dele&te...</string>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'app/ui/main_window.ui'
|
# Form implementation generated from reading ui file 'app/ui/main_window.ui'
|
||||||
#
|
#
|
||||||
# Created by: PyQt5 UI code generator 5.15.9
|
# Created by: PyQt5 UI code generator 5.15.6
|
||||||
#
|
#
|
||||||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
||||||
# run again. Do not edit this file unless you know what you are doing.
|
# run again. Do not edit this file unless you know what you are doing.
|
||||||
@ -452,10 +452,10 @@ class Ui_MainWindow(object):
|
|||||||
self.actionClosePlaylist.setEnabled(True)
|
self.actionClosePlaylist.setEnabled(True)
|
||||||
self.actionClosePlaylist.setObjectName("actionClosePlaylist")
|
self.actionClosePlaylist.setObjectName("actionClosePlaylist")
|
||||||
self.actionRenamePlaylist = QtWidgets.QAction(MainWindow)
|
self.actionRenamePlaylist = QtWidgets.QAction(MainWindow)
|
||||||
self.actionRenamePlaylist.setEnabled(True)
|
self.actionRenamePlaylist.setEnabled(False)
|
||||||
self.actionRenamePlaylist.setObjectName("actionRenamePlaylist")
|
self.actionRenamePlaylist.setObjectName("actionRenamePlaylist")
|
||||||
self.actionDeletePlaylist = QtWidgets.QAction(MainWindow)
|
self.actionDeletePlaylist = QtWidgets.QAction(MainWindow)
|
||||||
self.actionDeletePlaylist.setEnabled(True)
|
self.actionDeletePlaylist.setEnabled(False)
|
||||||
self.actionDeletePlaylist.setObjectName("actionDeletePlaylist")
|
self.actionDeletePlaylist.setObjectName("actionDeletePlaylist")
|
||||||
self.actionMoveSelected = QtWidgets.QAction(MainWindow)
|
self.actionMoveSelected = QtWidgets.QAction(MainWindow)
|
||||||
self.actionMoveSelected.setObjectName("actionMoveSelected")
|
self.actionMoveSelected.setObjectName("actionMoveSelected")
|
||||||
@ -506,17 +506,18 @@ class Ui_MainWindow(object):
|
|||||||
self.actionResume = QtWidgets.QAction(MainWindow)
|
self.actionResume = QtWidgets.QAction(MainWindow)
|
||||||
self.actionResume.setObjectName("actionResume")
|
self.actionResume.setObjectName("actionResume")
|
||||||
self.menuFile.addAction(self.actionNewPlaylist)
|
self.menuFile.addAction(self.actionNewPlaylist)
|
||||||
self.menuFile.addAction(self.actionNew_from_template)
|
|
||||||
self.menuFile.addAction(self.actionOpenPlaylist)
|
self.menuFile.addAction(self.actionOpenPlaylist)
|
||||||
self.menuFile.addAction(self.actionClosePlaylist)
|
self.menuFile.addAction(self.actionClosePlaylist)
|
||||||
self.menuFile.addAction(self.actionRenamePlaylist)
|
self.menuFile.addAction(self.actionRenamePlaylist)
|
||||||
self.menuFile.addAction(self.actionDeletePlaylist)
|
|
||||||
self.menuFile.addAction(self.actionExport_playlist)
|
self.menuFile.addAction(self.actionExport_playlist)
|
||||||
|
self.menuFile.addAction(self.actionDeletePlaylist)
|
||||||
|
self.menuFile.addSeparator()
|
||||||
|
self.menuFile.addAction(self.actionNew_from_template)
|
||||||
|
self.menuFile.addAction(self.actionSave_as_template)
|
||||||
self.menuFile.addSeparator()
|
self.menuFile.addSeparator()
|
||||||
self.menuFile.addAction(self.actionMoveSelected)
|
self.menuFile.addAction(self.actionMoveSelected)
|
||||||
self.menuFile.addAction(self.actionMoveUnplayed)
|
self.menuFile.addAction(self.actionMoveUnplayed)
|
||||||
self.menuFile.addAction(self.actionDownload_CSV_of_played_tracks)
|
self.menuFile.addAction(self.actionDownload_CSV_of_played_tracks)
|
||||||
self.menuFile.addAction(self.actionSave_as_template)
|
|
||||||
self.menuFile.addSeparator()
|
self.menuFile.addSeparator()
|
||||||
self.menuFile.addAction(self.actionE_xit)
|
self.menuFile.addAction(self.actionE_xit)
|
||||||
self.menuPlaylist.addSeparator()
|
self.menuPlaylist.addSeparator()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user