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