def thumbnailCapture(self, show=False):
        """Capture a playblast and save it to the temp thumbnail path."""
        options = self._formWidget.values()
        startFrame, endFrame = options.get("frameRange", [None, None])
        step = options.get("byFrame", 1)

        # Ignore the by frame dialog when the control modifier is pressed.
        if not studioqt.isControlModifier():
            self.showByFrameDialog()

        try:
            path = studiolibrary.tempPath("sequence", "thumbnail.jpg")
            mutils.gui.thumbnailCapture(
                show=show,
                path=path,
                startFrame=startFrame,
                endFrame=endFrame,
                step=step,
                clearCache=True,
                captured=self.setSequence,
            )

        except Exception as e:
            title = "Error while capturing thumbnail"
            studiolibrary.widgets.MessageBox.critical(self.libraryWindow(),
                                                      title, str(e))
            raise
示例#2
0
    def mousePressEvent(self, event):
        """
        :type event: QtCore.QEvent
        :rtype: None
        """
        folder = self.folderAt(event.pos())
        selectedFolders = self.selectedFolders()
        isSelected = folder in selectedFolders

        if event.button() == QtCore.Qt.RightButton:
            QtWidgets.QTreeView.mousePressEvent(self, event)
        else:
            QtWidgets.QTreeView.mousePressEvent(self, event)

        if not folder:
            self.clearSelection()

        elif event.button(
        ) == QtCore.Qt.LeftButton and studioqt.isControlModifier():

            if folder and isSelected:
                self.clearSelection()
                selectedFolders.remove(folder)
                self.selectFolders(selectedFolders)

            if folder and not isSelected:
                selectedFolders.append(folder)
                self.selectFolders(selectedFolders)

        self.repaint()
def showMessageBox(parent,
                   title,
                   text,
                   width=None,
                   height=None,
                   buttons=None,
                   headerIcon=None,
                   headerColor=None,
                   enableDontShowCheckBox=False,
                   force=False):
    """
    Open a question message box with the given options.

    :type parent: QWidget
    :type title: str
    :type text: str
    :type buttons: list[QMessageBox.StandardButton]
    :type headerIcon: str
    :type headerColor: str
    :type enableDontShowCheckBox: bool
    :type force: bool

    :rtype: MessageBox
    """
    key = '{0}MessageBox'.format(title.replace(" ", ""))
    data = settings.get(key, {})

    clickedButton = data.get("clickedButton", -1)
    dontShowAgain = data.get("dontShowAgain", False)

    # Force show the dialog if the user is holding the ctrl key down
    if studioqt.isControlModifier() or studioqt.isAltModifier():
        force = True

    if force or not dontShowAgain or not enableDontShowCheckBox:

        mb = createMessageBox(parent,
                              title,
                              text,
                              width=width,
                              height=height,
                              buttons=buttons,
                              headerIcon=headerIcon,
                              headerColor=headerColor,
                              enableDontShowCheckBox=enableDontShowCheckBox)

        mb.exec_()
        mb.close()

        clickedButton = mb.clickedStandardButton()
        if clickedButton != QtWidgets.QDialogButtonBox.Cancel:

            # Save the button that was clicked by the user
            settings.set(
                key, {
                    "clickedButton": int(clickedButton),
                    "dontShowAgain": bool(mb.isDontShowCheckboxChecked()),
                })

    return clickedButton
示例#4
0
    def thumbnailCapture(self):
        """
        :raise: AnimItemError
        """
        startFrame, endFrame = mutils.selectedFrameRange()
        if startFrame == endFrame:
            self.validateFrameRange()
            endFrame = self.endFrame()
            startFrame = self.startFrame()

        # Ignore the by frame dialog when the control modifier is pressed.
        if not studioqt.isControlModifier():
            self.showByFrameDialog()

        try:
            step = self.byFrame()
            playblastPath = mutils.gui.tempPlayblastPath()

            mutils.gui.thumbnailCapture(
                path=playblastPath,
                startFrame=startFrame,
                endFrame=endFrame,
                step=step,
                clearCache=True,
                captured=self._thumbnailCaptured,
            )

        except Exception as e:
            title = "Error while capturing thumbnail"
            QtWidgets.QMessageBox.critical(self.libraryWidget(), title, str(e))
            raise
