mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 15:50:00 -06:00
actually make the path dialog work
This commit is contained in:
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
@ -29,6 +30,9 @@
|
|||||||
PathSettingsDialog* PathSettingsDialog::currentDlg = nullptr;
|
PathSettingsDialog* PathSettingsDialog::currentDlg = nullptr;
|
||||||
|
|
||||||
extern std::string EmuDirectory;
|
extern std::string EmuDirectory;
|
||||||
|
extern bool RunningSomething;
|
||||||
|
|
||||||
|
bool PathSettingsDialog::needsReset = false;
|
||||||
|
|
||||||
|
|
||||||
PathSettingsDialog::PathSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::PathSettingsDialog)
|
PathSettingsDialog::PathSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::PathSettingsDialog)
|
||||||
@ -36,7 +40,9 @@ PathSettingsDialog::PathSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
//
|
ui->txtSaveFilePath->setText(QString::fromStdString(Config::SaveFilePath));
|
||||||
|
ui->txtSavestatePath->setText(QString::fromStdString(Config::SavestatePath));
|
||||||
|
ui->txtCheatFilePath->setText(QString::fromStdString(Config::CheatFilePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
PathSettingsDialog::~PathSettingsDialog()
|
PathSettingsDialog::~PathSettingsDialog()
|
||||||
@ -44,14 +50,70 @@ PathSettingsDialog::~PathSettingsDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathSettingsDialog::on_PathSettingsDialog_accepted()
|
void PathSettingsDialog::done(int r)
|
||||||
{
|
{
|
||||||
//
|
needsReset = false;
|
||||||
|
|
||||||
|
if (r == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
std::string saveFilePath = ui->txtSaveFilePath->text().toStdString();
|
||||||
|
std::string savestatePath = ui->txtSavestatePath->text().toStdString();
|
||||||
|
std::string cheatFilePath = ui->txtCheatFilePath->text().toStdString();
|
||||||
|
|
||||||
|
if ( saveFilePath != Config::SaveFilePath
|
||||||
|
|| savestatePath != Config::SavestatePath
|
||||||
|
|| cheatFilePath != Config::CheatFilePath)
|
||||||
|
{
|
||||||
|
if (RunningSomething
|
||||||
|
&& QMessageBox::warning(this, "Reset necessary to apply changes",
|
||||||
|
"The emulation will be reset for the changes to take place.",
|
||||||
|
QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Ok)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Config::SaveFilePath = saveFilePath;
|
||||||
|
Config::SavestatePath = savestatePath;
|
||||||
|
Config::CheatFilePath = cheatFilePath;
|
||||||
|
|
||||||
|
Config::Save();
|
||||||
|
|
||||||
|
needsReset = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDialog::done(r);
|
||||||
|
|
||||||
closeDlg();
|
closeDlg();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathSettingsDialog::on_PathSettingsDialog_rejected()
|
void PathSettingsDialog::on_btnSaveFileBrowse_clicked()
|
||||||
{
|
{
|
||||||
//
|
QString dir = QFileDialog::getExistingDirectory(this,
|
||||||
closeDlg();
|
"Select save files path...",
|
||||||
|
QString::fromStdString(EmuDirectory));
|
||||||
|
|
||||||
|
if (dir.isEmpty()) return;
|
||||||
|
|
||||||
|
ui->txtSaveFilePath->setText(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathSettingsDialog::on_btnSavestateBrowse_clicked()
|
||||||
|
{
|
||||||
|
QString dir = QFileDialog::getExistingDirectory(this,
|
||||||
|
"Select savestates path...",
|
||||||
|
QString::fromStdString(EmuDirectory));
|
||||||
|
|
||||||
|
if (dir.isEmpty()) return;
|
||||||
|
|
||||||
|
ui->txtSavestatePath->setText(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathSettingsDialog::on_btnCheatFileBrowse_clicked()
|
||||||
|
{
|
||||||
|
QString dir = QFileDialog::getExistingDirectory(this,
|
||||||
|
"Select cheat files path...",
|
||||||
|
QString::fromStdString(EmuDirectory));
|
||||||
|
|
||||||
|
if (dir.isEmpty()) return;
|
||||||
|
|
||||||
|
ui->txtCheatFilePath->setText(dir);
|
||||||
}
|
}
|
||||||
|
@ -51,16 +51,17 @@ public:
|
|||||||
currentDlg = nullptr;
|
currentDlg = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
static bool needsReset;
|
||||||
void on_PathSettingsDialog_accepted();
|
|
||||||
void on_PathSettingsDialog_rejected();
|
|
||||||
|
|
||||||
//
|
private slots:
|
||||||
|
void done(int r);
|
||||||
|
|
||||||
|
void on_btnSaveFileBrowse_clicked();
|
||||||
|
void on_btnSavestateBrowse_clicked();
|
||||||
|
void on_btnCheatFileBrowse_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PathSettingsDialog* ui;
|
Ui::PathSettingsDialog* ui;
|
||||||
|
|
||||||
//
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PATHSETTINGSDIALOG_H
|
#endif // PATHSETTINGSDIALOG_H
|
||||||
|
@ -103,6 +103,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>txtSaveFilePath</tabstop>
|
||||||
|
<tabstop>btnSaveFileBrowse</tabstop>
|
||||||
|
<tabstop>txtSavestatePath</tabstop>
|
||||||
|
<tabstop>btnSavestateBrowse</tabstop>
|
||||||
|
<tabstop>txtCheatFilePath</tabstop>
|
||||||
|
<tabstop>btnCheatFileBrowse</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
Reference in New Issue
Block a user