def gui(dev_mode=False): """Run the QAX gui""" # temporary fix for CORS warning (QTBUG-70228) sys.argv.append("--disable-web-security") # stop auto scaling on windows # os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" # stop auto scaling on windows - part 2 # app.setAttribute(QtCore.Qt.AA_DisableHighDpiScaling) # app.setStyleSheet(AppStyle.load_stylesheet()) cfg_dir = GuiSettings.config() # setup user editable config directory if not os.path.isdir(cfg_dir): # config does not exist, so copy out default settings logger.info("Copying default config to {}".format(cfg_dir)) import shutil shutil.copytree(GuiSettings.config_default(), cfg_dir) else: logger.info("Using existing config {}".format(cfg_dir)) config = QaxConfig(Path(cfg_dir)) config.load() plugins = QaxPlugins() plugins.load(config) main_win = MainWin() main_win.initialize() sys.excepthook = main_win.exception_hook # install the exception hook main_win.show() if dev_mode: main_win.do() sys.exit(app.exec_())
def gui(dev_mode=False): """Run the QAX gui""" # temporary fix for CORS warning (QTBUG-70228) sys.argv.append("--disable-web-security") # stop auto scaling on windows # os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" # stop auto scaling on windows - part 2 # app.setAttribute(QtCore.Qt.AA_DisableHighDpiScaling) # app.setStyleSheet(AppStyle.load_stylesheet()) cfg_dir = GuiSettings.config_default() logger.info("Using config {}".format(cfg_dir)) config = QaxConfig(Path(cfg_dir)) config.load() plugins = QaxPlugins() plugins.load(config) main_win = MainWin() main_win.initialize() sys.excepthook = main_win.exception_hook # install the exception hook main_win.show() if dev_mode: main_win.do() sys.exit(app.exec_())
def update_plugin_tabs(self): """ Updates what plugins are shown in the bottom tabs """ for plugin_tab in self.plugin_tabs: plugin_tab.setParent(None) self.plugin_tabs.clear() if self.profile is None: return # get plugin instances for current profile from singleton plugins = (QaxPlugins.instance().get_profile_plugins( self.profile).plugins) for plugin in plugins: plugin_tab = PluginTab(parent_win=self, prj=self.prj, plugin=plugin) plugin_tab.plugin_changed.connect(self._on_plugin_changed) self.plugin_tabs.append(plugin_tab) icon_path = GuiSettings.icon_path(plugin.icon) if icon_path is not None: tab_index = self.tabs.addTab(plugin_tab, QtGui.QIcon(icon_path), "") else: tab_index = self.tabs.addTab(plugin_tab, plugin.name) self.tabs.setTabToolTip(tab_index, plugin.name)
def _build_qa_json(self) -> QajsonRoot: """ Builds a QA JSON root object based on the information currently entered into the user interface. """ root = QajsonRoot(None) # update the qajson object with the check tool details for config_check_tool in self.tab_inputs.selected_check_tools: plugin_check_tool = QaxPlugins.instance().get_plugin( self.profile.name, config_check_tool.plugin_class) # update the `root` qa json object with the selected checks plugin_check_tool.update_qa_json(root) # get a list of user selected files from the relevant controls # for this plugin (based on the file groups) file_groups = plugin_check_tool.get_file_groups() all_files = self.tab_inputs.file_group_selection.get_files( file_groups) # update the `root` qa json object with files selected by the # user plugin_check_tool.update_qa_json_input_files(root, all_files) # get the plugin tab for the current check tool plugin_tab = next((ptab for ptab in self.tab_plugins.plugin_tabs if ptab.plugin == plugin_check_tool), None) if plugin_tab is None: raise RuntimeError("No plugin tab found for {}".format( config_check_tool.name)) check_param_details = plugin_tab.get_check_ids_and_params() for (check_id, params) in check_param_details: plugin_check_tool.update_qa_json_input_params( root, check_id, params) return root
def test_qa_json_generation(self): qa_json = QajsonRoot(qa=None) plugins = QaxPlugins() check_tool_plugin = plugins._load_plugin( TestQaxPlugins.check_tool_profile, TestQaxPlugins.check_tool_config) check_tool_plugin_other = plugins._load_plugin( TestQaxPlugins.check_tool_profile, TestQaxPlugins.check_tool_config_other) check_tool_plugin.update_qa_json(qa_json) check_tool_plugin_other.update_qa_json(qa_json) files = [ (Path('/my/test/bagfile.bag'), 'Raw Files'), (Path('/my/test/csarfile.csar'), 'Raw Files'), (Path('/my/test/shpfile.shp'), 'Raw Files'), ] check_tool_plugin.update_qa_json_input_files(qa_json, files) check_tool_plugin_other.update_qa_json_input_files(qa_json, files)
def _on_check_tools_selected(self, check_tools): self.selected_check_tools = check_tools all_file_groups = [] for check_tool in check_tools: check_tool_plugin = QaxPlugins.instance().get_plugin( self.selected_profile.name, check_tool.plugin_class) file_groups = check_tool_plugin.get_file_groups() all_file_groups.extend(file_groups) unique_file_groups = QaxFileGroup.merge(all_file_groups) if self.file_group_selection is not None: # it may be None during initialisation self.file_group_selection.update_file_groups(unique_file_groups) self.check_inputs_changed.emit()
def __init__(self, qa_json: QajsonRoot, profile_name: str, check_tool_class_names: List[str]): self.qa_json = qa_json self.profile_name = profile_name self.check_tool_class_names = check_tool_class_names self.current_check_number = 1 self.stopped = False self.status = "Not started" # dictionary containing some options that will be passed to each check # includes things lke location to write spatial outputs too, what # spatial outputs to write self.options = {} self.check_tools = [ QaxPlugins.instance().get_plugin(self.profile_name, check_tool_class_name) for check_tool_class_name in self.check_tool_class_names ]
def test_load_plugin(self): plugins = QaxPlugins() check_tool_plugin = plugins._load_plugin( TestQaxPlugins.check_tool_profile, TestQaxPlugins.check_tool_config) self.assertIsInstance(check_tool_plugin, MyPlugin)