Remember last used path in file/directory picker

This commit is contained in:
Luca D'Amico
2024-08-19 17:06:18 +02:00
parent e17d3805aa
commit a2739a9ca8
4 changed files with 47 additions and 69 deletions

21
ui/utils/filepicker.h Normal file
View File

@@ -0,0 +1,21 @@
#pragma once
#include <QFileDialog>
QString customSaveFileDialog(const QString& title, const QString& defaultName, const QString& filter)
{
static QString lastUsedPath;
QString selectedPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
title,
lastUsedPath + defaultName,
filter);
if (!selectedPath.isNull())
lastUsedPath = selectedPath.mid(0, selectedPath.lastIndexOf('/', Qt::CaseInsensitive)+1);
return selectedPath;
}