Skip to content

Commit

Permalink
Merge pull request #265 from liorbenhorin/master
Browse files Browse the repository at this point in the history
Added support for publish and validate from within the host app
  • Loading branch information
mottosso authored Sep 25, 2017
2 parents 2a91bae + ee8ca29 commit 7e86c44
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
14 changes: 14 additions & 0 deletions pyblish_qml/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class Application(QtGui.QGuiApplication):
risen = QtCore.pyqtSignal()
inFocused = QtCore.pyqtSignal()
outFocused = QtCore.pyqtSignal()
published = QtCore.pyqtSignal()
validated = QtCore.pyqtSignal()

def __init__(self, source, targets=[]):
super(Application, self).__init__(sys.argv)
Expand Down Expand Up @@ -102,6 +104,8 @@ def __init__(self, source, targets=[]):
self.risen.connect(self.rise)
self.inFocused.connect(self.inFocus)
self.outFocused.connect(self.outFocus)
self.published.connect(self.publish)
self.validated.connect(self.validate)

window.setSource(QtCore.QUrl.fromLocalFile(source))

Expand Down Expand Up @@ -207,6 +211,14 @@ def outFocus(self):
previous_flags = self.window.flags()
self.window.setFlags(previous_flags ^ QtCore.Qt.WindowStaysOnTopHint)

def publish(self):
"""Fire up the publish sequence"""
self.controller.publish()

def validate(self):
"""Fire up the validation sequance"""
self.controller.validate()

def listen(self):
"""Listen on incoming messages from host
Expand All @@ -232,6 +244,8 @@ def _listen():
"rise": "risen",
"inFocus": "inFocused",
"outFocus": "outFocused",
"publish": "published",
"validate": "validated"
}.get(payload["name"])

if not signal:
Expand Down
25 changes: 25 additions & 0 deletions pyblish_qml/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,31 @@ def on_shown():

return server

def publish():
# get existing GUI
if _state.get("currentServer"):
server = _state["currentServer"]
proxy = ipc.server.Proxy(server)

try:
proxy.publish()

except IOError:
# The running instance has already been closed.
_state.pop("currentServer")

def validate():
# get existing GUI
if _state.get("currentServer"):
server = _state["currentServer"]
proxy = ipc.server.Proxy(server)

try:
proxy.validate()

except IOError:
# The running instance has already been closed.
_state.pop("currentServer")

def install_callbacks():
pyblish.api.register_callback("instanceToggled", _toggle_instance)
Expand Down
6 changes: 6 additions & 0 deletions pyblish_qml/ipc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def kill(self):
"""Forcefully destroy the process"""
self.popen.kill()

def publish(self):
self._dispatch("publish")

def validate(self):
self._dispatch("validate")

def _dispatch(self, func, args=None):
data = json.dumps(
{
Expand Down
2 changes: 1 addition & 1 deletion pyblish_qml/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

VERSION_MAJOR = 1
VERSION_MINOR = 4
VERSION_PATCH = 3
VERSION_PATCH = 4

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

0 comments on commit 7e86c44

Please sign in to comment.