""" Quick Actions Panel Main action buttons for ripeness, quality, calibration, and batch processing. """ from PyQt5.QtWidgets import QGroupBox, QGridLayout, QPushButton from PyQt5.QtCore import pyqtSignal, Qt from resources.styles import ( GROUP_BOX_STYLE, RIPENESS_BUTTON_STYLE, QUALITY_BUTTON_STYLE, CALIBRATION_BUTTON_STYLE, BATCH_BUTTON_STYLE ) class QuickActionsPanel(QGroupBox): """ Panel with quick action buttons. Provides buttons for: - Analyze Durian (with manual/auto mode) - Ripeness Classification - Quality Assessment - System Calibration - Batch Processing Signals: analyze_durian_clicked: Emitted when analyze durian button clicked (bool: manual_mode) ripeness_clicked: Emitted when ripeness button clicked quality_clicked: Emitted when quality button clicked calibration_clicked: Emitted when calibration button clicked batch_clicked: Emitted when batch button clicked """ # Define signals analyze_durian_clicked = pyqtSignal(bool) # bool indicates manual mode ripeness_clicked = pyqtSignal() quality_clicked = pyqtSignal() calibration_clicked = pyqtSignal() batch_clicked = pyqtSignal() def __init__(self): """Initialize the quick actions panel.""" super().__init__("Quick Actions") self.setStyleSheet(GROUP_BOX_STYLE) self.init_ui() def init_ui(self): """Initialize the UI components.""" layout = QGridLayout() layout.setSpacing(10) # ========== ANALYZE DURIAN SECTION (Row 0) ========== # Auto Analyze Button (left) self.auto_analyze_btn = QPushButton("Auto Analyze\nDurian") self.auto_analyze_btn.setMinimumHeight(80) self.auto_analyze_btn.setStyleSheet(""" QPushButton { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #2ecc71, stop:1 #27ae60); color: white; font-size: 18px; font-weight: bold; border-radius: 8px; border: 2px solid #229954; } QPushButton:hover { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #27ae60, stop:1 #229954); } QPushButton:pressed { background: #1e8449; } """) self.auto_analyze_btn.clicked.connect(self._on_auto_analyze_clicked) layout.addWidget(self.auto_analyze_btn, 0, 0) # Manual Entry Button (right) self.manual_entry_btn = QPushButton("Manual\nEntry") self.manual_entry_btn.setMinimumHeight(80) self.manual_entry_btn.setStyleSheet(""" QPushButton { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #3498db, stop:1 #2980b9); color: white; font-size: 18px; font-weight: bold; border-radius: 8px; border: 2px solid #2471a3; } QPushButton:hover { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #2980b9, stop:1 #2471a3); } QPushButton:pressed { background: #1f618d; } """) self.manual_entry_btn.clicked.connect(self._on_manual_entry_clicked) layout.addWidget(self.manual_entry_btn, 0, 1) # ========== OTHER ACTION BUTTONS ========== # Ripeness Classifier Button (row 1, left) - HIDDEN FOR NOW ripeness_btn = QPushButton("Ripeness\nClassifier") ripeness_btn.setMinimumHeight(70) ripeness_btn.setStyleSheet(RIPENESS_BUTTON_STYLE) ripeness_btn.clicked.connect(self.ripeness_clicked.emit) ripeness_btn.hide() layout.addWidget(ripeness_btn, 1, 0) # Quality Classifier Button (row 1, right) - HIDDEN FOR NOW quality_btn = QPushButton("Quality\nClassifier") quality_btn.setMinimumHeight(70) quality_btn.setStyleSheet(QUALITY_BUTTON_STYLE) quality_btn.clicked.connect(self.quality_clicked.emit) quality_btn.hide() layout.addWidget(quality_btn, 1, 1) # System Calibration Button (row 2, left) - HIDDEN FOR NOW calibration_btn = QPushButton("System\nCalibration") calibration_btn.setMinimumHeight(70) calibration_btn.setStyleSheet(CALIBRATION_BUTTON_STYLE) calibration_btn.clicked.connect(self.calibration_clicked.emit) calibration_btn.hide() layout.addWidget(calibration_btn, 2, 0) # Batch Mode Button (row 2, right) - HIDDEN FOR NOW batch_btn = QPushButton("Batch Mode\nAuto Processing") batch_btn.setMinimumHeight(70) batch_btn.setStyleSheet(BATCH_BUTTON_STYLE) batch_btn.clicked.connect(self.batch_clicked.emit) batch_btn.hide() layout.addWidget(batch_btn, 2, 1) self.setLayout(layout) def _on_auto_analyze_clicked(self): """Handle auto analyze durian button click.""" self.analyze_durian_clicked.emit(False) # Auto mode def _on_manual_entry_clicked(self): """Handle manual entry button click.""" self.analyze_durian_clicked.emit(True) # Manual mode