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

Add lock/unlock option for panes #2345

Merged
merged 7 commits into from
Apr 28, 2015
Merged
Show file tree
Hide file tree
Changes from 6 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
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 @@ -469,11 +470,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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're removing these options, you need to bump CONF_VERSION below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually renaming them,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but that's exactly the same as removing some options and adding new ones. And the removing part needs a bump in CONF_VERSION :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will make the bump then

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now I have 16.1.0 I should change it to 17.0.0 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

'_/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 @@ -713,7 +715,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this line fits in 79 columns?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

79 exactly ;-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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:"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for these changes. Thanks for doing them and making things more consistent :-)

'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 @@ -376,8 +376,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 @@ -485,7 +485,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', True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add default values to CONF.get (i.e. remove the True at the end). This messes up with updates in CONF_VERSION

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the argument should be removed from the fuction then, to avoid future similar problems ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops.. that is a remnant from the first code ... 👍 fixed

self.floating_dockwidgets = []
self.window_size = None
self.window_position = None
Expand Down Expand Up @@ -542,20 +542,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 @@ -1113,23 +1117,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 @@ -1242,6 +1250,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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line needs to go in the toggle_lock_dockwidgets method

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is the one that will make sure the action is selected according to the status when spyder was closed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

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 @@ -2147,6 +2159,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 @@ -2517,15 +2535,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