59 lines
4.4 KiB
Python
59 lines
4.4 KiB
Python
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)
|
|
self.w_form.add_group("devices", "Devices")
|
|
self.w_form.add_group("interface", "Interface")
|
|
self.w_form.add_group("led_script", "LED Script")
|
|
self.w_form.add_group("power_switch", "Power Switch")
|
|
|
|
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")
|
|
# devices
|
|
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", group="devices")
|
|
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", group="devices")
|
|
w_idle_dt = QSpinBox()
|
|
w_idle_dt.setMinimum(10)
|
|
w_idle_dt.setMaximum(200000)
|
|
w_idle_dt.setSingleStep(10)
|
|
self.w_form.add_form_row("idle_update_interval_s", "Device Connection Check Interval (s)", 30, w_idle_dt, "How often to check whether the devices are still connected.\nApplies only when not in a measurement.", group="devices")
|
|
|
|
# interface
|
|
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", group="interface")
|
|
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", group="interface")
|
|
self.w_form.add_form_row("error_show_dialog", "Show Dialog on Error", True, QCheckBox(), "Whether to show a dialog window when uncaught errors occur\nLeave this on.", group="interface")
|
|
self.w_form.add_form_row("error_stack_trace", "Stacktrace in errors", False, QCheckBox(), "Whether to show the call stack in unexpected error messages", group="interface")
|
|
|
|
# led_script
|
|
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", group="led_script")
|
|
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", group="led_script")
|
|
|
|
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")
|
|
|
|
# power_switch
|
|
w_usb_switch_exe = FileSelection(filemode=QFileDialog.FileMode.ExistingFile)
|
|
self.w_form.add_form_row("power_switch_exe", "Power Switch Executable", "", w_usb_switch_exe, "Path to the USBSwitchCmd executable for the Cleware USB switch\nRequires a relaunch to take effect", group="power_switch")
|
|
w_power_on_reconnect_dt = QSpinBox()
|
|
w_power_on_reconnect_dt.setMinimum(0)
|
|
w_power_on_reconnect_dt.setMaximum(60)
|
|
w_power_on_reconnect_dt.setSingleStep(1)
|
|
self.w_form.add_form_row("power_switch_autoconnect_devices_timeout_s", "Autoconnect devices after (s)", 15, w_power_on_reconnect_dt, "After switching on, wait x seconds before trying to reconnect to the last devices\nSet to 0 to disable the auto-connection attempt.", group="power_switch")
|
|
|
|
self.w_form.update_alignment()
|