diff -r 76f3a96e82b5 -r c3a781b4d35b src/ChartCarbonate.cpp --- a/src/ChartCarbonate.cpp Fri Feb 10 14:06:47 2023 +0100 +++ b/src/ChartCarbonate.cpp Fri Feb 10 17:28:46 2023 +0100 @@ -120,12 +120,30 @@ void ChartCarbonate::savePNG() { - QString path = QFileDialog::getSaveFileName(this, tr("Save Image"), QDir::homePath() + "/carbonation.png", tr("Image (*.png)")); + QSettings settings(QSettings::IniFormat, QSettings::UserScope, "mbse", "bmsapp"); + QString dirName; + + /* + * First check if the directory stored in the settings file exists. + * It might be on a removable media that was last used ... + * If so, fallback to the user's home directory. + */ + dirName = settings.value("paths/download").toString(); + if (! QDir(dirName).exists()) { + dirName = QDir::homePath(); + } + + QString path = QFileDialog::getSaveFileName(this, tr("Save Image"), dirName + "/carbonation.png", tr("Image (*.png)")); if (path.isEmpty()) { QMessageBox::warning(this, tr("Save File"), tr("No image file selected.")); return; } + /* + * Update to current selected path + */ + settings.setValue("paths/download", QFileInfo(path).absolutePath()); + QImage img((chartView->size()), QImage::Format_ARGB32); QPainter painter; painter.begin(&img);