This commit is contained in:
Auric Vente 2024-07-25 09:21:01 -06:00
parent d0053368e3
commit 92d517f2e2
1 changed files with 17 additions and 1 deletions

View File

@ -22,8 +22,10 @@ from PySide6.QtWidgets import QLineEdit
from PySide6.QtGui import QFontDatabase # type: ignore from PySide6.QtGui import QFontDatabase # type: ignore
from PySide6.QtGui import QIcon from PySide6.QtGui import QIcon
from PySide6.QtGui import QKeyEvent from PySide6.QtGui import QKeyEvent
from PySide6.QtGui import QMouseEvent
from PySide6.QtCore import Qt # type: ignore from PySide6.QtCore import Qt # type: ignore
from PySide6.QtCore import QUrl from PySide6.QtCore import QUrl
from PySide6.QtCore import Signal
from PySide6.QtMultimedia import QMediaPlayer # type: ignore from PySide6.QtMultimedia import QMediaPlayer # type: ignore
from PySide6.QtMultimedia import QAudioOutput from PySide6.QtMultimedia import QAudioOutput
@ -31,6 +33,19 @@ from .config import Config
from .utils import Utils from .utils import Utils
class SpecialButton(QPushButton): # type: ignore
middleClicked = Signal()
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
def mousePressEvent(self, e: QMouseEvent) -> None:
if e.button() == Qt.MiddleButton:
self.middleClicked.emit()
else:
super().mousePressEvent(e)
class FilterLineEdit(QLineEdit): # type: ignore class FilterLineEdit(QLineEdit): # type: ignore
def keyPressEvent(self, e: QKeyEvent) -> None: def keyPressEvent(self, e: QKeyEvent) -> None:
if e.key() == Qt.Key_Escape: if e.key() == Qt.Key_Escape:
@ -229,9 +244,10 @@ class Window:
root = QWidget() root = QWidget()
container = QHBoxLayout() container = QHBoxLayout()
btn_menu = QPushButton("Menu") btn_menu = SpecialButton("Menu")
btn_menu.setToolTip("The main menu") btn_menu.setToolTip("The main menu")
btn_menu.clicked.connect(Game.menu) btn_menu.clicked.connect(Game.menu)
btn_menu.middleClicked.connect(Game.force_update)
Window.speed = QComboBox() Window.speed = QComboBox()
tooltip = "The speed of the updates\n" tooltip = "The speed of the updates\n"