Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dock pane layout #545

Merged
merged 3 commits into from
Jun 30, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions pyface/ui/qt4/tasks/main_window_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import logging


from pyface.qt import QtCore, QtGui
from pyface.qt import QtCore, QtGui, is_qt4


from traits.api import Any, HasTraits
Expand Down Expand Up @@ -154,8 +154,9 @@ def set_layout(self, layout):
sublayout, q_dock_area, _toplevel_call=False
)

# Remove the fixed sizes once Qt activates the layout.
QtCore.QTimer.singleShot(0, self._reset_fixed_sizes)
if is_qt4:
# Remove the fixed sizes once Qt activates the layout.
QtCore.QTimer.singleShot(0, self._reset_fixed_sizes)

def set_layout_for_area(
self, layout, q_dock_area, _toplevel_added=False, _toplevel_call=True
Expand Down Expand Up @@ -227,9 +228,10 @@ def set_layout_for_area(
else:
raise MainWindowLayoutError("Unknown layout item %r" % layout)

# Remove the fixed sizes once Qt activates the layout.
if _toplevel_call:
QtCore.QTimer.singleShot(0, self._reset_fixed_sizes)
if is_qt4:
# Remove the fixed sizes once Qt activates the layout.
if _toplevel_call:
QtCore.QTimer.singleShot(0, self._reset_fixed_sizes)

# ------------------------------------------------------------------------
# 'MainWindowLayout' abstract interface.
Expand Down Expand Up @@ -309,10 +311,14 @@ def _prepare_toplevel_for_item(self, layout):
"Cannot retrieve dock widget for pane %r" % layout.id
)
else:
if layout.width > 0:
dock_widget.widget().setFixedWidth(layout.width)
if layout.height > 0:
dock_widget.widget().setFixedHeight(layout.height)
if is_qt4:
if layout.width > 0:
dock_widget.widget().setFixedWidth(layout.width)
if layout.height > 0:
dock_widget.widget().setFixedHeight(layout.height)
else:
sizeHint = lambda : QtCore.QSize(layout.width, layout.height)
dock_widget.widget().sizeHint = sizeHint
return dock_widget

elif isinstance(layout, LayoutContainer):
Expand Down