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

PR: Create a separate window when undocking plugins #3824

Merged
merged 26 commits into from Oct 14, 2017

Conversation

dalthviz
Copy link
Member

@dalthviz dalthviz commented Dec 10, 2016

Fixes #3790
Fixes #3563

@ccordoba12
Copy link
Member

Please update with the latest changes in the 3.x branch to fix the errors in CircleCI

@@ -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."""
Copy link
Member

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

@ccordoba12
Copy link
Member

There's one thing that worries me about this change. What happens when users press Ctrl+Shift+E to move to the Editor?

I think that makes the Editor pane to appear in the main window, right?

@dalthviz
Copy link
Member Author

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.

@ccordoba12
Copy link
Member

If you are with the focus in the main window, yes it makes appear the Editor pane

Then we need to fix this, and make Ctrl+Shift+E to move to the new window, if the pane is hidden and an Editor window is visible.

We also need to prevent to more than window for this to make sense :-)

@ccordoba12 ccordoba12 added this to the v3.2 milestone Jan 8, 2017
@ccordoba12
Copy link
Member

Sorry @dalthviz for my big delay on reviewing this one. I hope to do it after we release 3.1 :-)

@ccordoba12 ccordoba12 modified the milestones: v3.2, v3.3 Feb 14, 2017
@goanpeca
Copy link
Member

@dalthviz please rebase or merge with the latest 3,x to fix conflicts

@ccordoba12 ccordoba12 modified the milestones: v3.2, v4.0beta2 Jun 21, 2017
self.editor.toggle_view_action.setChecked(False)
self.editor.dockwidget.setFloating(False)
self.editor.undocked = False
self.editor.get_current_editorstack().new_window = False
Copy link
Member

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.

@@ -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)
Copy link
Member

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.

@ccordoba12
Copy link
Member

@dalthviz, please merge with 3.x and finish this one for Spyder 3.2. I think it's almost ready ;-)

@ccordoba12
Copy link
Member

@dalthviz, please create an animated gif so that @goanpeca and me could see how this is working.

@dalthviz
Copy link
Member Author

Preview:

undock

@ccordoba12
Copy link
Member

@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.

@ccordoba12
Copy link
Member

Problem is this is not the same behavior for the rest of plugins.

@ccordoba12
Copy link
Member

@dalthviz, this needs another merge with 3.x.

@goanpeca
Copy link
Member

@ccordoba12 yeah, this change would be a bit inconsistent with the rest and is better suited for 4.x

@ccordoba12 ccordoba12 modified the milestones: v4.0beta1, v3.2 Jun 22, 2017
@ccordoba12
Copy link
Member

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 plugins/base.py in master.

@ccordoba12
Copy link
Member

the only think that I don't like is that when undocking plugins are somehow small and square

Could you post a screenshot to see what you mean?

Copy link
Member

@rlaverde rlaverde left a 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.

@@ -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,
Copy link
Member

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

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

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.

@@ -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):
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 you revert the changes to this method, so It no longer needs to receive the event.

Please remove the event argument.

Reimplemented method to desactivate shortcut when
opening a new window.
"""
if len(self.editorwindows) == 0 or self.dockwidget.isVisible():
Copy link
Member

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

# Add actions to context menu
add_actions(self.shell.menu, plugin_actions)

option_menu, None, quit_action, self.undock_action]
Copy link
Member

Choose a reason for hiding this comment

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

MENU_SEPARATOR

@@ -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)
Copy link
Member

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

@@ -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)
Copy link
Member

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


def __init__(self, title, parent):
super(SpyderDockWidget, self).__init__(title, parent)
super(SpyderDockWidget, self).__init__(title)
Copy link
Member

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?

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 think this change is not necessary. I will revert this 👍

@@ -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,
Copy link
Member

Choose a reason for hiding this comment

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

MENU_SEPARATOR

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:
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 could be changed for a pythonic shortcut:

self.button_menu = options_button or QToolButton(self)

@rlaverde
Copy link
Member

rlaverde commented Oct 9, 2017

Could you post a screenshot to see what you mean?

If you see the video that @dalthviz posted, after undocking the plugin is necessary to resize the window because it is somehow small

def create_undock_action(self):
"""Create the undock action for the plugin."""
self.undock_action = create_action(self,
_("Undock the plugin"),
Copy link
Member

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.

self.undock_action.setDisabled(True)


class PluginMainWindow(QMainWindow):
Copy link
Member

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

self.options_button = create_toolbutton(self, text=_('Options'),
icon=ima.icon('tooloptions'))
self.options_button.setPopupMode(QToolButton.InstantPopup)
self.menu = QMenu(self)
Copy link
Member

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.

@ccordoba12
Copy link
Member

@dalthviz, I left some simple comments, then I'll merge.

@ccordoba12
Copy link
Member

@dalthviz, please squash the last two commits into one with the message "Fix tests".

Copy link
Member

@ccordoba12 ccordoba12 left a 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 ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants