moleditpy 5.1.1__tar.gz → 5.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. {moleditpy-5.1.1 → moleditpy-5.1.3}/PKG-INFO +1 -1
  2. {moleditpy-5.1.1 → moleditpy-5.1.3}/pyproject.toml +1 -1
  3. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/MoleditPy.egg-info/PKG-INFO +1 -1
  4. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/app_state.py +21 -4
  5. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/compute_logic.py +5 -5
  6. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/constrained_optimization_dialog.py +11 -10
  7. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/edit_actions_logic.py +7 -0
  8. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/main_window.py +7 -1
  9. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/ui_manager.py +25 -7
  10. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/view_3d_logic.py +3 -0
  11. {moleditpy-5.1.1 → moleditpy-5.1.3}/COPYING +0 -0
  12. {moleditpy-5.1.1 → moleditpy-5.1.3}/DISTRIBUTION.md +0 -0
  13. {moleditpy-5.1.1 → moleditpy-5.1.3}/LICENSE +0 -0
  14. {moleditpy-5.1.1 → moleditpy-5.1.3}/LICENSING.md +0 -0
  15. {moleditpy-5.1.1 → moleditpy-5.1.3}/README.md +0 -0
  16. {moleditpy-5.1.1 → moleditpy-5.1.3}/THIRD_PARTY_NOTICES.md +0 -0
  17. {moleditpy-5.1.1 → moleditpy-5.1.3}/setup.cfg +0 -0
  18. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/MoleditPy.egg-info/SOURCES.txt +0 -0
  19. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/MoleditPy.egg-info/dependency_links.txt +0 -0
  20. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/MoleditPy.egg-info/entry_points.txt +0 -0
  21. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/MoleditPy.egg-info/requires.txt +0 -0
  22. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/MoleditPy.egg-info/top_level.txt +0 -0
  23. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/__init__.py +0 -0
  24. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/__main__.py +0 -0
  25. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/assets/file_icon.ico +0 -0
  26. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/assets/icon.icns +0 -0
  27. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/assets/icon.ico +0 -0
  28. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/assets/icon.png +0 -0
  29. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/core/__init__.py +0 -0
  30. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/core/formal_charge.py +0 -0
  31. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/core/mol_geometry.py +0 -0
  32. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/core/molecular_data.py +0 -0
  33. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/core/project_validation.py +0 -0
  34. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/core/stereo_check.py +0 -0
  35. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/main.py +0 -0
  36. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/plugins/__init__.py +0 -0
  37. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/plugins/plugin_interface.py +0 -0
  38. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/plugins/plugin_manager.py +0 -0
  39. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/plugins/plugin_manager_window.py +0 -0
  40. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/__init__.py +0 -0
  41. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/about_dialog.py +0 -0
  42. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/align_plane_dialog.py +0 -0
  43. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/alignment_dialog.py +0 -0
  44. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/analysis_window.py +0 -0
  45. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/angle_dialog.py +0 -0
  46. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/atom_item.py +0 -0
  47. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/atom_picking.py +0 -0
  48. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/base_picking_dialog.py +0 -0
  49. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/bond_item.py +0 -0
  50. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/bond_length_dialog.py +0 -0
  51. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/calculation_worker.py +0 -0
  52. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/chain_mixin.py +0 -0
  53. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/chirality_warning_dialog.py +0 -0
  54. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/color_settings_dialog.py +0 -0
  55. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/custom_interactor_style.py +0 -0
  56. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/custom_qt_interactor.py +0 -0
  57. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/dialog_3d_picking_mixin.py +0 -0
  58. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/dialog_logic.py +0 -0
  59. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/dihedral_dialog.py +0 -0
  60. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/edit_3d_logic.py +0 -0
  61. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/export_logic.py +0 -0
  62. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/geometry_base_dialog.py +0 -0
  63. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/io_logic.py +0 -0
  64. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/main_window_init.py +0 -0
  65. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/menu_utils.py +0 -0
  66. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/mirror_dialog.py +0 -0
  67. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/molecular_scene_handler.py +0 -0
  68. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/molecule_scene.py +0 -0
  69. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/move_dialog_mixin.py +0 -0
  70. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/move_group_dialog.py +0 -0
  71. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/move_selected_atoms_dialog.py +0 -0
  72. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/periodic_table_dialog.py +0 -0
  73. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/planarize_dialog.py +0 -0
  74. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/plugin_menu_manager.py +0 -0
  75. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/preview_molecule.py +0 -0
  76. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/sdf_record_dialog.py +0 -0
  77. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/settings_dialog.py +0 -0
  78. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/settings_tabs/__init__.py +0 -0
  79. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/settings_tabs/settings_2d_cleanup_tab.py +0 -0
  80. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/settings_tabs/settings_2d_tab.py +0 -0
  81. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/settings_tabs/settings_3d_tabs.py +0 -0
  82. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/settings_tabs/settings_labels_tab.py +0 -0
  83. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/settings_tabs/settings_other_tab.py +0 -0
  84. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/settings_tabs/settings_tab_base.py +0 -0
  85. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/string_importers.py +0 -0
  86. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/template_preview_item.py +0 -0
  87. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/template_preview_view.py +0 -0
  88. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/translation_dialog.py +0 -0
  89. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/user_template_dialog.py +0 -0
  90. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/ui/zoomable_view.py +0 -0
  91. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/utils/__init__.py +0 -0
  92. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/utils/constants.py +0 -0
  93. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/utils/default_settings.py +0 -0
  94. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/utils/finite_float.py +0 -0
  95. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/utils/hit_radius.py +0 -0
  96. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/utils/label_style.py +0 -0
  97. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/utils/sdf_records.py +0 -0
  98. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/utils/sip_isdeleted_safe.py +0 -0
  99. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/utils/suppress_log.py +0 -0
  100. {moleditpy-5.1.1 → moleditpy-5.1.3}/src/moleditpy/utils/system_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MoleditPy
3
- Version: 5.1.1
3
+ Version: 5.1.3
4
4
  Summary: A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files for input to DFT calculation software.
5
5
  Author-email: HiroYokoyama <titech.yoko.hiro@gmail.com>
6
6
  License-Expression: LGPL-3.0-or-later
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "MoleditPy"
7
7
 
8
- version = "5.1.1"
8
+ version = "5.1.3"
9
9
 
10
10
  license = "LGPL-3.0-or-later"
11
11
  license-files = ["LICENSE", "COPYING", "THIRD_PARTY_NOTICES.md", "DISTRIBUTION.md", "LICENSING.md"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MoleditPy
3
- Version: 5.1.1
3
+ Version: 5.1.3
4
4
  Summary: A cross-platform, simple, and intuitive molecular structure editor built in Python. It allows 2D molecular drawing and 3D structure visualization. It supports exporting structure files for input to DFT calculation software.
5
5
  Author-email: HiroYokoyama <titech.yoko.hiro@gmail.com>
6
6
  License-Expression: LGPL-3.0-or-later
@@ -127,6 +127,9 @@ class StateManager:
127
127
  state["constraints_3d"] = _serialize_constraints(
128
128
  self.host.edit_3d_manager.constraints_3d
129
129
  )
130
+ state["last_successful_optimization_method"] = getattr(
131
+ self.host.compute_manager, "last_successful_optimization_method", None
132
+ )
130
133
 
131
134
  return state
132
135
 
@@ -266,6 +269,15 @@ class StateManager:
266
269
  ):
267
270
  self.host.ui_manager.enable_3d_edit_actions(True)
268
271
 
272
+ # Restored after the 3D molecule, whose replacement clears it, and only
273
+ # with that molecule: a failed 3D restore leaves nothing it describes.
274
+ with suppress_log(AttributeError, RuntimeError, TypeError):
275
+ self.host.set_last_successful_optimization_method(
276
+ loaded_data.get("last_successful_optimization_method")
277
+ if self.host.view_3d_manager.current_mol is not None
278
+ else None
279
+ )
280
+
269
281
  # Update labels after undo/redo
