take this somewhere

This commit is contained in:
Arisotura 2020-05-17 04:02:16 +02:00
parent 492a4b4b46
commit 60ba163f08
3 changed files with 97 additions and 3 deletions

View File

@ -16,16 +16,86 @@
with melonDS. If not, see http://www.gnu.org/licenses/.
*/
#include <QFileDialog>
#include "types.h"
#include "Config.h"
#include "PlatformConfig.h"
#include "EmuSettingsDialog.h"
#include "ui_EmuSettingsDialog.h"
EmuSettingsDialog* EmuSettingsDialog::currentDlg = nullptr;
extern char* EmuDirectory;
EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::EmuSettingsDialog)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
ui->txtBIOS9Path->setText(Config::BIOS9Path);
ui->txtBIOS7Path->setText(Config::BIOS7Path);
ui->txtFirmwarePath->setText(Config::FirmwarePath);
ui->chkDirectBoot->setChecked(Config::DirectBoot != 0);
}
EmuSettingsDialog::~EmuSettingsDialog()
{
delete ui;
}
void EmuSettingsDialog::on_EmuSettingsDialog_accepted()
{
strncpy(Config::BIOS9Path, ui->txtBIOS9Path->text().toStdString().c_str(), 1023); Config::BIOS9Path[1023] = '\0';
strncpy(Config::BIOS7Path, ui->txtBIOS7Path->text().toStdString().c_str(), 1023); Config::BIOS7Path[1023] = '\0';
strncpy(Config::FirmwarePath, ui->txtFirmwarePath->text().toStdString().c_str(), 1023); Config::FirmwarePath[1023] = '\0';
Config::DirectBoot = ui->chkDirectBoot->isChecked() ? 1:0;
closeDlg();
}
void EmuSettingsDialog::on_EmuSettingsDialog_rejected()
{
closeDlg();
}
void EmuSettingsDialog::on_btnBIOS9Browse_clicked()
{
QString file = QFileDialog::getOpenFileName(this,
"Select DS-mode ARM9 BIOS...",
EmuDirectory,
"BIOS files (*.bin *.rom);;Any file (*.*)");
if (file.isEmpty()) return;
ui->txtBIOS9Path->setText(file);
}
void EmuSettingsDialog::on_btnBIOS7Browse_clicked()
{
QString file = QFileDialog::getOpenFileName(this,
"Select DS-mode ARM7 BIOS...",
EmuDirectory,
"BIOS files (*.bin *.rom);;Any file (*.*)");
if (file.isEmpty()) return;
ui->txtBIOS7Path->setText(file);
}
void EmuSettingsDialog::on_btnFirmwareBrowse_clicked()
{
QString file = QFileDialog::getOpenFileName(this,
"Select DS-mode firmware...",
EmuDirectory,
"Firmware files (*.bin *.rom);;Any file (*.*)");
if (file.isEmpty()) return;
// TODO: check for shitty hacked firmware here?
ui->txtFirmwarePath->setText(file);
}

View File

@ -22,6 +22,7 @@
#include <QDialog>
namespace Ui { class EmuSettingsDialog; }
class EmuSettingsDialog;
class EmuSettingsDialog : public QDialog
{
@ -31,6 +32,31 @@ public:
explicit EmuSettingsDialog(QWidget* parent);
~EmuSettingsDialog();
static EmuSettingsDialog* currentDlg;
static void openDlg(QWidget* parent)
{
if (currentDlg)
{
currentDlg->activateWindow();
return;
}
currentDlg = new EmuSettingsDialog(parent);
currentDlg->show();
}
static void closeDlg()
{
currentDlg = nullptr;
}
private slots:
void on_EmuSettingsDialog_accepted();
void on_EmuSettingsDialog_rejected();
void on_btnBIOS9Browse_clicked();
void on_btnBIOS7Browse_clicked();
void on_btnFirmwareBrowse_clicked();
private:
Ui::EmuSettingsDialog* ui;
};

View File

@ -820,9 +820,7 @@ void MainWindow::onEmuUnpause()
void MainWindow::onOpenEmuSettings()
{
// TODO keep track of this pointer!!
EmuSettingsDialog* dlg = new EmuSettingsDialog(this);
dlg->show();
EmuSettingsDialog::openDlg(this);
}