Exemple #1
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)
    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())
Exemple #3
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
Exemple #4
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)
Exemple #5
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)
Exemple #6
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)
Exemple #7
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)
Exemple #8
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)
    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)
Exemple #10
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)
Exemple #11
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
Exemple #12
0
    def __init__(self, title, text, items=[], parent=None):
        """A confirmation dialog
        @type  title: string
        @param title: The title for the confirmation dialog
        @type  text: string
        @param text: The text to display
        @type  items: list<string>
        @param items: Optional, a list of items, such as job names that will be
                      acted on
        @type  parent: QObject
        @param parent: The parent for this object"""
        QtWidgets.QDialog.__init__(self, parent)

        __btn_accept = QtWidgets.QPushButton("Ok", self)
        __btn_cancel = QtWidgets.QPushButton("Cancel", self)
        __label_text = QtWidgets.QLabel(text, self)
        __label_text.setWordWrap(True)
        __icon = QtWidgets.QLabel(self)
        __icon.setPixmap(QtGui.QIcon(":warning.png").pixmap(30, 30))

        layout = QtWidgets.QHBoxLayout(self)
        layout.addWidget(__icon)
        # Alignment is not correct unless done using setAlignment
        layout.setAlignment(__icon, QtCore.Qt.AlignTop)

        __vlayout = QtWidgets.QVBoxLayout()
        __vlayout.addWidget(__label_text)
        layout.addLayout(__vlayout)

        if items:
            __list_items = QtWidgets.QListWidget(self)
            __list_items.addItems(items)
            __list_items.setSelectionMode(
                QtWidgets.QAbstractItemView.NoSelection)
            __vlayout.addWidget(__list_items)

        __hlayout = QtWidgets.QHBoxLayout()
        __hlayout.addWidget(__btn_accept)
        __hlayout.addWidget(__btn_cancel)
        __vlayout.addLayout(__hlayout)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setSizeGripEnabled(True)
        self.setMaximumSize(400, 300)
        self.setWindowTitle(title)

        __btn_accept.clicked.connect(self.accept)
        __btn_cancel.clicked.connect(self.reject)
Exemple #13
0
def createAction(parent, id, text, tip, callback=None, icon=None):
    """create(QtWidgets.QWidget, string text, string tip, callable callback=None, string icon=None)
        creates a QtGui.QAction and optionally connects it to a slot
    """
    if id in Actions:
        raise Exception("Action %s has already been created" % (id))

    a = QtWidgets.QAction(parent)
    a.setText(text)
    if tip:
        a.setToolTip(tip)
    if icon:
        a.setIcon(QtGui.QIcon(":/images/%s.png" % icon))
    if callback:
        connectActionSlot(a,callback)
    Actions[id] = a
    return a
Exemple #14
0
    def data(self, col, role):
        """Returns the proper display data for the given column and role
        @type  col: int
        @param col: The column being displayed
        @type  role: QtCore.Qt.ItemDataRole
        @param role: The role being displayed
        @rtype:  object
        @return: The desired data"""
        if role == QtCore.Qt.DisplayRole:
            return self.column_info[col][Constants.COLUMN_INFO_DISPLAY](
                self._source, self.rpcObject)


#        if role == QtCore.Qt.DisplayRole:
#            if col not in self._cache:
#                self._cache[col] = QtCore.QVariant(self.column_info[col][Constants.COLUMN_INFO_DISPLAY](self._source, self.rpcObject))
#            return self._cache.get(col, Constants.QVARIANT_NULL)

        elif role == QtCore.Qt.ForegroundRole:
            if col == STATUS_COLUMN:
                return self.__foregroundColorBlack
            elif col == PROC_COLUMN and self.rpcObject.data.last_resource.startswith(
                    LOCALRESOURCE):
                return self.__foregroundColorGreen
            else:
                return self.__foregroundColor

        elif role == QtCore.Qt.BackgroundRole and col == STATUS_COLUMN:
            return self.__rgbFrameState[self.rpcObject.data.state]

        elif role == QtCore.Qt.DecorationRole and col == CHECKPOINT_COLUMN:
            if self.rpcObject.data.checkpoint_state == opencue.api.job_pb2.ENABLED:
                return QtGui.QIcon(":markdone.png")
        elif role == QtCore.Qt.TextAlignmentRole:
            if col == STATUS_COLUMN:
                return self.__alignCenter

            if col == PROC_COLUMN:
                return self.__alignRight

        elif role == QtCore.Qt.UserRole:
            return self.__type

        return Constants.QVARIANT_NULL
