Beispiel #1
0
    def __addHost(self, entry):
        host = entry["host"]
        procs = entry["procs"]
        rtime = entry["time"]

        checkbox = QtGui.QStandardItem(host.data.name)
        checkbox.setCheckable(True)

        self.__model.appendRow([
            checkbox,
            QtGui.QStandardItem(str(entry["cores"])),
            QtGui.QStandardItem("%0.2fGB" % (entry["mem"] / 1048576.0)),
            QtGui.QStandardItem(Utils.secondsToHHMMSS(rtime))
        ])

        for proc in procs:
            checkbox.appendRow([
                QtGui.QStandardItem(proc.data.jobName),
                QtGui.QStandardItem(str(proc.data.reservedCores)),
                QtGui.QStandardItem("%0.2fGB" %
                                    (proc.data.reservedMemory / 1048576.0)),
                QtGui.QStandardItem(
                    Utils.secondsToHHMMSS(time.time() -
                                          proc.data.dispatchTime)),
                QtGui.QStandardItem(proc.data.groupName),
                QtGui.QStandardItem(",".join(proc.data.services))
            ])

        self.__tree.setExpanded(self.__model.indexFromItem(checkbox), True)
        self.__tree.resizeColumnToContents(0)
Beispiel #2
0
    def _paintSelected(self, painter, option, index):
        painter.save()
        try:
            self._drawBackground(painter, option, index)

            # Draw the selection overlay
            self._drawSelectionOverlay(painter, option)

            # Draw the icon, if any
            value = index.data(QtCore.Qt.DecorationRole)
            if value is not None:
                icon = QtGui.QIcon(value)
                icon.paint(painter, option.rect.adjusted(3, 1, -1, -1),
                           QtCore.Qt.AlignLeft)
                option.rect.adjust(22, 0, 0, 0)

            # Draw the text
            painter.setPen(QtGui.QColor(index.data(QtCore.Qt.ForegroundRole)))
            painter.setFont(QtGui.QFont(index.data(QtCore.Qt.FontRole)))
            painter.drawText(
                option.rect.adjusted(3, -1, -3, 0),
                QtCore.Qt.TextAlignmentRole | QtCore.Qt.AlignVCenter,
                str(index.data(QtCore.Qt.DisplayRole)))
        finally:
            painter.restore()
            del painter
Beispiel #3
0
    def __updateBackgroundPixmap(self, colors):
        """Updates the background image buffer based on the given colors
        @type  colors: list<QBrush>
        @param colors: List of job background colors"""
        # Could draw it the max size and allow the resize on drawPixmap
        # that way the same buffer is always used
        assert threading.currentThread().getName() == "MainThread"
        buffer = QtGui.QPixmap(self.contentsRect().size())
        buffer.fill(self.__baseColor)

        if colors:
            painter = QtGui.QPainter()
            painter.begin(buffer)
            try:
                rect = buffer.rect()

                # Number of jobs
                amount = len(colors)
                # Number of pixels per job
                ratio = float(rect.height())/amount

                for index, color in enumerate(colors):
                    if color:
                        painter.fillRect(rect.adjusted(0,
                                                       ratio * index,
                                                       0,
                                                       -(ratio * (amount - index - 1))),
                                         color)
            finally:
                painter.end()
                del painter

        self.__background = buffer
    def __paintSelection(self, painter):
        if self.__selectionRange == None: return
        selection = (min(self.__selectionRange[0], self.__selectionRange[1]), max(self.__selectionRange[0], self.__selectionRange[1]))

        leftExtent = self.__getTickArea(selection[0])
        rightExtent = self.__getTickArea(selection[1] - 1)
        selectionExtent = QtCore.QRect(leftExtent.left(), leftExtent.top(), rightExtent.right() - leftExtent.left() + 2, leftExtent.height()/2)
        painter.fillRect(selectionExtent, QtGui.QBrush(QtGui.QColor(75, 75, 75)))
