2 // configdialog.cpp - Configuration dialog
5 // (C) 2010 Underground Software
7 // JLH = James Hammons <jlhamm@acm.org>
10 // --- ---------- -------------------------------------------------------------
11 // JLH 01/29/2010 Created this file
12 // JLH 06/23/2011 Added initial implementation
13 // JLH 10/14/2011 Fixed possibly missing final slash in paths
16 #include "configdialog.h"
18 #include "alpinetab.h"
19 #include "controllertab.h"
20 #include "controllerwidget.h"
21 #include "generaltab.h"
25 ConfigDialog::ConfigDialog(QWidget * parent/*= 0*/): QDialog(parent)
27 tabWidget = new QTabWidget;
28 generalTab = new GeneralTab(this);
29 controllerTab1 = new ControllerTab(this);
30 controllerTab2 = new ControllerTab(this);
32 if (vjs.hardwareTypeAlpine)
33 alpineTab = new AlpineTab(this);
35 tabWidget->addTab(generalTab, tr("General"));
36 tabWidget->addTab(controllerTab1, tr("Controller #1"));
37 tabWidget->addTab(controllerTab2, tr("Controller #2"));
39 if (vjs.hardwareTypeAlpine)
40 tabWidget->addTab(alpineTab, tr("Alpine"));
42 buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
44 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
45 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
47 QVBoxLayout * mainLayout = new QVBoxLayout;
48 mainLayout->addWidget(tabWidget);
49 mainLayout->addWidget(buttonBox);
50 setLayout(mainLayout);
52 setWindowTitle(tr("Virtual Jaguar Settings"));
54 LoadDialogFromSettings();
55 // controllerTab1->UpdateLabel(); // Now it's safe to do this... ;-)
56 // controllerTab2->UpdateLabel(); // Now it's safe to do this... ;-)
59 ConfigDialog::~ConfigDialog()
63 void ConfigDialog::LoadDialogFromSettings(void)
65 generalTab->edit1->setText(vjs.jagBootPath);
66 generalTab->edit2->setText(vjs.CDBootPath);
67 generalTab->edit3->setText(vjs.EEPROMPath);
68 generalTab->edit4->setText(vjs.ROMPath);
70 generalTab->useBIOS->setChecked(vjs.useJaguarBIOS);
71 generalTab->useGPU->setChecked(vjs.GPUEnabled);
72 generalTab->useDSP->setChecked(vjs.DSPEnabled);
73 generalTab->useHostAudio->setChecked(vjs.audioEnabled);
75 if (vjs.hardwareTypeAlpine)
77 alpineTab->edit1->setText(vjs.alpineROMPath);
78 alpineTab->edit2->setText(vjs.absROMPath);
79 alpineTab->writeROM->setChecked(vjs.allowWritesToROM);
82 for(int i=0; i<21; i++)
84 controllerTab1->controllerWidget->keys[i] = vjs.p1KeyBindings[i];
85 controllerTab2->controllerWidget->keys[i] = vjs.p2KeyBindings[i];
89 void ConfigDialog::UpdateVJSettings(void)
91 strcpy(vjs.jagBootPath, generalTab->edit1->text().toAscii().data());
92 strcpy(vjs.CDBootPath, generalTab->edit2->text().toAscii().data());
93 strcpy(vjs.EEPROMPath, CheckForTrailingSlash(
94 generalTab->edit3->text()).toAscii().data());
95 strcpy(vjs.ROMPath, CheckForTrailingSlash(
96 generalTab->edit4->text()).toAscii().data());
98 vjs.useJaguarBIOS = generalTab->useBIOS->isChecked();
99 vjs.GPUEnabled = generalTab->useGPU->isChecked();
100 vjs.DSPEnabled = generalTab->useDSP->isChecked();
101 vjs.audioEnabled = generalTab->useHostAudio->isChecked();
103 if (vjs.hardwareTypeAlpine)
105 strcpy(vjs.alpineROMPath, alpineTab->edit1->text().toAscii().data());
106 strcpy(vjs.absROMPath, alpineTab->edit2->text().toAscii().data());
107 vjs.allowWritesToROM = alpineTab->writeROM->isChecked();
110 for(int i=0; i<21; i++)
112 vjs.p1KeyBindings[i] = controllerTab1->controllerWidget->keys[i];
113 vjs.p2KeyBindings[i] = controllerTab2->controllerWidget->keys[i];
117 QString ConfigDialog::CheckForTrailingSlash(QString s)
119 if (!s.endsWith('/') && !s.endsWith('\\'))