From 65be01870083b1b0b9791b78417447425ba916a5 Mon Sep 17 00:00:00 2001 From: rattatwinko Date: Mon, 26 May 2025 16:47:53 +0200 Subject: [PATCH] fixed the stupid ass fswindow --- mucapy/main.py | 69 +++++++------------------------------------------- 1 file changed, 9 insertions(+), 60 deletions(-) diff --git a/mucapy/main.py b/mucapy/main.py index c2e2282..fe9da44 100644 --- a/mucapy/main.py +++ b/mucapy/main.py @@ -481,60 +481,23 @@ class CameraDisplay(QLabel): self.close_fullscreen() def show_fullscreen(self): - """Show this camera in fullscreen mode""" + """Show this camera in a new window""" if not self.pixmap(): return self.fullscreen_window = QMainWindow(self.window()) - self.fullscreen_window.setWindowTitle(f"Camera {self.cam_id} - Fullscreen") - self.fullscreen_window.setWindowFlags(Qt.Window | Qt.FramelessWindowHint) + self.fullscreen_window.setWindowTitle(f"Camera {self.cam_id}") # Create central widget central_widget = QWidget() layout = QVBoxLayout(central_widget) - layout.setContentsMargins(0, 0, 0, 0) - - # Create title bar - title_bar = QWidget() - title_bar.setStyleSheet(""" - QWidget { - background-color: #1E1E1E; - color: #DDD; - } - """) - title_bar.setFixedHeight(30) - title_layout = QHBoxLayout(title_bar) - title_layout.setContentsMargins(10, 0, 10, 0) - - # Add title label - title_label = QLabel(f"Camera {self.cam_id} - Fullscreen") - title_layout.addWidget(title_label) - - # Add close button - close_btn = QPushButton("×") - close_btn.setFixedSize(20, 20) - close_btn.setStyleSheet(""" - QPushButton { - background-color: transparent; - color: #DDD; - border: none; - font-size: 16px; - } - QPushButton:hover { - background-color: #E81123; - color: white; - } - """) - close_btn.clicked.connect(self.close_fullscreen) - title_layout.addWidget(close_btn) - - layout.addWidget(title_bar) # Create fullscreen label self.fullscreen_label = QLabel() self.fullscreen_label.setAlignment(Qt.AlignCenter) + self.fullscreen_label.setMinimumSize(640, 480) # Set minimum size self.fullscreen_label.setPixmap(self.pixmap().scaled( - QApplication.primaryScreen().size(), + QSize(1280, 720), # Default HD size Qt.KeepAspectRatio, Qt.SmoothTransformation )) @@ -542,7 +505,7 @@ class CameraDisplay(QLabel): self.fullscreen_window.setCentralWidget(central_widget) - # Add ESC shortcut + # Add ESC shortcut to close shortcut = QShortcut(QKeySequence(Qt.Key_Escape), self.fullscreen_window) shortcut.activated.connect(self.close_fullscreen) @@ -550,10 +513,6 @@ class CameraDisplay(QLabel): screenshot_shortcut = QShortcut(QKeySequence("Ctrl+S"), self.fullscreen_window) screenshot_shortcut.activated.connect(self.take_screenshot) - # Make window draggable - title_bar.mousePressEvent = self.fullscreen_mousePressEvent - title_bar.mouseMoveEvent = self.fullscreen_mouseMoveEvent - # Update fullscreen image when main window updates self.fullscreen_timer = QTimer() self.fullscreen_timer.timeout.connect( @@ -561,20 +520,10 @@ class CameraDisplay(QLabel): ) self.fullscreen_timer.start(30) - # Show fullscreen - self.fullscreen_window.showMaximized() - - def fullscreen_mousePressEvent(self, event): - """Handle mouse press events for dragging""" - if event.button() == Qt.LeftButton: - self.fullscreen_window.drag_position = event.globalPos() - self.fullscreen_window.frameGeometry().topLeft() - event.accept() - - def fullscreen_mouseMoveEvent(self, event): - """Handle mouse move events for dragging""" - if hasattr(self.fullscreen_window, 'drag_position'): - self.fullscreen_window.move(event.globalPos() - self.fullscreen_window.drag_position) - event.accept() + # Set window size and show + screen = QApplication.primaryScreen().availableGeometry() + self.fullscreen_window.resize(min(1280, screen.width() * 0.8), min(720, screen.height() * 0.8)) + self.fullscreen_window.show() def update_fullscreen(self, label): """Update the fullscreen display"""