mirror of https://github.com/mgba-emu/mgba.git
Qt: Pay down some technical debt in the shader selector
This commit is contained in:
parent
a8a7372083
commit
d44a26d962
|
@ -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<Window*> 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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "VFileDevice.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDir>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QFileDialog>
|
||||
#include <QFormLayout>
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue