Beispiel #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());
  }
Beispiel #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);
    }
  }
Beispiel #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;
  }
Beispiel #4
0
 private void penColor() {
   QColor newColor = QColorDialog.getColor(scribbleArea.penColor());
   if (newColor.isValid()) scribbleArea.setPenColor(newColor);
 }
Beispiel #5
0
 private void open() {
   if (maybeSave()) {
     String fileName = QFileDialog.getOpenFileName(this, tr("Open File"), QDir.currentPath());
     if (fileName.length() != 0) scribbleArea.openImage(fileName);
   }
 }