mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-08-02 00:13:51 +02:00
fix(dock-area): avoid switching profile when saving new profile
This commit is contained in:
@@ -235,11 +235,8 @@ class BECDockArea(DockAreaWidget):
|
|||||||
def _load_initial_profile(self, name: str) -> None:
|
def _load_initial_profile(self, name: str) -> None:
|
||||||
"""Load the initial profile."""
|
"""Load the initial profile."""
|
||||||
self.load_profile(name)
|
self.load_profile(name)
|
||||||
combo = self.toolbar.components.get_action("workspace_combo").widget
|
|
||||||
combo.blockSignals(True)
|
|
||||||
if not self._empty_profile_active:
|
if not self._empty_profile_active:
|
||||||
combo.setCurrentText(name)
|
self._set_workspace_combo_text_silent(name)
|
||||||
combo.blockSignals(False)
|
|
||||||
|
|
||||||
def _start_empty_workspace(self) -> None:
|
def _start_empty_workspace(self) -> None:
|
||||||
"""
|
"""
|
||||||
@@ -669,6 +666,14 @@ class BECDockArea(DockAreaWidget):
|
|||||||
combo = self.toolbar.components.get_action("workspace_combo").widget
|
combo = self.toolbar.components.get_action("workspace_combo").widget
|
||||||
combo.refresh_profiles(active_profile=name)
|
combo.refresh_profiles(active_profile=name)
|
||||||
|
|
||||||
|
def _set_workspace_combo_text_silent(self, text: str) -> None:
|
||||||
|
combo = self.toolbar.components.get_action("workspace_combo").widget
|
||||||
|
was_blocked = combo.blockSignals(True)
|
||||||
|
try:
|
||||||
|
combo.setCurrentText(text)
|
||||||
|
finally:
|
||||||
|
combo.blockSignals(was_blocked)
|
||||||
|
|
||||||
def _enter_empty_profile_state(self) -> None:
|
def _enter_empty_profile_state(self) -> None:
|
||||||
"""
|
"""
|
||||||
Switch to the transient empty workspace state.
|
Switch to the transient empty workspace state.
|
||||||
@@ -796,7 +801,6 @@ class BECDockArea(DockAreaWidget):
|
|||||||
self._pending_autosave_skip = (current_profile, name)
|
self._pending_autosave_skip = (current_profile, name)
|
||||||
else:
|
else:
|
||||||
self._pending_autosave_skip = None
|
self._pending_autosave_skip = None
|
||||||
workspace_combo.setCurrentText(name)
|
|
||||||
self._finalize_profile_change(name, namespace)
|
self._finalize_profile_change(name, namespace)
|
||||||
|
|
||||||
@SafeSlot()
|
@SafeSlot()
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ class ProfileComboBox(QComboBox):
|
|||||||
if index >= 0:
|
if index >= 0:
|
||||||
self.setCurrentIndex(index)
|
self.setCurrentIndex(index)
|
||||||
|
|
||||||
self.blockSignals(False)
|
|
||||||
if active_profile and self.currentText() != active_profile:
|
if active_profile and self.currentText() != active_profile:
|
||||||
idx = self.findText(active_profile)
|
idx = self.findText(active_profile)
|
||||||
if idx >= 0:
|
if idx >= 0:
|
||||||
@@ -114,6 +113,7 @@ class ProfileComboBox(QComboBox):
|
|||||||
self.setToolTip("Active profile is not in quick select")
|
self.setToolTip("Active profile is not in quick select")
|
||||||
else:
|
else:
|
||||||
self.setToolTip("")
|
self.setToolTip("")
|
||||||
|
self.blockSignals(False)
|
||||||
|
|
||||||
|
|
||||||
def workspace_bundle(components: ToolbarComponents, enable_tools: bool = True) -> ToolbarBundle:
|
def workspace_bundle(components: ToolbarComponents, enable_tools: bool = True) -> ToolbarBundle:
|
||||||
|
|||||||
@@ -1863,9 +1863,14 @@ class TestWorkspaceProfileOperations:
|
|||||||
with patch(
|
with patch(
|
||||||
"bec_widgets.widgets.containers.dock_area.dock_area.SaveProfileDialog", StubDialog
|
"bec_widgets.widgets.containers.dock_area.dock_area.SaveProfileDialog", StubDialog
|
||||||
):
|
):
|
||||||
advanced_dock_area.save_profile(show_dialog=True)
|
widgets_before_save = list(advanced_dock_area.widget_list())
|
||||||
|
with patch.object(advanced_dock_area, "load_profile") as mock_load_profile:
|
||||||
|
advanced_dock_area.save_profile(show_dialog=True)
|
||||||
|
qtbot.wait(100)
|
||||||
|
mock_load_profile.assert_not_called()
|
||||||
|
|
||||||
qtbot.wait(500)
|
qtbot.wait(500)
|
||||||
|
assert list(advanced_dock_area.widget_list()) == widgets_before_save
|
||||||
source_manifest = read_manifest(helper.open_user(source_profile))
|
source_manifest = read_manifest(helper.open_user(source_profile))
|
||||||
new_manifest = read_manifest(helper.open_user(new_profile))
|
new_manifest = read_manifest(helper.open_user(new_profile))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user