close tabs with middle mouse button

This commit is contained in:
2022-06-25 08:36:00 +02:00
parent df68063c28
commit af69988b4a
2 changed files with 17 additions and 0 deletions

15
src/ui/CustomTabBar.py Normal file
View File

@@ -0,0 +1,15 @@
import PySide6
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QTabBar
class CustomTabBar(QTabBar):
def __init__(self):
super(CustomTabBar, self).__init__()
def mouseReleaseEvent(self, event: PySide6.QtGui.QMouseEvent) -> None:
print(event.button())
if event.button() == Qt.MouseButton.MiddleButton:
self.tabCloseRequested.emit(self.tabAt(event.pos()))
super(CustomTabBar, self).mouseReleaseEvent(event)