Fixed some crashs that occurred when clicking on the tab bar, but not on a tab.
This commit is contained in:
parent
1decb3adea
commit
8a3d5a5b15
1 changed files with 9 additions and 0 deletions
|
@ -26,6 +26,9 @@ class PlaylistTabBar(QTabBar):
|
|||
self.tab_widget.setCurrentIndex(index)
|
||||
|
||||
def on_click(self, index):
|
||||
if index == -1: # do nothing if no tab was clicked
|
||||
return
|
||||
|
||||
playlist_view = self.tab_widget.widget(index)
|
||||
playlist = playlist_view.playlist
|
||||
|
||||
|
@ -38,10 +41,16 @@ class PlaylistTabBar(QTabBar):
|
|||
self.app.player.start_playlist(playlist)
|
||||
|
||||
def contextMenuEvent(self, event: QContextMenuEvent, title=None):
|
||||
# get title by self.tabAt() if the event is called from PyQt, else its executed from the tab title and getting
|
||||
# the index by tabAt() wouldn't be possible
|
||||
if title is None:
|
||||
pos = event.pos()
|
||||
|
||||
index = self.tabAt(pos)
|
||||
|
||||
if index == -1: # when no tab was clicked, do nothing
|
||||
return
|
||||
|
||||
title = self.tabButton(index, QTabBar.ButtonPosition.RightSide)
|
||||
|
||||
self.context_menu.exec(event.globalPos(), title)
|
||||
|
|
Loading…
Add table
Reference in a new issue