Beispiel #5
0
    def __createMenus(self):
        """Creates the menus at the top of the window"""
        self.menuBar().setFont(Constants.STANDARD_FONT)

        # Menu bar
        self.fileMenu = self.menuBar().addMenu("&File")
        self.facilityMenu = self.__facilityMenuSetup(
            self.menuBar().addMenu("&Cuebot"))
        self.PluginMenu = self.menuBar().addMenu("&Views/Plugins")
        self.windowMenu = self.menuBar().addMenu("&Window")
        self.helpMenu = self.menuBar().addMenu("&Help")

        # Menu Bar: File -> Close Window
        close = QtWidgets.QAction(QtGui.QIcon('icons/exit.png'),
                                  '&Close Window', self)
        close.setStatusTip('Close Window')
        close.triggered.connect(self.__windowCloseWindow)
        self.fileMenu.addAction(close)

        # Menu Bar: File -> Exit Application
        exit = QtWidgets.QAction(QtGui.QIcon('icons/exit.png'),
                                 'E&xit Application', self)
        exit.setShortcut('Ctrl+Q')
        exit.setStatusTip('Exit application')
        exit.triggered.connect(self.__windowCloseApplication)
        self.fileMenu.addAction(exit)

        self.__windowMenuSetup(self.windowMenu)

        self.windowMenu.addSeparator()

        self.__toggleFullscreenSetup(self.windowMenu)

        # Menu Bar: Help -> Online User Guide.
        action = QtWidgets.QAction('Online User Guide', self)
        action.triggered.connect(self.openUserGuide)
        self.helpMenu.addAction(action)

        # Menu Bar: Help -> Make a Suggestion
        action = QtWidgets.QAction('Make a Suggestion', self)
        action.triggered.connect(self.openSuggestionPage)
        self.helpMenu.addAction(action)

        # Menu Bar: Help -> Report a Bug
        action = QtWidgets.QAction('Report a Bug', self)
        action.triggered.connect(self.openBugPage)
        self.helpMenu.addAction(action)

        self.helpMenu.addSeparator()

        # Menu Bar: Help -> About
        about = QtWidgets.QAction(QtGui.QIcon('icons/about.png'), 'About',
                                  self)
        about.setShortcut('F1')
        about.setStatusTip('About')
        about.triggered.connect(self.displayAbout)
        self.helpMenu.addAction(about)
Beispiel #6
0
    def paintEvent(self, event):
        QtWidgets.QWidget.paintEvent(self, event)

        #Skip this if too small, if splitter is all the way over

        painter = QtGui.QPainter(self)
        try:
            rect = self.contentsRect().adjusted(5, 5, -5, -5)
            painter.save()

            painter.fillRect(rect,
                             QtGui.qApp.palette().color(QtGui.QPalette.Base))

            if len(self.__history) > 1:
                stepWidth = rect.width() / float(len(self.__history) - 1)
                ratioHeight = (rect.height() - 2) / float(self.__max)

                # Box outline
                painter.setPen(QtCore.Qt.black)
                painter.drawRect(rect)

                painter.setPen(self.__color)
                points = QtGui.QPolygon(len(self.__history) + 2)

                # Bottom left
                #points.setPoint(0, rect.bottomLeft())
                points.setPoint(0, rect.left() + 1, rect.bottom())

                # All the data points
                num = 1
                for i in range(len(self.__history)):
                    points.setPoint(
                        num, max(rect.x() + 1,
                                 rect.x() - 1 + stepWidth * i),
                        rect.bottom() - ratioHeight * self.__history[i])
                    num += 1

                # Bottom right
                points.setPoint(num, rect.bottomRight())

                # Draw filled in
                painter.setBrush(self.__brush)
                painter.drawPolygon(points)

                # Draw subscription size line
                painter.setPen(QtCore.Qt.red)
                height = rect.bottom() - ratioHeight * self.__line
                painter.drawLine(rect.left() + 1, height,
                                 rect.right() - 1, height)

        finally:
            painter.restore()
            painter.end()
            del painter
