Passage à PySide6 car licence plus permissive
This commit is contained in:
@@ -1,32 +1,29 @@
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
from PyQt6 import uic
|
||||
from PyQt6.QtCore import Qt
|
||||
from PyQt6.QtGui import QFontDatabase, QFont
|
||||
from PyQt6.QtWidgets import QApplication, QMainWindow
|
||||
from PySide6 import QtGui
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtGui import QFontDatabase, QFont
|
||||
from PySide6.QtUiTools import QUiLoader
|
||||
from PySide6.QtWidgets import QMainWindow, QApplication
|
||||
|
||||
# Compile resources.qrc into resources_rc.py
|
||||
# rcc -g python .\resources.qrc -o .\src\resources_rc.py
|
||||
|
||||
import resources as resources # This is generated from the .qrc file # noqa: F401
|
||||
|
||||
# À placer tout en haut, avant les imports PyQt6 si possible
|
||||
if sys.platform.startswith('linux'):
|
||||
os.environ["QT_QPA_PLATFORM"] = "xcb"
|
||||
|
||||
if sys.platform=='windows' or sys.platform=="win32":
|
||||
from win11toast import toast # type: ignore
|
||||
|
||||
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
|
||||
bundle_dir = Path(sys._MEIPASS)
|
||||
else:
|
||||
bundle_dir = Path(__file__).parent
|
||||
bundle_dir = Path(__file__).parent.parent
|
||||
|
||||
# Remove this into final release
|
||||
from fake_patch_notes import patch_note
|
||||
NO_STAFF = True
|
||||
|
||||
NO_STAFF = True
|
||||
CURRENT = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
def load_custom_font():
|
||||
@@ -42,67 +39,54 @@ def load_custom_font():
|
||||
return font_families[0]
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.ui = QUiLoader().load(f"{bundle_dir}/ui/mainwindow.ui", self)
|
||||
central = self.ui.centralWidget()
|
||||
self.setCentralWidget(central)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# Remove the title bar and window frame
|
||||
self.setWindowFlags(Qt.WindowType.FramelessWindowHint |Qt.WindowType.Window)
|
||||
|
||||
self.setWindowFlags(Qt.WindowType.FramelessWindowHint | Qt.WindowType.Window)
|
||||
# Optional: Make background transparent (if you want rounded corners, etc.)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
# Track mouse position for dragging
|
||||
self._drag_pos = None
|
||||
|
||||
uic.loadUi(f"{bundle_dir}/ui/mainwindow.ui", self)
|
||||
|
||||
# Fixe some qss properties not taken into account
|
||||
self.subtitle_label.setStyleSheet("color: rgb(163, 177, 198);")
|
||||
self.queue_position.setStyleSheet("color: rgb(17, 248, 183);")
|
||||
|
||||
if NO_STAFF :
|
||||
self.staff_btn.hide()
|
||||
self.spacer_substitution.hide()
|
||||
self.ui.staff_btn.hide()
|
||||
self.ui.spacer_substitution.hide()
|
||||
|
||||
self.info_text.setMarkdown(patch_note)
|
||||
self.ui.info_text.setMarkdown(patch_note)
|
||||
|
||||
# Find the button by its objectName in Qt Designer
|
||||
# Example: objectName = "close_btn"
|
||||
self.close_btn.clicked.connect(self.close_link)
|
||||
self.minimize_btn.clicked.connect(self.minimize_link)
|
||||
self.connexion_btn.clicked.connect(self.connexion_btn_link)
|
||||
self.ui.close_btn.clicked.connect(self.close)
|
||||
self.ui.minimize_btn.clicked.connect(self.showMinimized)
|
||||
self.ui.connexion_btn.clicked.connect(self.connexion_btn_link)
|
||||
|
||||
@staticmethod
|
||||
def close_link():
|
||||
sys.exit(app.exec())
|
||||
self.show()
|
||||
|
||||
def minimize_link(self):
|
||||
# Minimize the application
|
||||
self.setWindowState(Qt.WindowState.WindowMinimized)
|
||||
|
||||
# Mouse press event to start dragging
|
||||
def mousePressEvent(self, event):
|
||||
# Mouse press event to start dragging
|
||||
def mousePressEvent(self, event: QtGui.QMouseEvent) -> None:
|
||||
if event.button() == Qt.MouseButton.LeftButton:
|
||||
self._drag_pos = event.globalPosition().toPoint() - self.frameGeometry().topLeft()
|
||||
event.accept()
|
||||
super().mousePressEvent(event)
|
||||
|
||||
# Mouse move event to drag window
|
||||
def mouseMoveEvent(self, event):
|
||||
if event.buttons() == Qt.MouseButton.LeftButton and self._drag_pos is not None:
|
||||
def mouseMoveEvent(self, event: QtGui.QMouseEvent) -> None:
|
||||
if event.buttons() & Qt.MouseButton.LeftButton and self._drag_pos is not None:
|
||||
self.move(event.globalPosition().toPoint() - self._drag_pos)
|
||||
event.accept()
|
||||
super().mouseMoveEvent(event)
|
||||
|
||||
# Mouse release event to stop dragging
|
||||
def mouseReleaseEvent(self, event):
|
||||
self._drag_pos = None
|
||||
event.accept()
|
||||
super().mouseReleaseEvent(event)
|
||||
|
||||
@staticmethod
|
||||
def connexion_btn_link():
|
||||
icon = {
|
||||
'src': ':/assets/background.png',
|
||||
'placement': 'appLogoOverride'
|
||||
}
|
||||
buttons = [
|
||||
{'activationType': 'protocol', 'arguments': '', 'content': 'Entrer en jeu'},
|
||||
]
|
||||
@@ -124,5 +108,5 @@ if __name__ == "__main__":
|
||||
app.setStyleSheet(style)
|
||||
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
|
||||
sys.exit(app.exec())
|
||||
|
||||
Reference in New Issue
Block a user