[Qt] Fix save/load supportdirs

This commit is contained in:
Marcos Medeiros 2014-09-11 17:20:56 +00:00
parent baece5ce9c
commit cab8dcaf98
3 changed files with 21 additions and 14 deletions

View File

@ -182,7 +182,8 @@ void SelectDialog::doSearch()
void SelectDialog::updateTitleScreen()
{
QString drv = BurnDrvGetTextA(DRV_NAME);
QString path = (QString(tr("support/titles/%0.png").arg(drv)));
QString path = QString(szAppTitlesPath);
path += QString("%0.png").arg(drv);
if (QFile(path).exists()) {
QPixmap p(path);
ui->imgTitleScreen->setPixmap(p);

View File

@ -65,19 +65,11 @@ bool SupportDirsDialog::load()
settings.beginGroup("support_directories");
auto readPath = [&](const QString &name, int i) -> void {
QString path(settings.value(name).toString());
if (!path.isEmpty()) {
m_handlers[i].edit->setText(settings.value(path).toString());
m_handlers[i].editorToString();
}
};
readPath("previews", PATH_PREVIEWS);
readPath("titles", PATH_TITLES);
readPath("hiscores", PATH_HISCORES);
readPath("samples", PATH_SAMPLES);
readPath("cheats", PATH_CHEATS);
loadPath(settings, "previews", PATH_PREVIEWS);
loadPath(settings, "titles", PATH_TITLES);
loadPath(settings, "hiscores", PATH_HISCORES);
loadPath(settings, "samples", PATH_SAMPLES);
loadPath(settings, "cheats", PATH_CHEATS);
settings.endGroup();
return true;
@ -100,3 +92,15 @@ bool SupportDirsDialog::save()
settings.endGroup();
settings.sync();
}
void SupportDirsDialog::loadPath(QSettings &settings, QString name, int i)
{
if (i >= PATH_MAX_HANDLERS)
return;
QString path(settings.value(name).toString());
if (QFile(path).exists()) {
m_handlers[i].edit->setText(path);
m_handlers[i].editorToString();
}
}

View File

@ -4,6 +4,7 @@
#include <QDialog>
#include <QButtonGroup>
#include <QLineEdit>
#include <QSettings>
#include "qutil.h"
namespace Ui {
@ -25,6 +26,7 @@ public slots:
bool save();
private:
void loadPath(QSettings &settings, QString name, int i);
Ui::SupportDirsDialog *ui;
QButtonGroup *m_group;
enum {