1
0
Fork 0
mirror of https://github.com/eliboa/TegraRcmGUI.git synced 2024-11-25 03:32:05 +00:00
TegraRcmGUI/qutils.cpp

24 lines
658 B
C++
Raw Normal View History

2020-06-24 19:30:39 +01:00
#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;
}