2025-01-27 18:02:06 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
from PyQt6.QtCore import QPoint
|
|
|
|
from PyQt6.QtGui import QAction
|
|
|
|
from PyQt6.QtWidgets import QMenu, QTabBar
|
|
|
|
|
|
|
|
|
|
|
|
class PlaylistContextMenu(QMenu):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
|
|
|
|
self.tab_bar: QTabBar = parent
|
|
|
|
|
|
|
|
self.playlist_title = None
|
|
|
|
|
2025-01-28 18:23:43 +01:00
|
|
|
self.title = self.addSection("Playlist Actions")
|
2025-01-27 18:02:06 +01:00
|
|
|
|
2025-01-28 18:23:43 +01:00
|
|
|
self.rename_action = QAction("Rename")
|
2025-01-27 18:02:06 +01:00
|
|
|
self.addAction(self.rename_action)
|
|
|
|
|
2025-01-28 18:23:43 +01:00
|
|
|
self.delete_action = QAction("Delete")
|
|
|
|
self.addAction(self.delete_action)
|
|
|
|
|
2025-01-27 18:02:06 +01:00
|
|
|
self.rename_action.triggered.connect(self.rename)
|
2025-01-28 18:23:43 +01:00
|
|
|
self.delete_action.triggered.connect(self.delete)
|
2025-01-27 18:02:06 +01:00
|
|
|
|
|
|
|
def exec(self, pos: QPoint, title):
|
|
|
|
self.playlist_title = title
|
|
|
|
|
2025-01-28 18:23:43 +01:00
|
|
|
self.title.setText(title.text()) # set section title
|
|
|
|
|
2025-01-27 18:02:06 +01:00
|
|
|
super().exec(pos)
|
|
|
|
|
|
|
|
def rename(self):
|
|
|
|
self.playlist_title.setFocus()
|
|
|
|
|
2025-01-28 18:23:43 +01:00
|
|
|
def delete(self):
|
|
|
|
self.playlist_title.playlist_view.playlist.delete()
|
|
|
|
self.playlist_title.playlist_view.deleteLater()
|
|
|
|
|