-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Changes from 6 commits
9e6ce3f
51e8589
f6ebb02
fedb1ba
58ae0f0
55bfa22
059da1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this line fits in 79 columns? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 79 exactly ;-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
DISABLE_ACTIONS_WHEN_HIDDEN = True | ||
|
||
# Signals | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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:"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't add default values to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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") | ||
|
@@ -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: | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this line needs to go in the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
@@ -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") | ||
|
@@ -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'), | ||
|
There was a problem hiding this comment.
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
belowThere was a problem hiding this comment.
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,
There was a problem hiding this comment.
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
:-)There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes