from PyQt6.QtWidgets import QWidget, QVBoxLayout, QFormLayout, QFileDialog, QCheckBox, QSpinBox from cpdctrl_gui.utility.config import AppConfig from .base import FileSelection, SettingsForm class AppSettings(QWidget): def __init__(self): super().__init__() self.setLayout(QVBoxLayout()) self.w_form = SettingsForm(AppConfig.MAIN_CFG) self.layout().addWidget(self.w_form) w_cache_dir = FileSelection(filemode=QFileDialog.FileMode.Directory) self.w_form.add_form_row("dir_cache", "Cache Directory", "~/.cache/cpdctrl", w_cache_dir, "Directory to store temporary data") self.w_form.add_form_row("led_device_auto_reconnect", "Autoconnect to last LED Controller", True, QCheckBox(), "Automatically connect to the last used LED Controller") self.w_form.add_form_row("voltage_measurement_device_auto_reconnect", "Autoconnect to last Voltage Measurement Device", True, QCheckBox(), "Automatically connect to the last used Voltage Measurement Device") w_plot_n = QSpinBox() w_plot_n.setMinimum(1000) w_plot_n.setMaximum(200000) w_plot_n.setSingleStep(1000) self.w_form.add_form_row("plot_max_data_points", "Max. Datapoints in the Plot", 20000, w_plot_n, "Maximum number of datapoints in the live plot.\nThis value is limited to ensure performance is not degraded in long measurements") w_plot_dt = QSpinBox() w_plot_dt.setMinimum(10) w_plot_dt.setMaximum(200000) w_plot_dt.setSingleStep(100) self.w_form.add_form_row("plot_update_interval_ms", "Plot Update Interval (ms)", 200, w_plot_dt, "Number of milliseconds to wait before updating the live plot") self.w_form.add_form_row("led_script_watch_file", "Watch Led Script File", False, QCheckBox(), "Watch the LED script file for changes and reload it automatically") self.w_form.add_form_row("led_script_save_copy", "Copy Led Script to Cache Dir", True, QCheckBox(), "Save the final version of the led script in the cache directory") self.w_form.add_form_row("metadata_auto_update", "Auto-Update Metadata", True, QCheckBox(), "Allow metadata updates while the program is running") self.w_form.add_form_row("metadata_auto_add", "Auto-Add Metadata", True, QCheckBox(), "Automatically add measurement metadata to the data file.\nThis includes: device names, measurement mode, measurement interval, start and stop times, led script")