270
282
  self.host.edit_3d_manager.update_2d_measurement_labels()
271
283
 
@@ -573,10 +585,6 @@ class StateManager:
573
585
 
574
586
  # 3D viewer mode
575
587
  is_3d_mode = json_data.get("is_3d_viewer_mode", False)
576
- # Restore last successful optimization method if present in file
577
- method = json_data.get("last_successful_optimization_method", None)
578
- with suppress_log(AttributeError, RuntimeError, TypeError):
579
- self.host.set_last_successful_optimization_method(method)
580
588
 
581
589
  # Plugin State Restoration (Phase 3)
582
590
  self._preserved_plugin_data = {} # Reset preserved data on new load
@@ -710,3 +718,12 @@ class StateManager:
710
718
  except (RuntimeError, ValueError, TypeError, binascii.Error) as e:
711
719
  logging.warning(f"Could not restore 3D molecular data: {e}")
712
720
  self.host.set_current_molecule(None)
721
+
722
+ # Restore the last successful optimization method after the 3D molecule:
723
+ # setting a new molecule clears the method of the previous one. Without
724
+ # a restored molecule there is nothing for the method to describe.
725
+ method = json_data.get("last_successful_optimization_method", None)
726
+ if self.host.view_3d_manager.current_mol is None:
727
+ method = None
728
+ with suppress_log(AttributeError, RuntimeError, TypeError):
729
+ self.host.set_last_successful_optimization_method(method)
@@ -682,11 +682,8 @@ class ComputeManager:
682
682
  self.host.view_3d_manager.draw_molecule_3d(mol)
683
683
  self._remove_calculating_text()
684
684
  self._refresh_ui_state()
685
- self.host.edit_actions_manager.push_undo_state()
686
- if self.host.view_3d_manager.plotter:
687
- self.host.view_3d_manager.plotter.reset_camera() # type: ignore[call-arg]
688
-
689
- # Record the successful optimization method from mol property or current setting
685
+ # Record the successful optimization method from mol property or current
686
+ # setting, before the undo snapshot so that undo/redo carry it.
690
687
  try:
691
688
  method_key = None
692
689
  if mol and mol.HasProp("_pme_optimization_method"):
@@ -701,6 +698,9 @@ class ComputeManager:
701
698
  except (AttributeError, TypeError):
702
699
  # Safe defensive fallback catching AttributeError, TypeError
703
700
  logging.debug("Suppressed non-critical error", exc_info=True)
701
+ self.host.edit_actions_manager.push_undo_state()
702
+ if self.host.view_3d_manager.plotter:
703
+ self.host.view_3d_manager.plotter.reset_camera() # type: ignore[call-arg]
704
704
 
705
705
  # Update 3D interactive features (hovers, menus)
706
706
  self.host.view_3d_manager.setup_3d_hover()
@@ -736,16 +736,7 @@ class ConstrainedOptimizationDialog(QDialog, Dialog3DPickingMixin):
736
736
  except (AttributeError, RuntimeError, ValueError, TypeError) as e:
737
737
  logging.warning("Failed to save constraints post-optimization: %s", e)
738
738
 
739
- # Update 3D view
740
- self.main_window.view_3d_manager.draw_molecule_3d(self.mol)
741
- self.main_window.view_3d_manager.update_chiral_labels()
742
- self.main_window.edit_actions_manager.push_undo_state()
743
- self.main_window.state_manager.has_unsaved_changes = True
744
- self.main_window.state_manager.update_window_title()
745
- status_bar = self.main_window.statusBar()
746
- if status_bar is not None:
747
- status_bar.showMessage("Constrained optimization finished.")
748
-
739
+ # Record the method before the undo snapshot so undo/redo carry it.
749
740
  try:
750
741
  constrained_method_name = f"Constrained_{ff_name}"
751
742
  self.main_window.compute_manager.last_successful_optimization_method = (
@@ -756,6 +747,16 @@ class ConstrainedOptimizationDialog(QDialog, Dialog3DPickingMixin):
756
747
  "Failed to set last_successful_optimization_method: %s", e
757
748
  )
758
749
 
750
+ # Update 3D view
751
+ self.main_window.view_3d_manager.draw_molecule_3d(self.mol)
752
+ self.main_window.view_3d_manager.update_chiral_labels()
753
+ self.main_window.edit_actions_manager.push_undo_state()
754
+ self.main_window.state_manager.has_unsaved_changes = True
755
+ self.main_window.state_manager.update_window_title()
756
+ status_bar = self.main_window.statusBar()
757
+ if status_bar is not None:
758
+ status_bar.showMessage("Constrained optimization finished.")
759
+
759
760
  except (AttributeError, RuntimeError, ValueError, TypeError) as e:
760
761
  logging.exception("Optimization failed: %s", e)
761
762
 
@@ -183,6 +183,10 @@ class EditActionsManager:
183
183
  if self.host.view_3d_manager.current_mol
184
184
  else None,
185
185
  "constraints_3d": self._constraints_for_comparison(),
186
+ # Saved with the project, so a change to it alone is a change.
187
+ "last_successful_optimization_method": getattr(
188
+ self.host.compute_manager, "last_successful_optimization_method", None
189
+ ),
186
190
  }
187
191
 
188
192
  last_state_for_comparison = None
@@ -209,6 +213,9 @@ class EditActionsManager:
209
213
  "mol_3d": last_state.get("mol_3d", None),
210
214
  "mol_3d_atom_ids": last_state.get("mol_3d_atom_ids", None),
211
215
  "constraints_3d": last_state.get("constraints_3d") or [],
216
+ "last_successful_optimization_method": last_state.get(
217
+ "last_successful_optimization_method"
218
+ ),
212
219
  }
213
220
 
214
221
  if (
@@ -132,9 +132,15 @@ class MainWindow(QMainWindow):
132
132
  # --- Mediator Methods ---
133
133
 
134
134
  def set_current_molecule(self, mol: Optional[Chem.Mol]) -> None:
135
- """Set the current 3D molecule and trigger rendering updates."""
135
+ """Set the current 3D molecule and trigger rendering updates.
136
+
137
+ A different molecule clears the last optimization method, which
138
+ described the previous structure; callers that set the molecule as the
139
+ result of an optimization record the method afterwards.
140
+ """
136
141
  if mol is not self.view_3d_manager.current_mol:
137
142
  self.edit_3d_manager.invalidate_molecule_dialogs()
143
+ self.compute_manager.last_successful_optimization_method = None
138
144
  self.view_3d_manager.current_mol = mol
139
145
 
140
146
  def set_3d_atom_positions(self, positions: Any) -> None:
@@ -13,7 +13,7 @@ DOI: 10.5281/zenodo.17268532
13
13
  from __future__ import annotations
14
14
 
15
15
  import logging
16
- from typing import Any, Optional
16
+ from typing import Any, Optional, Union
17
17
 
18
18
  import vtk
19
19
 
@@ -370,6 +370,20 @@ class UIManager(QObject):
370
370
  except (AttributeError, RuntimeError):
371
371
  logging.debug("Style watchdog check failed", exc_info=True)
372
372
 
373
+ @staticmethod
374
+ def _accept_as_copy(event: Union[QDragEnterEvent, QDropEvent]) -> None:
375
+ """Accept a file drag as a copy, or refuse it if the source cannot copy.
376
+
377
+ Never acceptProposedAction(): Shift during a drag from Explorer proposes
378
+ a move, and accepting one tells Explorer the file now lives here, so it
379
+ removes the original. MoleditPy only ever reads a dropped file.
380
+ """
381
+ if event.possibleActions() & Qt.DropAction.CopyAction:
382
+ event.setDropAction(Qt.DropAction.CopyAction)
383
+ event.accept()
384
+ else:
385
+ event.ignore()
386
+
373
387
  def handle_drag_enter_event(self, event: QDragEnterEvent) -> None:
374
388
  """Internal handler for drag enter event (bypasses PyQt type checks in tests)."""
375
389
  mime_data = event.mimeData()
@@ -384,13 +398,13 @@ class UIManager(QObject):
384
398
  file_lower = url.toLocalFile().lower()
385
399
  # 1. Built-in extensions
386
400
  if file_lower.endswith((".pmeraw", ".pmeprj", ".mol", ".sdf", ".xyz")):
387
- event.acceptProposedAction()
401
+ self._accept_as_copy(event)
388
402
  return
389
403
 
390
404
  # 2. Plugin drop handlers (accept if any handlers exist)
391
405
  plugin_mgr = getattr(self.host, "plugin_manager", None)
392
406
  if plugin_mgr and getattr(plugin_mgr, "drop_handlers", []):
393
- event.acceptProposedAction()
407
+ self._accept_as_copy(event)
394
408
  return
395
409
 
396
410
  event.ignore()
@@ -406,13 +420,17 @@ class UIManager(QObject):
406
420
  if not file_path:
407
421
  event.ignore()
408
422
  return
423
+ # Before anything opens: a source that can only move is refused outright.
424
+ if not event.possibleActions() & Qt.DropAction.CopyAction:
425
+ event.ignore()
426
+ return
409
427
 
410
428
  # 1. Plugin Handlers
411
429
  plugin_mgr = getattr(self.host, "plugin_manager", None)
412
430
  for handler_def in getattr(plugin_mgr, "drop_handlers", []):
413
431
  try:
414
432
  if handler_def["callback"](file_path):
415
- event.acceptProposedAction()
433
+ self._accept_as_copy(event)
416
434
  return
417
435
  except Exception: # plugins have full app access; catch everything to prevent app-wide crash
418
436
  logging.warning("Error in plugin drop handler", exc_info=True)
@@ -422,7 +440,7 @@ class UIManager(QObject):
422
440
  if file_lower.endswith((".pmeraw", ".pmeprj")):
423
441
  self.host.io_manager.open_project_file(file_path=file_path)
424
442
  QTimer.singleShot(100, self.host.view_3d_manager.fit_to_view)
425
- event.acceptProposedAction()
443
+ self._accept_as_copy(event)
426
444
  elif file_lower.endswith((".mol", ".sdf")):
427
445
  # Robust check for drop target using childAt
428
446
  drag_point = event.position().toPoint()
@@ -450,11 +468,11 @@ class UIManager(QObject):
450
468
  self.host.io_manager.load_mol_file(file_path=file_path)
451
469
  QTimer.singleShot(100, self.host.view_3d_manager.fit_to_view)
452
470
 
453
- event.acceptProposedAction()
471
+ self._accept_as_copy(event)
454
472
  elif file_lower.endswith(".xyz"):
455
473
  self.host.io_manager.load_xyz_for_3d_viewing(file_path=file_path)
456
474
  QTimer.singleShot(100, self.host.view_3d_manager.fit_to_view)
457
- event.acceptProposedAction()
475
+ self._accept_as_copy(event)
458
476
  else:
459
477
  self.host.statusBar().showMessage(f"Unsupported file type: {file_path}")
460
478
  event.ignore()
@@ -233,6 +233,9 @@ class View3DManager:
233
233
  # 3. End with background and axes if mol is None or empty
234
234
  if mol is None or mol.GetNumAtoms() == 0:
235
235
  self.atom_actor = None
236
+ if self.current_mol is not None:
237
+ # The structure is gone, and with it what its method described.
238
+ self.host.set_last_successful_optimization_method(None)
236
239
  self.current_mol = None
237
240
  self.plotter.render() # type: ignore[union-attr]
238
241
  return
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes