fixed the stupid ass fswindow

This commit is contained in:
rattatwinko
2025-05-26 16:47:53 +02:00
parent 5399cb8739
commit 65be018700

View File

@@ -481,60 +481,23 @@ class CameraDisplay(QLabel):
self.close_fullscreen() self.close_fullscreen()
def show_fullscreen(self): def show_fullscreen(self):
"""Show this camera in fullscreen mode""" """Show this camera in a new window"""
if not self.pixmap(): if not self.pixmap():
return return
self.fullscreen_window = QMainWindow(self.window()) self.fullscreen_window = QMainWindow(self.window())
self.fullscreen_window.setWindowTitle(f"Camera {self.cam_id} - Fullscreen") self.fullscreen_window.setWindowTitle(f"Camera {self.cam_id}")
self.fullscreen_window.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)
# Create central widget # Create central widget
central_widget = QWidget() central_widget = QWidget()
layout = QVBoxLayout(central_widget) 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 # Create fullscreen label
self.fullscreen_label = QLabel() self.fullscreen_label = QLabel()
self.fullscreen_label.setAlignment(Qt.AlignCenter) self.fullscreen_label.setAlignment(Qt.AlignCenter)
self.fullscreen_label.setMinimumSize(640, 480) # Set minimum size
self.fullscreen_label.setPixmap(self.pixmap().scaled( self.fullscreen_label.setPixmap(self.pixmap().scaled(
QApplication.primaryScreen().size(), QSize(1280, 720), # Default HD size
Qt.KeepAspectRatio, Qt.KeepAspectRatio,
Qt.SmoothTransformation Qt.SmoothTransformation
)) ))
@@ -542,7 +505,7 @@ class CameraDisplay(QLabel):
self.fullscreen_window.setCentralWidget(central_widget) self.fullscreen_window.setCentralWidget(central_widget)
# Add ESC shortcut # Add ESC shortcut to close
shortcut = QShortcut(QKeySequence(Qt.Key_Escape), self.fullscreen_window) shortcut = QShortcut(QKeySequence(Qt.Key_Escape), self.fullscreen_window)
shortcut.activated.connect(self.close_fullscreen) shortcut.activated.connect(self.close_fullscreen)
@@ -550,10 +513,6 @@ class CameraDisplay(QLabel):
screenshot_shortcut = QShortcut(QKeySequence("Ctrl+S"), self.fullscreen_window) screenshot_shortcut = QShortcut(QKeySequence("Ctrl+S"), self.fullscreen_window)
screenshot_shortcut.activated.connect(self.take_screenshot) 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 # Update fullscreen image when main window updates
self.fullscreen_timer = QTimer() self.fullscreen_timer = QTimer()
self.fullscreen_timer.timeout.connect( self.fullscreen_timer.timeout.connect(
@@ -561,20 +520,10 @@ class CameraDisplay(QLabel):
) )
self.fullscreen_timer.start(30) self.fullscreen_timer.start(30)
# Show fullscreen # Set window size and show
self.fullscreen_window.showMaximized() screen = QApplication.primaryScreen().availableGeometry()
self.fullscreen_window.resize(min(1280, screen.width() * 0.8), min(720, screen.height() * 0.8))
def fullscreen_mousePressEvent(self, event): self.fullscreen_window.show()
"""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()
def update_fullscreen(self, label): def update_fullscreen(self, label):
"""Update the fullscreen display""" """Update the fullscreen display"""