diff --git a/include/core/filedialog.h b/include/core/filedialog.h index 374f243d..a02f6193 100644 --- a/include/core/filedialog.h +++ b/include/core/filedialog.h @@ -36,6 +36,18 @@ class FileDialog : public QFileDialog QString *selectedFilter = nullptr, QFileDialog::Options options = Options()); + static QStringList getOpenFileNames(QWidget *parent = nullptr, + const QString &caption = QString(), + const QString &dir = QString(), + const QString &filter = QString(), + QString *selectedFilter = nullptr, + QFileDialog::Options options = Options()); + + static QString getExistingDirectory(QWidget *parent = nullptr, + const QString &caption = QString(), + const QString &dir = QString(), + QFileDialog::Options options = ShowDirsOnly); + static QString getSaveFileName(QWidget *parent = nullptr, const QString &caption = QString(), const QString &dir = QString(), diff --git a/src/core/filedialog.cpp b/src/core/filedialog.cpp index 9e17cce3..94826090 100644 --- a/src/core/filedialog.cpp +++ b/src/core/filedialog.cpp @@ -27,6 +27,14 @@ QString FileDialog::getOpenFileName(QWidget *parent, const QString &caption, con return fileName; } +QStringList FileDialog::getOpenFileNames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options) { + const QStringList fileNames = QFileDialog::getOpenFileNames(parent, caption, getDirectoryFromInput(dir), filter, selectedFilter, options); + if (!fileNames.isEmpty()) + setDirectoryFromFile(fileNames.last()); + restoreFocus(parent); + return fileNames; +} + QString FileDialog::getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options) { const QString fileName = QFileDialog::getSaveFileName(parent, caption, getDirectoryFromInput(dir), filter, selectedFilter, options); setDirectoryFromFile(fileName); @@ -34,3 +42,10 @@ QString FileDialog::getSaveFileName(QWidget *parent, const QString &caption, con return fileName; } +QString FileDialog::getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options) { + const QString existingDir = QFileDialog::getExistingDirectory(parent, caption, getDirectoryFromInput(dir), options); + if (!existingDir.isEmpty()) + setDirectory(existingDir); + restoreFocus(parent); + return existingDir; +}