def __init__(self): super().__init__() self._style_creator = StyleCreator() self._style_sheet = '' self.setText('Apply parameters') self.setEnabled(False)
class ApplyButton(QPushButton, ProcessorUpdater): def __init__(self): super().__init__() self._style_creator = StyleCreator() self._style_sheet = '' self.setText('Apply parameters') self.setEnabled(False) def _on_setup(self): self._style_creator.set_ui_model(self._ui_model) self.register_action('signal_au', self._update_status) self.register_action(self._get_update_signal_type(), self._update_status) self.register_action('signal_style_changed', self._update_style) self.clicked.connect(self._apply_params) self._style_sheet = QApplication.instance().styleSheet() self._update_status() def _on_teardown(self): self._style_creator.unregister_updaters() def _get_update_signal_type(self): return 'signal_padsynth_{}'.format(self._proc_id) def _update_style(self): self._style_sheet = self._style_creator.get_updated_style_sheet() self.setStyleSheet(self._style_sheet) def _update_status(self): params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) self.setEnabled(not params.is_config_applied()) self.setObjectName('Important' if self.isEnabled() else '') self.setStyleSheet(self._style_sheet) def _apply_params(self): params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) def on_complete(): self._updater.signal_update(self._get_update_signal_type()) task_executor = self._ui_model.get_task_executor() task = params.get_task_apply_config(on_complete) task_executor(task)
def __init__(self): super().__init__() self._au_id = None self._proc_id = None self._ui_model = None self._updater = None self._style_creator = StyleCreator() self._style_sheet = '' self.setText('Apply parameters') self.setEnabled(False)
class ApplyButton(QPushButton): def __init__(self): super().__init__() self._au_id = None self._proc_id = None self._ui_model = None self._updater = None self._style_creator = StyleCreator() self._style_sheet = '' self.setText('Apply parameters') self.setEnabled(False) def set_au_id(self, au_id): self._au_id = au_id def set_proc_id(self, proc_id): self._proc_id = proc_id def set_ui_model(self, ui_model): self._ui_model = ui_model self._updater = ui_model.get_updater() self._updater.register_updater(self._perform_updates) self._style_creator.set_ui_model(ui_model) QObject.connect(self, SIGNAL('clicked()'), self._apply_params) self._style_sheet = QApplication.instance().styleSheet() self._update_status() def unregister_updaters(self): self._style_creator.unregister_updaters() self._updater.unregister_updater(self._perform_updates) def _get_update_signal_type(self): return 'signal_padsynth_{}'.format(self._proc_id) def _perform_updates(self, signals): update_signals = set(['signal_au', self._get_update_signal_type()]) if not signals.isdisjoint(update_signals): self._update_status() if 'signal_style_changed' in signals: self._update_style() def _update_style(self): self._style_sheet = self._style_creator.get_updated_style_sheet() self.setStyleSheet(self._style_sheet) def _update_status(self): params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) self.setEnabled(not params.is_config_applied()) self.setObjectName('Important' if self.isEnabled() else '') self.setStyleSheet(self._style_sheet) def _apply_params(self): params = utils.get_proc_params(self._ui_model, self._au_id, self._proc_id) params.apply_config() self._updater.signal_update(set([self._get_update_signal_type()]))