-
-
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
PR: Create a separate window when undocking plugins #3824
Conversation
Please update with the latest changes in the 3.x branch to fix the errors in CircleCI |
spyder/app/mainwindow.py
Outdated
@@ -2209,6 +2210,15 @@ def __update_fullscreen_action(self): | |||
self.fullscreen_action.setIcon(icon) | |||
|
|||
@Slot() | |||
def undock_editor(self): | |||
"""Open a new window instance of the Editor instead of undoking it.""" |
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.
undoking
is misspelled here. It's undocking
There's one thing that worries me about this change. What happens when users press I think that makes the Editor pane to appear in the main window, right? |
If you are with the focus in the main window, yes it makes appear the Editor pane. If you, in the other hand, have the focus in a new window it doesn't appear. |
Then we need to fix this, and make We also need to prevent to more than window for this to make sense :-) |
Sorry @dalthviz for my big delay on reviewing this one. I hope to do it after we release 3.1 :-) |
@dalthviz please rebase or merge with the latest 3,x to fix conflicts |
spyder/app/mainwindow.py
Outdated
self.editor.toggle_view_action.setChecked(False) | ||
self.editor.dockwidget.setFloating(False) | ||
self.editor.undocked = False | ||
self.editor.get_current_editorstack().new_window = False |
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.
@dalthviz, does this method need to be here in the main window? As far as I can see, it doesn't use any attribute/method of the window, so I think we can safely move it to the Editor plugin file.
spyder/app/mainwindow.py
Outdated
@@ -799,6 +799,7 @@ def create_edit_action(text, tr_text, icon): | |||
from spyder.plugins.editor import Editor | |||
self.editor = Editor(self) | |||
self.editor.register_plugin() | |||
self.editor.dockwidget.topLevelChanged.connect(self.undock_editor) |
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.
This line can also be moved to the Editor plugin. We can make it the last line of its register_plugin
method.
@dalthviz, please merge with 3.x and finish this one for Spyder 3.2. I think it's almost ready ;-) |
@goanpeca, what do you think? There is an action in the Editor options menu to undock it so users can move next to other plugins. |
Problem is this is not the same behavior for the rest of plugins. |
@dalthviz, this needs another merge with |
@ccordoba12 yeah, this change would be a bit inconsistent with the rest and is better suited for 4.x |
Ok, you're right. @dalthviz, please rebase this PR in top of master and keep working on it, so that when users press the undock button they see a new window for every plugin, and not just the Editor. This functionality could go to |
…or window. Disabled shortcut for the editor when working in a new window.
Could you post a screenshot to see what you mean? |
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.
Looking great, and pretty concise (I think that the this PR will be longer 🙈)
My only concern is the size of the window when undocking a plugin.
spyder/api/plugins.py
Outdated
@@ -88,7 +94,12 @@ def initialize_plugin(self): | |||
It must be run at the end of __init__ | |||
""" | |||
self.create_toggle_view_action() | |||
self.plugin_actions = self.get_plugin_actions() | |||
self.create_undock_action() | |||
self.plugin_actions = self.get_plugin_actions() + [None, |
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.
Please use MENU_SEPARATOR
(spyder.utils.qthelpers
) instead of None
spyder/api/plugins.py
Outdated
def refresh_actions(self): | ||
"""Clear the menu of the plugin and add the actions.""" | ||
self.menu.clear() | ||
self.plugin_actions = self.get_plugin_actions() + [None, |
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.
Please also change None for MENU_SEPARATOR
here.
spyder/plugins/base.py
Outdated
@@ -109,7 +112,7 @@ def switch_to_plugin(self): | |||
self.toggle_view_action.setChecked(True) | |||
self.visibility_changed(True) | |||
|
|||
def plugin_closed(self): | |||
def plugin_closed(self, event): |
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 think you revert the changes to this method, so It no longer needs to receive the event
.
Please remove the event
argument.
spyder/plugins/editor.py
Outdated
Reimplemented method to desactivate shortcut when | ||
opening a new window. | ||
""" | ||
if len(self.editorwindows) == 0 or self.dockwidget.isVisible(): |
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.
You could use: if not self.editorwindows or ...
, It will evaluate to True when len is 0
spyder/plugins/console.py
Outdated
# Add actions to context menu | ||
add_actions(self.shell.menu, plugin_actions) | ||
|
||
option_menu, None, quit_action, self.undock_action] |
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.
MENU_SEPARATOR
spyder/widgets/dock.py
Outdated
@@ -153,10 +153,10 @@ def show_nontab_menu(self, event): | |||
|
|||
class SpyderDockWidget(QDockWidget): | |||
"""Subclass to override needed methods""" | |||
plugin_closed = Signal() | |||
plugin_closed = Signal(object) |
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.
Revert this, this signal doesn't need to send the event
spyder/widgets/dock.py
Outdated
@@ -173,7 +173,7 @@ def closeEvent(self, event): | |||
Reimplement Qt method to send a signal on close so that "Panes" main | |||
window menu can be updated correctly | |||
""" | |||
self.plugin_closed.emit() | |||
self.plugin_closed.emit(event) |
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.
Revert this, this signal doesn't need to send the event
spyder/widgets/dock.py
Outdated
|
||
def __init__(self, title, parent): | ||
super(SpyderDockWidget, self).__init__(title, parent) | ||
super(SpyderDockWidget, self).__init__(title) |
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.
Why this change is necessary?
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 think this change is not necessary. I will revert this 👍
spyder/widgets/editor.py
Outdated
@@ -1339,8 +1341,12 @@ def __get_split_actions(self): | |||
triggered=lambda: self.split_horizontally.emit()) | |||
self.close_action = create_action(self, _("Close this panel"), | |||
icon=ima.icon('close_panel'), triggered=self.close) | |||
return [None, self.newwindow_action, None, | |||
self.versplit_action, self.horsplit_action, self.close_action] | |||
actions = [None, self.undock_action, None, self.versplit_action, |
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.
MENU_SEPARATOR
spyder/widgets/explorer.py
Outdated
QWidget.__init__(self, parent) | ||
|
||
# Widgets | ||
self.treewidget = ExplorerTreeWidget(self, show_cd_only=show_cd_only) | ||
button_previous = QToolButton(self) | ||
button_next = QToolButton(self) | ||
button_parent = QToolButton(self) | ||
self.button_menu = QToolButton(self) | ||
menu = QMenu(self) | ||
if options_button: |
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 think this could be changed for a pythonic shortcut:
self.button_menu = options_button or QToolButton(self)
If you see the video that @dalthviz posted, after undocking the plugin is necessary to resize the window because it is somehow small |
spyder/plugins/base.py
Outdated
def create_undock_action(self): | ||
"""Create the undock action for the plugin.""" | ||
self.undock_action = create_action(self, | ||
_("Undock the plugin"), |
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.
Let's change this to simply Undock
, instead of Undock the plugin
.
spyder/plugins/base.py
Outdated
self.undock_action.setDisabled(True) | ||
|
||
|
||
class PluginMainWindow(QMainWindow): |
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.
Please move this class to be before BasePluginWidget
spyder/api/plugins.py
Outdated
self.options_button = create_toolbutton(self, text=_('Options'), | ||
icon=ima.icon('tooloptions')) | ||
self.options_button.setPopupMode(QToolButton.InstantPopup) | ||
self.menu = QMenu(self) |
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.
menu
is too generic. Please change it to options_menu
.
@dalthviz, I left some simple comments, then I'll merge. |
@dalthviz, please squash the last two commits into one with the message "Fix tests". |
f8e56a0
to
3437f75
Compare
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.
Another great improvement @dalthviz!! Thanks a lot for all your work and patience with this one ;-)
Fixes #3790
Fixes #3563