Beispiel #7
0
    def redirect(self):
        '''
        Redirect the selected procs to the target job, after running a few
        checks to verify it's safe to do that.

        @postcondition: The selected procs are redirected to the target job
        '''

        # Get selected items
        items = [
            self.__model.item(row) for row in range(0, self.__model.rowCount())
        ]
        selected_items = [
            item for item in items if item.checkState() == QtCore.Qt.Checked
        ]
        if not selected_items:  # Nothing selected, exit
            self.__warn('You have not selected anything to redirect.')
            return

        # Get the Target Job
        job_name = self.__controls.getJob()
        if not job_name:  # No target job, exit
            self.__warn('You must have a job name selected.')
            return
        job = None
        try:
            job = opencue.api.findJob(job_name)
        except opencue.EntityNotFoundException:  # Target job finished, exit
            self.__warn_and_stop('The job you\'re trying to redirect to '
                                 'appears to be no longer in the cue!')
            return

        # Gather Selected Procs
        procs_by_alloc = self.__get_selected_procs_by_alloc(selected_items)
        show_name = job.show()
        for alloc, procs in procs_by_alloc.items():
            if not self.__is_cross_show_safe(procs, show_name):  # Cross-show
                return
            if not self.__is_burst_safe(alloc, procs, show_name):  # At burst
                return

        # Redirect
        errors = []
        for item in selected_items:
            entry = self.__hosts.get(str(item.text()))
            procs = entry["procs"]
            try:
                host = entry["host"]
                host.redirectToJob(procs, job)
            except Exception, e:
                errors.append(str(e))
            item.setIcon(QtGui.QIcon(QtGui.QPixmap(":retry.png")))
            item.setEnabled(False)
    def __paintEndTime(self, painter):
        endFrame = self.endFrame()
        timeExtent = self.__getTickArea(endFrame)
        oldPen = painter.pen()
        painter.setPen(QtGui.QColor(255, 0, 0))
        painter.drawLine(timeExtent.left(), timeExtent.top(), timeExtent.left(), 0)

        metric = QtGui.QFontMetrics(painter.font())
        frameString = str(int(endFrame))
        xPos = timeExtent.left() - metric.width(frameString) / 2
        yPos =  metric.ascent() + 1
        painter.drawText(xPos, yPos, frameString)
        painter.setPen(oldPen)
    def updateWidgets(self):
        if not self.__widgets:
            parent = self.parent()
            treeWidget = self.treeWidget()

            combo = NoWheelComboBox(parent)
            combo.addItems(MATCHSUBJECT)
            treeWidget.setItemWidget(self, 0, combo)
            combo.currentIndexChanged.connect(self.setSubject)
            self.__widgets["subject"] = combo

            combo = NoWheelComboBox(parent)
            combo.addItems(MATCHTYPE)
            treeWidget.setItemWidget(self, 1, combo)
            combo.currentIndexChanged.connect(self.setType)
            self.__widgets["type"] = combo

            edit = QtWidgets.QLineEdit("", parent)
            treeWidget.setItemWidget(self, 2, edit)
            edit.editingFinished.connect(self.setInput)
            self.__widgets["input"] = edit

            btn = QtWidgets.QPushButton(QtGui.QIcon(":kill.png"), "", parent)
            treeWidget.setItemWidget(self, 3, btn)
            btn.clicked.connect(self.delete)
            self.__widgets["delete"] = btn

        self.__widgets["subject"].setCurrentIndex(
            MATCHSUBJECT.index(str(self.rpcObject.subject())))
        self.__widgets["type"].setCurrentIndex(
            MATCHTYPE.index(str(self.rpcObject.type())))
        # Only update input if user is not currently editing the value
        if not self.__widgets["input"].hasFocus() or \
           not self.__widgets["input"].isModified():
            self.__widgets["input"].setText(self.rpcObject.input())
Beispiel #10
0
    def __processUpdateColors(self):
        """Updates the list of colors to display
        calls __updateBackgroundPixmap to build pixmap
        calls update to redraw"""
        items = self.__sourceTree.findItems("",
                                            QtCore.Qt.MatchContains |
                                            QtCore.Qt.MatchRecursive,
                                            0)

        colors = []
        for item in items:
            color = QtGui.QBrush(item.data(0, QtCore.Qt.BackgroundRole))
            if color.color() == self.__baseColor:
                colors.append(None)
            else:
                colors.append(color)

        self.__colorsLock.lockForWrite()
        try:
            self.__colors = colors
        finally:
            self.__colorsLock.unlock()

        self.__updateBackgroundPixmap(colors)

        self.update()
Beispiel #11
0
 def _generateSplashFromImage(self, imagePath):
     if os.path.isfile(imagePath):
         try:
             return imagePath and QtGui.QImage(imagePath)
         except StandardError:
             pass
     return None
Beispiel #12
0
def startDrag(dragSource, dropActions, objects):
    mimeData = QtCore.QMimeData()
    mimeData.setText("\n".join(["%s" % job.data.name for job in objects]))

    mimeDataAdd(mimeData, "application/x-job-names",
                [object.data.name for object in objects if isJob(object)])

    mimeDataAdd(mimeData, "application/x-job-ids",
                [opencue.id(object) for object in objects if isJob(object)])

    mimeDataAdd(mimeData, "application/x-group-names",
                [object.data.name for object in objects if isGroup(object)])

    mimeDataAdd(mimeData, "application/x-group-ids",
                [opencue.id(object) for object in objects if isGroup(object)])

    mimeDataAdd(mimeData, "application/x-host-names",
                [object.data.name for object in objects if isHost(object)])

    mimeDataAdd(mimeData, "application/x-host-ids",
                [opencue.id(object) for object in objects if isHost(object)])

    drag = QtGui.QDrag(dragSource)
    drag.setMimeData(mimeData)
    drag.exec_(QtCore.Qt.MoveAction)
Beispiel #13
0
 def __toggleFullscreenSetup(self, menu):
     # Menu Bar: Window -> Toggle Full-Screen
     fullscreen = QtWidgets.QAction(QtGui.QIcon('icons/fullscreen.png'),
                                    'Toggle Full-Screen', self)
     fullscreen.setShortcut('Ctrl+F')
     fullscreen.setStatusTip('Toggle Full-Screen')
     fullscreen.triggered.connect(self.__toggleFullscreen)
     menu.addAction(fullscreen)
Beispiel #14
0
    def __init__(self, parent):
        QtWidgets.QWidget.__init__(self, parent)

        self.__color = QtGui.QColor(55, 200, 55)
        self.__brush = QtGui.QBrush()
        self.__brush.setColor(self.__color)
        self.__brush.setStyle(QtCore.Qt.SolidPattern)

        self.__show = opencue.api.findShow("clo")
        self.__history = [0] * 100
        self.__line = 575
        self.__max = max(self.__line * 1.2, 80)

        self.__timer = QtCore.QTimer(self)
        self.__timer.timeout.connect(self.addNumber)

        self.__timer.start(10000)
Beispiel #15
0
 def _drawSelectionOverlay(self, painter, option):
     # Draw the selection
     if option.rect.width() > 0:
         selectionPen = QtGui.QPen(self.__colorInvalid)
         selectionPen.setWidth(0)
         painter.setPen(selectionPen)
         painter.setBrush(self.__brushSelected)
         painter.drawRect(option.rect)
    def __paintFloatTime(self, painter):
        if self.__floatTime == None: return

        timeExtent = self.__getTickArea(self.__floatTime)
        oldPen = painter.pen()
        painter.setPen(QtGui.QColor(90, 90, 90))
        painter.drawLine(timeExtent.left(), timeExtent.top(), timeExtent.left(), timeExtent.bottom())

        if self.__selectionRange:
            painter.setPen(QtGui.QColor(255,255,255))
        else:
            painter.setPen(QtGui.QColor(128, 128, 128))
        metric = QtGui.QFontMetrics(painter.font())
        frameString = str(self.__floatTime)
        xPos = timeExtent.left() - metric.width(frameString) / 2
        yPos =  timeExtent.top() + metric.ascent()
        painter.drawText(xPos, yPos, frameString)
        painter.setPen(oldPen)
