Esempio n. 1
0
 def __save_atlas(self) -> None:
     """Save function as same as type synthesis widget."""
     count = self.collection_list.count()
     if count < 1:
         return
     lateral, ok = QInputDialog.getInt(self, "Atlas",
                                       "The number of lateral:", 5, 1)
     if not ok:
         return
     file_name = self.output_to("atlas image", qt_image_format)
     if not file_name:
         return
     icon_size = self.collection_list.iconSize()
     width = icon_size.width()
     image = self.collection_list.item(0).icon().pixmap(icon_size).toImage()
     image_main = QImage(
         QSize(lateral if count > lateral else count,
               (count // lateral) + bool(count % lateral)) * width,
         image.format())
     image_main.fill(Qt.transparent)
     painter = QPainter(image_main)
     for row in range(count):
         image = self.collection_list.item(row).icon().pixmap(
             icon_size).toImage()
         painter.drawImage(
             QPointF(row % lateral, row // lateral) * width, image)
     painter.end()
     pixmap = QPixmap()
     pixmap.convertFromImage(image_main)
     pixmap.save(file_name)
     self.save_reply_box("Atlas", file_name)
Esempio n. 2
0
def get_thumbnail(project_dir_path):
    thumb_path = os.path.join(project_dir_path, '.thumbnail')
    if os.path.isfile(thumb_path):
        pix = QPixmap()
        pix.convertFromImage(QImage(thumb_path, 'PNG'))
        icon = QIcon(pix)
    else:
        icon = get_icon('missing_thumbnail.png')
    return icon