Skip to content

Commit

Permalink
Suggest default image name for saving using file basename
Browse files Browse the repository at this point in the history
  • Loading branch information
agruzdev committed Oct 3, 2021
1 parent 9ed56de commit 5633483
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/CanvasWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,11 +959,12 @@ void CanvasWidget::keyPressEvent(QKeyEvent* event)
if (mImage && mImage->notNull() && mImageProcessor) {
QString error;
try {
QDir imageDir;
QString savePath = "./Untitled.png";
if (!mImage->info().path.isEmpty()) {
imageDir = QFileInfo(mImage->info().path).dir();
QFileInfo currentPathInfo(mImage->info().path);
savePath = currentPathInfo.dir().filePath(currentPathInfo.completeBaseName() + ".png");
}
const QString filename = QFileDialog::getSaveFileName(this, tr("Save file"), imageDir.filePath("Untitled.png"), tr("Images (*.png *.jpg *.bmp)"));
const QString filename = QFileDialog::getSaveFileName(this, tr("Save file"), savePath, tr("Images (*.png *.jpg *.bmp)"));
if (!filename.isEmpty()) {
const auto& bitmap = mImageProcessor->getResultBitmap();
ImageSource::Save(bitmap.get(), filename);
Expand Down

0 comments on commit 5633483

Please sign in to comment.