Beispiel #17
0
    def __init__(self, object, parent):
        if not self.__initialized:
            self.__class__.__initialized = True
            self.__class__.__icon = QtGui.QIcon(":group.png")
            self.__class__.__foregroundColor = Style.ColorTheme.COLOR_GROUP_FOREGROUND
            self.__class__.__backgroundColor = Style.ColorTheme.COLOR_GROUP_BACKGROUND
            self.__class__.__type = Constants.TYPE_GROUP

        AbstractWidgetItem.__init__(self, Constants.TYPE_GROUP, object, parent)
Beispiel #18
0
 def _drawBackground(self, painter, option, index):
     # Draw the background color
     painter.setPen(NO_PEN)
     role = index.data(QtCore.Qt.BackgroundRole)
     if role is not None:
         painter.setBrush(QtGui.QBrush(role))
     else:
         painter.setBrush(NO_BRUSH)
     painter.drawRect(option.rect)
    def __paintLabels(self, painter):
        tickExtent = self.__getTickAreaExtent()
        labelHeight = tickExtent.height() / 3
        labelPeriod = self.__getLabelPeriod()
        if labelPeriod == 0: return

        firstLabel = self.__frameRange[0] + labelPeriod - 1
        firstLabel = firstLabel - (firstLabel % labelPeriod)

        frames = []
        for frame in range(int(firstLabel), int(self.__frameRange[1])+1, int(labelPeriod)):
            frames.append(frame)
        if frames[0] != self.__frameRange[0]:
            frames.insert(0, self.__frameRange[0])
        if frames[-1] != self.__frameRange[1]:
            frames.append(self.__frameRange[1])

        oldPen = painter.pen()

        # draw hatches for labelled frames
        painter.setPen(self.palette().color(QtGui.QPalette.Foreground))
        for frame in frames:
            xPos = self.__getTickArea(frame).left()
            painter.drawLine(xPos, -labelHeight, xPos, 0)

        painter.setPen(QtGui.QColor(10, 10, 10))

        metric = QtGui.QFontMetrics(painter.font())
        yPos = metric.ascent() + 1
        rightEdge = -10000
        width = metric.width(str(frames[-1]))
        farEdge = self.__getTickArea(frames[-1]).right() - width / 2

        farEdge -= 4

        for frame in frames:
            xPos = self.__getTickArea(frame).left()
            frameString = str(frame)
            width = metric.width(frameString)
            xPos = xPos - width / 2
            if (xPos > rightEdge and xPos + width < farEdge) or frame is frames[-1]:
                painter.drawText(xPos, yPos, frameString)
                rightEdge = xPos + width + 4
        painter.setPen(oldPen)
Beispiel #20
0
    def __init__(self, object, parent):
        if not self.__initialized:
            self.__class__.__initialized = True
            self.__class__.__commentIcon = QtGui.QIcon(":comment.png")
            self.__class__.__eatIcon = QtGui.QIcon(":eat.png")
            self.__class__.__backgroundColor = QtGui.qApp.palette().color(
                QtGui.QPalette.Base)
            self.__class__.__foregroundColor = Style.ColorTheme.COLOR_JOB_FOREGROUND
            self.__class__.__pausedColor = Style.ColorTheme.COLOR_JOB_PAUSED_BACKGROUND
            self.__class__.__finishedColor = Style.ColorTheme.COLOR_JOB_FINISHED_BACKGROUND
            self.__class__.__dyingColor = Style.ColorTheme.COLOR_JOB_DYING_BACKGROUND
            self.__class__.__dependedColor = Style.ColorTheme.COLOR_JOB_DEPENDED
            self.__class__.__noRunningColor = Style.ColorTheme.COLOR_JOB_WITHOUT_PROCS
            self.__class__.__highMemoryColor = Style.ColorTheme.COLOR_JOB_HIGH_MEMORY
            self.__class__.__type = Constants.TYPE_JOB

        object.parent = None

        AbstractWidgetItem.__init__(self, Constants.TYPE_JOB, object, parent)
