1
0
Fork 0
mirror of https://github.com/eliboa/TegraRcmGUI.git synced 2024-11-25 03:32:05 +00:00
TegraRcmGUI/qutils.cpp
2020-06-24 20:30:39 +02:00

23 lines
658 B
C++

#include "qutils.h"
QString FileDialog(QWidget *parent, fdMode mode, const QString& defaultName)
{
QFileDialog fd(parent);
QString filePath;
if (mode == open_file)
{
filePath = QFileDialog::getOpenFileName(parent, "Open file", "default_dir\\");
}
else
{
fd.setAcceptMode(QFileDialog::AcceptSave); // Ask overwrite
filePath = fd.getSaveFileName(parent, "Save as", "default_dir\\" + defaultName);
}
if (!filePath.isEmpty())
{
QSettings appSettings;
QDir CurrentDir;
appSettings.setValue("default_dir", CurrentDir.absoluteFilePath(filePath));
}
return filePath;
}