Initial commit
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user