Skip to content

Commit

Permalink
Add progressbar to layers panel. (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbijl committed Dec 2, 2020
1 parent 068d0e3 commit 4366d86
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cuegui/cuegui/ItemDelegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,51 @@ def __init__(self, parent, *args):

def paint(self, painter, option, index):
AbstractDelegate.paint(self, painter, option, index)


class ProgressDelegate(AbstractDelegate):

def __init__(self, parent, *args):
AbstractDelegate.__init__(self, parent, *args)

def paint(self, painter, option, index):
if index.data(QtCore.Qt.UserRole) == cuegui.Constants.TYPE_FRAME:
frame = self.parent().itemFromIndex(index).rpcObject
opts = QtWidgets.QStyleOptionProgressBar()
opts.rect = option.rect
opts.minimum = 1
opts.maximum = 100
opts.textVisible = True

if frame.data.state == opencue.api.job_pb2.SUCCEEDED:
progress = 100
elif frame.data.state == opencue.api.job_pb2.RUNNING:
progress = int(cuegui.Progress.progress(frame.id()))
else:
progress = 0

opts.progress = progress
opts.text = "{0:d} %".format(progress)
opts.textVisible = True

QtWidgets.QApplication.style().drawControl(QtWidgets.QStyle.CE_ProgressBar, opts, painter)

elif index.data(QtCore.Qt.UserRole) == cuegui.Constants.TYPE_LAYER:
layer = self.parent().itemFromIndex(index).rpcObject
opts = QtWidgets.QStyleOptionProgressBar()
opts.rect = option.rect
opts.minimum = 1
opts.maximum = 100
opts.textVisible = True

progress = int(layer.percentCompleted())
opts.progress = progress
opts.text = "{0:d} %".format(progress)
opts.textVisible = True

QtWidgets.QApplication.style().drawControl(QtWidgets.QStyle.CE_ProgressBar, opts, painter)
else:
AbstractDelegate.paint(self, painter, option, index)

def sizeHint(self, option, index):
return QtCore.QSize(12, 12)
5 changes: 5 additions & 0 deletions cuegui/cuegui/LayerMonitorTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ def __init__(self, parent):
data=lambda layer: " | ".join(layer.data.tags),
tip="The tags define what resources may be booked on\n"
"frames in this layer.")
self.addColumn("Progress", 100, id=19,
delegate=cuegui.ItemDelegate.ProgressDelegate,
data=lambda layer: layer.percentCompleted(),
sort=lambda layer: layer.percentCompleted(),
tip="Progress for the Layer")

cuegui.AbstractTreeWidget.AbstractTreeWidget.__init__(self, parent)

Expand Down

0 comments on commit 4366d86

Please sign in to comment.