コード例 #1
0
  private void penWidth() {

    Integer newWidth =
        QInputDialog.getInteger(
            this, tr("Scribble"), tr("Select pen width:"), scribbleArea.penWidth(), 1, 50, 1);
    if (newWidth != null) scribbleArea.setPenWidth(newWidth.intValue());
  }
コード例 #2
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);
    }
  }
コード例 #3
0
  private boolean maybeSave() {
    if (scribbleArea.isModified()) {
      QMessageBox.StandardButton ret;
      ret =
          QMessageBox.warning(
              this,
              tr("Scribble"),
              tr("The image has been modified.\n" + "Do you want to save your changes?"),
              new QMessageBox.StandardButtons(
                  QMessageBox.StandardButton.Save, QMessageBox.StandardButton.Discard));

      if (ret == QMessageBox.StandardButton.Save) {
        return saveFile("png");
      } else if (ret == QMessageBox.StandardButton.Cancel) {
        return false;
      }
    }
    return true;
  }
コード例 #4
0
 private void penColor() {
   QColor newColor = QColorDialog.getColor(scribbleArea.penColor());
   if (newColor.isValid()) scribbleArea.setPenColor(newColor);
 }
コード例 #5
0
 private void open() {
   if (maybeSave()) {
     String fileName = QFileDialog.getOpenFileName(this, tr("Open File"), QDir.currentPath());
     if (fileName.length() != 0) scribbleArea.openImage(fileName);
   }
 }