Skip to content

Commit

Permalink
Layout: Fix visual glitches when switching layouts
Browse files Browse the repository at this point in the history
- We were not unmaximizing a possibly maximized plugin before the
switch, which left the window in an inconsistent state.
- We also need to reapply the dock tabbar style after the switch so the
window looks as expected.
  • Loading branch information
ccordoba12 committed May 16, 2024
1 parent 369544d commit 1149dcf
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions spyder/plugins/layout/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,25 @@ def _update_lock_interface_action(self):
self.lock_interface_action.setIcon(icon)
self.lock_interface_action.setText(text)

def _reapply_docktabbar_style(self):
"""Reapply dock tabbar style if necessary."""
def _reapply_docktabbar_style(self, force=False):
"""Reapply dock tabbar style."""
saved_state_version = self.get_conf(
"window_state_version", default=WINDOW_STATE_VERSION
)

# Reapplying style by installing the tab event filter if the window
# state version changed or the previous session ran a Spyder version
# older than 6.0.0a5, which is when this change became necessary.
# Reapplying style by installing the tab event filter again.
if (
# Check if the window state version changed. This covers the case
# of starting a Spyder 5 session after a Spyder 6 one, but only if
# users have 5.5.4 or greater.
saved_state_version < WINDOW_STATE_VERSION
# 82.2.0 is the conf version for 6.0 alpha5
# The previous session ran a Spyder version older than 6.0.0a5,
# which is when this change became necessary (82.2.0 is the conf
# version for that release)
or parse(self.old_conf_version) < parse("82.2.0")
# This is used when switching to a different layout, which also
# requires this.
or force
):
plugins = self.get_dockable_plugins()
for plugin in plugins:
Expand Down Expand Up @@ -442,6 +448,9 @@ def quick_layout_switch(self, index_or_layout_id):
----------
index_or_layout_id: int or str
"""
# We need to do this first so the new layout is applied as expected.
self.unmaximize_dockwidget()

section = 'quick_layouts'
container = self.get_container()
try:
Expand Down Expand Up @@ -490,6 +499,10 @@ def quick_layout_switch(self, index_or_layout_id):
action = plugin._toggle_view_action
action.setChecked(plugin.dockwidget.isVisible())

# This is necessary to restore the style for dock tabbars after the
# switch
self._reapply_docktabbar_style(force=True)

return index_or_layout_id

def load_window_settings(self, prefix, default=False, section='main'):
Expand Down

0 comments on commit 1149dcf

Please sign in to comment.