Initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
from .image_params import ImageParamsPanel
|
||||
from .color_panel import ColorPanel
|
||||
from .console_panel import ConsolePanel
|
||||
from .stream_panel import StreamPanel
|
||||
from .settings_panel import SettingsPanel
|
||||
|
||||
__all__ = [
|
||||
"ImageParamsPanel",
|
||||
"ColorPanel",
|
||||
"ConsolePanel",
|
||||
"StreamPanel",
|
||||
"SettingsPanel",
|
||||
]
|
||||
@@ -0,0 +1,106 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Audio settings section."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtWidgets import QWidget, QHBoxLayout, QLabel, QComboBox
|
||||
|
||||
from ..widgets import CollapsibleSection, ParamSlider, ToggleSwitch
|
||||
|
||||
NOISE_LEVELS = ["Close", "Weak", "Middle", "Strong"]
|
||||
REVERB_LEVELS = ["Close", "Weak", "Middle", "Strong"]
|
||||
|
||||
|
||||
class AudioSection(CollapsibleSection):
|
||||
"""Collapsible panel for audio settings."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("Audio Settings", parent)
|
||||
|
||||
self.volume_slider = ParamSlider("Volume", min_val=0, max_val=100, default=50, step=1)
|
||||
self.volume_slider.value_changed.connect(lambda v: self.param_changed.emit("au-volume", v))
|
||||
self.add_widget(self.volume_slider)
|
||||
|
||||
self.noise_combo = QComboBox()
|
||||
self.noise_combo.addItems(NOISE_LEVELS)
|
||||
self.noise_combo.setCurrentIndex(2)
|
||||
self.noise_combo.currentIndexChanged.connect(
|
||||
lambda idx: self.param_changed.emit("au-denoise", idx)
|
||||
)
|
||||
self.add_widget(self._labeled("Noise Reduction", self.noise_combo))
|
||||
|
||||
self.delay_slider = ParamSlider("Audio Delay", min_val=0, max_val=400, default=0, step=1, suffix="ms")
|
||||
self.delay_slider.value_changed.connect(lambda v: self.param_changed.emit("au-delay", v))
|
||||
self.add_widget(self.delay_slider)
|
||||
|
||||
self.auto_gain_toggle = ToggleSwitch(checked=True)
|
||||
self.auto_gain_toggle.toggled.connect(lambda v: self.param_changed.emit("au-gain", v))
|
||||
self._auto_gain_row = self._toggle_row("Auto Gain", self.auto_gain_toggle)
|
||||
self.add_widget(self._auto_gain_row)
|
||||
|
||||
self.reverb_combo = QComboBox()
|
||||
self.reverb_combo.addItems(REVERB_LEVELS)
|
||||
self.reverb_combo.currentIndexChanged.connect(
|
||||
lambda idx: self.param_changed.emit("au-reverb", idx)
|
||||
)
|
||||
self.add_widget(self._labeled("Reverb", self.reverb_combo))
|
||||
|
||||
@staticmethod
|
||||
def _labeled(text: str, widget: QWidget) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(110)
|
||||
layout.addWidget(lbl)
|
||||
layout.addWidget(widget)
|
||||
layout.addStretch()
|
||||
return row
|
||||
|
||||
@staticmethod
|
||||
def _toggle_row(text: str, toggle: ToggleSwitch) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(170)
|
||||
layout.addWidget(lbl)
|
||||
layout.addStretch()
|
||||
layout.addWidget(toggle)
|
||||
return row
|
||||
|
||||
def set_volume(self, value: int):
|
||||
self.volume_slider.set_value(float(value), emit=False)
|
||||
|
||||
def set_noise_reduction(self, value: int):
|
||||
self.noise_combo.blockSignals(True)
|
||||
self.noise_combo.setCurrentIndex(value)
|
||||
self.noise_combo.blockSignals(False)
|
||||
|
||||
def set_delay(self, value: int):
|
||||
self.delay_slider.set_value(float(value), emit=False)
|
||||
|
||||
def set_auto_gain(self, enabled: bool):
|
||||
self.auto_gain_toggle.set_checked(enabled, emit=False)
|
||||
|
||||
def set_reverb(self, value: int):
|
||||
self.reverb_combo.blockSignals(True)
|
||||
self.reverb_combo.setCurrentIndex(value)
|
||||
self.reverb_combo.blockSignals(False)
|
||||
@@ -0,0 +1,215 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Color correction panel with HSV color wheel, sliders, and CLUT controls."""
|
||||
|
||||
from PySide6.QtCore import Qt, Signal
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QSizePolicy,
|
||||
)
|
||||
from PySide6.QtGui import QFont
|
||||
|
||||
from ..theme import COLOR_ACCENT, COLOR_BG_PANEL, COLOR_TEXT_SECONDARY
|
||||
from ..widgets import CollapsibleSection, ColorWheel, ParamSlider, ToggleSwitch, SegmentButton
|
||||
|
||||
|
||||
class ColorPanel(QWidget):
|
||||
"""Panel for HSV color grading and CLUT control.
|
||||
|
||||
Provides a visual color wheel for hue/saturation selection,
|
||||
sliders for fine control, and CLUT enable/disable toggle.
|
||||
"""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setObjectName("colorPanel")
|
||||
self.setStyleSheet(f"#colorPanel {{ background-color: {COLOR_BG_PANEL}; }}")
|
||||
|
||||
outer = QVBoxLayout(self)
|
||||
outer.setContentsMargins(0, 0, 0, 0)
|
||||
outer.setSpacing(0)
|
||||
|
||||
header = QWidget()
|
||||
header.setFixedHeight(36)
|
||||
header_layout = QHBoxLayout(header)
|
||||
header_layout.setContentsMargins(12, 4, 12, 4)
|
||||
header_layout.setSpacing(8)
|
||||
|
||||
title = QLabel("Color")
|
||||
title_font = QFont()
|
||||
title_font.setBold(True)
|
||||
title_font.setPointSize(11)
|
||||
title.setFont(title_font)
|
||||
header_layout.addWidget(title)
|
||||
header_layout.addStretch()
|
||||
|
||||
outer.addWidget(header)
|
||||
|
||||
self._mode = SegmentButton(["Fast", "Professional"])
|
||||
mode_row = QWidget()
|
||||
mode_layout = QHBoxLayout(mode_row)
|
||||
mode_layout.setContentsMargins(12, 4, 12, 4)
|
||||
mode_layout.setSpacing(8)
|
||||
mode_layout.addWidget(self._mode)
|
||||
outer.addWidget(mode_row)
|
||||
|
||||
wheel_container = QWidget()
|
||||
wheel_layout = QVBoxLayout(wheel_container)
|
||||
wheel_layout.setContentsMargins(0, 8, 0, 4)
|
||||
wheel_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self._wheel = ColorWheel()
|
||||
wheel_layout.addWidget(self._wheel, 0, Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self._grid_reset_btn = QPushButton("Reset Grid")
|
||||
self._grid_reset_btn.setFixedHeight(28)
|
||||
self._grid_reset_btn.setFixedWidth(self._wheel.WHEEL_SIZE)
|
||||
wheel_layout.addWidget(self._grid_reset_btn, 0, Qt.AlignmentFlag.AlignCenter)
|
||||
outer.addWidget(wheel_container)
|
||||
|
||||
slider_section = CollapsibleSection("HSV Controls")
|
||||
self._hue_slider = ParamSlider("Hue", min_val=0, max_val=360, default=0, step=1)
|
||||
slider_section.add_widget(self._hue_slider)
|
||||
|
||||
self._sat_slider = ParamSlider("Saturation", min_val=0, max_val=100, default=0, step=1)
|
||||
slider_section.add_widget(self._sat_slider)
|
||||
|
||||
self._bright_slider = ParamSlider("Brightness", min_val=0, max_val=100, default=100, step=1)
|
||||
slider_section.add_widget(self._bright_slider)
|
||||
|
||||
outer.addWidget(slider_section)
|
||||
|
||||
clut_section = CollapsibleSection("Color LUT")
|
||||
self._clut_toggle = ToggleSwitch()
|
||||
clut_section.add_widget(self._toggle_row("Enable CLUT", self._clut_toggle))
|
||||
|
||||
self._clut_attr = ParamSlider("Intensity", min_val=0, max_val=255, default=0, step=1)
|
||||
clut_section.add_widget(self._clut_attr)
|
||||
|
||||
self._clut_reset_btn = QPushButton("Reset Color Grading")
|
||||
self._clut_reset_btn.setProperty("accent", True)
|
||||
self._clut_reset_btn.setFixedHeight(32)
|
||||
clut_section.add_widget(self._clut_reset_btn)
|
||||
|
||||
outer.addWidget(clut_section)
|
||||
|
||||
tuning_section = CollapsibleSection("Tuning", expanded=False)
|
||||
self._tuning_brightness = ParamSlider("Brightness", min_val=0, max_val=100, default=50, step=1)
|
||||
tuning_section.add_widget(self._tuning_brightness)
|
||||
|
||||
self._tuning_color_temp = ParamSlider("Color Temp", min_val=2000, max_val=10000, default=5500, step=50)
|
||||
tuning_section.add_widget(self._tuning_color_temp)
|
||||
|
||||
outer.addWidget(tuning_section)
|
||||
outer.addStretch()
|
||||
|
||||
self._wire_signals()
|
||||
|
||||
def _wire_signals(self):
|
||||
self._wheel.hue_changed.connect(self._on_wheel_hue)
|
||||
self._wheel.saturation_changed.connect(self._on_wheel_sat)
|
||||
|
||||
self._hue_slider.value_changed.connect(self._on_slider_hue)
|
||||
self._sat_slider.value_changed.connect(self._on_slider_sat)
|
||||
self._bright_slider.value_changed.connect(self._on_slider_bright)
|
||||
|
||||
self._clut_toggle.toggled.connect(
|
||||
lambda v: self.param_changed.emit("clut-enable", v)
|
||||
)
|
||||
|
||||
self._clut_attr.value_changed.connect(
|
||||
lambda v: self.param_changed.emit("clut-attr", int(v))
|
||||
)
|
||||
|
||||
self._clut_reset_btn.clicked.connect(
|
||||
lambda: self.param_changed.emit("clut-reset", True)
|
||||
)
|
||||
|
||||
self._grid_reset_btn.clicked.connect(self._on_grid_reset)
|
||||
self._mode.selection_changed.connect(self._on_mode_changed)
|
||||
|
||||
self._wheel.grid_changed.connect(
|
||||
lambda data: self.param_changed.emit("clut-grid-changed", data)
|
||||
)
|
||||
|
||||
self._tuning_brightness.value_changed.connect(
|
||||
lambda v: self.param_changed.emit("tuning-brightness", v)
|
||||
)
|
||||
self._tuning_color_temp.value_changed.connect(
|
||||
lambda v: self.param_changed.emit("tuning-color-temp", v)
|
||||
)
|
||||
|
||||
def _on_wheel_hue(self, hue: int):
|
||||
self._hue_slider.set_value(float(hue), emit=False)
|
||||
self.param_changed.emit("color-hue", hue)
|
||||
|
||||
def _on_wheel_sat(self, sat: int):
|
||||
self._sat_slider.set_value(float(sat), emit=False)
|
||||
self.param_changed.emit("color-saturation", sat)
|
||||
|
||||
def _on_slider_hue(self, val: float):
|
||||
self._wheel.set_hue(int(val))
|
||||
self.param_changed.emit("color-hue", int(val))
|
||||
|
||||
def _on_slider_sat(self, val: float):
|
||||
self._wheel.set_saturation(int(val))
|
||||
self.param_changed.emit("color-saturation", int(val))
|
||||
|
||||
def _on_slider_bright(self, val: float):
|
||||
self._wheel.set_brightness(int(val))
|
||||
self.param_changed.emit("color-brightness", int(val))
|
||||
|
||||
@staticmethod
|
||||
def _toggle_row(text: str, toggle: ToggleSwitch) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(170)
|
||||
layout.addWidget(lbl)
|
||||
layout.addStretch()
|
||||
layout.addWidget(toggle)
|
||||
return row
|
||||
|
||||
def set_hue(self, value: int):
|
||||
self._wheel.set_hue(value)
|
||||
self._hue_slider.set_value(float(value), emit=False)
|
||||
|
||||
def set_saturation(self, value: int):
|
||||
self._wheel.set_saturation(value)
|
||||
self._sat_slider.set_value(float(value), emit=False)
|
||||
|
||||
def set_brightness(self, value: int):
|
||||
self._wheel.set_brightness(value)
|
||||
self._bright_slider.set_value(float(value), emit=False)
|
||||
|
||||
def set_clut_enabled(self, enabled: bool):
|
||||
self._clut_toggle.set_checked(enabled, emit=False)
|
||||
|
||||
def set_clut_attr(self, value: int):
|
||||
self._clut_attr.set_value(float(value), emit=False)
|
||||
|
||||
def set_grid_data(self, data: dict):
|
||||
self._wheel.set_grid_data(data)
|
||||
|
||||
def _on_grid_reset(self):
|
||||
self._wheel.reset_grid()
|
||||
self.param_changed.emit("clut-reset", True)
|
||||
|
||||
def _on_mode_changed(self, index: int):
|
||||
mode = "fast" if index == 0 else "professional"
|
||||
self._wheel.set_mode(mode)
|
||||
@@ -0,0 +1,306 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Console panel with recording, AI tracking, and zoom controls."""
|
||||
|
||||
from PySide6.QtCore import Qt, Signal
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton,
|
||||
)
|
||||
from PySide6.QtGui import QFont, QPainter, QColor
|
||||
|
||||
from ..theme import (
|
||||
COLOR_ACCENT, COLOR_BG_PANEL, COLOR_BG_INPUT, COLOR_BORDER,
|
||||
COLOR_TEXT_PRIMARY, COLOR_TEXT_SECONDARY,
|
||||
)
|
||||
from ..widgets import CollapsibleSection, SegmentButton
|
||||
|
||||
AI_TRACKING_MAP = {0: 2, 1: 0, 2: 1}
|
||||
|
||||
|
||||
class _RecordButton(QPushButton):
|
||||
"""Circular record button that toggles between ready and recording states."""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self._recording = False
|
||||
self.setFixedSize(60, 60)
|
||||
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.setStyleSheet("QPushButton { background: transparent; border: none; }")
|
||||
|
||||
@property
|
||||
def recording(self) -> bool:
|
||||
return self._recording
|
||||
|
||||
@recording.setter
|
||||
def recording(self, value: bool):
|
||||
self._recording = value
|
||||
self.update()
|
||||
|
||||
def paintEvent(self, event):
|
||||
p = QPainter(self)
|
||||
p.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
|
||||
p.setPen(Qt.PenStyle.NoPen)
|
||||
p.setBrush(QColor(COLOR_ACCENT))
|
||||
p.drawEllipse(2, 2, 56, 56)
|
||||
|
||||
p.setBrush(QColor(COLOR_TEXT_PRIMARY))
|
||||
|
||||
if self._recording:
|
||||
# White square (stop icon)
|
||||
p.drawRoundedRect(20, 20, 20, 20, 3, 3)
|
||||
else:
|
||||
# White circle (record icon)
|
||||
p.drawEllipse(17, 17, 26, 26)
|
||||
|
||||
p.end()
|
||||
|
||||
|
||||
class _RecordingSection(CollapsibleSection):
|
||||
"""Recording controls with record button, duration, and status."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("Recording", parent)
|
||||
|
||||
self._recording = False
|
||||
|
||||
btn_container = QWidget()
|
||||
btn_layout = QVBoxLayout(btn_container)
|
||||
btn_layout.setContentsMargins(0, 4, 0, 4)
|
||||
btn_layout.setSpacing(6)
|
||||
btn_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.record_btn = _RecordButton()
|
||||
self.record_btn.clicked.connect(self._toggle_recording)
|
||||
btn_layout.addWidget(self.record_btn, 0, Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.duration_label = QLabel("00:00:00")
|
||||
duration_font = QFont("monospace", 14)
|
||||
self.duration_label.setFont(duration_font)
|
||||
self.duration_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
btn_layout.addWidget(self.duration_label)
|
||||
|
||||
self.status_label = QLabel("Ready")
|
||||
self.status_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.status_label.setStyleSheet(f"color: {COLOR_TEXT_SECONDARY};")
|
||||
btn_layout.addWidget(self.status_label)
|
||||
|
||||
self.add_widget(btn_container)
|
||||
|
||||
def _toggle_recording(self):
|
||||
self._recording = not self._recording
|
||||
self.record_btn.recording = self._recording
|
||||
|
||||
if self._recording:
|
||||
self.status_label.setText("Recording")
|
||||
self.status_label.setStyleSheet(f"color: {COLOR_ACCENT};")
|
||||
self.param_changed.emit("recording-start", True)
|
||||
else:
|
||||
self.status_label.setText("Ready")
|
||||
self.status_label.setStyleSheet(f"color: {COLOR_TEXT_SECONDARY};")
|
||||
self.param_changed.emit("recording-stop", True)
|
||||
|
||||
def set_recording_state(self, recording: bool):
|
||||
self._recording = recording
|
||||
self.record_btn.recording = recording
|
||||
|
||||
if recording:
|
||||
self.status_label.setText("Recording")
|
||||
self.status_label.setStyleSheet(f"color: {COLOR_ACCENT};")
|
||||
else:
|
||||
self.status_label.setText("Ready")
|
||||
self.status_label.setStyleSheet(f"color: {COLOR_TEXT_SECONDARY};")
|
||||
self.duration_label.setText("00:00:00")
|
||||
|
||||
def set_recording_duration(self, seconds: int):
|
||||
h = seconds // 3600
|
||||
m = (seconds % 3600) // 60
|
||||
s = seconds % 60
|
||||
self.duration_label.setText(f"{h:02d}:{m:02d}:{s:02d}")
|
||||
|
||||
|
||||
class _AITrackingSection(CollapsibleSection):
|
||||
"""AI tracking mode selection."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("AI Tracking", parent)
|
||||
|
||||
self.mode_btn = SegmentButton(["Off", "Portrait", "Thing"])
|
||||
self.mode_btn.selection_changed.connect(self._mode_changed)
|
||||
self.add_widget(self._labeled("Mode", self.mode_btn))
|
||||
|
||||
def _mode_changed(self, index: int):
|
||||
self.param_changed.emit("ai-tracking", AI_TRACKING_MAP[index])
|
||||
|
||||
def set_ai_tracking_mode(self, wire_value: int):
|
||||
"""Set mode by wire protocol value (0=Portrait, 1=Thing, 2=Close)."""
|
||||
reverse_map = {2: 0, 0: 1, 1: 2}
|
||||
ui_index = reverse_map.get(wire_value, 0)
|
||||
self.mode_btn.set_selected(ui_index, emit=False)
|
||||
|
||||
@staticmethod
|
||||
def _labeled(text: str, widget: QWidget) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(110)
|
||||
layout.addWidget(lbl)
|
||||
layout.addWidget(widget)
|
||||
layout.addStretch()
|
||||
return row
|
||||
|
||||
|
||||
class _ZoomSection(CollapsibleSection):
|
||||
"""Zoom controls with +/- buttons and quick presets."""
|
||||
|
||||
ZOOM_MIN = 1.0
|
||||
ZOOM_MAX = 4.0
|
||||
ZOOM_STEP = 0.5
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("Zoom Controls", parent)
|
||||
|
||||
self._zoom = 1.0
|
||||
|
||||
self.zoom_display = QLabel("1.0x")
|
||||
display_font = QFont()
|
||||
display_font.setPointSize(18)
|
||||
display_font.setBold(True)
|
||||
self.zoom_display.setFont(display_font)
|
||||
self.zoom_display.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.add_widget(self.zoom_display)
|
||||
|
||||
step_row = QWidget()
|
||||
step_layout = QHBoxLayout(step_row)
|
||||
step_layout.setContentsMargins(0, 4, 0, 4)
|
||||
step_layout.setSpacing(8)
|
||||
step_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.zoom_minus = QPushButton("\u2212")
|
||||
self.zoom_minus.setFixedSize(40, 40)
|
||||
self.zoom_minus.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.zoom_minus.setStyleSheet(f"""
|
||||
QPushButton {{ font-size: 20px; font-weight: bold; background-color: {COLOR_BG_INPUT};
|
||||
border: 1px solid {COLOR_BORDER}; border-radius: 20px; }}
|
||||
QPushButton:hover {{ background-color: {COLOR_BORDER}; }}
|
||||
""")
|
||||
self.zoom_minus.clicked.connect(self._zoom_out)
|
||||
step_layout.addWidget(self.zoom_minus)
|
||||
|
||||
self.zoom_plus = QPushButton("+")
|
||||
self.zoom_plus.setFixedSize(40, 40)
|
||||
self.zoom_plus.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.zoom_plus.setStyleSheet(f"""
|
||||
QPushButton {{ font-size: 20px; font-weight: bold; background-color: {COLOR_BG_INPUT};
|
||||
border: 1px solid {COLOR_BORDER}; border-radius: 20px; }}
|
||||
QPushButton:hover {{ background-color: {COLOR_BORDER}; }}
|
||||
""")
|
||||
self.zoom_plus.clicked.connect(self._zoom_in)
|
||||
step_layout.addWidget(self.zoom_plus)
|
||||
|
||||
self.add_widget(step_row)
|
||||
|
||||
preset_row = QWidget()
|
||||
preset_layout = QHBoxLayout(preset_row)
|
||||
preset_layout.setContentsMargins(0, 2, 0, 2)
|
||||
preset_layout.setSpacing(6)
|
||||
|
||||
for zoom_val in [1.0, 2.0, 3.0, 4.0]:
|
||||
btn = QPushButton(f"{int(zoom_val)}x")
|
||||
btn.setFixedSize(48, 28)
|
||||
btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btn.clicked.connect(lambda checked, v=zoom_val: self._preset_clicked(v))
|
||||
preset_layout.addWidget(btn)
|
||||
|
||||
preset_layout.addStretch()
|
||||
self.add_widget(preset_row)
|
||||
|
||||
def _apply_zoom(self, value: float):
|
||||
self._zoom = max(self.ZOOM_MIN, min(self.ZOOM_MAX, round(value, 1)))
|
||||
self.zoom_display.setText(f"{self._zoom:.1f}x")
|
||||
self.param_changed.emit("zoom", self._zoom)
|
||||
|
||||
def _zoom_in(self):
|
||||
self._apply_zoom(self._zoom + self.ZOOM_STEP)
|
||||
|
||||
def _zoom_out(self):
|
||||
self._apply_zoom(self._zoom - self.ZOOM_STEP)
|
||||
|
||||
def _preset_clicked(self, value: float):
|
||||
self._apply_zoom(value)
|
||||
|
||||
def set_zoom(self, value: float):
|
||||
self._zoom = max(self.ZOOM_MIN, min(self.ZOOM_MAX, round(value, 1)))
|
||||
self.zoom_display.setText(f"{self._zoom:.1f}x")
|
||||
|
||||
|
||||
class ConsolePanel(QWidget):
|
||||
"""Panel with recording, AI tracking, and zoom controls."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setObjectName("consolePanel")
|
||||
self.setStyleSheet(f"#consolePanel {{ background-color: {COLOR_BG_PANEL}; }}")
|
||||
|
||||
outer = QVBoxLayout(self)
|
||||
outer.setContentsMargins(0, 0, 0, 0)
|
||||
outer.setSpacing(0)
|
||||
|
||||
header = QWidget()
|
||||
header.setFixedHeight(36)
|
||||
header_layout = QHBoxLayout(header)
|
||||
header_layout.setContentsMargins(12, 4, 12, 4)
|
||||
header_layout.setSpacing(8)
|
||||
title = QLabel("Console")
|
||||
title_font = QFont()
|
||||
title_font.setBold(True)
|
||||
title_font.setPointSize(11)
|
||||
title.setFont(title_font)
|
||||
header_layout.addWidget(title)
|
||||
header_layout.addStretch()
|
||||
outer.addWidget(header)
|
||||
|
||||
self.recording = _RecordingSection()
|
||||
self.ai_tracking = _AITrackingSection()
|
||||
self.zoom = _ZoomSection()
|
||||
|
||||
for section in [self.recording, self.ai_tracking, self.zoom]:
|
||||
section.param_changed.connect(self.param_changed.emit)
|
||||
outer.addWidget(section)
|
||||
|
||||
outer.addStretch()
|
||||
|
||||
def set_recording_state(self, recording: bool):
|
||||
self.recording.set_recording_state(recording)
|
||||
|
||||
def set_recording_duration(self, seconds: int):
|
||||
self.recording.set_recording_duration(seconds)
|
||||
|
||||
def set_zoom(self, value: float):
|
||||
self.zoom.set_zoom(value)
|
||||
|
||||
def set_ai_tracking_mode(self, wire_value: int):
|
||||
self.ai_tracking.set_ai_tracking_mode(wire_value)
|
||||
@@ -0,0 +1,182 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Exposure settings section with mode-dependent controls."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtWidgets import QWidget, QHBoxLayout, QLabel, QComboBox
|
||||
|
||||
from ..widgets import CollapsibleSection, SegmentButton, ParamSlider, ToggleSwitch
|
||||
|
||||
S3_ISO_VALUES = [
|
||||
100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1250,
|
||||
1600, 2000, 2500, 3200, 4000, 5000, 6400, 8000, 9600, 12800,
|
||||
]
|
||||
|
||||
SHUTTER_LABELS = [
|
||||
("1/25", 40000), ("1/30", 33333), ("1/50", 20000), ("1/60", 16666),
|
||||
("1/80", 12500), ("1/100", 10000), ("1/125", 8000), ("1/160", 6250),
|
||||
("1/200", 5000), ("1/250", 4000), ("1/320", 3125), ("1/400", 2500),
|
||||
("1/500", 2000), ("1/640", 1562), ("1/800", 1250), ("1/1000", 1000),
|
||||
("1/1250", 800), ("1/1600", 625), ("1/2000", 500), ("1/2500", 400),
|
||||
("1/3200", 312), ("1/4000", 250), ("1/5000", 200), ("1/6400", 156),
|
||||
("1/8000", 125),
|
||||
]
|
||||
|
||||
EV_LABELS = [
|
||||
"-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1",
|
||||
"0", "+1", "+2", "+3", "+4", "+5", "+6", "+7", "+8",
|
||||
]
|
||||
|
||||
|
||||
class ExposureSection(CollapsibleSection):
|
||||
"""Collapsible panel for exposure with auto/manual mode switching."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("Exposure", parent)
|
||||
|
||||
self.exposure_mode = SegmentButton(["Auto", "Manual"])
|
||||
self.exposure_mode.selection_changed.connect(self._mode_changed)
|
||||
self.add_widget(self._labeled("Mode", self.exposure_mode))
|
||||
|
||||
self.hdr_toggle = ToggleSwitch()
|
||||
self.hdr_toggle.toggled.connect(lambda v: self.param_changed.emit("hdr", v))
|
||||
self._hdr_row = self._toggle_row("HDR", self.hdr_toggle)
|
||||
self.add_widget(self._hdr_row)
|
||||
|
||||
self.anti_flicker = SegmentButton(["Close", "50Hz", "60Hz"])
|
||||
self.anti_flicker.selection_changed.connect(
|
||||
lambda idx: self.param_changed.emit("anti-flicker", idx)
|
||||
)
|
||||
self._anti_flicker_row = self._labeled("Anti-Flicker", self.anti_flicker)
|
||||
self.add_widget(self._anti_flicker_row)
|
||||
|
||||
self.ev_slider = ParamSlider("EV Comp", min_val=0, max_val=16, default=8, step=1)
|
||||
self.ev_slider.value_changed.connect(lambda v: self.param_changed.emit("exposure-ev", v))
|
||||
self.add_widget(self.ev_slider)
|
||||
|
||||
self.iso_combo = QComboBox()
|
||||
for iso in S3_ISO_VALUES:
|
||||
self.iso_combo.addItem(str(iso), iso)
|
||||
self.iso_combo.currentIndexChanged.connect(self._iso_changed)
|
||||
self._iso_row = self._labeled("ISO", self.iso_combo)
|
||||
self.add_widget(self._iso_row)
|
||||
|
||||
self.shutter_combo = QComboBox()
|
||||
for label, us in SHUTTER_LABELS:
|
||||
self.shutter_combo.addItem(label, us)
|
||||
self.shutter_combo.setCurrentIndex(3)
|
||||
self.shutter_combo.currentIndexChanged.connect(self._shutter_changed)
|
||||
self._shutter_row = self._labeled("Shutter", self.shutter_combo)
|
||||
self.add_widget(self._shutter_row)
|
||||
|
||||
self.exposure_lock_toggle = ToggleSwitch()
|
||||
self.exposure_lock_toggle.toggled.connect(
|
||||
lambda v: self.param_changed.emit("exposure-lock", v)
|
||||
)
|
||||
self._exp_lock_row = self._toggle_row("Exposure Lock", self.exposure_lock_toggle)
|
||||
self.add_widget(self._exp_lock_row)
|
||||
|
||||
self._apply_mode_visibility(auto=True)
|
||||
|
||||
@staticmethod
|
||||
def _labeled(text: str, widget: QWidget) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(110)
|
||||
layout.addWidget(lbl)
|
||||
layout.addWidget(widget)
|
||||
layout.addStretch()
|
||||
return row
|
||||
|
||||
@staticmethod
|
||||
def _toggle_row(text: str, toggle: ToggleSwitch) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(170)
|
||||
layout.addWidget(lbl)
|
||||
layout.addStretch()
|
||||
layout.addWidget(toggle)
|
||||
return row
|
||||
|
||||
def _mode_changed(self, index: int):
|
||||
auto = (index == 0)
|
||||
self.param_changed.emit("exposure-mode", index)
|
||||
self._apply_mode_visibility(auto)
|
||||
|
||||
def _apply_mode_visibility(self, auto: bool):
|
||||
self._anti_flicker_row.setVisible(auto)
|
||||
self.ev_slider.setVisible(auto)
|
||||
self._exp_lock_row.setVisible(auto)
|
||||
self._iso_row.setVisible(not auto)
|
||||
self._shutter_row.setVisible(not auto)
|
||||
|
||||
def _iso_changed(self, index: int):
|
||||
if index >= 0:
|
||||
iso_val = self.iso_combo.itemData(index)
|
||||
self.param_changed.emit("exposure-iso", iso_val)
|
||||
|
||||
def _shutter_changed(self, index: int):
|
||||
if index >= 0:
|
||||
us_val = self.shutter_combo.itemData(index)
|
||||
self.param_changed.emit("exposure-time", us_val)
|
||||
|
||||
def set_exposure_mode(self, value: int):
|
||||
self.exposure_mode.set_selected(value, emit=False)
|
||||
self._apply_mode_visibility(value == 0)
|
||||
|
||||
def set_hdr(self, enabled: bool):
|
||||
self.hdr_toggle.set_checked(enabled, emit=False)
|
||||
|
||||
def set_anti_flicker(self, value: int):
|
||||
self.anti_flicker.set_selected(value, emit=False)
|
||||
|
||||
def set_ev(self, raw: int):
|
||||
self.ev_slider.set_value(float(raw), emit=False)
|
||||
|
||||
def set_iso(self, value: int):
|
||||
"""Set ISO by raw protocol value."""
|
||||
self.iso_combo.blockSignals(True)
|
||||
|
||||
for i in range(self.iso_combo.count()):
|
||||
|
||||
if self.iso_combo.itemData(i) == value:
|
||||
self.iso_combo.setCurrentIndex(i)
|
||||
break
|
||||
|
||||
self.iso_combo.blockSignals(False)
|
||||
|
||||
def set_shutter(self, us: int):
|
||||
"""Set shutter by microsecond value."""
|
||||
self.shutter_combo.blockSignals(True)
|
||||
|
||||
for i in range(self.shutter_combo.count()):
|
||||
|
||||
if self.shutter_combo.itemData(i) == us:
|
||||
self.shutter_combo.setCurrentIndex(i)
|
||||
break
|
||||
|
||||
self.shutter_combo.blockSignals(False)
|
||||
|
||||
def set_exposure_lock(self, enabled: bool):
|
||||
self.exposure_lock_toggle.set_checked(enabled, emit=False)
|
||||
@@ -0,0 +1,134 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Focus settings section."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtWidgets import QWidget, QHBoxLayout, QLabel, QComboBox
|
||||
|
||||
from ..widgets import CollapsibleSection, SegmentButton, ToggleSwitch, ParamSlider
|
||||
|
||||
|
||||
class FocusSection(CollapsibleSection):
|
||||
"""Collapsible panel for focus settings with mode-dependent controls."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
MODES = ["AF-S", "Manual", "AF-C", "Face"]
|
||||
MODE_VALUES = {"AF-S": 1, "Manual": 2, "AF-C": 3, "Face": 4}
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("Focus", parent)
|
||||
|
||||
self.focus_mode = SegmentButton(self.MODES)
|
||||
self.focus_mode.set_selected(2, emit=False)
|
||||
self.focus_mode.selection_changed_text.connect(self._mode_changed)
|
||||
self.add_widget(self._labeled("Mode", self.focus_mode))
|
||||
|
||||
self.focus_area_combo = QComboBox()
|
||||
self.focus_area_combo.addItems(["Large", "Middle", "Small"])
|
||||
self.focus_area_combo.currentIndexChanged.connect(
|
||||
lambda idx: self.param_changed.emit("focus-level", idx)
|
||||
)
|
||||
self._focus_area_row = self._labeled("Focus Area", self.focus_area_combo)
|
||||
self.add_widget(self._focus_area_row)
|
||||
|
||||
self.manual_focus = ParamSlider("Manual Focus", min_val=0, max_val=100, default=50, step=1)
|
||||
self.manual_focus.value_changed.connect(
|
||||
lambda v: self.param_changed.emit("focus-manual", v)
|
||||
)
|
||||
self._manual_focus_row = self.manual_focus
|
||||
self.add_widget(self._manual_focus_row)
|
||||
|
||||
self.focus_power_toggle = ToggleSwitch(checked=True)
|
||||
self.focus_power_toggle.toggled.connect(
|
||||
lambda v: self.param_changed.emit("focus-caf", v)
|
||||
)
|
||||
self._focus_power_row = self._toggle_row("Focus Power", self.focus_power_toggle)
|
||||
self.add_widget(self._focus_power_row)
|
||||
|
||||
self.focus_speed = SegmentButton(["Basic", "Quick"])
|
||||
self.focus_speed.selection_changed.connect(
|
||||
lambda idx: self.param_changed.emit("focus-trigger", idx)
|
||||
)
|
||||
self._focus_speed_row = self._labeled("Speed", self.focus_speed)
|
||||
self.add_widget(self._focus_speed_row)
|
||||
|
||||
self._apply_mode_visibility("AF-C")
|
||||
|
||||
@staticmethod
|
||||
def _labeled(text: str, widget: QWidget, stretch: bool = False) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(110)
|
||||
layout.addWidget(lbl)
|
||||
|
||||
if stretch:
|
||||
layout.addStretch()
|
||||
|
||||
layout.addWidget(widget)
|
||||
|
||||
if not stretch:
|
||||
layout.addStretch()
|
||||
|
||||
return row
|
||||
|
||||
@staticmethod
|
||||
def _toggle_row(text: str, toggle: ToggleSwitch) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(170)
|
||||
layout.addWidget(lbl)
|
||||
layout.addStretch()
|
||||
layout.addWidget(toggle)
|
||||
return row
|
||||
|
||||
def _mode_changed(self, mode_text: str):
|
||||
value = self.MODE_VALUES.get(mode_text, 3)
|
||||
self.param_changed.emit("focus-mode", value)
|
||||
self._apply_mode_visibility(mode_text)
|
||||
|
||||
def _apply_mode_visibility(self, mode_text: str):
|
||||
self._focus_area_row.setVisible(mode_text in ("AF-S", "AF-C"))
|
||||
self._manual_focus_row.setVisible(mode_text == "Manual")
|
||||
self._focus_power_row.setVisible(mode_text in ("AF-C", "Face"))
|
||||
self._focus_speed_row.setVisible(mode_text == "AF-C")
|
||||
|
||||
def set_focus_mode(self, value: int):
|
||||
"""Set focus mode by raw protocol value (1=AFS, 2=Manual, 3=AFC, 4=Face)."""
|
||||
value_to_index = {1: 0, 2: 1, 3: 2, 4: 3}
|
||||
idx = value_to_index.get(value, 2)
|
||||
self.focus_mode.set_selected(idx, emit=False)
|
||||
self._apply_mode_visibility(self.MODES[idx])
|
||||
|
||||
def set_focus_area(self, value: int):
|
||||
self.focus_area_combo.blockSignals(True)
|
||||
self.focus_area_combo.setCurrentIndex(value)
|
||||
self.focus_area_combo.blockSignals(False)
|
||||
|
||||
def set_focus_power(self, enabled: bool):
|
||||
self.focus_power_toggle.set_checked(enabled, emit=False)
|
||||
|
||||
def set_focus_speed(self, value: int):
|
||||
self.focus_speed.set_selected(value, emit=False)
|
||||
|
||||
def set_manual_focus(self, value: int):
|
||||
self.manual_focus.set_value(float(value), emit=False)
|
||||
@@ -0,0 +1,78 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Graphics settings section (frame rate, lens shading)."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtWidgets import QWidget, QHBoxLayout, QLabel, QComboBox
|
||||
|
||||
from ..widgets import CollapsibleSection, ToggleSwitch
|
||||
|
||||
|
||||
class GraphicsSection(CollapsibleSection):
|
||||
"""Collapsible panel for graphics/output settings."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("Graphics Settings", parent)
|
||||
|
||||
self.framerate_combo = QComboBox()
|
||||
self.framerate_combo.addItems(["25", "30", "50", "60"])
|
||||
self.framerate_combo.setCurrentText("30")
|
||||
self.framerate_combo.currentTextChanged.connect(
|
||||
lambda v: self.param_changed.emit("frame-rate", int(v))
|
||||
)
|
||||
self.add_widget(self._labeled("Frame Rate", self.framerate_combo))
|
||||
|
||||
self.shading_toggle = ToggleSwitch(checked=True)
|
||||
self.shading_toggle.toggled.connect(
|
||||
lambda v: self.param_changed.emit("shading", v)
|
||||
)
|
||||
self.add_widget(self._toggle_row("Lens Shading", self.shading_toggle))
|
||||
|
||||
@staticmethod
|
||||
def _labeled(text: str, widget: QWidget) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(110)
|
||||
layout.addWidget(lbl)
|
||||
layout.addWidget(widget)
|
||||
layout.addStretch()
|
||||
return row
|
||||
|
||||
@staticmethod
|
||||
def _toggle_row(text: str, toggle: ToggleSwitch) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(170)
|
||||
layout.addWidget(lbl)
|
||||
layout.addStretch()
|
||||
layout.addWidget(toggle)
|
||||
return row
|
||||
|
||||
def set_frame_rate(self, value: int):
|
||||
self.framerate_combo.blockSignals(True)
|
||||
self.framerate_combo.setCurrentText(str(value))
|
||||
self.framerate_combo.blockSignals(False)
|
||||
|
||||
def set_shading(self, enabled: bool):
|
||||
self.shading_toggle.set_checked(enabled, emit=False)
|
||||
@@ -0,0 +1,108 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Image parameters panel that contains all collapsible settings sections."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QComboBox, QSizePolicy,
|
||||
)
|
||||
from PySide6.QtGui import QFont
|
||||
|
||||
from ..theme import COLOR_ACCENT, COLOR_BG_PANEL, COLOR_BORDER, COLOR_TEXT_SECONDARY
|
||||
from ..widgets import PresetBar
|
||||
from .graphics_section import GraphicsSection
|
||||
from .image_section import ImageSection
|
||||
from .focus_section import FocusSection
|
||||
from .zoom_section import ZoomSection
|
||||
from .exposure_section import ExposureSection
|
||||
from .white_balance_section import WhiteBalanceSection
|
||||
from .audio_section import AudioSection
|
||||
|
||||
|
||||
class ImageParamsPanel(QWidget):
|
||||
"""Scrollable panel containing all camera parameter sections."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
save_scene_requested = Signal()
|
||||
refresh_requested = Signal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setObjectName("imageParamsPanel")
|
||||
self.setStyleSheet(f"#imageParamsPanel {{ background-color: {COLOR_BG_PANEL}; }}")
|
||||
outer = QVBoxLayout(self)
|
||||
outer.setContentsMargins(0, 0, 0, 0)
|
||||
outer.setSpacing(0)
|
||||
top_bar = QWidget()
|
||||
top_bar.setFixedHeight(44)
|
||||
top_layout = QHBoxLayout(top_bar)
|
||||
top_layout.setContentsMargins(12, 6, 12, 6)
|
||||
top_layout.setSpacing(8)
|
||||
self.camera_combo = QComboBox()
|
||||
self.camera_combo.addItem("Y-CAM (disconnected)")
|
||||
self.camera_combo.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
|
||||
top_layout.addWidget(self.camera_combo)
|
||||
self.capture_btn = QPushButton()
|
||||
self.capture_btn.setText("\u25cf")
|
||||
self.capture_btn.setFixedSize(32, 32)
|
||||
self.capture_btn.setStyleSheet(f"""
|
||||
QPushButton {{ background-color: {COLOR_ACCENT}; color: white; border: none;
|
||||
border-radius: 16px; font-size: 18px; }}
|
||||
QPushButton:hover {{ background-color: #f02574; }}
|
||||
""")
|
||||
top_layout.addWidget(self.capture_btn)
|
||||
outer.addWidget(top_bar)
|
||||
header = QWidget()
|
||||
header.setFixedHeight(36)
|
||||
header_layout = QHBoxLayout(header)
|
||||
header_layout.setContentsMargins(12, 4, 12, 4)
|
||||
header_layout.setSpacing(8)
|
||||
title = QLabel("Image Parameters")
|
||||
title_font = QFont()
|
||||
title_font.setBold(True)
|
||||
title_font.setPointSize(11)
|
||||
title.setFont(title_font)
|
||||
header_layout.addWidget(title)
|
||||
header_layout.addStretch()
|
||||
self.refresh_btn = QPushButton("\u21bb")
|
||||
self.refresh_btn.setFixedSize(28, 28)
|
||||
self.refresh_btn.setToolTip("Refresh parameters from camera")
|
||||
self.refresh_btn.setStyleSheet(f"""
|
||||
QPushButton {{ background: transparent; color: {COLOR_TEXT_SECONDARY}; border: none; font-size: 16px; }}
|
||||
QPushButton:hover {{ color: white; }}
|
||||
""")
|
||||
self.refresh_btn.clicked.connect(self.refresh_requested.emit)
|
||||
header_layout.addWidget(self.refresh_btn)
|
||||
self.save_scene_btn = QPushButton("Save Scene")
|
||||
self.save_scene_btn.setProperty("accent", True)
|
||||
self.save_scene_btn.setFixedHeight(28)
|
||||
self.save_scene_btn.clicked.connect(self.save_scene_requested.emit)
|
||||
header_layout.addWidget(self.save_scene_btn)
|
||||
outer.addWidget(header)
|
||||
self.preset_bar = PresetBar()
|
||||
outer.addWidget(self.preset_bar)
|
||||
self.graphics = GraphicsSection()
|
||||
self.image = ImageSection()
|
||||
self.focus = FocusSection()
|
||||
self.zoom = ZoomSection()
|
||||
self.exposure = ExposureSection()
|
||||
self.white_balance = WhiteBalanceSection()
|
||||
self.audio = AudioSection()
|
||||
for section in [self.graphics, self.image, self.focus, self.zoom,
|
||||
self.exposure, self.white_balance, self.audio]:
|
||||
section.param_changed.connect(self.param_changed.emit)
|
||||
outer.addWidget(section)
|
||||
outer.addStretch()
|
||||
@@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Image settings section (sharpness, contrast, saturation, dynamic range)."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
|
||||
from ..widgets import CollapsibleSection, ParamSlider
|
||||
|
||||
|
||||
class ImageSection(CollapsibleSection):
|
||||
"""Collapsible panel for image quality settings."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("Image Settings", parent)
|
||||
|
||||
self.sharpness = ParamSlider("Sharpness", min_val=-10, max_val=30, default=5, step=1)
|
||||
self.sharpness.value_changed.connect(lambda v: self.param_changed.emit("sharpness", v))
|
||||
self.add_widget(self.sharpness)
|
||||
|
||||
self.contrast = ParamSlider("Contrast", min_val=0, max_val=100, default=50, step=1)
|
||||
self.contrast.value_changed.connect(lambda v: self.param_changed.emit("contrast", v))
|
||||
self.add_widget(self.contrast)
|
||||
|
||||
self.saturation = ParamSlider("Saturation", min_val=0, max_val=100, default=50, step=1)
|
||||
self.saturation.value_changed.connect(lambda v: self.param_changed.emit("saturation", v))
|
||||
self.add_widget(self.saturation)
|
||||
|
||||
self.dynamic_range = ParamSlider("Dynamic Range", min_val=0, max_val=100, default=50, step=1)
|
||||
self.dynamic_range.value_changed.connect(lambda v: self.param_changed.emit("dynamic-range", v))
|
||||
self.add_widget(self.dynamic_range)
|
||||
|
||||
def set_sharpness(self, value: int):
|
||||
self.sharpness.set_value(float(value), emit=False)
|
||||
|
||||
def set_contrast(self, value: int):
|
||||
self.contrast.set_value(float(value), emit=False)
|
||||
|
||||
def set_saturation(self, value: int):
|
||||
self.saturation.set_value(float(value), emit=False)
|
||||
|
||||
def set_dynamic_range(self, value: int):
|
||||
self.dynamic_range.set_value(float(value), emit=False)
|
||||
@@ -0,0 +1,159 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Settings panel with device info and SD card management."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QMessageBox
|
||||
from PySide6.QtGui import QFont
|
||||
|
||||
from ..theme import COLOR_BG_PANEL, COLOR_TEXT_SECONDARY
|
||||
from ..widgets import CollapsibleSection
|
||||
|
||||
|
||||
class _DeviceInfoSection(CollapsibleSection):
|
||||
"""Read-only device information display."""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("Device Info", parent)
|
||||
|
||||
self.firmware_label = QLabel("--")
|
||||
self.add_widget(self._info_row("Firmware", self.firmware_label))
|
||||
|
||||
self.serial_label = QLabel("--")
|
||||
self.add_widget(self._info_row("Serial Number", self.serial_label))
|
||||
|
||||
self.lens_label = QLabel("--")
|
||||
self.add_widget(self._info_row("Lens Info", self.lens_label))
|
||||
|
||||
def set_firmware_info(self, text: str):
|
||||
self.firmware_label.setText(text)
|
||||
|
||||
def set_serial(self, text: str):
|
||||
self.serial_label.setText(text)
|
||||
|
||||
def set_lens_info(self, text: str):
|
||||
self.lens_label.setText(text)
|
||||
|
||||
@staticmethod
|
||||
def _info_row(label_text: str, value_label: QLabel) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(label_text)
|
||||
lbl.setFixedWidth(110)
|
||||
lbl.setStyleSheet(f"color: {COLOR_TEXT_SECONDARY};")
|
||||
layout.addWidget(lbl)
|
||||
layout.addWidget(value_label)
|
||||
layout.addStretch()
|
||||
return row
|
||||
|
||||
|
||||
class _SDCardSection(CollapsibleSection):
|
||||
"""SD card storage info and format action."""
|
||||
|
||||
format_sd_requested = Signal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("SD Card", parent)
|
||||
|
||||
self.storage_label = QLabel("-- / -- MB")
|
||||
self.add_widget(self._info_row("Storage", self.storage_label))
|
||||
|
||||
self.format_btn = QPushButton("Format SD Card")
|
||||
self.format_btn.setProperty("accent", True)
|
||||
self.format_btn.setFixedHeight(32)
|
||||
self.format_btn.clicked.connect(self._confirm_format)
|
||||
self.add_widget(self.format_btn)
|
||||
|
||||
def _confirm_format(self):
|
||||
result = QMessageBox.warning(
|
||||
self, "Format SD Card",
|
||||
"All data on the SD card will be erased. Continue?",
|
||||
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
|
||||
QMessageBox.StandardButton.No,
|
||||
)
|
||||
|
||||
if result == QMessageBox.StandardButton.Yes:
|
||||
self.format_sd_requested.emit()
|
||||
|
||||
def set_disk_info(self, available: int, total: int):
|
||||
self.storage_label.setText(f"{available} / {total} MB")
|
||||
|
||||
@staticmethod
|
||||
def _info_row(label_text: str, value_label: QLabel) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(label_text)
|
||||
lbl.setFixedWidth(110)
|
||||
lbl.setStyleSheet(f"color: {COLOR_TEXT_SECONDARY};")
|
||||
layout.addWidget(lbl)
|
||||
layout.addWidget(value_label)
|
||||
layout.addStretch()
|
||||
return row
|
||||
|
||||
|
||||
class SettingsPanel(QWidget):
|
||||
"""Panel with device information and SD card management."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
format_sd_requested = Signal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setObjectName("settingsPanel")
|
||||
self.setStyleSheet(f"#settingsPanel {{ background-color: {COLOR_BG_PANEL}; }}")
|
||||
|
||||
outer = QVBoxLayout(self)
|
||||
outer.setContentsMargins(0, 0, 0, 0)
|
||||
outer.setSpacing(0)
|
||||
|
||||
header = QWidget()
|
||||
header.setFixedHeight(36)
|
||||
header_layout = QHBoxLayout(header)
|
||||
header_layout.setContentsMargins(12, 4, 12, 4)
|
||||
header_layout.setSpacing(8)
|
||||
title = QLabel("Settings")
|
||||
title_font = QFont()
|
||||
title_font.setBold(True)
|
||||
title_font.setPointSize(11)
|
||||
title.setFont(title_font)
|
||||
header_layout.addWidget(title)
|
||||
header_layout.addStretch()
|
||||
outer.addWidget(header)
|
||||
|
||||
self.device_info = _DeviceInfoSection()
|
||||
outer.addWidget(self.device_info)
|
||||
|
||||
self.sd_card = _SDCardSection()
|
||||
self.sd_card.format_sd_requested.connect(self.format_sd_requested.emit)
|
||||
outer.addWidget(self.sd_card)
|
||||
|
||||
outer.addStretch()
|
||||
|
||||
def set_firmware_info(self, text: str):
|
||||
self.device_info.set_firmware_info(text)
|
||||
|
||||
def set_serial(self, text: str):
|
||||
self.device_info.set_serial(text)
|
||||
|
||||
def set_lens_info(self, text: str):
|
||||
self.device_info.set_lens_info(text)
|
||||
|
||||
def set_disk_info(self, available: int, total: int):
|
||||
self.sd_card.set_disk_info(available, total)
|
||||
@@ -0,0 +1,165 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Stream output panel with HDMI and UVC settings."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QComboBox
|
||||
from PySide6.QtGui import QFont
|
||||
|
||||
from ..theme import COLOR_BG_PANEL
|
||||
from ..widgets import CollapsibleSection, ToggleSwitch
|
||||
|
||||
|
||||
class _HDMISection(CollapsibleSection):
|
||||
"""HDMI output format and color space settings."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("HDMI Output", parent)
|
||||
|
||||
self.format_combo = QComboBox()
|
||||
for label, data in [("Auto", 0), ("4K", 1), ("1080p", 2), ("720p", 3)]:
|
||||
self.format_combo.addItem(label, data)
|
||||
|
||||
self.format_combo.currentIndexChanged.connect(self._format_changed)
|
||||
self.add_widget(self._labeled("Format", self.format_combo))
|
||||
|
||||
self.color_combo = QComboBox()
|
||||
for label, data in [("Auto", 0), ("RGB", 1), ("YUV422", 2)]:
|
||||
self.color_combo.addItem(label, data)
|
||||
|
||||
self.color_combo.currentIndexChanged.connect(self._color_changed)
|
||||
self.add_widget(self._labeled("Color Space", self.color_combo))
|
||||
|
||||
def _format_changed(self, index: int):
|
||||
if index >= 0:
|
||||
self.param_changed.emit("hdmi-format", self.format_combo.itemData(index))
|
||||
|
||||
def _color_changed(self, index: int):
|
||||
if index >= 0:
|
||||
self.param_changed.emit("hdmi-color", self.color_combo.itemData(index))
|
||||
|
||||
def set_hdmi_format(self, value: int):
|
||||
self.format_combo.blockSignals(True)
|
||||
|
||||
for i in range(self.format_combo.count()):
|
||||
|
||||
if self.format_combo.itemData(i) == value:
|
||||
self.format_combo.setCurrentIndex(i)
|
||||
break
|
||||
|
||||
self.format_combo.blockSignals(False)
|
||||
|
||||
def set_hdmi_color(self, value: int):
|
||||
self.color_combo.blockSignals(True)
|
||||
|
||||
for i in range(self.color_combo.count()):
|
||||
|
||||
if self.color_combo.itemData(i) == value:
|
||||
self.color_combo.setCurrentIndex(i)
|
||||
break
|
||||
|
||||
self.color_combo.blockSignals(False)
|
||||
|
||||
@staticmethod
|
||||
def _labeled(text: str, widget: QWidget) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(110)
|
||||
layout.addWidget(lbl)
|
||||
layout.addWidget(widget)
|
||||
layout.addStretch()
|
||||
return row
|
||||
|
||||
|
||||
class _UVCSection(CollapsibleSection):
|
||||
"""UVC output enable/disable toggle."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("UVC Output", parent)
|
||||
|
||||
self.uvc_toggle = ToggleSwitch()
|
||||
self.uvc_toggle.toggled.connect(lambda v: self.param_changed.emit("uvc", v))
|
||||
self.add_widget(self._toggle_row("Enable", self.uvc_toggle))
|
||||
|
||||
def set_uvc_enabled(self, enabled: bool):
|
||||
self.uvc_toggle.set_checked(enabled, emit=False)
|
||||
|
||||
@staticmethod
|
||||
def _toggle_row(text: str, toggle: ToggleSwitch) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(170)
|
||||
layout.addWidget(lbl)
|
||||
layout.addStretch()
|
||||
layout.addWidget(toggle)
|
||||
return row
|
||||
|
||||
|
||||
class StreamPanel(QWidget):
|
||||
"""Panel with HDMI and UVC output settings."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setObjectName("streamPanel")
|
||||
self.setStyleSheet(f"#streamPanel {{ background-color: {COLOR_BG_PANEL}; }}")
|
||||
|
||||
outer = QVBoxLayout(self)
|
||||
outer.setContentsMargins(0, 0, 0, 0)
|
||||
outer.setSpacing(0)
|
||||
|
||||
header = QWidget()
|
||||
header.setFixedHeight(36)
|
||||
header_layout = QHBoxLayout(header)
|
||||
header_layout.setContentsMargins(12, 4, 12, 4)
|
||||
header_layout.setSpacing(8)
|
||||
title = QLabel("Stream")
|
||||
title_font = QFont()
|
||||
title_font.setBold(True)
|
||||
title_font.setPointSize(11)
|
||||
title.setFont(title_font)
|
||||
header_layout.addWidget(title)
|
||||
header_layout.addStretch()
|
||||
outer.addWidget(header)
|
||||
|
||||
self.hdmi = _HDMISection()
|
||||
self.uvc = _UVCSection()
|
||||
|
||||
for section in [self.hdmi, self.uvc]:
|
||||
section.param_changed.connect(self.param_changed.emit)
|
||||
outer.addWidget(section)
|
||||
|
||||
outer.addStretch()
|
||||
|
||||
def set_hdmi_format(self, value: int):
|
||||
self.hdmi.set_hdmi_format(value)
|
||||
|
||||
def set_hdmi_color(self, value: int):
|
||||
self.hdmi.set_hdmi_color(value)
|
||||
|
||||
def set_uvc_enabled(self, enabled: bool):
|
||||
self.uvc.set_uvc_enabled(enabled)
|
||||
@@ -0,0 +1,158 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""White balance settings section with mode-dependent controls."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtGui import QFont
|
||||
from PySide6.QtWidgets import QWidget, QHBoxLayout, QLabel, QToolButton
|
||||
|
||||
from ..widgets import CollapsibleSection, SegmentButton, ParamSlider, ToggleSwitch
|
||||
|
||||
|
||||
class WhiteBalanceSection(CollapsibleSection):
|
||||
"""Collapsible panel for white balance with auto/manual mode switching."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
eyedropper_requested = Signal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("White Balance", parent)
|
||||
|
||||
self.wb_mode = SegmentButton(["Auto", "Manual"])
|
||||
self.wb_mode.selection_changed_text.connect(self._mode_changed)
|
||||
|
||||
self._eyedropper_btn = QToolButton()
|
||||
self._eyedropper_btn.setText("\u2316")
|
||||
self._eyedropper_btn.setToolTip("Pick White Balance from Video")
|
||||
self._eyedropper_btn.setCheckable(True)
|
||||
btn_font = QFont()
|
||||
btn_font.setPointSize(14)
|
||||
self._eyedropper_btn.setFont(btn_font)
|
||||
self._eyedropper_btn.setFixedSize(28, 28)
|
||||
self._eyedropper_btn.toggled.connect(self._on_eyedropper_toggled)
|
||||
|
||||
mode_row = self._labeled("Mode", self.wb_mode)
|
||||
mode_row.layout().addWidget(self._eyedropper_btn)
|
||||
self.add_widget(mode_row)
|
||||
|
||||
self.wb_lock_toggle = ToggleSwitch()
|
||||
self.wb_lock_toggle.toggled.connect(lambda v: self.param_changed.emit("wb-lock", v))
|
||||
self._lock_row = self._toggle_row("WB Lock", self.wb_lock_toggle)
|
||||
self.add_widget(self._lock_row)
|
||||
|
||||
self.temperature_slider = ParamSlider(
|
||||
"Temperature", min_val=2000, max_val=10000, default=5000, step=50, suffix="K"
|
||||
)
|
||||
self.temperature_slider.value_changed.connect(
|
||||
lambda v: self.param_changed.emit("wb-temp", v)
|
||||
)
|
||||
self.add_widget(self.temperature_slider)
|
||||
|
||||
self.temp_shift_slider = ParamSlider(
|
||||
"Temp Shift", min_val=0, max_val=128, default=64, step=1
|
||||
)
|
||||
self.temp_shift_slider.value_changed.connect(
|
||||
lambda v: self.param_changed.emit("wb-temp-shift", v)
|
||||
)
|
||||
self.add_widget(self.temp_shift_slider)
|
||||
|
||||
self.blue_offset_slider = ParamSlider(
|
||||
"Blue Offset", min_val=0, max_val=20, default=10, step=1
|
||||
)
|
||||
self.blue_offset_slider.value_changed.connect(
|
||||
lambda v: self.param_changed.emit("wb-blue-offset", v)
|
||||
)
|
||||
self.add_widget(self.blue_offset_slider)
|
||||
|
||||
self.red_offset_slider = ParamSlider(
|
||||
"Red Offset", min_val=0, max_val=20, default=10, step=1
|
||||
)
|
||||
self.red_offset_slider.value_changed.connect(
|
||||
lambda v: self.param_changed.emit("wb-red-offset", v)
|
||||
)
|
||||
self.add_widget(self.red_offset_slider)
|
||||
|
||||
self._apply_mode_visibility(auto=True)
|
||||
|
||||
@staticmethod
|
||||
def _labeled(text: str, widget: QWidget) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(110)
|
||||
layout.addWidget(lbl)
|
||||
layout.addWidget(widget)
|
||||
layout.addStretch()
|
||||
return row
|
||||
|
||||
@staticmethod
|
||||
def _toggle_row(text: str, toggle: ToggleSwitch) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(170)
|
||||
layout.addWidget(lbl)
|
||||
layout.addStretch()
|
||||
layout.addWidget(toggle)
|
||||
return row
|
||||
|
||||
def _mode_changed(self, mode: str):
|
||||
auto = (mode == "Auto")
|
||||
value = 1 if auto else 0
|
||||
self.param_changed.emit("wb-mode", value)
|
||||
self._apply_mode_visibility(auto)
|
||||
|
||||
def _apply_mode_visibility(self, auto: bool):
|
||||
self._lock_row.setVisible(auto)
|
||||
self.temperature_slider.setVisible(not auto)
|
||||
self.temp_shift_slider.setVisible(not auto)
|
||||
self.blue_offset_slider.setVisible(not auto)
|
||||
self.red_offset_slider.setVisible(not auto)
|
||||
|
||||
def _on_eyedropper_toggled(self, checked: bool):
|
||||
if checked:
|
||||
self.eyedropper_requested.emit()
|
||||
|
||||
def set_eyedropper_active(self, active: bool):
|
||||
"""Set the eyedropper button check state without emitting signals."""
|
||||
self._eyedropper_btn.blockSignals(True)
|
||||
self._eyedropper_btn.setChecked(active)
|
||||
self._eyedropper_btn.blockSignals(False)
|
||||
|
||||
def set_wb_mode(self, value: int):
|
||||
"""Set WB mode by raw value (0=Manual, 1=Auto)."""
|
||||
idx = 0 if value == 1 else 1
|
||||
self.wb_mode.set_selected(idx, emit=False)
|
||||
self._apply_mode_visibility(value == 1)
|
||||
|
||||
def set_wb_lock(self, enabled: bool):
|
||||
self.wb_lock_toggle.set_checked(enabled, emit=False)
|
||||
|
||||
def set_temperature(self, value: int):
|
||||
self.temperature_slider.set_value(float(value), emit=False)
|
||||
|
||||
def set_temp_shift(self, value: int):
|
||||
self.temp_shift_slider.set_value(float(value), emit=False)
|
||||
|
||||
def set_blue_offset(self, value: int):
|
||||
self.blue_offset_slider.set_value(float(value), emit=False)
|
||||
|
||||
def set_red_offset(self, value: int):
|
||||
self.red_offset_slider.set_value(float(value), emit=False)
|
||||
@@ -0,0 +1,38 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Zoom settings section."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
|
||||
from ..widgets import CollapsibleSection, ParamSlider
|
||||
|
||||
|
||||
class ZoomSection(CollapsibleSection):
|
||||
"""Collapsible panel for zoom control."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("Zoom", parent)
|
||||
|
||||
self.zoom_slider = ParamSlider(
|
||||
"Zoom", min_val=1.0, max_val=4.0, default=1.0, step=0.1, decimals=1, suffix="x"
|
||||
)
|
||||
self.zoom_slider.value_changed.connect(lambda v: self.param_changed.emit("zoom", v))
|
||||
self.add_widget(self.zoom_slider)
|
||||
|
||||
def set_zoom(self, mult: float):
|
||||
self.zoom_slider.set_value(mult, emit=False)
|
||||
Reference in New Issue
Block a user