Skip to content

Commit

Permalink
Merge pull request #83 from mottosso/master
Browse files Browse the repository at this point in the history
0.2.9
  • Loading branch information
mottosso committed Apr 17, 2015
2 parents 59ada36 + 60ce7f1 commit 0ed34ec
Show file tree
Hide file tree
Showing 49 changed files with 1,644 additions and 715 deletions.
10 changes: 10 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

Version 0.2.9
-------------

- Feature: Perspective
- Enhancement: Uniform sizes in Terminal
- Bugfix: Repair now repairs broken context (see #73)
- API: New model (see #81)
- API: Added Pyblish.Scrollbar
- API: Added Pyblish.Spacer

Version 0.2.8
-------------

Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

The Pyblish QML project provides for a graphical frontend to [Pyblish][].

- [Installation][install]
- [User Guide][userguide]
- [Contributing][contributing]

[install]: https://github.com/pyblish/pyblish-qml/wiki/Installation
[contributing]: https://github.com/pyblish/pyblish-qml/wiki/Contributing
[userguide]: https://github.com/pyblish/pyblish-qml/wiki/User-Guide
[Pyblish]: https://github.com/pyblish/pyblish
[userguide]: https://github.com/pyblish/pyblish-qml/wiki
24 changes: 13 additions & 11 deletions pyblish_qml/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def __init__(self, parent=None):
self.setTitle("Pyblish")
self.setResizeMode(self.SizeRootObjectToView)

self.setWidth(430)
self.setHeight(600)
self.setMinimumSize(QtCore.QSize(430, 300))

def event(self, event):
"""Allow GUI to be closed upon holding Shift"""
if event.type() == QtCore.QEvent.Close:
Expand Down Expand Up @@ -67,18 +71,14 @@ class Application(QtGui.QGuiApplication):
quit_signal = QtCore.pyqtSignal()
keep_alive = False

def __init__(self, port):
def __init__(self, source, port):
super(Application, self).__init__(sys.argv)

self.setWindowIcon(QtGui.QIcon(ICON_PATH))

window = Window(self)
window.statusChanged.connect(self.on_status_changed)

window.setWidth(400)
window.setHeight(600)
window.setMinimumSize(QtCore.QSize(300, 300))

engine = window.engine()
engine.addImportPath(QML_IMPORT_DIR)

Expand All @@ -95,7 +95,7 @@ def __init__(self, port):
self.server_unresponsive.connect(self.on_server_unresponsive)
self.show_signal.connect(self.show)

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

def on_status_changed(self, status):
if status == QtQuick.QQuickView.Error:
Expand Down Expand Up @@ -239,14 +239,16 @@ def request(self, *args, **kwargs):
return rest.request("http://127.0.0.1", self.port, *args, **kwargs)


def main(port, pid=None, preload=False, debug=False, validate=True):
def main(port, source=None, pid=None,
preload=False, debug=False, validate=True):
"""Start the Qt-runtime and show the window
Arguments:
port (int): Port through which to communicate
pid (int, optional): Process id of parent process.
debug (bool, optional): Whether or not to run in debug-mode.
Defaults to False
source (str): QML entry-point
pid (int, optional): Process id of parent process. Deprecated
preload (bool, optional): Load in backgrund. Defaults to False
debug (bool, optional): Run in debug-mode. Defaults to False
validate (bool, optional): Whether the environment should be validated
prior to launching. Defaults to True
Expand Down Expand Up @@ -306,7 +308,7 @@ def main(port, pid=None, preload=False, debug=False, validate=True):

util.timer("application")

app = Application(port)
app = Application(source or APP_PATH, port)

app.keep_alive = not debug
app.listen()
Expand Down
86 changes: 52 additions & 34 deletions pyblish_qml/control.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@

import time

# Dependencies
from PyQt5 import QtCore
from PyQt5 import QtCore, QtQml

# Local libraries
import util
import rest
import models


def pyqtConstantProperty(fget):
return QtCore.pyqtProperty(QtCore.QVariant,
fget=fget,
constant=True)


class Controller(QtCore.QObject):
"""Handle events coming from QML
Expand All @@ -18,6 +27,7 @@ class Controller(QtCore.QObject):
"""

# PyQt Signals
info = QtCore.pyqtSignal(str, arguments=["message"])
error = QtCore.pyqtSignal(str, arguments=["message"])

Expand All @@ -39,15 +49,32 @@ class Controller(QtCore.QObject):

state_changed = QtCore.pyqtSignal(str, arguments=["state"])

# PyQt Properties
itemModel = pyqtConstantProperty(lambda self: self.item_model)
itemProxy = pyqtConstantProperty(lambda self: self.item_proxy)
recordProxy = pyqtConstantProperty(lambda self: self.record_proxy)
errorProxy = pyqtConstantProperty(lambda self: self.error_proxy)
instanceProxy = pyqtConstantProperty(lambda self: self.instance_proxy)
pluginProxy = pyqtConstantProperty(lambda self: self.plugin_proxy)
resultModel = pyqtConstantProperty(lambda self: self.result_model)
resultProxy = pyqtConstantProperty(lambda self: self.result_proxy)

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

self._temp = [1, 2, 3, 4]

self.item_model = models.ItemModel()
self.terminal_model = models.TerminalModel()
self.result_model = models.ResultModel()

self.instance_proxy = models.InstanceProxy(self.item_model)
self.plugin_proxy = models.PluginProxy(self.item_model)
self.terminal_proxy = models.TerminalProxy(self.terminal_model)
self.result_proxy = models.ResultProxy(self.result_model)

# Used in Perspective
self.item_proxy = models.ProxyModel(self.item_model)
self.record_proxy = models.RecordProxy(self.result_model)
self.error_proxy = models.ErrorProxy(self.result_model)

self.changes = dict()
self.is_running = False
Expand All @@ -59,7 +86,7 @@ def __init__(self, port, parent=None):
self.info.connect(self.on_info)
self.error.connect(self.on_error)
self.finished.connect(self.on_finished)
self.item_model.data_changed.connect(self.on_data_changed)
# self.item_model.data_changed.connect(self.on_data_changed)

self.state_changed.connect(self.on_state_changed)

Expand Down Expand Up @@ -178,21 +205,9 @@ def state(self):
def states(self):
return self._states

@QtCore.pyqtProperty(QtCore.QVariant, constant=True)
def instanceProxy(self):
return self.instance_proxy

@QtCore.pyqtProperty(QtCore.QVariant, constant=True)
def pluginProxy(self):
return self.plugin_proxy

@QtCore.pyqtProperty(QtCore.QVariant, constant=True)
def terminalModel(self):
return self.terminal_model

@QtCore.pyqtProperty(QtCore.QVariant, constant=True)
def terminalProxy(self):
return self.terminal_proxy
@QtCore.pyqtSlot(result=float)
def time(self):
return time.time()

@QtCore.pyqtSlot(int)
def toggleInstance(self, index):
Expand Down Expand Up @@ -243,15 +258,15 @@ def exclude(self, target, operation, role, value):
"""

target = {"terminal": self.terminal_proxy,
target = {"result": self.result_proxy,
"instance": self.instance_proxy,
"plugin": self.plugin_proxy}[target]

if operation == "add":
target.add_exclusion(role, value)

elif operation == "remove":
target.remove_exclusion(role)
target.remove_exclusion(role, value)

else:
raise TypeError("operation must be either `add` or `remove`")
Expand Down Expand Up @@ -283,12 +298,12 @@ def __toggle_item(self, model, index):
if "ready" not in self.states:
return self.error.emit("Not ready")

item = model.itemFromIndex(index)
model.setData(index, "isToggled", not item.isToggled)
item = model.items[index]
item.isToggled = not item.isToggled

def echo(self, data):
"""Append `data` to terminal model"""
self.terminal_model.add_item(data)
"""Append `data` to result model"""
self.result_model.add_item(**data)

# Event handlers

Expand Down Expand Up @@ -525,14 +540,14 @@ def finish():

# NOTE(marcus): This is temporary
plugin_name = result["plugin"]
plugin_item = self.item_model.itemFromName(plugin_name)
plugin_item = self.item_model.plugins[plugin_name]
result["doc"] = plugin_item.doc
# end

self.terminal_model.update_with_result(result)
self.result_model.update_with_result(result)

if iterator is None:
iterator = self.item_model.iterator()
iterator = models.ItemIterator(self.item_model)

if test is None:
def test(pair):
Expand Down Expand Up @@ -580,7 +595,7 @@ def publish(self):
self.is_running = True
self.save()
self.process_next(
iterator=self.item_model.iterator(),
iterator=models.ItemIterator(self.item_model),
test=self.tests("publish"))

@QtCore.pyqtSlot()
Expand All @@ -605,7 +620,7 @@ def reset(self):

self.initialising.emit()
self.item_model.reset()
self.terminal_model.reset()
self.result_model.reset()
self.changes.clear()

def init():
Expand All @@ -622,7 +637,7 @@ def on_finished(state):
return self.error.emit(str(state))

self.item_model.update_with_state(state)
self.terminal_model.update_with_state(state)
self.result_model.update_with_state(state)

def selectors():
for item in self.item_model.plugins:
Expand All @@ -647,11 +662,12 @@ def on_finished():

@QtCore.pyqtSlot(int)
def repairPlugin(self, index):
if "finished" not in self.states:
return self.error.emit("Not ready")

index = self.plugin_proxy.index(index, 0, QtCore.QModelIndex())
index = self.plugin_proxy.mapToSource(index)

self.item_model.setData(index, "hasError", False)

def iterator(plugin):
if plugin.canRepairContext:
yield plugin, None
Expand All @@ -668,5 +684,7 @@ def iterator(plugin):
self.publishing.emit()
self.is_running = True

plugin = self.item_model.itemFromIndex(index.row())
plugin = self.item_model.items[index.row()]
plugin.hasError = False

self.repair_next(iterator=iterator(plugin))
Loading

0 comments on commit 0ed34ec

Please sign in to comment.