Example #1
0
    def set_project_folder(self, path, ask_for_new_project=True):
        if path != self.project_path:
            self.maincontroller.close_all()
        self.project_path = path
        self.project_file = os.path.join(self.project_path, constants.PROJECT_FILE)
        if not os.path.isfile(self.project_file):
            if ask_for_new_project:
                reply = QMessageBox.question(self.maincontroller, "Project File",
                                             "Do you want to create a Project File for this folder?\n"
                                             "If you chose No, you can do it later via File->Convert Folder to Project.",
                                             QMessageBox.Yes | QMessageBox.No)

                if reply == QMessageBox.Yes:
                    dialog = ProjectDialogController(new_project=False, parent=self.maincontroller)
                    dialog.set_path(path)
                    dialog.finished.connect(self.on_dialog_finished)
                    dialog.exec_()

                else:
                    self.project_file = None

            if self.project_file is not None:
                root = ET.Element("UniversalRadioHackerProject")
                tree = ET.ElementTree(root)
                tree.write(self.project_file)
        else:
            self.read_recording_parameters()
            self.maincontroller.add_files(self.read_opened_filenames())
            self.read_compare_frame_groups() # Labels are read out here
            cfc = self.maincontroller.compare_frame_controller
            cfc.load_decodings()
            cfc.fill_decoding_combobox()

            for group_id, decoding_index in self.read_decodings().items():
                cfc.groups[group_id].decoding = cfc.decodings[decoding_index]

            #cfc.ui.cbDecoding.setCurrentIndex(index)
            cfc.refresh_protocol_labels()
            cfc.updateUI()
            modulators = self.read_modulators_from_project_file()
            self.maincontroller.generator_tab_controller.modulators = modulators if modulators else [
                Modulator("Modulation")]
            self.maincontroller.generator_tab_controller.refresh_modulators()

        if len(self.project_path) > 0 and self.project_file is None:
            self.maincontroller.ui.actionConvert_Folder_to_Project.setEnabled(True)
        else:
            self.maincontroller.ui.actionConvert_Folder_to_Project.setEnabled(False)

        self.maincontroller.adjustForCurrentFile(path)
        self.maincontroller.filemodel.setRootPath(path)
        self.maincontroller.ui.fileTree.setRootIndex(
            self.maincontroller.file_proxy_model.mapFromSource(self.maincontroller.filemodel.index(path)))
        self.maincontroller.ui.fileTree.setToolTip(path)
        self.maincontroller.ui.splitter.setSizes([1, 1])
        self.maincontroller.setWindowTitle("Universal Radio Hacker [" + path + "]")
Example #2
0
    def on_new_project_action_triggered(self):
        pdc = ProjectDialogController(parent=self)
        try:
            path = os.path.dirname(self.signal_tab_controller.signal_frames[0].signal.filename)
        except (IndexError, AttributeError, TypeError):
            path = None

        if path:
            pdc.set_path(path)
        pdc.finished.connect(self.on_project_dialog_finished)
        pdc.show()
Example #3
0
    def convert_folder_to_project(self):
        self.project_file = os.path.join(self.project_path, constants.PROJECT_FILE)
        dialog = ProjectDialogController(new_project=False, parent=self.maincontroller)
        dialog.set_path(self.project_path)
        dialog.finished.connect(self.on_dialog_finished)
        dialog.exec_()

        if self.project_file is not None:
            root = ET.Element("UniversalRadioHackerProject")
            tree = ET.ElementTree(root)
            tree.write(self.project_file)
            self.maincontroller.ui.actionConvert_Folder_to_Project.setEnabled(False)