def save_all(self): if self.num_frames == 0: return try: not_show = settings.read('not_show_save_dialog', False, type=bool) except TypeError: not_show = False if not not_show: cb = QCheckBox("Don't ask me again.") msg_box = QMessageBox( QMessageBox.Question, self.tr("Confirm saving all signals"), self.tr("All changed signal files will be overwritten. OK?")) msg_box.addButton(QMessageBox.Yes) msg_box.addButton(QMessageBox.No) msg_box.setCheckBox(cb) reply = msg_box.exec() not_show_again = cb.isChecked() settings.write("not_show_save_dialog", not_show_again) self.not_show_again_changed.emit() if reply != QMessageBox.Yes: return for f in self.signal_frames: if f.signal is None or f.signal.filename == "": continue f.signal.save()
def closeEvent(self, event: QCloseEvent): if self.device.backend is not Backends.none: self.emit_editing_finished_signals() self.timer.stop() self.device.stop("Dialog closed. Killing recording process.") logger.debug("Device stopped successfully.") if not self.testing_mode: if not self.save_before_close(): event.ignore() return time.sleep(0.1) if self.device.backend not in (Backends.none, Backends.network): # Backend none is selected, when no device is available logger.debug("Cleaning up device") self.device.cleanup() logger.debug("Successfully cleaned up device") self.device_settings_widget.emit_device_parameters_changed() settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry()) if self.device is not None: self.device.free_data() self.scene_manager.eliminate() self._eliminate_graphic_view() super().closeEvent(event)
def __init__(self): python2_exe = settings.read('python2_exe', '') if not python2_exe: self.__python2_exe = self.__get_python2_interpreter() settings.write("python2_exe", self.__python2_exe) else: self.__python2_exe = python2_exe settings.write("python2_exe", self.__python2_exe) self.gnuradio_install_dir = settings.read('gnuradio_install_dir', "") self.use_gnuradio_install_dir = settings.read( 'use_gnuradio_install_dir', os.name == "nt", bool) self.gnuradio_is_installed = settings.read('gnuradio_is_installed', -1, int) if self.gnuradio_is_installed == -1: self.set_gnuradio_installed_status() else: self.gnuradio_is_installed = bool(self.gnuradio_is_installed) if not hasattr(sys, 'frozen'): self.path = os.path.dirname(os.path.realpath(__file__)) else: self.path = os.path.dirname(sys.executable) self.device_backends = {} """:type: dict[str, BackendContainer] """ self.get_backends()
def set_gnuradio_installed_status(self): if self.use_gnuradio_install_dir: # We are probably on windows with a bundled gnuradio installation bin_dir = os.path.join(self.gnuradio_install_dir, "bin") site_packages_dir = os.path.join(self.gnuradio_install_dir, "lib", "site-packages") if all( os.path.isdir(dir) for dir in [self.gnuradio_install_dir, bin_dir, site_packages_dir]): self.gnuradio_is_installed = True else: self.gnuradio_is_installed = False else: if os.path.isfile(self.python2_exe) and os.access( self.python2_exe, os.X_OK): try: # Use shell=True to prevent console window popping up on windows self.gnuradio_is_installed = call( '"{0}" -c "import gnuradio"'.format(self.python2_exe), shell=True, stderr=DEVNULL) == 0 except OSError as e: logger.error( "Could not determine GNU Radio install status. Assuming true. Error: " + str(e)) self.gnuradio_is_installed = True else: self.gnuradio_is_installed = False settings.write("gnuradio_is_installed", int(self.gnuradio_is_installed))
def on_accepted(self): if self.checked_radiobutton is not None: bw_type = self.checked_radiobutton.objectName().replace( "radioButton", "").replace("_", " ") settings.write("bandpass_filter_bw_type", bw_type) settings.write("bandpass_filter_custom_bw", self.ui.doubleSpinBoxCustomBandwidth.value())
def test_open_recent_file(self): settings.write("recentFiles", []) # Ensure we have at least one recent action self.form.add_files([get_path_for_data_file("esaver.complex16s")]) self.assertEqual(len(self.form.signal_tab_controller.signal_frames), 1) self.form.recentFileActionList[0].trigger() self.assertEqual(len(self.form.signal_tab_controller.signal_frames), 2)
def closeEvent(self, event: QCloseEvent): self.ui.lineEditParameters.editingFinished.emit() settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry()) for gv in (self.ui.gVCarrier, self.ui.gVData, self.ui.gVModulated, self.ui.gVOriginalSignal): # Eliminate graphic views to prevent segfaults gv.eliminate() super().closeEvent(event)
def on_btn_lock_bw_sr_clicked(self): self.bw_sr_are_locked = self.ui.btnLockBWSR.isChecked() settings.write("lock_bandwidth_sample_rate", self.bw_sr_are_locked) if self.bw_sr_are_locked: self.ui.btnLockBWSR.setIcon(QIcon(":/icons/icons/lock.svg")) self.ui.spinBoxBandwidth.setValue( self.ui.spinBoxSampleRate.value()) self.ui.spinBoxBandwidth.editingFinished.emit() else: self.ui.btnLockBWSR.setIcon(QIcon(":/icons/icons/unlock.svg"))
def write_settings(self): settings.write(self.name + "_is_enabled", self.is_enabled) if self.selected_backend == Backends.grc and len( self.avail_backends) == 1: # if GNU Radio is the only backend available we do not save it to ini, # in order to auto enable native backend if a native extension is built afterwards # see: https://github.com/jopohl/urh/issues/270 pass else: settings.write(self.name + "_selected_backend", self.selected_backend.name)
def test_set_icon_theme(self): settings.write("icon_theme_index", 0) util.set_icon_theme() self.assertEqual(QIcon.themeName(), "oxy") settings.write("icon_theme_index", 1) util.set_icon_theme() if sys.platform == "linux": self.assertNotEqual(QIcon.themeName(), "oxy") else: self.assertEqual(QIcon.themeName(), "oxy")
def closeEvent(self, event: QCloseEvent): changed_values = {} if bool(self.ui.checkBoxPauseTime.isChecked()) != self.old_show_pause_as_time: changed_values['show_pause_as_time'] = bool(self.ui.checkBoxPauseTime.isChecked()) if self.old_default_view != self.ui.comboBoxDefaultView.currentIndex(): changed_values['default_view'] = self.ui.comboBoxDefaultView.currentIndex() if self.old_num_sending_repeats != self.ui.spinBoxNumSendingRepeats.value(): changed_values["num_sending_repeats"] = self.ui.spinBoxNumSendingRepeats.value() settings.write('default_view', self.ui.comboBoxDefaultView.currentIndex()) settings.write('num_sending_repeats', self.ui.spinBoxNumSendingRepeats.value()) settings.write('show_pause_as_time', self.ui.checkBoxPauseTime.isChecked()) FieldType.save_to_xml(self.field_type_table_model.field_types) self.plugin_controller.save_enabled_states() for plugin in self.plugin_controller.model.plugins: plugin.destroy_settings_frame() for i in range(self.ui.scrollAreaWidgetSpectrogramColormapContents.layout().count()): widget = self.ui.scrollAreaWidgetSpectrogramColormapContents.layout().itemAt(i).widget() if isinstance(widget, QRadioButton) and widget.isChecked(): selected_colormap_name = widget.objectName() if selected_colormap_name != colormaps.read_selected_colormap_name_from_settings(): colormaps.choose_colormap(selected_colormap_name) colormaps.write_selected_colormap_to_settings(selected_colormap_name) changed_values["spectrogram_colormap"] = selected_colormap_name break self.values_changed.emit(changed_values) settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry()) super().closeEvent(event)
def adjust_for_current_file(self, file_path): if file_path is None: return if file_path in FileOperator.archives.keys(): file_path = copy.copy(FileOperator.archives[file_path]) recent_file_paths = settings.read("recentFiles", [], list) recent_file_paths = [] if recent_file_paths is None else recent_file_paths # check None for OSX recent_file_paths = [p for p in recent_file_paths if p != file_path and p is not None and os.path.exists(p)] recent_file_paths.insert(0, file_path) recent_file_paths = recent_file_paths[:settings.MAX_RECENT_FILE_NR] self.init_recent_file_action_list(recent_file_paths) settings.write("recentFiles", recent_file_paths)
def set_gnuradio_status(self): self.backend_handler.python2_exe = self.ui.lineEditPython2Interpreter.text( ) self.backend_handler.gnuradio_install_dir = self.ui.lineEditGnuradioDirectory.text( ) settings.write("gnuradio_install_dir", self.ui.lineEditGnuradioDirectory.text()) self.backend_handler.use_gnuradio_install_dir = self.ui.radioButtonGnuradioDirectory.isChecked( ) self.backend_handler.set_gnuradio_installed_status() settings.write("use_gnuradio_install_dir", self.backend_handler.use_gnuradio_install_dir) self.refresh_device_tab()
def set_gnuradio_installed_status(self, force=False): current_setting = settings.read('gnuradio_is_installed', -1, int) if not force and current_setting != -1: self.gnuradio_is_installed = bool(current_setting) return if os.path.isfile(self.gr_python_interpreter) and os.access( self.gr_python_interpreter, os.X_OK): try: self.gnuradio_is_installed = self.__check_gr_python_interpreter( self.gr_python_interpreter) except OSError: self.gnuradio_is_installed = False else: self.gnuradio_is_installed = False settings.write("gnuradio_is_installed", int(self.gnuradio_is_installed))
def write_settings(): global settings_written try: settings_written except NameError: settings_written = True settings.write("not_show_close_dialog", True) # prevent interactive close questions settings.write("not_show_save_dialog", True) settings.write("NetworkSDRInterface", True) settings.write("align_labels", True)
def write_default_options(): keys = settings.all_keys() if 'default_view' not in keys: settings.write('default_view', 0) if 'num_sending_repeats' not in keys: settings.write('num_sending_repeats', 0) if 'show_pause_as_time' not in keys: settings.write('show_pause_as_time', False) settings.sync() # Ensure conf dir is created to have field types in place if not os.path.isfile(settings.FIELD_TYPE_SETTINGS): FieldType.save_to_xml(FieldType.default_field_types()) bh = BackendHandler() for be in bh.device_backends.values(): be.write_settings()
def on_radio_button_low_modulation_accuracy_clicked(self, checked): if checked: settings.write("modulation_dtype", "int8")
def on_radio_button_high_modulation_accuracy_clicked(self, checked): if checked: settings.write("modulation_dtype", "float32")
def on_spin_box_font_size_editing_finished(self): settings.write("font_size", self.ui.spinBoxFontSize.value()) font = qApp.font() font.setPointSize(self.ui.spinBoxFontSize.value()) qApp.setFont(font)
def on_checkbox_multiple_modulations_clicked(self): settings.write("multiple_modulations", self.ui.checkBoxMultipleModulations.isChecked())
def on_checkbox_align_labels_clicked(self, checked: bool): settings.write("align_labels", checked)
def on_spinbox_fuzzing_pause_value_changed(self, value: float): settings.write("default_fuzzing_pause", int(value))
def on_checkbox_default_fuzzing_pause_clicked(self, checked: bool): settings.write('use_default_fuzzing_pause', checked) self.ui.doubleSpinBoxFuzzingPause.setEnabled(checked)
def on_checkbox_hold_shift_to_drag_clicked(self, checked: bool): settings.write("hold_shift_to_drag", checked)
def on_combobox_icon_theme_index_changed(self, index: int): settings.write('icon_theme_index', index) util.set_icon_theme()
def on_combo_box_theme_index_changed(self, index: int): settings.write('theme_index', index)
def on_checkbox_confirm_close_dialog_clicked(self, checked: bool): settings.write("not_show_close_dialog", not checked)
def on_double_spinbox_ram_threshold_value_changed(self): val = self.ui.doubleSpinBoxRAMThreshold.value() settings.write("ram_threshold", val / 100)
def closeEvent(self, event: QCloseEvent): settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry()) super().closeEvent(event)
def python2_exe(self, value): if value != self.__python2_exe: self.__python2_exe = value settings.write("python2_exe", value)