示例#5
0
    def thumbnailCapture(self, show=False):
        """Capture a playblast and save it to the temp thumbnail path."""
        options = self._optionsWidget.optionsToDict()
        startFrame, endFrame = options.get("frameRange", [None, None])
        step = options.get("byFrame", 1)

        # Ignore the by frame dialog when the control modifier is pressed.
        if not studioqt.isControlModifier():
            self.showByFrameDialog()

        try:
            path = studiolibrary.tempPath("sequence", "thumbnail.jpg")
            mutils.gui.thumbnailCapture(
                show=show,
                path=path,
                startFrame=startFrame,
                endFrame=endFrame,
                step=step,
                clearCache=True,
                captured=self.setSequence,
            )

        except Exception as e:
            title = "Error while capturing thumbnail"
            studiolibrary.widgets.MessageBox.critical(self.libraryWindow(), title, str(e))
            raise
示例#6
0
 def mouseMoveEvent(self, event):
     if studioqt.isControlModifier():
         return
     folder = self.folderAt(event.pos())
     selectedFolders = self.selectedFolders()
     isSelected = folder in selectedFolders
     if folder:
         self.clearSelection()
         self.selectFolder(folder)
def thumbnailCapture(
        path,
        startFrame=None,
        endFrame=None,
        step=1,
        clearCache=False,
        captured=None,
        show=False,
        modifier=True,
):
    """
    Capture a playblast and save it to the given path.

    :type path: str
    :type startFrame: int or None
    :type endFrame:  int or None
    :type step: int
    :type clearCache: bool
    :type captured: func or None
    :rtype: ThumbnailCaptureDialog
    """

    global _instance

    def _clearCache():
        dirname = os.path.dirname(path)
        if os.path.exists(dirname):
            shutil.rmtree(dirname)

    if _instance:
        _instance.close()

    d = mutils.gui.ThumbnailCaptureDialog(
        path=path,
        startFrame=startFrame,
        endFrame=endFrame,
        step=step,
    )

    if captured:
        d.captured.connect(captured)

    if clearCache:
        d.capturing.connect(_clearCache)

    d.show()

    if not show and not (modifier and studioqt.isControlModifier()):
        d.capture()
        d.close()

    _instance = d

    return _instance
示例#8
0
def thumbnailCapture(
    path,
    startFrame=None,
    endFrame=None,
    step=1,
    clearCache=False,
    captured=None,
    show=False,
    modifier=True,
):
    """
    Capture a playblast and save it to the given path.

    :type path: str
    :type startFrame: int or None
    :type endFrame:  int or None
    :type step: int
    :type clearCache: bool
    :type captured: func or None
    :rtype: ThumbnailCaptureDialog
    """

    global _instance

    def _clearCache():
        dirname = os.path.dirname(path)
        if os.path.exists(dirname):
            shutil.rmtree(dirname)

    if _instance:
        _instance.close()

    d = mutils.gui.ThumbnailCaptureDialog(
        path=path,
        startFrame=startFrame,
        endFrame=endFrame,
        step=step,
    )

    if captured:
        d.captured.connect(captured)

    if clearCache:
        d.capturing.connect(_clearCache)

    d.show()

    if not show and not (modifier and studioqt.isControlModifier()):
        d.capture()
        d.close()

    _instance = d

    return _instance
示例#9
0
 def mouseMoveEvent(self, event):
     """
     :type event: QtGui.QEvent
     """
     mayabaseplugin.Record.mouseMoveEvent(self, event)
     if studioqt.isControlModifier():
         x = event.pos().x() - self.rect().x()
         width = self.rect().width()
         percent = 1.0 - (float(width - x) / float(width))
         frame = int(self.imageSequenceTimer().duration() * percent)
         self.imageSequenceTimer().setCurrentFrame(frame)
         self.repaint()
示例#10
0
 def mouseMoveEvent(self, event):
     """
     :type event: QtGui.QEvent
     """
     mayabaseplugin.Record.mouseMoveEvent(self, event)
     if studioqt.isControlModifier():
         x = event.pos().x() - self.rect().x()
         width = self.rect().width()
         percent = 1.0 - (float(width - x) / float(width))
         frame = int(self.imageSequenceTimer().duration() * percent)
         self.imageSequenceTimer().setCurrentFrame(frame)
         self.repaint()
示例#11
0
 def imageSequenceEvent(self, event):
     """
     :type event: QtCore.QEvent
     :rtype: None
     """
     if self.imageSequence():
         if studioqt.isControlModifier():
             if self.rect():
                 x = event.pos().x() - self.rect().x()
                 width = self.rect().width()
                 percent = 1.0 - (float(width - x) / float(width))
                 frame = int(self.imageSequence().frameCount() * percent)
                 self.imageSequence().jumpToFrame(frame)
                 self.updateFrame()
