[Qt] Fix save/load supportdirs
This commit is contained in:
parent
baece5ce9c
commit
cab8dcaf98
|
@ -182,7 +182,8 @@ void SelectDialog::doSearch()
|
||||||
void SelectDialog::updateTitleScreen()
|
void SelectDialog::updateTitleScreen()
|
||||||
{
|
{
|
||||||
QString drv = BurnDrvGetTextA(DRV_NAME);
|
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()) {
|
if (QFile(path).exists()) {
|
||||||
QPixmap p(path);
|
QPixmap p(path);
|
||||||
ui->imgTitleScreen->setPixmap(p);
|
ui->imgTitleScreen->setPixmap(p);
|
||||||
|
|
|
@ -65,19 +65,11 @@ bool SupportDirsDialog::load()
|
||||||
|
|
||||||
settings.beginGroup("support_directories");
|
settings.beginGroup("support_directories");
|
||||||
|
|
||||||
auto readPath = [&](const QString &name, int i) -> void {
|
loadPath(settings, "previews", PATH_PREVIEWS);
|
||||||
QString path(settings.value(name).toString());
|
loadPath(settings, "titles", PATH_TITLES);
|
||||||
if (!path.isEmpty()) {
|
loadPath(settings, "hiscores", PATH_HISCORES);
|
||||||
m_handlers[i].edit->setText(settings.value(path).toString());
|
loadPath(settings, "samples", PATH_SAMPLES);
|
||||||
m_handlers[i].editorToString();
|
loadPath(settings, "cheats", PATH_CHEATS);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
readPath("previews", PATH_PREVIEWS);
|
|
||||||
readPath("titles", PATH_TITLES);
|
|
||||||
readPath("hiscores", PATH_HISCORES);
|
|
||||||
readPath("samples", PATH_SAMPLES);
|
|
||||||
readPath("cheats", PATH_CHEATS);
|
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
return true;
|
return true;
|
||||||
|
@ -100,3 +92,15 @@ bool SupportDirsDialog::save()
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.sync();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QSettings>
|
||||||
#include "qutil.h"
|
#include "qutil.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -25,6 +26,7 @@ public slots:
|
||||||
bool save();
|
bool save();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void loadPath(QSettings &settings, QString name, int i);
|
||||||
Ui::SupportDirsDialog *ui;
|
Ui::SupportDirsDialog *ui;
|
||||||
QButtonGroup *m_group;
|
QButtonGroup *m_group;
|
||||||
enum {
|
enum {
|
||||||
|
|
Loading…
Reference in New Issue