def _create_mode_box(self) -> QWidget: box = create_group_box(texts.SETTINGS_MODE, self) self._root_path_form = RootPathForm( self._ui_app, self._config.root_path, self._on_root_path_change, parent=box, ) self._named_dirs_form = NamedDirsForm( self._ui_app, self._config.named_dirs, self._on_named_dirs_change, parent=box, ) # Mode radios must be created after the forms, because the radio # callback immediately tries to toggle the forms. radio_configs = [ RadioConfig(value, label) for value, label in MODES.items() ] self._mode_radios = create_radio_group( box, radio_configs, active_value=self._config.mode, callback=self._on_mode_radio_toggled, ) add_layout_items( box.layout(), [ self._mode_radios[MODE_ROOT_PATH], self._root_path_form, self._mode_radios[MODE_NAMED_DIRS], self._named_dirs_form, ], ) return box
def _create_threshold_days_ago_box(self) -> QWidget: box = create_group_box(texts.SETTINGS_THRESHOLD_DAYS_OLD, self) self._threshold_days_ago_entry = create_spin_box( self, value=self._config.threshold_days_ago, callback=self._on_threshold_days_ago_changed, ) add_layout_items(box.layout(), [self._threshold_days_ago_entry]) return box
def _create_interval_hours_box(self) -> QWidget: box = create_group_box(texts.SETTINGS_INTERVAL_HOURS, self) self._interval_hours_entry = create_spin_box( self, value=self._config.interval_hours, callback=self._on_interval_hours_changed, max_val=999, ) add_layout_items(box.layout(), [self._interval_hours_entry]) return box
def _create_unit_box(self) -> QWidget: box = create_group_box(texts.SETTINGS_UNIT, self) radio_configs = [ RadioConfig(value, label) for value, label in UNITS.items() ] self._unit_radios = create_radio_group( box, radio_configs, active_value=self._config.unit, callback=self._on_unit_radio_toggled, ) add_layout_items(box.layout(), self._unit_radios.values()) return box
def __init__( self, config: Config, on_accept: Callable, ui_app: QApplication ): self._config = config self._on_accept = on_accept self._ui_app = ui_app super().__init__() self._init_window() widgets = [ self._create_interval_hours_box(), self._create_unit_box(), self._create_threshold_days_ago_box(), self._create_mode_box(), self._create_dialog_buttons(), ] add_layout_items(self._layout, widgets) self._show()