From b060c0254044ebf245a0f381748f411b1a593449 Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 11:55:52 +0000 Subject: [PATCH 01/14] Using valueChanged rather than editingFinished --- mantidimaging/gui/utility/qt_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mantidimaging/gui/utility/qt_helpers.py b/mantidimaging/gui/utility/qt_helpers.py index 6d04b63ee96..8bbf83c0b74 100644 --- a/mantidimaging/gui/utility/qt_helpers.py +++ b/mantidimaging/gui/utility/qt_helpers.py @@ -136,13 +136,13 @@ def set_spin_box(box, cast_func): right_widget = Qt.QSpinBox() set_spin_box(right_widget, int) if on_change is not None: - right_widget.editingFinished.connect(lambda: on_change()) + right_widget.valueChanged.connect(lambda: on_change()) elif dtype == 'float' or dtype == Type.FLOAT: right_widget = Qt.QDoubleSpinBox() set_spin_box(right_widget, float) if on_change is not None: - right_widget.editingFinished.connect(lambda: on_change()) + right_widget.valueChanged.connect(lambda: on_change()) elif dtype == 'bool' or dtype == Type.BOOL: right_widget = Qt.QCheckBox() From cf21fa0882691889da3b55103991062017873ae1 Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 14:35:31 +0000 Subject: [PATCH 02/14] Making signal send an object argument --- mantidimaging/gui/utility/qt_helpers.py | 12 ++++++------ mantidimaging/gui/windows/operations/presenter.py | 8 +++----- mantidimaging/gui/windows/operations/view.py | 15 +++++++++++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/mantidimaging/gui/utility/qt_helpers.py b/mantidimaging/gui/utility/qt_helpers.py index 8bbf83c0b74..aaabe81a53a 100644 --- a/mantidimaging/gui/utility/qt_helpers.py +++ b/mantidimaging/gui/utility/qt_helpers.py @@ -130,19 +130,19 @@ def set_spin_box(box, cast_func): right_widget.setText(default_value) if on_change is not None: - right_widget.editingFinished.connect(lambda: on_change()) + right_widget.editingFinished.connect(lambda: on_change(None)) elif dtype == 'int' or dtype == Type.INT: right_widget = Qt.QSpinBox() set_spin_box(right_widget, int) if on_change is not None: - right_widget.valueChanged.connect(lambda: on_change()) + right_widget.valueChanged.connect(lambda: on_change(None)) elif dtype == 'float' or dtype == Type.FLOAT: right_widget = Qt.QDoubleSpinBox() set_spin_box(right_widget, float) if on_change is not None: - right_widget.valueChanged.connect(lambda: on_change()) + right_widget.valueChanged.connect(lambda: on_change(None)) elif dtype == 'bool' or dtype == Type.BOOL: right_widget = Qt.QCheckBox() @@ -157,7 +157,7 @@ def set_spin_box(box, cast_func): raise ValueError(f"Cannot convert value {default_value} to a Boolean.") if on_change is not None: - right_widget.stateChanged[int].connect(lambda: on_change()) + right_widget.stateChanged[int].connect(lambda: on_change(None)) elif dtype == "choice" or dtype == Type.CHOICE: right_widget = Qt.QComboBox() @@ -165,13 +165,13 @@ def set_spin_box(box, cast_func): if valid_values: right_widget.addItems(valid_values) if on_change is not None: - right_widget.currentIndexChanged[int].connect(lambda: on_change()) + right_widget.currentIndexChanged[int].connect(lambda: on_change(None)) elif dtype == 'stack' or dtype == Type.STACK: from mantidimaging.gui.widgets.stack_selector import StackSelectorWidgetView right_widget = StackSelectorWidgetView(filters_view) if on_change is not None: - right_widget.currentIndexChanged[int].connect(lambda: on_change()) + right_widget.currentIndexChanged[int].connect(lambda: on_change(None)) elif dtype == 'button' or dtype == Type.BUTTON: left_widget = Qt.QPushButton(label) diff --git a/mantidimaging/gui/windows/operations/presenter.py b/mantidimaging/gui/windows/operations/presenter.py index 3c4eab68fbd..15f18692450 100644 --- a/mantidimaging/gui/windows/operations/presenter.py +++ b/mantidimaging/gui/windows/operations/presenter.py @@ -103,7 +103,7 @@ def set_preview_image_index(self, image_idx): preview_idx_spin.setValue(self.model.preview_image_idx) # Trigger preview updating - self.view.auto_update_triggered.emit() + self.view.auto_update_triggered.emit(None) def do_register_active_filter(self): filter_name = self.view.filterSelector.currentText() @@ -220,8 +220,7 @@ def _do_apply_filter_sync(self, apply_to): def do_update_previews(self): self.view.clear_previews() - # Disable preview image index scrollbox to prevent double-increase - self.view.previewImageIndex.setEnabled(False) + self.view.disable_spin_boxes() if self.stack is not None: stack_presenter = self.stack.presenter subset: Images = stack_presenter.get_image(self.model.preview_image_idx) @@ -255,8 +254,7 @@ def do_update_previews(self): # Ensure all of it is visible self.view.previews.auto_range() - # Enable preview image index box when preview has been created - self.view.previewImageIndex.setEnabled(True) + self.view.enable_spin_boxes() @staticmethod def _update_preview_image(image_data: Optional[np.ndarray], image: ImageItem): diff --git a/mantidimaging/gui/windows/operations/view.py b/mantidimaging/gui/windows/operations/view.py index dcea55ffed8..8e50089eda6 100644 --- a/mantidimaging/gui/windows/operations/view.py +++ b/mantidimaging/gui/windows/operations/view.py @@ -24,7 +24,7 @@ class FiltersWindowView(BaseMainWindowView): - auto_update_triggered = Qt.pyqtSignal() + auto_update_triggered = Qt.pyqtSignal(object) splitter: QSplitter collapseToggleButton: QPushButton @@ -66,7 +66,7 @@ def __init__(self, main_window: 'MainWindowView'): # Handle stack selection self.stackSelector.stack_selected_uuid.connect(self.presenter.set_stack_uuid) - self.stackSelector.stack_selected_uuid.connect(self.auto_update_triggered.emit) + self.stackSelector.stack_selected_uuid.connect(lambda: self.auto_update_triggered.emit(None)) # Handle apply filter self.applyButton.clicked.connect(lambda: self.presenter.notify(PresNotification.APPLY_FILTER)) @@ -113,7 +113,7 @@ def cleanup(self): def show(self): super(FiltersWindowView, self).show() - self.auto_update_triggered.emit() + self.auto_update_triggered.emit(None) def handle_filter_selection(self, filter_name: str): """ @@ -131,7 +131,7 @@ def handle_filter_selection(self, filter_name: str): # Update preview on filter selection (on the off chance the default # options are valid) - self.auto_update_triggered.emit() + self.auto_update_triggered.emit(None) def on_auto_update_triggered(self): """ @@ -288,3 +288,10 @@ def toggle_filters_section(self): else: self.splitter.setSizes([200, 9999]) self.collapseToggleButton.setText("<<") + + def disable_spin_boxes(self): + self.previewImageIndex.setEnabled(False) + print(self.filterPropertiesLayout) + + def enable_spin_boxes(self): + self.previewImageIndex.setEnabled(True) From a39977ea53a5c183f70cbf697df1b8e667027315 Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 14:37:16 +0000 Subject: [PATCH 03/14] Sending spinboxes in signal --- mantidimaging/gui/utility/qt_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mantidimaging/gui/utility/qt_helpers.py b/mantidimaging/gui/utility/qt_helpers.py index aaabe81a53a..101fcdb04ef 100644 --- a/mantidimaging/gui/utility/qt_helpers.py +++ b/mantidimaging/gui/utility/qt_helpers.py @@ -136,13 +136,13 @@ def set_spin_box(box, cast_func): right_widget = Qt.QSpinBox() set_spin_box(right_widget, int) if on_change is not None: - right_widget.valueChanged.connect(lambda: on_change(None)) + right_widget.valueChanged.connect(lambda: on_change(right_widget)) elif dtype == 'float' or dtype == Type.FLOAT: right_widget = Qt.QDoubleSpinBox() set_spin_box(right_widget, float) if on_change is not None: - right_widget.valueChanged.connect(lambda: on_change(None)) + right_widget.valueChanged.connect(lambda: on_change(right_widget)) elif dtype == 'bool' or dtype == Type.BOOL: right_widget = Qt.QCheckBox() From f7f246e8271220354c37556eaa56b045e77f4d2f Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 14:54:23 +0000 Subject: [PATCH 04/14] Extra on_change changes --- mantidimaging/core/operations/rebin/rebin.py | 4 ++-- mantidimaging/core/operations/remove_stripe/stripe_removal.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mantidimaging/core/operations/rebin/rebin.py b/mantidimaging/core/operations/rebin/rebin.py index 7e71837d122..09129f430ee 100644 --- a/mantidimaging/core/operations/rebin/rebin.py +++ b/mantidimaging/core/operations/rebin/rebin.py @@ -88,7 +88,7 @@ def register_gui(form, on_change, view): def size_by_factor_toggled(enabled): factor.setEnabled(enabled) - on_change() + on_change(None) rebin_by_factor_radio.toggled.connect(size_by_factor_toggled) @@ -97,7 +97,7 @@ def size_by_factor_toggled(enabled): def size_by_dimensions_toggled(enabled): shape_x.setEnabled(enabled) shape_y.setEnabled(enabled) - on_change() + on_change(None) rebin_to_dimensions_radio.toggled.connect(size_by_dimensions_toggled) diff --git a/mantidimaging/core/operations/remove_stripe/stripe_removal.py b/mantidimaging/core/operations/remove_stripe/stripe_removal.py index d7b39111301..13dc652c749 100644 --- a/mantidimaging/core/operations/remove_stripe/stripe_removal.py +++ b/mantidimaging/core/operations/remove_stripe/stripe_removal.py @@ -148,7 +148,7 @@ def on_filter_type_change(name): enabled = name == f[0] for ui_item in f[1]: ui_item.setEnabled(enabled) - on_change() + on_change(None) value_filter_type.addItems([f[0] for f in filters]) value_filter_type.currentIndexChanged[str].connect(on_filter_type_change) From 2efc70442268b9dbe663dfe8afcfb8805205f1a0 Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 14:54:39 +0000 Subject: [PATCH 05/14] Using widget argument in on_auto_update_triggered --- mantidimaging/gui/windows/operations/view.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mantidimaging/gui/windows/operations/view.py b/mantidimaging/gui/windows/operations/view.py index 8e50089eda6..1e04eafb0d1 100644 --- a/mantidimaging/gui/windows/operations/view.py +++ b/mantidimaging/gui/windows/operations/view.py @@ -133,15 +133,25 @@ def handle_filter_selection(self, filter_name: str): # options are valid) self.auto_update_triggered.emit(None) - def on_auto_update_triggered(self): + def on_auto_update_triggered(self, widget=None): """ Called when the signal indicating the filter, filter properties or data has changed such that the previews are now out of date. """ + # Disable the spinbox widgets that are prone to misbehaving when generating a preview takes too long + self.previewImageIndex.setEnabled(False) + if widget is not None: + widget.setEnabled(False) + self.clear_notification_dialog() if self.previewAutoUpdate.isChecked() and self.isVisible(): self.presenter.notify(PresNotification.UPDATE_PREVIEWS) + # Enable the spinbox widgets once the preview is done + self.previewImageIndex.setEnabled(True) + if widget is not None: + widget.setEnabled(True) + def clear_previews(self): self.previews.clear_items() @@ -290,8 +300,7 @@ def toggle_filters_section(self): self.collapseToggleButton.setText("<<") def disable_spin_boxes(self): - self.previewImageIndex.setEnabled(False) - print(self.filterPropertiesLayout) + pass def enable_spin_boxes(self): - self.previewImageIndex.setEnabled(True) + pass From cf34ba93ed3f1a629ee56d5449a72947f8053a9a Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 15:09:54 +0000 Subject: [PATCH 06/14] Far more simple --- mantidimaging/gui/utility/qt_helpers.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mantidimaging/gui/utility/qt_helpers.py b/mantidimaging/gui/utility/qt_helpers.py index 8bbf83c0b74..3c17deb7b8e 100644 --- a/mantidimaging/gui/utility/qt_helpers.py +++ b/mantidimaging/gui/utility/qt_helpers.py @@ -7,7 +7,7 @@ import os from enum import IntEnum, auto from logging import getLogger -from typing import Any, Tuple, Union, List +from typing import Any, Tuple, Union, List, Callable from PyQt5 import Qt from PyQt5 import uic # type: ignore @@ -76,6 +76,12 @@ class Type(IntEnum): BUTTON = auto() +def _on_change_and_disable(widget: QWidget, on_change: Callable): + widget.setEnabled(False) + on_change() + widget.setEnabled(True) + + def add_property_to_form(label: str, dtype: Union[Type, str], default_value=None, @@ -136,13 +142,13 @@ def set_spin_box(box, cast_func): right_widget = Qt.QSpinBox() set_spin_box(right_widget, int) if on_change is not None: - right_widget.valueChanged.connect(lambda: on_change()) + right_widget.valueChanged.connect(lambda: _on_change_and_disable(right_widget, on_change)) elif dtype == 'float' or dtype == Type.FLOAT: right_widget = Qt.QDoubleSpinBox() set_spin_box(right_widget, float) if on_change is not None: - right_widget.valueChanged.connect(lambda: on_change()) + right_widget.valueChanged.connect(lambda: _on_change_and_disable(right_widget, on_change)) elif dtype == 'bool' or dtype == Type.BOOL: right_widget = Qt.QCheckBox() From 75616a6c1208b5e803d83eabff19d1be10d13008 Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 15:24:08 +0000 Subject: [PATCH 07/14] Revert "Making signal send an object argument" This reverts commit cf21fa0882691889da3b55103991062017873ae1. --- mantidimaging/gui/utility/qt_helpers.py | 12 ++++++------ mantidimaging/gui/windows/operations/presenter.py | 8 +++++--- mantidimaging/gui/windows/operations/view.py | 14 ++++---------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/mantidimaging/gui/utility/qt_helpers.py b/mantidimaging/gui/utility/qt_helpers.py index 101fcdb04ef..8bbf83c0b74 100644 --- a/mantidimaging/gui/utility/qt_helpers.py +++ b/mantidimaging/gui/utility/qt_helpers.py @@ -130,19 +130,19 @@ def set_spin_box(box, cast_func): right_widget.setText(default_value) if on_change is not None: - right_widget.editingFinished.connect(lambda: on_change(None)) + right_widget.editingFinished.connect(lambda: on_change()) elif dtype == 'int' or dtype == Type.INT: right_widget = Qt.QSpinBox() set_spin_box(right_widget, int) if on_change is not None: - right_widget.valueChanged.connect(lambda: on_change(right_widget)) + right_widget.valueChanged.connect(lambda: on_change()) elif dtype == 'float' or dtype == Type.FLOAT: right_widget = Qt.QDoubleSpinBox() set_spin_box(right_widget, float) if on_change is not None: - right_widget.valueChanged.connect(lambda: on_change(right_widget)) + right_widget.valueChanged.connect(lambda: on_change()) elif dtype == 'bool' or dtype == Type.BOOL: right_widget = Qt.QCheckBox() @@ -157,7 +157,7 @@ def set_spin_box(box, cast_func): raise ValueError(f"Cannot convert value {default_value} to a Boolean.") if on_change is not None: - right_widget.stateChanged[int].connect(lambda: on_change(None)) + right_widget.stateChanged[int].connect(lambda: on_change()) elif dtype == "choice" or dtype == Type.CHOICE: right_widget = Qt.QComboBox() @@ -165,13 +165,13 @@ def set_spin_box(box, cast_func): if valid_values: right_widget.addItems(valid_values) if on_change is not None: - right_widget.currentIndexChanged[int].connect(lambda: on_change(None)) + right_widget.currentIndexChanged[int].connect(lambda: on_change()) elif dtype == 'stack' or dtype == Type.STACK: from mantidimaging.gui.widgets.stack_selector import StackSelectorWidgetView right_widget = StackSelectorWidgetView(filters_view) if on_change is not None: - right_widget.currentIndexChanged[int].connect(lambda: on_change(None)) + right_widget.currentIndexChanged[int].connect(lambda: on_change()) elif dtype == 'button' or dtype == Type.BUTTON: left_widget = Qt.QPushButton(label) diff --git a/mantidimaging/gui/windows/operations/presenter.py b/mantidimaging/gui/windows/operations/presenter.py index 15f18692450..3c4eab68fbd 100644 --- a/mantidimaging/gui/windows/operations/presenter.py +++ b/mantidimaging/gui/windows/operations/presenter.py @@ -103,7 +103,7 @@ def set_preview_image_index(self, image_idx): preview_idx_spin.setValue(self.model.preview_image_idx) # Trigger preview updating - self.view.auto_update_triggered.emit(None) + self.view.auto_update_triggered.emit() def do_register_active_filter(self): filter_name = self.view.filterSelector.currentText() @@ -220,7 +220,8 @@ def _do_apply_filter_sync(self, apply_to): def do_update_previews(self): self.view.clear_previews() - self.view.disable_spin_boxes() + # Disable preview image index scrollbox to prevent double-increase + self.view.previewImageIndex.setEnabled(False) if self.stack is not None: stack_presenter = self.stack.presenter subset: Images = stack_presenter.get_image(self.model.preview_image_idx) @@ -254,7 +255,8 @@ def do_update_previews(self): # Ensure all of it is visible self.view.previews.auto_range() - self.view.enable_spin_boxes() + # Enable preview image index box when preview has been created + self.view.previewImageIndex.setEnabled(True) @staticmethod def _update_preview_image(image_data: Optional[np.ndarray], image: ImageItem): diff --git a/mantidimaging/gui/windows/operations/view.py b/mantidimaging/gui/windows/operations/view.py index 1e04eafb0d1..b71ff10b15a 100644 --- a/mantidimaging/gui/windows/operations/view.py +++ b/mantidimaging/gui/windows/operations/view.py @@ -24,7 +24,7 @@ class FiltersWindowView(BaseMainWindowView): - auto_update_triggered = Qt.pyqtSignal(object) + auto_update_triggered = Qt.pyqtSignal() splitter: QSplitter collapseToggleButton: QPushButton @@ -66,7 +66,7 @@ def __init__(self, main_window: 'MainWindowView'): # Handle stack selection self.stackSelector.stack_selected_uuid.connect(self.presenter.set_stack_uuid) - self.stackSelector.stack_selected_uuid.connect(lambda: self.auto_update_triggered.emit(None)) + self.stackSelector.stack_selected_uuid.connect(self.auto_update_triggered.emit) # Handle apply filter self.applyButton.clicked.connect(lambda: self.presenter.notify(PresNotification.APPLY_FILTER)) @@ -113,7 +113,7 @@ def cleanup(self): def show(self): super(FiltersWindowView, self).show() - self.auto_update_triggered.emit(None) + self.auto_update_triggered.emit() def handle_filter_selection(self, filter_name: str): """ @@ -131,7 +131,7 @@ def handle_filter_selection(self, filter_name: str): # Update preview on filter selection (on the off chance the default # options are valid) - self.auto_update_triggered.emit(None) + self.auto_update_triggered.emit() def on_auto_update_triggered(self, widget=None): """ @@ -298,9 +298,3 @@ def toggle_filters_section(self): else: self.splitter.setSizes([200, 9999]) self.collapseToggleButton.setText("<<") - - def disable_spin_boxes(self): - pass - - def enable_spin_boxes(self): - pass From 0e892bb5c1a6f924e47fc01d71b0fd3197820c76 Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 15:26:54 +0000 Subject: [PATCH 08/14] further reverting --- mantidimaging/core/operations/rebin/rebin.py | 4 ++-- .../core/operations/remove_stripe/stripe_removal.py | 2 +- mantidimaging/gui/windows/operations/view.py | 6 +----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/mantidimaging/core/operations/rebin/rebin.py b/mantidimaging/core/operations/rebin/rebin.py index 09129f430ee..7e71837d122 100644 --- a/mantidimaging/core/operations/rebin/rebin.py +++ b/mantidimaging/core/operations/rebin/rebin.py @@ -88,7 +88,7 @@ def register_gui(form, on_change, view): def size_by_factor_toggled(enabled): factor.setEnabled(enabled) - on_change(None) + on_change() rebin_by_factor_radio.toggled.connect(size_by_factor_toggled) @@ -97,7 +97,7 @@ def size_by_factor_toggled(enabled): def size_by_dimensions_toggled(enabled): shape_x.setEnabled(enabled) shape_y.setEnabled(enabled) - on_change(None) + on_change() rebin_to_dimensions_radio.toggled.connect(size_by_dimensions_toggled) diff --git a/mantidimaging/core/operations/remove_stripe/stripe_removal.py b/mantidimaging/core/operations/remove_stripe/stripe_removal.py index 13dc652c749..d7b39111301 100644 --- a/mantidimaging/core/operations/remove_stripe/stripe_removal.py +++ b/mantidimaging/core/operations/remove_stripe/stripe_removal.py @@ -148,7 +148,7 @@ def on_filter_type_change(name): enabled = name == f[0] for ui_item in f[1]: ui_item.setEnabled(enabled) - on_change(None) + on_change() value_filter_type.addItems([f[0] for f in filters]) value_filter_type.currentIndexChanged[str].connect(on_filter_type_change) diff --git a/mantidimaging/gui/windows/operations/view.py b/mantidimaging/gui/windows/operations/view.py index b71ff10b15a..9107fe52d43 100644 --- a/mantidimaging/gui/windows/operations/view.py +++ b/mantidimaging/gui/windows/operations/view.py @@ -133,15 +133,13 @@ def handle_filter_selection(self, filter_name: str): # options are valid) self.auto_update_triggered.emit() - def on_auto_update_triggered(self, widget=None): + def on_auto_update_triggered(self): """ Called when the signal indicating the filter, filter properties or data has changed such that the previews are now out of date. """ # Disable the spinbox widgets that are prone to misbehaving when generating a preview takes too long self.previewImageIndex.setEnabled(False) - if widget is not None: - widget.setEnabled(False) self.clear_notification_dialog() if self.previewAutoUpdate.isChecked() and self.isVisible(): @@ -149,8 +147,6 @@ def on_auto_update_triggered(self, widget=None): # Enable the spinbox widgets once the preview is done self.previewImageIndex.setEnabled(True) - if widget is not None: - widget.setEnabled(True) def clear_previews(self): self.previews.clear_items() From 62ef024265dabae77e10cb11b04c9946563310cf Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 15:29:08 +0000 Subject: [PATCH 09/14] Moving the calls --- mantidimaging/gui/windows/operations/presenter.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mantidimaging/gui/windows/operations/presenter.py b/mantidimaging/gui/windows/operations/presenter.py index 3c4eab68fbd..371c62e26ed 100644 --- a/mantidimaging/gui/windows/operations/presenter.py +++ b/mantidimaging/gui/windows/operations/presenter.py @@ -220,8 +220,6 @@ def _do_apply_filter_sync(self, apply_to): def do_update_previews(self): self.view.clear_previews() - # Disable preview image index scrollbox to prevent double-increase - self.view.previewImageIndex.setEnabled(False) if self.stack is not None: stack_presenter = self.stack.presenter subset: Images = stack_presenter.get_image(self.model.preview_image_idx) @@ -255,9 +253,6 @@ def do_update_previews(self): # Ensure all of it is visible self.view.previews.auto_range() - # Enable preview image index box when preview has been created - self.view.previewImageIndex.setEnabled(True) - @staticmethod def _update_preview_image(image_data: Optional[np.ndarray], image: ImageItem): image.clear() From 214962d11bcb30fb612b08b4ba32d6af21421ee1 Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 15:42:38 +0000 Subject: [PATCH 10/14] A docstring --- mantidimaging/gui/utility/qt_helpers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mantidimaging/gui/utility/qt_helpers.py b/mantidimaging/gui/utility/qt_helpers.py index 3c17deb7b8e..4f086e310e8 100644 --- a/mantidimaging/gui/utility/qt_helpers.py +++ b/mantidimaging/gui/utility/qt_helpers.py @@ -77,6 +77,12 @@ class Type(IntEnum): def _on_change_and_disable(widget: QWidget, on_change: Callable): + """ + Makes sure the widget is disabled while running the on_update method. This is required for spin boxes that + continue increasing when generating a preview image is computationally intensive. + :param widget: The widget to disable. + :param on_change: The method to call when the widget has been changed. + """ widget.setEnabled(False) on_change() widget.setEnabled(True) From 5cf333e40eb1c5cd070bd0b19b18c72b6eb2ba8d Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 15:47:57 +0000 Subject: [PATCH 11/14] Removing test --- mantidimaging/gui/windows/operations/test/test_presenter.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mantidimaging/gui/windows/operations/test/test_presenter.py b/mantidimaging/gui/windows/operations/test/test_presenter.py index 7a988ef569f..e9b4d320b2d 100644 --- a/mantidimaging/gui/windows/operations/test/test_presenter.py +++ b/mantidimaging/gui/windows/operations/test/test_presenter.py @@ -226,7 +226,3 @@ def test_original_stack_assigned_when_safe_apply_checked(self, _): stack.presenter.images.copy.assert_called_once() self.assertEqual(stack_data, self.presenter.original_images_stack) - - def test_preview_image_spin_box_disabled_while_updating_preview(self): - self.presenter.do_update_previews() - self.view.previewImageIndex.setEnabled.assert_has_calls([mock.call(False), mock.call(True)]) From 093ee691009d5b5017770180d8ae96dcf580dc39 Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 16:06:58 +0000 Subject: [PATCH 12/14] Correcting comment --- mantidimaging/gui/windows/operations/view.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mantidimaging/gui/windows/operations/view.py b/mantidimaging/gui/windows/operations/view.py index 9107fe52d43..0cb224aa0d7 100644 --- a/mantidimaging/gui/windows/operations/view.py +++ b/mantidimaging/gui/windows/operations/view.py @@ -138,14 +138,14 @@ def on_auto_update_triggered(self): Called when the signal indicating the filter, filter properties or data has changed such that the previews are now out of date. """ - # Disable the spinbox widgets that are prone to misbehaving when generating a preview takes too long + # Disable the preview image box widget as it can misbehave if making a preview takes too long self.previewImageIndex.setEnabled(False) self.clear_notification_dialog() if self.previewAutoUpdate.isChecked() and self.isVisible(): self.presenter.notify(PresNotification.UPDATE_PREVIEWS) - # Enable the spinbox widgets once the preview is done + # Enable the spinbox widget once the preview has been created self.previewImageIndex.setEnabled(True) def clear_previews(self): From 78274b092a824c81fccaa0cc3fe255c77a6fdea7 Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Wed, 3 Mar 2021 16:09:57 +0000 Subject: [PATCH 13/14] Update release notes --- docs/release_notes/next.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release_notes/next.rst b/docs/release_notes/next.rst index fba73c37aea..3ff3d41d80f 100644 --- a/docs/release_notes/next.rst +++ b/docs/release_notes/next.rst @@ -18,3 +18,4 @@ Fixes - #843 : Error loading stack - #856 : Move shared array allocation to `multiprocessing.Array` when on Python 3.8 - #854 : Ops window, image selector in preview section skips by 2 +- #856 : Operations auto update not triggered on spinbox changes From 30982d948eeacf3115faad355d053f3def756d39 Mon Sep 17 00:00:00 2001 From: DolicaAkelloEgwel Date: Thu, 4 Mar 2021 10:37:52 +0000 Subject: [PATCH 14/14] Disable keyboard tracking --- mantidimaging/gui/utility/qt_helpers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mantidimaging/gui/utility/qt_helpers.py b/mantidimaging/gui/utility/qt_helpers.py index 4f086e310e8..93962f314ee 100644 --- a/mantidimaging/gui/utility/qt_helpers.py +++ b/mantidimaging/gui/utility/qt_helpers.py @@ -146,6 +146,7 @@ def set_spin_box(box, cast_func): elif dtype == 'int' or dtype == Type.INT: right_widget = Qt.QSpinBox() + right_widget.setKeyboardTracking(False) set_spin_box(right_widget, int) if on_change is not None: right_widget.valueChanged.connect(lambda: _on_change_and_disable(right_widget, on_change)) @@ -153,6 +154,7 @@ def set_spin_box(box, cast_func): elif dtype == 'float' or dtype == Type.FLOAT: right_widget = Qt.QDoubleSpinBox() set_spin_box(right_widget, float) + right_widget.setKeyboardTracking(False) if on_change is not None: right_widget.valueChanged.connect(lambda: _on_change_and_disable(right_widget, on_change))