Got the context menu and focusing working.

This commit is contained in:
The Wobbler 2025-01-27 18:02:06 +01:00
parent 60dee10d1a
commit b2aa7ffd8c
4 changed files with 51 additions and 4 deletions

View file

@ -1,8 +1,10 @@
#!/usr/bin/python3
from PyQt6.QtGui import QDragEnterEvent
from PyQt6.QtGui import QDragEnterEvent, QContextMenuEvent
from PyQt6.QtWidgets import QTabBar
from .tab_context_menu import PlaylistContextMenu
class PlaylistTabBar(QTabBar):
def __init__(self, parent=None):
@ -11,6 +13,8 @@ class PlaylistTabBar(QTabBar):
self.tab_widget = parent
self.app = parent.library.app
self.context_menu = PlaylistContextMenu(self)
self.setAcceptDrops(True)
self.tabBarClicked.connect(self.on_click)
@ -33,3 +37,13 @@ class PlaylistTabBar(QTabBar):
self.app.player.start_playlist(playlist)
def contextMenuEvent(self, event: QContextMenuEvent, title=None):
if title is None:
pos = event.pos()
index = self.tabAt(pos)
title = self.tabButton(index, QTabBar.ButtonPosition.RightSide)
print(index)
self.context_menu.exec(event.globalPos(), title)