Exemplo n.º 1
0
  private boolean saveFile(String fileFormat) {
    String initialPath = QDir.currentPath() + "/untitled." + fileFormat;

    String fileName =
        QFileDialog.getSaveFileName(
            this,
            tr("Save As"),
            initialPath,
            new QFileDialog.Filter(
                fileFormat.toUpperCase() + " Files (*." + fileFormat + ");;All Files (*)"));
    if (fileName.length() == 0) {
      return false;
    } else {
      return scribbleArea.saveImage(fileName, fileFormat);
    }
  }
Exemplo n.º 2
0
  private void addImages() {
    List<String> fileNames =
        QFileDialog.getOpenFileNames(
            this,
            tr("Open Images"),
            "",
            new QFileDialog.Filter(tr("Images (*.png *.xpm *.jpg);;" + "All Files (*)")));
    if (!fileNames.isEmpty()) {
      for (String fileName : fileNames) {
        int row = imagesTable.rowCount();
        imagesTable.setRowCount(row + 1);

        String imageName = new QFileInfo(fileName).baseName();
        QTableWidgetItem item0 = new QTableWidgetItem(imageName);
        item0.setData(Qt.ItemDataRole.UserRole, fileName);
        Qt.ItemFlags flags = item0.flags();
        flags.clear(Qt.ItemFlag.ItemIsEditable);
        item0.setFlags(flags);

        QTableWidgetItem item1 = new QTableWidgetItem(tr("Normal"));
        QTableWidgetItem item2 = new QTableWidgetItem(tr("Off"));

        if (guessModeStateAct.isChecked()) {
          if (fileName.contains("_act")) {
            item1.setText(tr("Active"));
          } else if (fileName.contains("_dis")) {
            item1.setText(tr("Disabled"));
          } else if (fileName.contains("_sel")) {
            item1.setText(tr("Selected"));
          }

          if (fileName.contains("_on")) item2.setText(tr("On"));
        }

        imagesTable.setItem(row, 0, item0);
        imagesTable.setItem(row, 1, item1);
        imagesTable.setItem(row, 2, item2);
        imagesTable.openPersistentEditor(item1);
        imagesTable.openPersistentEditor(item2);

        item0.setCheckState(Qt.CheckState.Checked);
      }
    }
  }
Exemplo n.º 3
0
 private void open() {
   if (maybeSave()) {
     String fileName = QFileDialog.getOpenFileName(this, tr("Open File"), QDir.currentPath());
     if (fileName.length() != 0) scribbleArea.openImage(fileName);
   }
 }