Skip to content

Commit

Permalink
Prevent most tools from docking in the top or bottom of the main window
Browse files Browse the repository at this point in the history
  • Loading branch information
e-pettersen committed Oct 31, 2024
1 parent 2ed6c6c commit 9ac2bbb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/bundles/buttons/src/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ def __init__(self, session, title):
layout.setContentsMargins(0,0,0,0)
layout.setSpacing(0)
tw.ui_area.setLayout(layout)
tw.manage(placement="side")
from Qt.QtCore import Qt
da = Qt.DockWidgetArea
tw.manage(placement="side",
allowed_areas=da.RightDockWidgetArea|da.LeftDockWidgetArea|da.TopDockWidgetArea)

def add_button(self, name, command, row=None, column=None):
parent = self.tool_window.ui_area
Expand Down
3 changes: 2 additions & 1 deletion src/bundles/seq_view/src/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ def _finalize_init(self, alignment, *, from_session=True):
# opened along with MAV a chance to load
parent.after_idle(lambda: self._loadStructures(auto=1))
"""
self.tool_window.manage('side')
from Qt.QtCore import Qt
self.tool_window.manage('side', allowed_areas=Qt.DockWidgetArea.AllDockWidgetAreas)

@property
def active_region(self):
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/ui/bundle_info.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<BundleInfo name="ChimeraX-UI" version="1.41"
<BundleInfo name="ChimeraX-UI" version="1.42"
package="chimerax.ui"
minSessionVersion="1" maxSessionVersion="1">

Expand Down
6 changes: 4 additions & 2 deletions src/bundles/ui/src/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2218,7 +2218,8 @@ def hides_title_bar(self):
dock_area_value(Qt.DockWidgetArea.TopDockWidgetArea): "top",
dock_area_value(Qt.DockWidgetArea.BottomDockWidgetArea): "bottom"
}
def manage(self, placement = None, fixed_size=False, allowed_areas=Qt.DockWidgetArea.AllDockWidgetAreas,
def manage(self, placement = None, fixed_size=False,
allowed_areas=Qt.DockWidgetArea.RightDockWidgetArea|Qt.DockWidgetArea.LeftDockWidgetArea,
initially_hidden=False):
"""Supported API. Show this tool window in the interface
Expand Down Expand Up @@ -2246,6 +2247,7 @@ def manage(self, placement = None, fixed_size=False, allowed_areas=Qt.DockWidget
if tool_name not in settings.undockable:
settings.undockable = settings.undockable + [tool_name]
from Qt.QtCore import Qt
self.default_allowed_areas = allowed_areas
if tool_name in settings.undockable:
allowed_areas = Qt.DockWidgetArea.NoDockWidgetArea
geometry = None
Expand Down Expand Up @@ -2562,7 +2564,7 @@ def dockable(self):
@dockable.setter
def dockable(self, dockable):
from Qt.QtCore import Qt
areas = Qt.DockWidgetArea.AllDockWidgetAreas if dockable else Qt.DockWidgetArea.NoDockWidgetArea
areas = self.tool_window.default_allowed_areas if dockable else Qt.DockWidgetArea.NoDockWidgetArea
self.dock_widget.setAllowedAreas(areas)
if not dockable and not self.dock_widget.isFloating():
self.dock_widget.setFloating(True)
Expand Down

0 comments on commit 9ac2bbb

Please sign in to comment.