diff --git a/QgisModelBaker/gui/ili2db_options.py b/QgisModelBaker/gui/ili2db_options.py index 65031af41..55aaf8111 100644 --- a/QgisModelBaker/gui/ili2db_options.py +++ b/QgisModelBaker/gui/ili2db_options.py @@ -191,6 +191,9 @@ def set_toml_file_key(self, key_postfix): self.toml_file_key = None self.restore_configuration() + def set_toml_file(self, toml_file): + self.toml_file_line_edit.setText(toml_file) + def toml_file(self): return self.toml_file_line_edit.text().strip() diff --git a/QgisModelBaker/gui/workflow_wizard/workflow_wizard.py b/QgisModelBaker/gui/workflow_wizard/workflow_wizard.py index 7174fa38a..cd580dffb 100644 --- a/QgisModelBaker/gui/workflow_wizard/workflow_wizard.py +++ b/QgisModelBaker/gui/workflow_wizard/workflow_wizard.py @@ -16,6 +16,7 @@ * * ***************************************************************************/ """ +import logging import os import pathlib import re @@ -578,13 +579,25 @@ def add_source(self, source, origin_info): path = None return self.source_model.add_source(name, type, path, origin_info) - def append_dropped_files(self, dropped_files): + def append_dropped_files(self, dropped_files, dropped_ini_files): if dropped_files: for dropped_file in dropped_files: self.add_source( dropped_file, self.tr("Added by user with drag'n'drop.") ) + if dropped_ini_files: + if len(dropped_ini_files) > 1: + logging.warning( + "Only one INI/TOML file is supported by drag&drop: {}".format( + dropped_ini_files + ) + ) + + self.schema_configuration_page.ili2db_options.set_toml_file( + dropped_ini_files[0] + ) + class WorkflowWizardDialog(QDialog): def __init__(self, iface, base_config, parent): @@ -607,10 +620,10 @@ def __init__(self, iface, base_config, parent): layout.addWidget(splitter) self.setLayout(layout) - def append_dropped_files(self, dropped_files): + def append_dropped_files(self, dropped_files, dropped_ini_files): """ Appends the files, restarts the wizard and jumps to the next page (what is ImportSourceSelection) """ - self.workflow_wizard.append_dropped_files(dropped_files) + self.workflow_wizard.append_dropped_files(dropped_files, dropped_ini_files) self.workflow_wizard.restart() self.workflow_wizard.next() diff --git a/QgisModelBaker/qgismodelbaker.py b/QgisModelBaker/qgismodelbaker.py index 9acaf34a3..0383c34a9 100644 --- a/QgisModelBaker/qgismodelbaker.py +++ b/QgisModelBaker/qgismodelbaker.py @@ -458,11 +458,11 @@ def create_project( qgis_project = QgsProject.instance() project.create(None, qgis_project, group) - def handle_dropped_files(self, dropped_files): + def handle_dropped_files(self, dropped_files, dropped_ini_files): if not self.workflow_wizard_dlg: self._set_dropped_file_configuration() self.show_workflow_wizard_dialog() - self.workflow_wizard_dlg.append_dropped_files(dropped_files) + self.workflow_wizard_dlg.append_dropped_files(dropped_files, dropped_ini_files) return True def _set_dropped_file_configuration(self): @@ -538,10 +538,18 @@ def eventFilter(self, obj, event): for url in event.mimeData().urls() if pathlib.Path(url.toLocalFile()).suffix[1:] in ["xml", "XML"] ] + additional_ini_files = [ + url.toLocalFile() + for url in event.mimeData().urls() + if pathlib.Path(url.toLocalFile()).suffix[1:] + in ["ini", "INI", "toml", "TOML"] + ] if dropped_files: - if self._is_handling_requested(dropped_files + additional_xml_files): + if self._is_handling_requested( + dropped_files + additional_xml_files + additional_ini_files + ): if self.parent.handle_dropped_files( - dropped_files + additional_xml_files + dropped_files + additional_xml_files, additional_ini_files ): return True return False