|
1 | 1 | import CLProject as clp |
2 | | -from CLGui import CLTab, CLParameter, CLParamNum, CLParamDropdown, CLParamFile, QCollapsible, QHSeparator, CalibrationDialog, undo_stack |
| 2 | +from CLGui import CLTab, CLParameter, CLParamNum, CLParamDropdown, CLParamFile, CLParamCheckBox, QCollapsible, QHSeparator, CalibrationDialog, undo_stack |
3 | 3 | from CLAnalysis import generate_stimulus, read_audio_file, read_response, generate_output_stimulus, generate_stimulus_file, audio_file_info, write_audio_file |
4 | 4 | import numpy as np |
5 | | -from qtpy.QtWidgets import QPushButton, QCheckBox, QAbstractSpinBox, QFileDialog, QComboBox, QFrame, QVBoxLayout |
| 5 | +from qtpy.QtWidgets import QPushButton, QAbstractSpinBox, QFileDialog, QComboBox, QFrame, QVBoxLayout |
6 | 6 | from qtpy.QtCore import Signal, Slot, QObject |
7 | 7 | import pyqtgraph as pg |
8 | 8 | from engineering_notation import EngNumber |
@@ -375,13 +375,18 @@ def update_post_sweep_units(index): |
375 | 375 | self.post_sweep.units_update_callback = update_post_sweep_units |
376 | 376 |
|
377 | 377 | # include leading silence checkbox |
378 | | - self.include_silence = QCheckBox('Include leading silence') |
| 378 | + self.include_silence = CLParamCheckBox('Include leading silence') |
379 | 379 | self.include_silence.setChecked(clp.project['output']['include_silence']) |
380 | 380 | layout.addWidget(self.include_silence) |
381 | 381 | def update_include_silence(checked): |
382 | 382 | clp.project['output']['include_silence'] = bool(checked) |
| 383 | + undo_stack.push(undo_include_silence, not checked, undo_include_silence, checked) |
383 | 384 | update_output_length() |
384 | | - self.include_silence.stateChanged.connect(update_include_silence) |
| 385 | + self.include_silence.update_callback = update_include_silence |
| 386 | + def undo_include_silence(checked): |
| 387 | + undo_stack.paused = True |
| 388 | + self.include_silence.setChecked(checked) |
| 389 | + undo_stack.paused = False |
385 | 390 |
|
386 | 391 | # total length text box (non-interactive) - s/sample dropdown |
387 | 392 | def calc_output_length(unit='samples'): |
@@ -540,7 +545,9 @@ def __init__(self, chirp_tab): |
540 | 545 | layout.addWidget(self.refresh) |
541 | 546 | def refresh_devices(): |
542 | 547 | DeviceIO.restart_pyaudio() |
| 548 | + undo_stack.paused = True |
543 | 549 | update_api(self.api.dropdown.currentIndex()) |
| 550 | + undo_stack.paused = False |
544 | 551 | # todo: also refresh input devices |
545 | 552 | self.refresh.clicked.connect(refresh_devices) |
546 | 553 |
|
@@ -662,15 +669,15 @@ def update_post_sweep_units(index): |
662 | 669 | self.post_sweep.units_update_callback = update_post_sweep_units |
663 | 670 |
|
664 | 671 | # include leading silence checkbox |
665 | | - self.include_silence = QCheckBox('Include leading silence') |
| 672 | + self.include_silence = CLParamCheckBox('Include leading silence') |
666 | 673 | self.include_silence.setChecked(clp.project['output']['include_silence']) |
667 | 674 | layout.addWidget(self.include_silence) |
668 | 675 | def update_include_silence(checked): |
669 | 676 | clp.project['output']['include_silence'] = bool(checked) |
670 | 677 | update_output_length() |
671 | 678 | if clp.project['input']['mode'] == 'device' and clp.project['input']['use_output_length']: |
672 | 679 | chirp_tab.input_params.device_input.update_auto_length(True) |
673 | | - self.include_silence.stateChanged.connect(update_include_silence) |
| 680 | + self.include_silence.update_callback = update_include_silence |
674 | 681 |
|
675 | 682 | # total length text box (non-interactive) - s/sample dropdown |
676 | 683 | def calc_output_length(unit='samples'): |
@@ -1024,7 +1031,9 @@ def __init__(self, chirp_tab): |
1024 | 1031 | layout.addWidget(self.refresh) |
1025 | 1032 | def refresh_devices(): |
1026 | 1033 | DeviceIO.restart_pyaudio() |
| 1034 | + undo_stack.paused = True |
1027 | 1035 | update_api(self.api.dropdown.currentIndex()) |
| 1036 | + undo_stack.paused = False |
1028 | 1037 | # todo: also refresh output devices |
1029 | 1038 | self.refresh.clicked.connect(refresh_devices) |
1030 | 1039 |
|
@@ -1087,15 +1096,15 @@ def update_device(index): |
1087 | 1096 | self.device.update_callback = update_device |
1088 | 1097 |
|
1089 | 1098 | # auto capture length checkbox |
1090 | | - self.auto_length = QCheckBox('auto') |
| 1099 | + self.auto_length = CLParamCheckBox('auto') |
1091 | 1100 | self.auto_length.setChecked(clp.project['input']['use_output_length']) |
1092 | 1101 | def update_auto_length(checked): |
1093 | 1102 | clp.project['input']['use_output_length'] = checked |
1094 | 1103 | self.capture_length.spin_box.setEnabled(not checked) |
1095 | 1104 | if checked: |
1096 | 1105 | clp.project['input']['capture_length'] = calc_output_length('seconds') |
1097 | 1106 | update_capture_length_units(self.capture_length.units.currentIndex()) |
1098 | | - self.auto_length.stateChanged.connect(update_auto_length) |
| 1107 | + self.auto_length.update_callback = update_auto_length |
1099 | 1108 | def calc_output_length(unit='samples'): |
1100 | 1109 | sig_length = round(clp.project['output']['pre_sweep']*clp.project['output']['sample_rate']) |
1101 | 1110 | sig_length += round(clp.project['chirp_length']*clp.project['output']['sample_rate']) |
|
0 commit comments