Skip to content

Commit

Permalink
Merge pull request #12181 from goanpeca/fix/organize-dockwidget
Browse files Browse the repository at this point in the history
PR: Move dock attributes from plugin to dockwidget
  • Loading branch information
ccordoba12 committed Apr 7, 2020
2 parents c93d8cb + 4216407 commit 20e2b7a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3100,7 +3100,7 @@ def apply_settings(self):
def apply_panes_settings(self):
"""Update dockwidgets features settings"""
for plugin in (self.widgetlist + self.thirdparty_plugins):
features = plugin._FEATURES
features = plugin.dockwidget.FEATURES
if CONF.get('main', 'vertical_dockwidget_titlebars'):
features = features | QDockWidget.DockWidgetVerticalTitleBar
plugin.dockwidget.setFeatures(features)
Expand Down
10 changes: 3 additions & 7 deletions spyder/plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ class BasePluginWidgetMixin(object):
Implementation of the basic functionality for Spyder plugin widgets.
"""

_ALLOWED_AREAS = Qt.AllDockWidgetAreas
_LOCATION = Qt.LeftDockWidgetArea
_FEATURES = QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetMovable

def __init__(self, parent=None):
super(BasePluginWidgetMixin, self).__init__()

Expand Down Expand Up @@ -255,8 +251,8 @@ def _create_dockwidget(self):

# Set properties
dock.setObjectName(self.__class__.__name__+"_dw")
dock.setAllowedAreas(self._ALLOWED_AREAS)
dock.setFeatures(self._FEATURES)
dock.setAllowedAreas(dock.ALLOWED_AREAS)
dock.setFeatures(dock.FEATURES)
dock.setWidget(self)
self._update_margins()
dock.visibilityChanged.connect(self._visibility_changed)
Expand All @@ -281,7 +277,7 @@ def _create_dockwidget(self):
self.register_shortcut(sc, "_", "Switch to {}".format(
self.CONF_SECTION))

return (dock, self._LOCATION)
return (dock, dock.LOCATION)

def _switch_to_plugin(self):
"""Switch to plugin."""
Expand Down
7 changes: 7 additions & 0 deletions spyder/widgets/dock.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ def mouseMoveEvent(self, event):

class SpyderDockWidget(QDockWidget):
"""Subclass to override needed methods"""

# Attributes
ALLOWED_AREAS = Qt.AllDockWidgetAreas
LOCATION = Qt.LeftDockWidgetArea
FEATURES = QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetMovable

# Signals
sig_plugin_closed = Signal()

def __init__(self, title, parent):
Expand Down

0 comments on commit 20e2b7a

Please sign in to comment.