"""Fullscreen timer widget optimized for large display.""" from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel, QFrame from PyQt6.QtCore import Qt from PyQt6.QtGui import QFont class FullscreenTimerWidget(QFrame): def __init__(self, timer_model): super().__init__() self.timer_model = timer_model self.remaining_seconds = timer_model.duration self.is_paused = False self.time_font_size = 120 self.title_font_size = 40 self.init_ui() def init_ui(self): # Frame styling with border between timers self.setStyleSheet(f""" QFrame {{ background-color: {self.timer_model.bg_color}; border-bottom: 3px solid #333333; }} """) # Main layout layout = QVBoxLayout(self) layout.setContentsMargins(40, 40, 40, 40) # Timer title self.title_label = QLabel(self.timer_model.name) self.title_label.setAlignment(Qt.AlignmentFlag.AlignCenter) self.title_label.setStyleSheet(f"color: {self.timer_model.text_color}; border: none;") self.title_label.setWordWrap(True) self.title_font = QFont("Arial", self.title_font_size, QFont.Weight.Bold) self.title_label.setFont(self.title_font) layout.addWidget(self.title_label, stretch=1) # Timer display self.time_label = QLabel(self.format_time(self.remaining_seconds)) self.time_label.setAlignment(Qt.AlignmentFlag.AlignCenter) self.time_label.setStyleSheet(f"color: {self.timer_model.text_color}; border: none;") self.time_font = QFont("Arial", self.time_font_size, QFont.Weight.Bold) self.time_label.setFont(self.time_font) layout.addWidget(self.time_label, stretch=3) # Pause indicator (optional, shown when paused) self.pause_indicator = QLabel("⏸ PAUSED") self.pause_indicator.setAlignment(Qt.AlignmentFlag.AlignCenter) self.pause_indicator.setStyleSheet(f"color: {self.timer_model.text_color}; border: none;") pause_font = QFont("Arial", 24, QFont.Weight.Bold) self.pause_indicator.setFont(pause_font) self.pause_indicator.hide() layout.addWidget(self.pause_indicator) def format_time(self, seconds): hours = seconds // 3600 minutes = (seconds % 3600) // 60 secs = seconds % 60 if hours > 0: return f"{hours:02d}:{minutes:02d}:{secs:02d}" else: return f"{minutes:02d}:{secs:02d}" def sync_with(self, source_widget): """Sync this mirror widget with the source widget.""" self.remaining_seconds = source_widget.remaining_seconds self.is_paused = source_widget.is_paused self.time_label.setText(self.format_time(self.remaining_seconds)) if self.is_paused: self.pause_indicator.show() else: self.pause_indicator.hide() def update_display(self, remaining_seconds): """Update the display with new time (for mirror widgets).""" self.remaining_seconds = remaining_seconds if remaining_seconds <= 0: self.time_label.setText("TIME'S UP!") else: self.time_label.setText(self.format_time(remaining_seconds)) def update_state(self, is_paused): """Update the paused state (for mirror widgets).""" self.is_paused = is_paused if is_paused: self.pause_indicator.show() else: self.pause_indicator.hide() def update_font_sizes(self, time_size, title_size): """Update font sizes based on number of timers.""" self.time_font_size = time_size self.title_font_size = title_size self.time_font.setPointSize(time_size) self.time_label.setFont(self.time_font) self.title_font.setPointSize(title_size) self.title_label.setFont(self.title_font)