feat: add view settings dialog with adjustable parameters and navigation controls
This commit is contained in:
19
ui/icons/arrow-left-335-svgrepo-com.svg
Normal file
19
ui/icons/arrow-left-335-svgrepo-com.svg
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="-4.5 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<title>arrow_left [#335]</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
|
||||
</defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Dribbble-Light-Preview" transform="translate(-345.000000, -6679.000000)" fill="#000000">
|
||||
<g id="icons" transform="translate(56.000000, 160.000000)">
|
||||
<path d="M299.633777,6519.29231 L299.633777,6519.29231 C299.228878,6518.90256 298.573377,6518.90256 298.169513,6519.29231 L289.606572,6527.55587 C288.797809,6528.33636 288.797809,6529.60253 289.606572,6530.38301 L298.231646,6538.70754 C298.632403,6539.09329 299.27962,6539.09828 299.685554,6538.71753 L299.685554,6538.71753 C300.100809,6538.32879 300.104951,6537.68821 299.696945,6537.29347 L291.802968,6529.67648 C291.398069,6529.28574 291.398069,6528.65315 291.802968,6528.26241 L299.633777,6520.70538 C300.038676,6520.31563 300.038676,6519.68305 299.633777,6519.29231" id="arrow_left-[#335]">
|
||||
|
||||
</path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
19
ui/icons/arrow-right-336-svgrepo-com.svg
Normal file
19
ui/icons/arrow-right-336-svgrepo-com.svg
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="-4.5 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<title>arrow_right [#336]</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
|
||||
</defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Dribbble-Light-Preview" transform="translate(-305.000000, -6679.000000)" fill="#000000">
|
||||
<g id="icons" transform="translate(56.000000, 160.000000)">
|
||||
<path d="M249.365851,6538.70769 L249.365851,6538.70769 C249.770764,6539.09744 250.426289,6539.09744 250.830166,6538.70769 L259.393407,6530.44413 C260.202198,6529.66364 260.202198,6528.39747 259.393407,6527.61699 L250.768031,6519.29246 C250.367261,6518.90671 249.720021,6518.90172 249.314072,6519.28247 L249.314072,6519.28247 C248.899839,6519.67121 248.894661,6520.31179 249.302681,6520.70653 L257.196934,6528.32352 C257.601847,6528.71426 257.601847,6529.34685 257.196934,6529.73759 L249.365851,6537.29462 C248.960938,6537.68437 248.960938,6538.31795 249.365851,6538.70769" id="arrow_right-[#336]">
|
||||
|
||||
</path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
@@ -44,7 +44,8 @@ class MainWindow(QMainWindow):
|
||||
histogram_view.setFixedHeight(200)
|
||||
|
||||
self.view_settings_button = QPushButton("Ustawienia widoku")
|
||||
control_layout.addWidget(self.view_settings_button)
|
||||
self.view_settings_button.setMinimumHeight(40)
|
||||
self.view_settings_button.setStyleSheet("font-size: 12pt;")
|
||||
|
||||
self.view_settings_dialog = ViewSettingsDialog(self)
|
||||
self.view_settings_button.clicked.connect(self.view_settings_dialog.show)
|
||||
@@ -61,6 +62,7 @@ class MainWindow(QMainWindow):
|
||||
self.photo_button.setStyleSheet("font-size: 12pt;")
|
||||
|
||||
control_layout.addWidget(histogram_view)
|
||||
control_layout.addWidget(self.view_settings_button)
|
||||
control_layout.addWidget(self.color_list_widget)
|
||||
control_layout.addWidget(self.record_button)
|
||||
control_layout.addWidget(self.photo_button)
|
||||
|
||||
@@ -1,30 +1,209 @@
|
||||
from PySide6.QtWidgets import QDialog, QHBoxLayout ,QVBoxLayout, QPushButton
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QDialog, QHBoxLayout ,QVBoxLayout, QPushButton, QGroupBox, QLabel, QRadioButton, QWidget, QToolButton, QSlider, QButtonGroup
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtCore import Qt, QSize, Signal
|
||||
|
||||
ISO_ARR = ["AUTO","100", "200", "400", "800", "1600", "3200"]
|
||||
SPEED_ARR = ["30", "25", "20", "15", "13", "10.3", "8", "6.3", "5", "4", "3.2", "2.5", "2", "1.6", "1.3", "1", "0.8", "0.6", "0.5", "0.4", "0.3", "1/4", "1/5", "1/6", "1/8", "1/10", "1/13", "1/15", "1/20", "1/25", "1/30", "1/40", "1/50", "1/60", "1/80", "1/100", "1/125", "1/160", "1/200", "1/250", "1/320", "1/400", "1/500", "1/640", "1/800", "1/1000", "1/1250", "1/1600", "1/2000", "1/2500", "1/3200", "1/4000"]
|
||||
|
||||
class LabeledSpinSelector(QWidget):
|
||||
indexChanged = Signal(int)
|
||||
|
||||
def __init__(self, title: str, values: list[str], show_slider: bool = False, parent=None):
|
||||
super().__init__(parent)
|
||||
self.values = values
|
||||
self.current_index = 0
|
||||
self.show_slider = show_slider
|
||||
self._init_ui(title)
|
||||
|
||||
def _init_ui(self, title: str, button_size: int = 24, icon_size: int = 16):
|
||||
self.title_label = QLabel(title)
|
||||
|
||||
decrement_button = QToolButton()
|
||||
decrement_button.setIcon(QIcon("ui/icons/arrow-left-335-svgrepo-com.svg"))
|
||||
decrement_button.setFixedSize(button_size, button_size)
|
||||
decrement_button.setIconSize(QSize(icon_size, icon_size))
|
||||
decrement_button.clicked.connect(self._decrement)
|
||||
|
||||
increment_button = QToolButton()
|
||||
increment_button.setIcon(QIcon("ui/icons/arrow-right-336-svgrepo-com.svg"))
|
||||
increment_button.setFixedSize(button_size, button_size)
|
||||
increment_button.setIconSize(QSize(icon_size, icon_size))
|
||||
increment_button.clicked.connect(self._increment)
|
||||
|
||||
self.value_label = QLabel(self.values[self.current_index] if self.values else "N/A")
|
||||
self.value_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.value_label.setStyleSheet("background-color: rgb(48, 48, 48);")
|
||||
self.value_label.setFixedHeight(button_size - 2)
|
||||
|
||||
spin_layout = QHBoxLayout()
|
||||
spin_layout.addWidget(decrement_button)
|
||||
spin_layout.addWidget(self.value_label)
|
||||
spin_layout.addWidget(increment_button)
|
||||
|
||||
top_layout = QHBoxLayout()
|
||||
top_layout.addWidget(self.title_label)
|
||||
top_layout.addLayout(spin_layout)
|
||||
|
||||
self.slider = QSlider(Qt.Orientation.Horizontal)
|
||||
self.slider.setRange(0, max(0, len(self.values) - 1))
|
||||
self.slider.setTickPosition(QSlider.TickPosition.TicksBelow)
|
||||
self.slider.valueChanged.connect(self._slider_changed)
|
||||
|
||||
main_layout = QVBoxLayout()
|
||||
main_layout.addLayout(top_layout)
|
||||
if self.show_slider:
|
||||
main_layout.addWidget(self.slider)
|
||||
|
||||
main_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.setLayout(main_layout)
|
||||
|
||||
def _increment(self):
|
||||
if not self.values:
|
||||
return
|
||||
new_index = min(self.current_index + 1, len(self.values) - 1)
|
||||
self.set_index(new_index)
|
||||
|
||||
def _decrement(self):
|
||||
if not self.values:
|
||||
return
|
||||
new_index = max(self.current_index - 1, 0)
|
||||
self.set_index(new_index)
|
||||
|
||||
def _slider_changed(self, index):
|
||||
if not self.values:
|
||||
return
|
||||
self.set_index(index)
|
||||
|
||||
def set_label(self, label: str):
|
||||
self.title_label.setText(label)
|
||||
|
||||
def set_index(self, index: int):
|
||||
if not self.values or not (0 <= index < len(self.values)):
|
||||
return
|
||||
if self.current_index != index:
|
||||
self.current_index = index
|
||||
self.value_label.setText(self.values[index])
|
||||
if self.show_slider:
|
||||
self.slider.setValue(index)
|
||||
self.indexChanged.emit(index)
|
||||
else:
|
||||
# Always update UI even if index is the same (for initial set)
|
||||
self.value_label.setText(self.values[index])
|
||||
if self.show_slider:
|
||||
self.slider.setValue(index)
|
||||
|
||||
class ViewSettingsDialog(QDialog):
|
||||
detectDevice = Signal(str)
|
||||
connectionChanged = Signal(str)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle("Ustawienia widoku")
|
||||
self.setFixedSize(300, 200)
|
||||
self.setFixedSize(640, 480)
|
||||
|
||||
self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
|
||||
self.setWindowFlags(self.windowFlags() | Qt.WindowType.WindowStaysOnTopHint)
|
||||
|
||||
self.setup_ui()
|
||||
# self.setup_ui()
|
||||
camera_frame = self._create_devices_frame("camera")
|
||||
hdmi_frame = self._create_devices_frame("hdmi")
|
||||
conn_frame = self._create_connection_frame()
|
||||
camera_settings = self._create_settings_frame()
|
||||
hdmi_settings = self._create_settings_frame()
|
||||
dialog_buttons = self._create_dialog_buttons()
|
||||
|
||||
def setup_ui(self):
|
||||
self.main_layout = QVBoxLayout(self)
|
||||
hdmi_settings.setEnabled(False)
|
||||
|
||||
self.btn_layout = QHBoxLayout()
|
||||
self.btn_layout.addStretch()
|
||||
settings_layout = QHBoxLayout()
|
||||
settings_layout.addWidget(camera_settings, 1)
|
||||
settings_layout.addWidget(hdmi_settings, 1)
|
||||
# main layout
|
||||
main_layout = QVBoxLayout(self)
|
||||
main_layout.addWidget(camera_frame)
|
||||
main_layout.addWidget(hdmi_frame)
|
||||
main_layout.addWidget(conn_frame)
|
||||
main_layout.addLayout(settings_layout)
|
||||
main_layout.addLayout(dialog_buttons)
|
||||
|
||||
self.ok_button = QPushButton("OK")
|
||||
self.ok_button.clicked.connect(self.accept)
|
||||
self.btn_layout.addWidget(self.ok_button)
|
||||
main_layout.setStretch(3, 1)
|
||||
|
||||
self.cancel_button = QPushButton("Anuluj")
|
||||
self.cancel_button.clicked.connect(self.reject)
|
||||
self.btn_layout.addWidget(self.cancel_button)
|
||||
self.last_choice = None
|
||||
|
||||
self.main_layout.addLayout(self.btn_layout)
|
||||
|
||||
def _create_dialog_buttons(self):
|
||||
ok_btn = QPushButton("OK")
|
||||
ok_btn.clicked.connect(self.accept)
|
||||
|
||||
cancel_btn = QPushButton("Anuluj")
|
||||
cancel_btn.setDefault(True)
|
||||
cancel_btn.clicked.connect(self.reject)
|
||||
|
||||
layout = QHBoxLayout()
|
||||
layout.addStretch()
|
||||
layout.addWidget(ok_btn)
|
||||
layout.addWidget(cancel_btn)
|
||||
|
||||
return layout
|
||||
|
||||
def _create_devices_frame(self, name):
|
||||
frame = QGroupBox()
|
||||
frame.setTitle("Wykryte aparaty")
|
||||
frame.setContentsMargins(6, 20, 6, 10)
|
||||
|
||||
device_label = QLabel("Nie wykryto podłączonych urządzeń.")
|
||||
detect_button = QPushButton("Wykryj...")
|
||||
detect_button.clicked.connect(lambda: self.detectDevice.emit(name))
|
||||
|
||||
layout = QHBoxLayout()
|
||||
layout.addWidget(device_label)
|
||||
layout.addStretch()
|
||||
layout.addWidget(detect_button)
|
||||
|
||||
frame.setLayout(layout)
|
||||
|
||||
return frame
|
||||
|
||||
def _create_connection_frame(self):
|
||||
frame = QGroupBox()
|
||||
frame.setTitle("Wybór połączenia")
|
||||
frame.setContentsMargins(6, 20, 6, 10)
|
||||
|
||||
radio_usb = QRadioButton("USB")
|
||||
radio_hybrid = QRadioButton("USB + HDMI")
|
||||
radio_hdmi = QRadioButton("HDMI")
|
||||
|
||||
radio_hdmi.setEnabled(False)
|
||||
|
||||
radio_usb.clicked.connect(lambda: self.radio_toggle("usb"))
|
||||
radio_hybrid.clicked.connect(lambda: self.radio_toggle("hybrid"))
|
||||
radio_hdmi.clicked.connect(lambda: self.radio_toggle("hdmi"))
|
||||
|
||||
radio_layout = QHBoxLayout()
|
||||
radio_layout.addStretch()
|
||||
radio_layout.addWidget(radio_usb)
|
||||
radio_layout.addStretch()
|
||||
radio_layout.addWidget(radio_hybrid)
|
||||
radio_layout.addStretch()
|
||||
radio_layout.addWidget(radio_hdmi)
|
||||
radio_layout.addStretch()
|
||||
|
||||
frame.setLayout(radio_layout)
|
||||
|
||||
return frame
|
||||
|
||||
# def _create_settings_frame(self, settings: dict[str, list[str]]):
|
||||
def _create_settings_frame(self):
|
||||
frame = QGroupBox()
|
||||
frame.setTitle("Ustawienia aparatu")
|
||||
|
||||
layout = QVBoxLayout()
|
||||
# for key, value in settings.items():
|
||||
# layout.addWidget(LabeledSpinSelector(key, value))
|
||||
layout.addStretch()
|
||||
|
||||
frame.setLayout(layout)
|
||||
return frame
|
||||
|
||||
def radio_toggle(self, value):
|
||||
if self.last_choice != value:
|
||||
self.last_choice = value
|
||||
self.connectionChanged.emit(value)
|
||||
Reference in New Issue
Block a user