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;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title) {
|
QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title, const QString& path) {
|
||||||
QList<Window*> paused;
|
QList<Window*> paused;
|
||||||
pauseAll(&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);
|
continueAll(paused);
|
||||||
if (!filename.isEmpty()) {
|
if (path.isNull() && !filename.isEmpty()) {
|
||||||
m_configController->setOption("lastDirectory", QFileInfo(filename).dir().canonicalPath());
|
m_configController->setOption("lastDirectory", QFileInfo(filename).dir().canonicalPath());
|
||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
|
|
|
@ -58,10 +58,10 @@ public:
|
||||||
|
|
||||||
Window* newWindow();
|
Window* newWindow();
|
||||||
|
|
||||||
QString getOpenFileName(QWidget* owner, const QString& title, const QString& filter = QString());
|
QString getOpenFileName(QWidget* owner, const QString& title, const QString& filter = {});
|
||||||
QStringList getOpenFileNames(QWidget* owner, const QString& title, const QString& filter = QString());
|
QStringList getOpenFileNames(QWidget* owner, const QString& title, const QString& filter = {});
|
||||||
QString getSaveFileName(QWidget* owner, const QString& title, const QString& filter = QString());
|
QString getSaveFileName(QWidget* owner, const QString& title, const QString& filter = {});
|
||||||
QString getOpenDirectoryName(QWidget* owner, const QString& title);
|
QString getOpenDirectoryName(QWidget* owner, const QString& title, const QString& path = {});
|
||||||
|
|
||||||
const NoIntroDB* gameDB() const { return m_db; }
|
const NoIntroDB* gameDB() const { return m_db; }
|
||||||
bool reloadGameDB();
|
bool reloadGameDB();
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "VFileDevice.h"
|
#include "VFileDevice.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QDir>
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
|
@ -60,14 +61,11 @@ void ShaderSelector::clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderSelector::selectShader() {
|
void ShaderSelector::selectShader() {
|
||||||
QString path(GBAApp::dataDir());
|
QDir path(GBAApp::dataDir());
|
||||||
path += QLatin1String("/shaders");
|
path.cd(QLatin1String("shaders"));
|
||||||
QFileDialog dialog(nullptr, tr("Load shader"), path);
|
QString name = GBAApp::app()->getOpenDirectoryName(this, tr("Load shader"), path.absolutePath());
|
||||||
dialog.setFileMode(QFileDialog::Directory);
|
if (!name.isNull()) {
|
||||||
dialog.exec();
|
loadShader(name);
|
||||||
QStringList names = dialog.selectedFiles();
|
|
||||||
if (names.count() == 1) {
|
|
||||||
loadShader(names[0]);
|
|
||||||
refreshShaders();
|
refreshShaders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue