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)
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()))
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)
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
def load(self, fileName): image = QImage(fileName) if image.isNull(): QMessageBox.information(self, QApplication.applicationName(), "Cannot load " + fileName)