Beispiel #21
0
def init():
    """initialize the global style settings"""
    settings = QtGui.qApp.settings
    loadColorTheme(settings.value("Style/colorTheme", DEFAULT_COLOR))
    setIconTheme(settings.value("Style/iconTheme", DEFAULT_ICON))

    font = QtGui.QFont(settings.value("Style/font", DEFAULT_FONT))
    fontSize = settings.value("Style/fontSize", DEFAULT_FONT_SIZE)
    font.setPointSizeF(fontSize)
    setFont(font)
Beispiel #22
0
 def __init__(self, object, parent):
     if not self.__initialized:
         Style.init()
         self.__class__.__initialized = True
         self.__class__.__commentIcon = QtGui.QIcon(":comment.png")
         self.__class__.__backgroundColor = QtGui.qApp.palette().color(QtGui.QPalette.Base)
         self.__class__.__foregroundColor = Style.ColorTheme.COLOR_JOB_FOREGROUND
         self.__class__.__pausedColor = Style.ColorTheme.COLOR_JOB_PAUSED_BACKGROUND
         self.__class__.__dyingColor = Style.ColorTheme.COLOR_JOB_DYING_BACKGROUND
         self.__class__.__type = Constants.TYPE_HOST
     AbstractWidgetItem.__init__(self, Constants.TYPE_HOST, object, parent)
    def __setupColumnMenu(self):
        self.__dropdown = QtWidgets.QToolButton(self)
        self.__dropdown.setFocusPolicy(QtCore.Qt.NoFocus)
        self.__dropdown.setFixedHeight(self.header().height() - 10)
        self.__dropdown.setToolTip("Click to select columns to display")
        self.__dropdown.setIcon(QtGui.QIcon(":column_popdown.png"))
        self.__dropdown.clicked.connect(self.__displayColumnMenu)

        layout = QtWidgets.QHBoxLayout(self.header())
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setAlignment(QtCore.Qt.AlignRight)
        layout.addWidget(self.__dropdown)
Beispiel #24
0
def DarkPalette():
    """The dark widget color scheme used by image viewing applications
    at Imageworks.
    """
    p = QtGui.QPalette()

    c = GreyF(0.175)
    p.setColor(p.Window, c)
    p.setColor(p.Button, c)

    c = GreyF(0.79)
    p.setColor(p.WindowText, c)
    p.setColor(p.Text, c)
    p.setColor(p.ButtonText, c)
    p.setColor(p.BrightText, c)

    c = ColorF(0.6, 0.6, 0.8)
    p.setColor(p.Link, c)
    c = ColorF(0.8, 0.6, 0.8)
    p.setColor(p.LinkVisited, c)

    c = GreyF(0.215)
    p.setColor(p.Base, c)
    c = GreyF(0.25)
    p.setColor(p.AlternateBase, c)

    c = GreyF(0.0)
    p.setColor(p.Shadow, c)

    c = GreyF(0.13)
    p.setColor(p.Dark, c)

    c = GreyF(0.21)
    p.setColor(p.Mid, c)

    c = GreyF(0.25)
    p.setColor(p.Midlight, c)

    c = GreyF(0.40)
    p.setColor(p.Light, c)

    c = ColorF(0.31, 0.31, 0.25)
    p.setColor(p.Highlight, c)

    c = GreyF(0.46)
    p.setColor(QtGui.QPalette.Disabled, p.WindowText, c)
    p.setColor(QtGui.QPalette.Disabled, p.Text, c)
    p.setColor(QtGui.QPalette.Disabled, p.ButtonText, c)

    c = GreyF(0.55)
    p.setColor(QtGui.QPalette.Disabled, p.BrightText, c)

    return p
