Skip to content

Commit 038a009

Browse files
fix: close ml2 widgets when tool has been run successfully
* Initial plan * Close map2loop dialogs after successful runs Co-authored-by: lachlangrose <7371904+lachlangrose@users.noreply.github.com> * fix: add boolean return for painter --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lachlangrose <7371904+lachlangrose@users.noreply.github.com> Co-authored-by: Lachlan Grose <lachlan.grose@monash.edu>
1 parent ad69700 commit 038a009

8 files changed

Lines changed: 208 additions & 190 deletions

File tree

loopstructural/gui/map2loop_tools/basal_contacts_widget.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _run_extractor(self):
177177
# Validate inputs
178178
if not self.geologyLayerComboBox.currentLayer():
179179
QMessageBox.warning(self, "Missing Input", "Please select a geology layer.")
180-
return
180+
return False
181181

182182
try:
183183
result, contact_type = self._extract_contacts()
@@ -197,6 +197,7 @@ def _run_extractor(self):
197197
message=f"[map2loop] Failed to save basal contacts debug output: {err}",
198198
log_level=2,
199199
)
200+
return True
200201
except Exception as err:
201202
if self._debug:
202203
self._debug.plugin.log(
@@ -205,6 +206,7 @@ def _run_extractor(self):
205206
)
206207
raise err
207208
QMessageBox.critical(self, "Error", f"An error occurred: {err}")
209+
return False
208210

209211
def get_parameters(self):
210212
"""Get current widget parameters.

loopstructural/gui/map2loop_tools/dialogs.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def setup_ui(self):
3636

3737
def _run_and_accept(self):
3838
"""Run the sampler and accept dialog if successful."""
39-
self.widget._run_sampler()
40-
# Dialog stays open so user can see the result
39+
if self.widget._run_sampler():
40+
self.accept()
4141

4242

4343
class SorterDialog(QDialog):
@@ -73,7 +73,8 @@ def setup_ui(self):
7373

7474
def _run_and_accept(self):
7575
"""Run the sorter and accept dialog if successful."""
76-
self.widget._run_sorter()
76+
if self.widget._run_sorter():
77+
self.accept()
7778

7879

7980
class UserDefinedSorterDialog(QDialog):
@@ -101,16 +102,15 @@ def setup_ui(self):
101102
layout.addWidget(self.widget)
102103

103104
# Replace the run button with dialog buttons
104-
# self.widget.runButton.hide()
105-
106-
# self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
107-
# self.button_box.accepted.connect(self._run_and_accept)
108-
# self.button_box.rejected.connect(self.reject)
109-
# layout.addWidget(self.button_box)
105+
self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
106+
self.button_box.accepted.connect(self._run_and_accept)
107+
self.button_box.rejected.connect(self.reject)
108+
layout.addWidget(self.button_box)
110109

111110
def _run_and_accept(self):
112111
"""Run the sorter and accept dialog if successful."""
113-
self.widget._run_sorter()
112+
if self.widget._run_sorter():
113+
self.accept()
114114

115115

116116
class BasalContactsDialog(QDialog):
@@ -146,7 +146,8 @@ def setup_ui(self):
146146

147147
def _run_and_accept(self):
148148
"""Run the extractor and accept dialog if successful."""
149-
self.widget._run_extractor()
149+
if self.widget._run_extractor():
150+
self.accept()
150151

151152

152153
class ThicknessCalculatorDialog(QDialog):
@@ -182,7 +183,8 @@ def setup_ui(self):
182183

183184
def _run_and_accept(self):
184185
"""Run the calculator and accept dialog if successful."""
185-
self.widget._run_calculator()
186+
if self.widget._run_calculator():
187+
self.accept()
186188

187189

188190
class PaintStratigraphicOrderDialog(QDialog):
@@ -218,5 +220,5 @@ def setup_ui(self):
218220

219221
def _run_and_accept(self):
220222
"""Run the painter and accept dialog if successful."""
221-
self.widget._run_painter()
222-
223+
if self.widget._run_painter():
224+
self.accept()

loopstructural/gui/map2loop_tools/fault_topology_widget.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@ def _run_topology(self):
9090
# addGeoDataFrameToproject(gdf, "Input Faults")
9191
# addGeoDataFrameToproject(df, "Fault Topology Table")
9292
QMessageBox.information(self, "Success", f"Calculated fault topology for {len(df)} pairs.")
93+
return True

0 commit comments

Comments
 (0)