示例#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);
   }
 }