diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index 9845ae494..c16f89535 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -184,12 +184,12 @@ QString GBAApp::getSaveFileName(QWidget* owner, const QString& title, const QStr return filename; } -QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title) { +QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title, const QString& path) { QList paused; pauseAll(&paused); - QString filename = QFileDialog::getExistingDirectory(owner, title, m_configController->getOption("lastDirectory")); + QString filename = QFileDialog::getExistingDirectory(owner, title, !path.isNull() ? path : m_configController->getOption("lastDirectory")); continueAll(paused); - if (!filename.isEmpty()) { + if (path.isNull() && !filename.isEmpty()) { m_configController->setOption("lastDirectory", QFileInfo(filename).dir().canonicalPath()); } return filename; diff --git a/src/platform/qt/GBAApp.h b/src/platform/qt/GBAApp.h index 805941f3b..67e5d1b01 100644 --- a/src/platform/qt/GBAApp.h +++ b/src/platform/qt/GBAApp.h @@ -58,10 +58,10 @@ public: Window* newWindow(); - QString getOpenFileName(QWidget* owner, const QString& title, const QString& filter = QString()); - QStringList getOpenFileNames(QWidget* owner, const QString& title, const QString& filter = QString()); - QString getSaveFileName(QWidget* owner, const QString& title, const QString& filter = QString()); - QString getOpenDirectoryName(QWidget* owner, const QString& title); + QString getOpenFileName(QWidget* owner, const QString& title, const QString& filter = {}); + QStringList getOpenFileNames(QWidget* owner, const QString& title, const QString& filter = {}); + QString getSaveFileName(QWidget* owner, const QString& title, const QString& filter = {}); + QString getOpenDirectoryName(QWidget* owner, const QString& title, const QString& path = {}); const NoIntroDB* gameDB() const { return m_db; } bool reloadGameDB(); diff --git a/src/platform/qt/ShaderSelector.cpp b/src/platform/qt/ShaderSelector.cpp index cf7f999a0..80a8fcd9d 100644 --- a/src/platform/qt/ShaderSelector.cpp +++ b/src/platform/qt/ShaderSelector.cpp @@ -11,6 +11,7 @@ #include "VFileDevice.h" #include +#include #include #include #include @@ -60,14 +61,11 @@ void ShaderSelector::clear() { } void ShaderSelector::selectShader() { - QString path(GBAApp::dataDir()); - path += QLatin1String("/shaders"); - QFileDialog dialog(nullptr, tr("Load shader"), path); - dialog.setFileMode(QFileDialog::Directory); - dialog.exec(); - QStringList names = dialog.selectedFiles(); - if (names.count() == 1) { - loadShader(names[0]); + QDir path(GBAApp::dataDir()); + path.cd(QLatin1String("shaders")); + QString name = GBAApp::app()->getOpenDirectoryName(this, tr("Load shader"), path.absolutePath()); + if (!name.isNull()) { + loadShader(name); refreshShaders(); } }