示例#12
0
 def imageSequenceEvent(self, event):
     """
     :type event: QtCore.QEvent
     :rtype: None
     """
     if self.imageSequence():
         if studioqt.isControlModifier():
             if self.rect():
                 x = event.pos().x() - self.rect().x()
                 width = self.rect().width()
                 percent = 1.0 - (float(width - x) / float(width))
                 frame = int(self.imageSequence().frameCount() * percent)
                 self.imageSequence().jumpToFrame(frame)
                 self.updateFrame()
    def _actionChecked(self, name, checked):
        """
        Triggered when an action has been clicked.
        
        :type name: str
        :type checked: bool
        """
        if studioqt.isControlModifier():
            self.setAllEnabled(False)
            self._settings[name] = True
        else:
            self._settings[name] = checked

        self.dataset().search()
示例#14
0
 def mouseMoveEvent(self, event):
     """
     :type event: QtCore.QEvent
     """
     studioqt.CombinedWidgetItem.mouseMoveEvent(self, event)
     self.blendingEvent(event)
     if self.imageSequence():
         if studioqt.isControlModifier():
             if self.rect():
                 x = event.pos().x() - self.rect().x()
                 width = self.rect().width()
                 percent = 1.0 - float(width - x) / float(width)
                 frame = int(self.imageSequence().duration() * percent)
                 self.imageSequence().setCurrentFrame(frame)
                 self.updateFrame()
示例#15
0
 def mouseMoveEvent(self, event):
     """
     :type event: QtCore.QEvent
     """
     studioqt.CombinedWidgetItem.mouseMoveEvent(self, event)
     self.blendingEvent(event)
     if self.imageSequence():
         if studioqt.isControlModifier():
             if self.rect():
                 x = event.pos().x() - self.rect().x()
                 width = self.rect().width()
                 percent = 1.0 - float(width - x) / float(width)
                 frame = int(self.imageSequence().duration() * percent)
                 self.imageSequence().setCurrentFrame(frame)
                 self.updateFrame()
示例#16
0
 def _frameChanged(self, frame):
     """Triggered when the movie object updates to the given frame."""
     if not studioqt.isControlModifier():
         self.updateFrame()
示例#17
0
 def frameChanged(self, path):
     """
     :type path: str
     """
     if not studioqt.isControlModifier():
         self.repaint()
示例#18
0
 def _frameChanged(self, frame):
     """Triggered when the movie object updates to the given frame."""
     if not studioqt.isControlModifier():
         self.updateFrame()
示例#19
0
 def frameChanged(self, path):
     """
     :type path: str
     """
     if not studioqt.isControlModifier():
         self.repaint()
示例#20
0
 def _frameChanged(self):
     """
     :rtype: None
     """
     if not studioqt.isControlModifier():
         self.updateFrame()
示例#21
0
def showMessageBox(parent,
                   title,
                   text,
                   width=None,
                   height=None,
                   buttons=None,
                   headerIcon=None,
                   headerColor=None,
                   enableDontShowCheckBox=False,
                   force=False):
    """
    Open a question message box with the given options.

    :type parent: QWidget
    :type title: str
    :type text: str
    :type buttons: list[QMessageBox.StandardButton]
    :type headerIcon: str
    :type headerColor: str
    :type enableDontShowCheckBox: bool
    :type force: bool

    :rtype: MessageBox
    """
    settings = QtCore.QSettings(SETTINGS_PATH, QtCore.QSettings.IniFormat)

    key = 'MessageBox/{}/'.format(title.replace(" ", "_"))

    clickedButton = int(settings.value(key + "clickedButton") or -1)
    dontShowAgain = settings.value(key + "dontShowAgain")

    if isinstance(dontShowAgain, basestring):
        dontShowAgain = dontShowAgain == "true"

    # Force show the dialog if the user is holding the ctrl key down
    if studioqt.isControlModifier() or studioqt.isAltModifier():
        force = True

    if force or not dontShowAgain or not enableDontShowCheckBox:

        mb = createMessageBox(parent,
                              title,
                              text,
                              width=width,
                              height=height,
                              buttons=buttons,
                              headerIcon=headerIcon,
                              headerColor=headerColor,
                              enableDontShowCheckBox=enableDontShowCheckBox)

        mb.exec_()
        mb.close()

        # Save the button that was clicked by the user
        clickedButton = mb.clickedStandardButton()
        settings.setValue(key + "clickedButton", clickedButton)

        # Save the dont show again checked state
        dontShowAgain = mb.isDontShowCheckboxChecked()
        settings.setValue(key + "dontShowAgain", dontShowAgain)

        settings.sync()

    return clickedButton
示例#22
0
 def _frameChanged(self):
     """
     :rtype: None
     """
     if not studioqt.isControlModifier():
         self.updateFrame()