Skip to content

Commit

Permalink
Merge pull request #31 from tokejepsen/master
Browse files Browse the repository at this point in the history
Single dock widget.
  • Loading branch information
tokejepsen authored Oct 13, 2016
2 parents 7d67dcd + cfce3cd commit 061de84
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
35 changes: 34 additions & 1 deletion pyblish_nuke/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
self._has_been_setup = False
self._has_menu = False
self._registered_gui = None
self._dock = None


def setup(console=False, port=None, menu=True):
Expand Down Expand Up @@ -255,6 +256,35 @@ def __init__(self):
def dock(window):
""" Expecting a window to parent into a Nuke panel, that is dockable. """

# Deleting existing dock
# There is a bug where existing docks are kept in-memory when closed via UI
if self._dock:
print "Deleting existing dock..."
parent = self._dock
dialog = None
stacked_widget = None
main_windows = []

# Getting dock parents
while parent:
if isinstance(parent, QtWidgets.QDialog):
dialog = parent
if isinstance(parent, QtWidgets.QStackedWidget):
stacked_widget = parent
if isinstance(parent, QtWidgets.QMainWindow):
main_windows.append(parent)
parent = parent.parent()

dialog.deleteLater()

if len(main_windows) > 1:
# Then it's a floating window
if stacked_widget.count() == 1:
# Then it's empty and we can close it,
# as is native Nuke UI behaviour
main_windows[0].deleteLater()

# Creating new dock
pane = nuke.getPaneFor("Properties.1")
widget_path = "pyblish_nuke.lib.pyblish_nuke_dockwidget"
panel = nukescripts.panels.registerWidgetAsPanel(widget_path,
Expand All @@ -263,5 +293,8 @@ def dock(window):
True).addToPane(pane)

panel_widget = panel.customKnob.getObject().widget
_nuke_set_zero_margins(panel_widget)
panel_widget.layout().addWidget(window)
_nuke_set_zero_margins(panel_widget)
self._dock = panel_widget

return self._dock
2 changes: 1 addition & 1 deletion pyblish_nuke/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

VERSION_MAJOR = 2
VERSION_MINOR = 0
VERSION_PATCH = 2
VERSION_PATCH = 3

version_info = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
version = '%i.%i.%i' % version_info
Expand Down

0 comments on commit 061de84

Please sign in to comment.