Made the playlist tabs look prettier by making the tab title editor non-static.
This commit is contained in:
parent
0101cf174c
commit
7ff1ad7a02
7 changed files with 46 additions and 84 deletions
|
@ -4,6 +4,8 @@ from PyQt6.QtCore import QPoint
|
|||
from PyQt6.QtGui import QAction
|
||||
from PyQt6.QtWidgets import QMenu, QTabBar
|
||||
|
||||
from .tab_title_editor import TabTitleEditor
|
||||
|
||||
|
||||
class PlaylistContextMenu(QMenu):
|
||||
def __init__(self, parent=None):
|
||||
|
@ -11,7 +13,8 @@ class PlaylistContextMenu(QMenu):
|
|||
|
||||
self.tab_bar: QTabBar = parent
|
||||
|
||||
self.playlist_title = None
|
||||
self.tab_index = -1
|
||||
self.playlist = None
|
||||
|
||||
self.title = self.addSection("Playlist Actions")
|
||||
|
||||
|
@ -24,15 +27,19 @@ class PlaylistContextMenu(QMenu):
|
|||
self.rename_action.triggered.connect(self.rename)
|
||||
self.delete_action.triggered.connect(self.delete)
|
||||
|
||||
def exec(self, pos: QPoint, title):
|
||||
self.playlist_title = title
|
||||
def exec(self, pos: QPoint, index: int, playlist):
|
||||
self.tab_index = index
|
||||
self.playlist = playlist
|
||||
|
||||
self.title.setText(title.text()) # set section title
|
||||
self.title.setText(playlist.title)
|
||||
|
||||
super().exec(pos)
|
||||
|
||||
def rename(self):
|
||||
self.playlist_title.setFocus()
|
||||
# create temporary QLineEdit for renaming the tab
|
||||
title_editor = TabTitleEditor(self.playlist, self.tab_bar, self.tab_index)
|
||||
|
||||
self.tab_bar.setTabButton(self.tab_index, QTabBar.ButtonPosition.RightSide, title_editor)
|
||||
|
||||
def delete(self):
|
||||
self.playlist_title.playlist_view.playlist.delete()
|
||||
self.playlist.delete()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue