Skip to content

Commit

Permalink
Merge pull request spyder-ide#2345 from goanpeca/lock-panes
Browse files Browse the repository at this point in the history
Add lock/unlock option for panes
  • Loading branch information
ccordoba12 committed Apr 28, 2015
2 parents 5e559ce + 059da1e commit b3fea4e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 29 deletions.
8 changes: 5 additions & 3 deletions spyderlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def is_ubuntu():
'vertical_tabs': False,
'animated_docks': True,
'prompt_on_exit': False,
'panes_locked': True,
'window/size': (1260, 740),
'window/position': (10, 10),
'window/is_maximized': True,
Expand Down Expand Up @@ -470,11 +471,12 @@ def is_ubuntu():
# ---- Global ----
# -- In spyder.py
'_/close pane': "Shift+Ctrl+F4",
'_/lock unlock panes': "Shift+Ctrl+F5",
'_/preferences': "Ctrl+Alt+Shift+P",
'_/maximize pane': "Ctrl+Alt+Shift+M",
'_/fullscreen mode': "F11",
'_/toggle next layout': "Shift+Alt+PgDown",
'_/toggle previous layout': "Shift+Alt+PgUp",
'_/use next layout': "Shift+Alt+PgDown",
'_/use previous layout': "Shift+Alt+PgUp",
'_/save current layout': "Shift+Alt+S",
'_/toggle default layout': "Shift+Alt+Home",
'_/layout preferences': "Shift+Alt+P",
Expand Down Expand Up @@ -715,7 +717,7 @@ def is_ubuntu():
# 2. If you want to *remove* options that are no longer needed in our codebase,
# you need to do a MAJOR update in version, e.g. from 3.0.0 to 4.0.0
# 3. You don't need to touch this value if you're just adding a new option
CONF_VERSION = '16.1.0'
CONF_VERSION = '17.0.0'

# XXX: Previously we had load=(not DEV) here but DEV was set to *False*.
# Check if it *really* needs to be updated or not
Expand Down
4 changes: 1 addition & 3 deletions spyderlib/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ class SpyderPluginMixin(object):
CONFIGWIDGET_CLASS = None
ALLOWED_AREAS = Qt.AllDockWidgetAreas
LOCATION = Qt.LeftDockWidgetArea
FEATURES = QDockWidget.DockWidgetClosable | \
QDockWidget.DockWidgetFloatable | \
QDockWidget.DockWidgetMovable
FEATURES = QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetFloatable
DISABLE_ACTIONS_WHEN_HIDDEN = True

# Signals
Expand Down
8 changes: 4 additions & 4 deletions spyderlib/plugins/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,16 +684,16 @@ def setup_page(self):
tip=_("Set this to open external<br> "
"Python files in an already running "
"instance (Requires a restart)"))
vertdock_box = newcb(_("Vertical dockwidget title bars"),
vertdock_box = newcb(_("Vertical title bars in panes"),
'vertical_dockwidget_titlebars')
verttabs_box = newcb(_("Vertical dockwidget tabs"),
verttabs_box = newcb(_("Vertical tabs in panes"),
'vertical_tabs')
animated_box = newcb(_("Animated toolbars and dockwidgets"),
animated_box = newcb(_("Animated toolbars and panes"),
'animated_docks')
tear_off_box = newcb(_("Tear off menus"), 'tear_off_menus',
tip=_("Set this to detach any<br> "
"menu from the main window"))
margin_box = newcb(_("Custom dockwidget margin:"),
margin_box = newcb(_("Custom margin for panes:"),
'use_custom_margin')
margin_spin = self.create_spinbox("", "pixels", 'custom_margin',
0, 0, 30)
Expand Down
62 changes: 43 additions & 19 deletions spyderlib/spyder.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ def __init__(self, options=None):
self.dialog_layout_settings = LayoutSettingsDialog

# Actions
self.lock_dockwidgets_action = None
self.close_dockwidget_action = None
self.lock_dockwidget_action = None
self.find_action = None
self.find_next_action = None
self.find_previous_action = None
Expand Down Expand Up @@ -494,7 +494,7 @@ def __init__(self, options=None):
self.is_starting_up = True
self.is_setting_up = True

self.dockwidgets_locked = False
self.dockwidgets_locked = CONF.get('main', 'panes_locked')
self.floating_dockwidgets = []
self.window_size = None
self.window_position = None
Expand Down Expand Up @@ -551,20 +551,24 @@ def setup(self):
context=Qt.ApplicationShortcut)
self.register_shortcut(self.close_dockwidget_action, "_",
"Close pane")

self.lock_dockwidgets_action = create_action(self, _("Lock panes"),
toggled=self.toggle_lock_dockwidgets,
context=Qt.ApplicationShortcut)
self.register_shortcut(self.lock_dockwidgets_action, "_",
"lock unlock panes")
# custom layouts shortcuts
self.toggle_next_layout_action = create_action(self,
_("Toggle next layout"),
_("Use next layout"),
triggered=self.toggle_next_layout,
context=Qt.ApplicationShortcut)
self.toggle_previous_layout_action = create_action(self,
_("Toggle previous layout"),
_("Use previous layout"),
triggered=self.toggle_previous_layout,
context=Qt.ApplicationShortcut)
self.register_shortcut(self.toggle_next_layout_action, "_",
"Toggle next layout")
"Use next layout")
self.register_shortcut(self.toggle_previous_layout_action, "_",
"Toggle previous layout")
"Use previous layout")


_text = _("&Find text")
Expand Down Expand Up @@ -1133,23 +1137,27 @@ def add_xydoc(text, pathlist):
# View menu
self.plugins_menu = QMenu(_("Panes"), self)
self.toolbars_menu = QMenu(_("Toolbars"), self)
self.view_menu.addMenu(self.plugins_menu)
self.view_menu.addMenu(self.toolbars_menu)
self.quick_layout_menu = QMenu(_("Custom window layouts"), self)
self.quick_layout_menu = QMenu(_("Window layouts"), self)
self.quick_layout_set_menu()

self.view_menu.addMenu(self.plugins_menu) # Panes
add_actions(self.view_menu, (self.lock_dockwidgets_action,
self.close_dockwidget_action,
self.maximize_action,
None))
self.view_menu.addMenu(self.toolbars_menu)
add_actions(self.view_menu, (None,
self.quick_layout_menu,
self.toggle_previous_layout_action,
self.toggle_next_layout_action,
None,
self.fullscreen_action))
if set_attached_console_visible is not None:
cmd_act = create_action(self,
_("Attached console window (debugging)"),
toggled=set_attached_console_visible)
cmd_act.setChecked(is_attached_console_visible())
add_actions(self.view_menu, (None, cmd_act))
add_actions(self.view_menu, (None, self.fullscreen_action,
self.maximize_action,
self.close_dockwidget_action, None,
self.toggle_previous_layout_action,
self.toggle_next_layout_action,
self.quick_layout_menu))

# Adding external tools action to "Tools" menu
if self.external_tools_menu_actions:
Expand Down Expand Up @@ -1262,6 +1270,10 @@ def post_visible_setup(self):
self.extconsole.setMinimumHeight(0)

if not self.light:
# Update lock status of dockidgets (panes)
self.lock_dockwidgets_action.setChecked(self.dockwidgets_locked)
self.apply_panes_settings()

# Hide Internal Console so that people don't use it instead of
# the External or IPython ones
if self.console.dockwidget.isVisible() and DEV is None:
Expand Down Expand Up @@ -2172,6 +2184,12 @@ def close_current_dockwidget(self):
plugin.dockwidget.hide()
break

def toggle_lock_dockwidgets(self, value):
"""Lock/Unlock dockwidgets"""
self.dockwidgets_locked = value
self.apply_panes_settings()
CONF.set('main', 'panes_locked', value)

def __update_maximize_action(self):
if self.state_before_maximizing is None:
text = _("Maximize current pane")
Expand Down Expand Up @@ -2542,15 +2560,21 @@ def apply_settings(self):
default = default|QMainWindow.AnimatedDocks
self.setDockOptions(default)

self.apply_panes_settings()
self.apply_statusbar_settings()

def apply_panes_settings(self):
"""Update dockwidgets features settings"""
# Update toggle action on menu
for child in self.widgetlist:
features = child.FEATURES
if CONF.get('main', 'vertical_dockwidget_titlebars'):
features = features|QDockWidget.DockWidgetVerticalTitleBar
features = features | QDockWidget.DockWidgetVerticalTitleBar
if not self.dockwidgets_locked:
features = features | QDockWidget.DockWidgetMovable
child.dockwidget.setFeatures(features)
child.update_margins()

self.apply_statusbar_settings()

def apply_statusbar_settings(self):
"""Update status bar widgets settings"""
for widget, name in ((self.mem_status, 'memory_usage'),
Expand Down

0 comments on commit b3fea4e

Please sign in to comment.