Пример #1
1
  private void changeIcon() {
    QIcon icon = new QIcon();

    for (int row = 0; row < imagesTable.rowCount(); ++row) {
      QTableWidgetItem item0 = imagesTable.item(row, 0);
      QTableWidgetItem item1 = imagesTable.item(row, 1);
      QTableWidgetItem item2 = imagesTable.item(row, 2);

      if (item0.checkState() == Qt.CheckState.Checked) {
        QIcon.Mode mode;
        if (item1.text().equals(tr("Normal"))) {
          mode = QIcon.Mode.Normal;
        } else if (item1.text().equals(tr("Active"))) {
          mode = QIcon.Mode.Active;
        } else if (item1.text().equals(tr("Disabled"))) {
          mode = QIcon.Mode.Disabled;
        } else {
          mode = QIcon.Mode.Selected;
        }

        QIcon.State state;
        if (item2.text().equals(tr("On"))) {
          state = QIcon.State.On;
        } else {
          state = QIcon.State.Off;
        }

        String fileName = (String) item0.data(Qt.ItemDataRole.UserRole);
        QImage image = new QImage(fileName);
        if (!image.isNull()) icon.addPixmap(QPixmap.fromImage(image), mode, state);
      }
    }

    previewArea.setIcon(icon);
  }
Пример #2
0
 public QImage getImage() {
   if (!fetched) {
     image = ThumbnailImageFactory.fetchThumbnailImage(imageFilename);
     if ((image == null) || (image.isNull()))
       log.debug("getImage(): couldn't load video link image=" + imageFilename);
     fetched = true;
   }
   return image;
 }