Beispiel #25
0
    def __init__(self, object, parent):
        if not self.__initialized:
            if Style.ColorTheme is None:
                Style.init()
            self.__class__.__initialized = True
            self.__class__.__icon = QtGui.QIcon(":show.png")
            self.__class__.__foregroundColor = Style.ColorTheme.COLOR_SHOW_FOREGROUND
            self.__class__.__backgroundColor = Style.ColorTheme.COLOR_SHOW_BACKGROUND
            self.__class__.__type = Constants.TYPE_ROOTGROUP

        AbstractWidgetItem.__init__(self, Constants.TYPE_ROOTGROUP, object,
                                    parent)
Beispiel #26
0
def create(parent, text, tip, callback=None, icon=None):
    """create(QtGui.QWidget, string text, string tip, callable callback=None, string icon=None)
        creates a QtGui.QAction and optionally connects it to a slot
    """
    a = QtWidgets.QAction(parent)
    a.setText(text)
    if tip:
        a.setToolTip(tip)
    if icon:
        a.setIcon(QtGui.QIcon(":%s.png" % (icon)))
    if callback:
        connectActionSlot(a,callback)
    return a
Beispiel #27
0
    def paintEvent(self, event):
        """Called when the widget is being redrawn
        @type  event: QEvent
        @param event: The draw event"""
        assert threading.currentThread().getName() == "MainThread"
        self.__colorsLock.lockForWrite()
        try:
            if not self.__colors:
                return
            colors = self.__colors
        finally:
            self.__colorsLock.unlock()

        painter = QtGui.QPainter(self)
        painter.save()
        try:
            rect = self.contentsRect()

            # Number of pixels per job
            ratio = float(rect.height())/len(colors)
            # How far down the slider is
            shift = self.__sourceTree.verticalScrollBar().value() * ratio
            # Length not covered by the slider
            offPage = self.__sourceTree.verticalScrollBar().maximum() * ratio

            painter.drawPixmap(self.contentsRect(),
                               self.__background,
                               self.__background.rect())

            # Draw the slider
            pen = QtGui.QPen(self.__colorInvalid)
            pen.setWidth(0)
            painter.setPen(pen)
            painter.setBrush(self.__brushPattern)
            painter.drawRect(rect.adjusted(2, shift, -2, -offPage + shift))
        finally:
            painter.restore()
            painter.end()
            del painter
    def paintEvent(self, paintEvent):
        painter = QtGui.QPainter(self)
        self.__paintBackground(painter)

        # Put the baseline at 0, 0
        painter.translate(0, self.height() / 2)
        painter.setFont(self.__labelFont)
        self.__paintSelection(painter)
        self.__paintTickmarks(painter)
        self.__paintLabels(painter)
        self.__paintFloatTime(painter)
        self.__paintStartTime(painter)
        self.__paintEndTime(painter)
Beispiel #29
0
    def __init__(self, app, app_name, version, resource_path):
        self.app = app

        self.WIDTH = 640
        self.HEIGHT = 346
        self.COLOR_TEXT = QtGui.QColor(180, 180, 180)
        self.MSG_FLAGS = QtCore.Qt.AlignRight | QtCore.Qt.AlignBottom

        image = self._findSplash(app_name, version, resource_path)
        if image:
            pixmap = QtGui.QPixmap.fromImage(image)
            self.splash = QtWidgets.QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint)
            self.splash.show()
            self.app.processEvents()
    def __paintTickmarks(self, painter):
        tickExtent = self.__getTickAreaExtent()
        tickHeight = tickExtent.height() / 8

        pen = QtGui.QPen(self.palette().window().color())
        painter.setPen(pen)

        # Draw the baseline
        painter.drawLine(tickExtent.left(), 0, tickExtent.right(), 0)

        tickArea = self.__getTickArea(self.__frameRange[0])
        if tickArea.width() >= 5:
            for frame in range(self.__frameRange[0], self.__frameRange[1] + 1, 1):
                xPos = self.__getTickArea(frame).left()
                painter.drawLine(xPos, -tickHeight, xPos, 0)