From db71116ff6190e0a34c8aacd59ff28f78a4b71e2 Mon Sep 17 00:00:00 2001 From: bordoray Date: Thu, 10 Aug 2023 15:22:53 +0900 Subject: [PATCH 1/3] Implement new way of start process --- ui/main_dialog.py | 14 +++++++++----- ui/main_dialog.ui | 7 ------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ui/main_dialog.py b/ui/main_dialog.py index 0df0d34..7e8afea 100644 --- a/ui/main_dialog.py +++ b/ui/main_dialog.py @@ -3,7 +3,7 @@ import sip from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QDialog, QMessageBox, QTreeWidgetItem +from PyQt5.QtWidgets import QDialog, QMessageBox, QTreeWidgetItem, QFileDialog from qgis.PyQt.QtGui import QIcon from qgis.core import ( QgsMapLayerModel, @@ -58,17 +58,21 @@ def init_ui(self): self.process_node ) - def _get_excution_params(self): + def _get_execution_params(self): params = { "extent": self.ui.mExtentGroupBox.outputExtent(), - "output_dir": self.ui.outputFileWidget.filePath(), + "output_dir": QFileDialog.getExistingDirectory(self, "Select Folder"), } return params def _run(self): layers = self._get_checked_layers() - params = self._get_excution_params() + params = self._get_execution_params() + + # close process when push cancel button on when select folder + if params["output_dir"] == "": + return # generate label vector includes labels of all layers all_labels = generate_label_vector(params["extent"]) @@ -144,7 +148,7 @@ def _run(self): } write_json( project_json, - os.path.join(self.ui.outputFileWidget.filePath(), "project.json"), + os.path.join(params["output_dir"], "project.json"), ) # messaging diff --git a/ui/main_dialog.ui b/ui/main_dialog.ui index ec31dbe..5a218cf 100644 --- a/ui/main_dialog.ui +++ b/ui/main_dialog.ui @@ -46,13 +46,6 @@ - - - - QgsFileWidget::GetDirectory - - - From 8b17f5c65a29eb81f928eb78e9b9dc3ff5779f6c Mon Sep 17 00:00:00 2001 From: bordoray Date: Thu, 10 Aug 2023 15:32:13 +0900 Subject: [PATCH 2/3] Button wording --- ui/main_dialog.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/main_dialog.ui b/ui/main_dialog.ui index 5a218cf..411453b 100644 --- a/ui/main_dialog.ui +++ b/ui/main_dialog.ui @@ -51,7 +51,7 @@ - 処理開始 + 出力フォルダーを選択して実行 From 763d1b0e835050ecd11ae848bc99b61377bcd57c Mon Sep 17 00:00:00 2001 From: bordoray Date: Thu, 10 Aug 2023 16:09:46 +0900 Subject: [PATCH 3/3] Refactor --- ui/main_dialog.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/ui/main_dialog.py b/ui/main_dialog.py index 7e8afea..7e37fb8 100644 --- a/ui/main_dialog.py +++ b/ui/main_dialog.py @@ -58,22 +58,18 @@ def init_ui(self): self.process_node ) - def _get_execution_params(self): - params = { - "extent": self.ui.mExtentGroupBox.outputExtent(), - "output_dir": QFileDialog.getExistingDirectory(self, "Select Folder"), - } - - return params - def _run(self): layers = self._get_checked_layers() - params = self._get_execution_params() - # close process when push cancel button on when select folder - if params["output_dir"] == "": + output_dir = QFileDialog.getExistingDirectory(self, "Select Folder") + if output_dir == "": return + params = { + "extent": self.ui.mExtentGroupBox.outputExtent(), + "output_dir": output_dir, + } + # generate label vector includes labels of all layers all_labels = generate_label_vector(params["extent"])