Exemple #15
0
def startup(app_name, app_version, argv):
    app = CueGuiApplication(argv)

    # Start splash screen
    from SplashWindow import SplashWindow
    splash = SplashWindow(app, app_name, app_version, Constants.RESOURCE_PATH)
    # Display a splash message with: splash.msg("Message")

    # Allow ctrl-c to kill the application
    import signal
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # Load window icon
    app.setWindowIcon(QtGui.QIcon('%s/images/windowIcon.png' % Constants.RESOURCE_PATH))

    app.setApplicationName(app_name)
    app.lastWindowClosed.connect(app.quit)

    QtGui.qApp.threadpool = ThreadPool(3)

    config_path = "/.%s/config" % app_name.lower()
    settings = QtCore.QSettings(QtCore.QSettings.IniFormat, QtCore.QSettings.UserScope, config_path)
    QtGui.qApp.settings = settings

    Style.init()

    # If the config file does not exist, copy over the default
    local = "%s%s.ini" % (os.getenv("HOME"), config_path)
    if not os.path.exists(local):
        default = os.path.join(Constants.DEFAULT_INI_PATH, "%s.ini" % app_name.lower())
        print "Not found: %s\nCopying:   %s" % (local, default)
        try:
            os.mkdir(os.path.dirname(local))
        except Exception, e:
            logger.debug(e)
        try:
            import shutil
            shutil.copy2(default, local)
        except Exception, e:
            logger.debug(e)
Exemple #16
0
 def __init__(self,callback=None, parent=None):
     QtWidgets.QAction.__init__(self,parent)
     self.setText("Refresh")
     self.setIcon(QtGui.QIcon(":/images/stock-refresh.png"))
     if callback:
         self.triggered.connect(callback)
    def updateWidgets(self):
        if not self.__widgets:
            widget = None

            # Create the proper widget depending on the action type
            if self.rpcObject.type() in (opencue.api.filter_pb2.PAUSE_JOB, ):
                widget = NoWheelComboBox(self.parent())
                widget.addItems(PAUSETYPE)
                widget.currentIndexChanged.connect(self.__setValue)

            elif self.rpcObject.type() in (
                    opencue.api.filter_pb2.SET_JOB_PRIORITY, ):
                widget = NoWheelSpinBox(self.parent())
                widget.setMaximum(99999)
                widget.editingFinished.connect(self.__setValue)

            elif self.rpcObject.type() in (
                    opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MEMORY,
                    opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_CORES):
                widget = NoWheelDoubleSpinBox(self.parent())
                widget.setDecimals(2)
                widget.setSingleStep(.10)
                widget.editingFinished.connect(self.__setValue)

            elif self.rpcObject.type() in (
                    opencue.api.filter_pb2.SET_JOB_MAX_CORES,
                    opencue.api.filter_pb2.SET_JOB_MIN_CORES):
                widget = NoWheelDoubleSpinBox(self.parent())
                widget.setDecimals(0)
                widget.setSingleStep(1)
                widget.setMaximum(1000)
                widget.editingFinished.connect(self.__setValue)

            elif self.rpcObject.type() in (
                    opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_TAGS, ):
                widget = QtWidgets.QLineEdit("", self.parent())
                widget.editingFinished.connect(self.__setValue)

            elif self.rpcObject.type() in (
                    opencue.api.filter_pb2.MOVE_JOB_TO_GROUP, ):
                widget = NoWheelComboBox(self.parent())
                widget.addItems(self.treeWidget().groupNames.keys())
                widget.currentIndexChanged.connect(self.__setValue)

            elif self.rpcObject.type() in (
                    opencue.api.filter_pb2.SET_MEMORY_OPTIMIZER, ):
                widget = NoWheelComboBox(self.parent())
                widget.addItems(MEMOPTTYPE)
                widget.currentIndexChanged.connect(self.__setValue)

            if widget:
                self.treeWidget().setItemWidget(self, 1, widget)
                self.__widgets["ActionValue"] = widget

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

        # Update the widget with the current value

        if self.rpcObject.type() in (opencue.api.filter_pb2.PAUSE_JOB, ):
            self.__widgets["ActionValue"].setCurrentIndex(
                int(not self.rpcObject.value()))

        elif self.rpcObject.type() in (
                opencue.api.filter_pb2.SET_JOB_PRIORITY, ):
            self.__widgets["ActionValue"].setValue(self.rpcObject.value())

        elif self.rpcObject.type() in (
                opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MEMORY, ):
            self.__widgets["ActionValue"].setValue(
                float(self.rpcObject.value()) / 1048576)

        elif self.rpcObject.type() in (
                opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_TAGS, ):
            self.__widgets["ActionValue"].setText(self.rpcObject.value())

        elif self.rpcObject.type() in (
                opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_CORES,
                opencue.api.filter_pb2.SET_JOB_MAX_CORES,
                opencue.api.filter_pb2.SET_JOB_MIN_CORES):
            self.__widgets["ActionValue"].setValue(
                float(str(self.rpcObject.value())))

        elif self.rpcObject.type() in (
                opencue.api.filter_pb2.MOVE_JOB_TO_GROUP, ):
            name = self.treeWidget().groupIds[self.rpcObject.value()].name()
            index = self.treeWidget().groupNames.keys().index(name)
            self.__widgets["ActionValue"].setCurrentIndex(index)

        elif self.rpcObject.type() in (
                opencue.api.filter_pb2.SET_MEMORY_OPTIMIZER, ):
            self.__widgets["ActionValue"].setCurrentIndex(
                int(not self.rpcObject.value()))