Esempio n. 1
0
    def _get_icons_info(self, file_list, added, removed):
        icons_info = []
        try:
            for path, is_dir, created_time, was_updated in file_list:
                if path not in added:
                    icons_info.append((None, None, None))
                    continue

                elif path in self._files:
                    icons_info.append(self._files[path])
                    continue

                abs_path = op.join(self._config.sync_directory, path)
                abs_path = ensure_unicode(abs_path)
                abs_path = FilePath(abs_path)           # .longpath doesn't work
                mime, _ = mimetypes.guess_type(path)
                image = QImage(abs_path)
                if image.isNull():
                    image = None
                icons_info.append((image, mime, QFileInfo(abs_path)))
        except Exception as e:
            logger.error("Icons info error: %s", e)

        self._icons_info_ready.emit(
            icons_info, file_list, added, removed)
Esempio n. 2
0
	def refresh_image(self, image_path):
		qimage = QImage(image_path)
		if qimage.isNull():
			return
		pixmap = QPixmap.fromImage(qimage)
		self.scene.removeItem(self.pixmapitem)
		self.pixmapitem = self.scene.addPixmap(pixmap)
		# This will make scrollbar fit the image
		self.setSceneRect(QRectF(pixmap.rect()))
Esempio n. 3
0
    def load(self, fileName):
        image = QImage(fileName)
        if image.isNull():
            QMessageBox.information(self, QApplication.applicationName(),
                                    "Cannot load " + fileName)
            self.setWindowTitle("Image viewer")
            self.setPixmap(QPixmap())

        self.imageLabel.setPixmap(QPixmap.fromImage(image))
        self.setWindowTitle(fileName)
Esempio n. 4
0
    def _get_application_icon() -> QIcon:
        """
        This finds the running blender process, extracts the blender icon from the blender.exe file on disk and saves it to the user's temp folder.
        It then creates a QIcon with that data and returns it.

        Returns QIcon: Application Icon
        """

        icon_filepath = Path(__file__).parent / ".." / "blender_icon_16.png"
        icon = QIcon()

        if icon_filepath.exists():
            image = QImage(str(icon_filepath))
            if not image.isNull():
                icon = QIcon(QPixmap().fromImage(image))

        return icon
Esempio n. 5
0
 def load(self, fileName):
     image = QImage(fileName)
     if image.isNull():
         QMessageBox.information(self, QApplication.applicationName(),
                                 "Cannot load " + fileName)