def on_mute_action_triggered(self): mute_action = EditSignalAction(signal=self.signal, protocol=self.protocol, start=self.selection_area.start, end=self.selection_area.end, mode=EditAction.mute, cache_qad=self.cache_qad) self.undo_stack.push(mute_action)
def on_insert_sine_wave_clicked(self): if self.insert_sine_plugin.complex_wave is not None: self.clear_selection() insert_action = EditSignalAction(signal=self.signal, protocol=self.protocol, data_to_insert=self.insert_sine_plugin.complex_wave, position=self.paste_position, mode=EditAction.insert, cache_qad=self.cache_qad) self.undo_stack.push(insert_action)
def on_crop_action_triggered(self): if self.something_is_selected: start, end = self.selection_area.start, self.selection_area.end self.clear_horizontal_selection() crop_action = EditSignalAction(signal=self.signal, protocol=self.protocol, start=start, end=end, mode=EditAction.crop, cache_qad=self.cache_qad) self.undo_stack.push(crop_action)
def on_crop_action_triggered(self): if not self.selection_area.is_empty: start, end = self.selection_area.start, self.selection_area.end self.clear_selection() crop_action = EditSignalAction(signal=self.signal, protocol=self.protocol, start=start, end=end, mode=EditAction.crop, cache_qad=self.cache_qad) self.undo_stack.push(crop_action)
def on_delete_action_triggered(self): if not self.selection_area.is_empty: start, end = self.selection_area.start, self.selection_area.end self.clear_selection() del_action = EditSignalAction(signal=self.signal, protocol=self.protocol, start=start, end=end, mode=EditAction.delete, cache_qad=self.cache_qad) self.undo_stack.push(del_action) self.centerOn(start, self.y_center)
def on_paste_action_triggered(self): if self.stored_item is not None: # paste_position is set in ContextMenuEvent self.clear_selection() paste_action = EditSignalAction(signal=self.signal, protocol=self.protocol, start=self.selection_area.start, end=self.selection_area.end, data_to_insert=self.stored_item, position=self.paste_position, mode=EditAction.paste, cache_qad=self.cache_qad) self.undo_stack.push(paste_action)
def on_btn_filter_clicked(self): if self.apply_filter_to_selection_only.isChecked(): start, end = self.ui.gvSignal.selection_area.start, self.ui.gvSignal.selection_area.end else: start, end = 0, self.signal.num_samples filter_action = EditSignalAction(signal=self.signal, mode=EditAction.filter, start=start, end=end, dsp_filter=self.dsp_filter, protocol=self.proto_analyzer) self.undo_stack.push(filter_action)
def contextMenuEvent(self, event: QContextMenuEvent): if self.ctrl_mode: return self.paste_position = int(self.mapToScene(event.pos()).x()) menu = QMenu(self) if self.save_enabled: menu.addAction(self.save_action) menu.addAction(self.save_as_action) menu.addSeparator() zoom_action = None create_action = None noise_action = None crop_action = None mute_action = None menu.addAction(self.copy_action) self.copy_action.setEnabled(not self.selection_area.is_empty) menu.addAction(self.paste_action) self.paste_action.setEnabled(self.stored_item is not None) menu.addSeparator() if PluginManager().is_plugin_enabled("InsertSine"): menu.addAction(self.insert_sine_action) if not self.selection_area.is_empty: menu.addSeparator() if not self.selection_area.is_empty: menu.addAction(self.delete_action) crop_action = menu.addAction(self.tr("Crop to selection")) mute_action = menu.addAction(self.tr("Mute selection")) menu.addSeparator() zoom_action = menu.addAction(self.tr("Zoom selection")) zoom_action.setIcon(QIcon.fromTheme("zoom-in")) if self.create_new_signal_enabled: create_action = menu.addAction(self.tr("Create signal from selection")) create_action.setIcon(QIcon.fromTheme("document-new")) if hasattr(self, "selected_messages"): selected_messages = self.selected_messages else: selected_messages = [] if len(selected_messages) == 1: selected_msg = selected_messages[0] else: selected_msg = None participant_actions = {} if len(selected_messages) > 0 and self.participants_assign_enabled: participant_group = QActionGroup(self) participant_menu = menu.addMenu("Participant") none_participant_action = participant_menu.addAction("None") none_participant_action.setCheckable(True) none_participant_action.setActionGroup(participant_group) if selected_msg and selected_msg.participant is None: none_participant_action.setChecked(True) for participant in self.participants: pa = participant_menu.addAction(participant.name + " (" + participant.shortname + ")") pa.setCheckable(True) pa.setActionGroup(participant_group) if selected_msg and selected_msg.participant == participant: pa.setChecked(True) participant_actions[pa] = participant else: none_participant_action = 42 if hasattr(self, "scene_type") and self.scene_type == 0: if not self.selection_area.is_empty: menu.addSeparator() noise_action = menu.addAction(self.tr("Set noise level from Selection")) menu.addSeparator() menu.addAction(self.undo_action) menu.addAction(self.redo_action) QApplication.processEvents() # without this the menu flickers on first create action = menu.exec_(self.mapToGlobal(event.pos())) if action is None: return elif action == zoom_action: self.zoom_to_selection(self.selection_area.x, self.selection_area.end) elif action == create_action: self.create_clicked.emit(self.selection_area.x, self.selection_area.end) elif action == crop_action: if not self.selection_area.is_empty: crop_action = EditSignalAction(signal=self.signal, protocol=self.protocol, start=self.selection_area.start, end=self.selection_area.end, mode=EditAction.crop, cache_qad=self.cache_qad) self.undo_stack.push(crop_action) elif action == noise_action: self.set_noise_clicked.emit() elif action == mute_action: mute_action = EditSignalAction(signal=self.signal, protocol=self.protocol, start=self.selection_area.start, end=self.selection_area.end, mode=EditAction.mute, cache_qad=self.cache_qad) self.undo_stack.push(mute_action) elif action == none_participant_action: for msg in selected_messages: msg.participant = None self.participant_changed.emit() elif action in participant_actions: for msg in selected_messages: msg.participant = participant_actions[action] self.participant_changed.emit()