From ef67c56046625d8b7ae01f414d3e32fc314f26a0 Mon Sep 17 00:00:00 2001 From: Lars van der Bijl <285658+larsbijl@users.noreply.github.com> Date: Thu, 10 Dec 2020 20:42:46 +0000 Subject: [PATCH] Add booking status bar into Monitor Cue widget. (#837) --- cuegui/cuegui/CueJobMonitorTree.py | 4 ++-- cuegui/cuegui/DarkPalette.py | 3 +++ cuegui/cuegui/ItemDelegate.py | 23 ++++++++++++----------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/cuegui/cuegui/CueJobMonitorTree.py b/cuegui/cuegui/CueJobMonitorTree.py index 4c5c03504..68c34486b 100644 --- a/cuegui/cuegui/CueJobMonitorTree.py +++ b/cuegui/cuegui/CueJobMonitorTree.py @@ -103,8 +103,8 @@ def __init__(self, parent): data=lambda job: job.data.job_stats.total_frames, sort=lambda job: job.data.job_stats.total_frames, tip="The total number of frames.") -# self.addColumn("_Booking Bar", 150, id=8, default=False, -# delegate=JobBookingBarDelegate) + self.addColumn("_Booking Bar", 150, id=8, + delegate=cuegui.ItemDelegate.JobBookingBarDelegate) self.addColumn("Min", 38, id=9, data=lambda job: "%.0f" % job.data.min_cores, sort=lambda job: job.data.min_cores, diff --git a/cuegui/cuegui/DarkPalette.py b/cuegui/cuegui/DarkPalette.py index 554426d64..224424598 100644 --- a/cuegui/cuegui/DarkPalette.py +++ b/cuegui/cuegui/DarkPalette.py @@ -126,3 +126,6 @@ def ColorF(r, g, b): COLOR_SHOW_BACKGROUND = GreyF(0.13) COLOR_SHOW_FOREGROUND = GreyF(0.79) COLOR_JOB_FOREGROUND = GreyF(0.79) + +KILL_ICON_COLOUR = QtGui.QColor(224, 52, 52) +PAUSE_ICON_COLOUR = QtGui.QColor(88, 163, 209) \ No newline at end of file diff --git a/cuegui/cuegui/ItemDelegate.py b/cuegui/cuegui/ItemDelegate.py index 0ec671aa6..5ea6c7888 100644 --- a/cuegui/cuegui/ItemDelegate.py +++ b/cuegui/cuegui/ItemDelegate.py @@ -165,34 +165,37 @@ def paint(self, painter, option, index): rect = option.rect.adjusted(12, 6, -12, -6) - jobMin = int(job.data.minCores * 100) - jobMax = int(job.data.maxCores * 100) - jobRunning = job.data.runningFrames - jobWaiting = job.data.waitingFrames - painter.save() try: self._drawBackground(painter, option, index) try: + jobRunning = job.data.job_stats.running_frames + jobWaiting = job.data.job_stats.waiting_frames + try: + cores_per_frame = float(job.data.job_stats.reserved_cores / jobRunning) + except: + cores_per_frame = float(6 / 1) + jobMin = int(job.data.min_cores / cores_per_frame) + jobMax = int(job.data.max_cores / cores_per_frame) ratio = rect.width() / float(jobRunning + jobWaiting) if jobWaiting: painter.fillRect( rect.adjusted(0, 2, 0, -2), - RGB_FRAME_STATE[opencue.api.job_pb2.FrameState.Waiting]) + RGB_FRAME_STATE[opencue.api.job_pb2.WAITING]) if jobRunning: painter.fillRect( rect.adjusted(0, 0, -int(ceil(ratio * jobWaiting)), 0), - RGB_FRAME_STATE[opencue.api.job_pb2.FrameState.Running]) + RGB_FRAME_STATE[opencue.api.job_pb2.RUNNING]) - painter.setPen(QtCore.Qt.blue) + painter.setPen(cuegui.Style.ColorTheme.PAUSE_ICON_COLOUR) x = min(rect.x() + ratio * jobMin, option.rect.right() - 9) painter.drawLine(x, option.rect.y(), x, option.rect.y() + option.rect.height()) - painter.setPen(QtCore.Qt.red) + painter.setPen(cuegui.Style.ColorTheme.KILL_ICON_COLOUR) x = min(rect.x() + ratio * jobMax, option.rect.right() - 6) painter.drawLine(x, option.rect.y(), x, option.rect.y() + option.rect.height()) @@ -200,8 +203,6 @@ def paint(self, painter, option, index): except ZeroDivisionError: pass - if option.state & QtWidgets.QStyle.State_Selected: - self._drawSelectionOverlay(painter, option) finally: painter.restore() del painter