Skip to content

Commit d3718e2

Browse files
authored
fix: phase 0 quick fixes for the usability plan (#131)
* docs: add a plan for a guided modelling workflow Describe the current usability problems, a step-based dock, a direct interpolation entry, and derived data that is updated when its inputs change. Split the work into phases. * fix: quick fixes to the toolbar, adjacency legend and success messages Add each toolbar action one time and call initProcessing one time. Show the fault adjacency instructions. Show one message for the basal contacts result. Show success results in the message bar. Ask for confirmation before the stratigraphic column is cleared. Delete the unused .ui files, and keep export_tab.ui for the export step. * fix: use pushMessage so the message bar accepts a duration QgsMessageBar.pushSuccess, pushInfo and pushWarning do not accept a duration argument. This caused a TypeError when a tool showed a success message. * style: format messages.py with black
1 parent a179940 commit d3718e2

12 files changed

Lines changed: 440 additions & 536 deletions

File tree

‎docs/development/usability-plan.md‎

Lines changed: 370 additions & 0 deletions
Large diffs are not rendered by default.

‎docs/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ development/translation
3434
development/packaging
3535
development/testing
3636
development/history
37+
development/usability-plan
3738
```

‎loopstructural/gui/map2loop_tools/basal_contacts_widget.py‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ...main.vectorLayerWrapper import addGeoDataFrameToproject
1313
from ..background_task import finish_background_task, start_background_task
1414
from ..compatibility import configure_layer_combo
15+
from ..messages import push_success, push_warning
1516

1617

1718
class BasalContactsWidget(QWidget):
@@ -268,16 +269,13 @@ def _on_extractor_finished(self, payload):
268269
basal_layer, 'basal_unit'
269270
)
270271
else:
271-
QMessageBox.information(
272-
self,
273-
"No Contacts Found",
274-
"No contacts were found with the given parameters.",
272+
contact_type = None
273+
if contact_type is None:
274+
push_warning(
275+
"No Contacts Found", "No contacts were found with the given parameters."
275276
)
276-
QMessageBox.information(
277-
self,
278-
"Success",
279-
f"Successfully extracted {contact_type}!",
280-
)
277+
else:
278+
push_success("Basal Contacts", f"Successfully extracted {contact_type}.")
281279
if self._debug and self._debug.is_debug():
282280
try:
283281
self._debug.save_debug_file(

‎loopstructural/gui/map2loop_tools/thickness_calculator_widget.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from loopstructural.gui.background_task import finish_background_task, start_background_task
1212
from loopstructural.gui.compatibility import configure_layer_combo
13+
from loopstructural.gui.messages import push_success
1314
from loopstructural.toolbelt.preferences import PlgOptionsManager
1415

1516
from ...main.helpers import ColumnMatcher, get_layer_names
@@ -468,25 +469,23 @@ def _on_calculator_finished(self, result):
468469
addGeoDataFrameToproject(lines, "Thickness Lines")
469470
if location_tracking is not None:
470471
addGeoDataFrameToproject(location_tracking, "Thickness Locations")
471-
QMessageBox.information(
472-
self,
473-
"Success",
472+
push_success(
473+
"Thickness Calculator",
474474
"Thickness calculation completed successfully and added to project.",
475475
)
476476
self.task_succeeded.emit()
477477
return
478478

479479
if hasattr(result, 'geometry'):
480480
addGeoDataFrameToproject(result, "Thickness Results")
481-
QMessageBox.information(
482-
self,
483-
"Success",
481+
push_success(
482+
"Thickness Calculator",
484483
"Thickness calculation completed successfully and added to project.",
485484
)
486485
self.task_succeeded.emit()
487486
return
488487

489-
QMessageBox.information(self, "Success", f"Thickness calculation completed: {result}")
488+
push_success("Thickness Calculator", f"Thickness calculation completed: {result}")
490489
self.task_succeeded.emit()
491490

492491
def _on_calculator_error(self, traceback_text):

‎loopstructural/gui/messages.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""Show the result of an action without a modal dialog."""
2+
3+
from qgis.core import Qgis, QgsMessageLog
4+
from qgis.utils import iface
5+
6+
7+
def push_success(title: str, text: str, duration: int = 5):
8+
"""Show a success message in the message bar of QGIS.
9+
10+
Use a `QMessageBox` only for an error that stops an action, and for the
11+
confirmation before a destructive action.
12+
"""
13+
if iface is not None:
14+
iface.messageBar().pushMessage(
15+
title, text, level=Qgis.MessageLevel.Success, duration=duration
16+
)
17+
else:
18+
# No main window, for example in the tests
19+
QgsMessageLog.logMessage(f"{title}: {text}", "LoopStructural", Qgis.MessageLevel.Success)
20+
21+
22+
def push_info(title: str, text: str, duration: int = 5):
23+
"""Show an information message in the message bar of QGIS."""
24+
if iface is not None:
25+
iface.messageBar().pushMessage(title, text, level=Qgis.MessageLevel.Info, duration=duration)
26+
else:
27+
QgsMessageLog.logMessage(f"{title}: {text}", "LoopStructural", Qgis.MessageLevel.Info)
28+
29+
30+
def push_warning(title: str, text: str, duration: int = 10):
31+
"""Show a warning in the message bar of QGIS, for a result that is not an error."""
32+
if iface is not None:
33+
iface.messageBar().pushMessage(
34+
title, text, level=Qgis.MessageLevel.Warning, duration=duration
35+
)
36+
else:
37+
QgsMessageLog.logMessage(f"{title}: {text}", "LoopStructural", Qgis.MessageLevel.Warning)

‎loopstructural/gui/modelling/fault_adjacency_tab.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def init_ui(self):
3838
)
3939
self.fault_fault_instructions_label = QLabel(self.fault_fault_instructions)
4040
self.fault_fault_instructions_label.setWordWrap(True)
41+
self.fault_table_layout.addWidget(self.fault_fault_instructions_label)
4142
self.update_fault_adjacency_table()
4243
self.layout().addWidget(self.fault_table_group)
4344

@@ -51,6 +52,7 @@ def init_ui(self):
5152
)
5253
self.strat_fault_instructions_label = QLabel(self.strat_fault_instructions)
5354
self.strat_fault_instructions_label.setWordWrap(True)
55+
self.stratigraphic_table_layout.addWidget(self.strat_fault_instructions_label)
5456
self.update_stratigraphic_units_table()
5557

5658
self.layout().addWidget(self.stratigraphic_table_group)

0 commit comments

Comments
 (0)