def set_pixmap(self, pixmap, initiate_zoom=False): self.erase_drawing() self._pixmap = pixmap if pixmap == None: pixmap = QtGui.QPixmap(self._scene.width(), self._scene.height()) pixmap.fill(QtCore.Qt.red) self._item.setPixmap(pixmap) self.center()
def startDrag(self, supportedActions): drag = QtGui.QDrag(self) version = self.current_version if version is not None: version_id = version.id id_ftrack = "FTRACK_DROP_ACTION" asset_name = version.asset_io().__name__ mime_data = QtCore.QMimeData() mime_data.setData("text/plain", ":".join([id_ftrack, asset_name, version_id])) pixmap = QtGui.QPixmap(':ftrack/image/integration/drag') drag.setPixmap(pixmap) drag.setMimeData(mime_data) drag.exec_()
def _pixmapFromUrl(self, url): '''Retrieve *url* and return data as a pixmap.''' try: pixmap = self._thumbnailCache.get(url) except KeyError: data = self._getFileFromUrl(url) pixmap = QtGui.QPixmap() pixmap.loadFromData(data) self._thumbnailCache.set(url, pixmap) # Handle null pixmaps. E.g. JPG on Windows. if pixmap.isNull(): try: pixmap = self._thumbnailCache.get(self._placholderThumbnail) except KeyError: pass return pixmap
def _populateBookmarks(self): '''Populate bookmarks view.''' # TODO: Extract bookmarks to separate widget. # For now just display non-editable list of projects from ftrack. projects = ftrack.getProjects() self._bookmarksView.setRowCount(len(projects)) # Sort projects by display name. projects = sorted(projects, key=lambda project: project.getName()) for index, project in enumerate(projects): item = QtWidgets.QTableWidgetItem(project.getName()) item.setData(QtCore.Qt.UserRole, project.getEntityRef()) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(':icon-home'), QtGui.QIcon.Normal, QtGui.QIcon.Off) item.setIcon(icon) self._bookmarksView.setItem(index, 0, item)
def __init__(self, name, parent): super(SnapshotsView, self).__init__(parent) self._pixmap = None self._name = name self._scene = QtGui.QGraphicsScene(parent) self.setGeometry(QtCore.QRect(0, 0, parent.width(), parent.height())) self._scale_factor = 1.15 css_frame = """ /*background: #000; border-top: 2px solid #000; border-left: 2px solid #000; border-right: 2px solid #000; border-top-left-radius: 4px; border-top-right-radius: 4px;*/ """ self.setStyleSheet(css_frame) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self._item = QtGui.QGraphicsPixmapItem() self._scene.addItem(self._item) self._drawings = [] image_pen_px = QtGui.QPixmap(':ftrack/image/integration/pencil') image_pen_px.setMask(image_pen_px.mask()) self._image_pen_cursor = QtGui.QCursor(image_pen_px) self._pen_color = QtCore.Qt.red self._drawing_mode = False self._pencil_pressed = False self._position_mouse = None self.setBackgroundBrush( QtGui.QBrush(QtCore.Qt.black, QtCore.Qt.SolidPattern)) self.setScene(self._scene)
def initiate_scene_version(self): if self.scene_version == None: return self._asset_name.setText(self.scene_version.getParent().getName()) self._status.set_status(self.scene_version.getStatus()) self._asset_version.setText("%03d" % self.scene_version.get('version')) image = QtGui.QPixmap() self._controller = Controller(self._load_image, [image]) self._controller.completed.connect( lambda: self._thumbnail_widget.update_image(image)) self._controller.start() self.set_owner(self.scene_version.getOwner()) self._date.setText(str(self.scene_version.getDate())) # self._availability.setText(', '.join(self.scene_version.locations)) # self.set_asset_type(self.scene_version.asset.connector.asset_type) self._comment.setText(self.scene_version.getComment()) self._validate()
def _getIcon(self, entity): '''Retrieve appropriate icon for *entity*.''' iconPath = None if isinstance(entity, ftrack.Project): iconPath = ':icon-home' elif isinstance(entity, ftrack.Task): objectType = entity.getObjectType() if objectType == 'Sequence': iconPath = ':icon-folder_open' elif objectType == 'Shot': iconPath = ':icon-movie' elif objectType == 'Task': iconPath = ':icon-signup' elif objectType == 'Asset Build': iconPath = ':icon-box' elif objectType is None: # Check for asset build id until getObjectType fixed if (entity.get('object_typeid') == 'ab77c654-df17-11e2-b2f3-20c9d0831e59'): iconPath = ':icon-box' elif isinstance(entity, ftrack.Asset): iconPath = ':icon-layers' if iconPath: icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(iconPath), QtGui.QIcon.Normal, QtGui.QIcon.Off) return icon return None