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->useFullScreen->setChecked(vjs.fullscreen);
74 // generalTab->useHostAudio->setChecked(vjs.audioEnabled);
76 if (vjs.hardwareTypeAlpine)
78 alpineTab->edit1->setText(vjs.alpineROMPath);
79 alpineTab->edit2->setText(vjs.absROMPath);
80 alpineTab->writeROM->setChecked(vjs.allowWritesToROM);
83 for(int i=0; i<21; i++)
85 controllerTab1->controllerWidget->keys[i] = vjs.p1KeyBindings[i];
86 controllerTab2->controllerWidget->keys[i] = vjs.p2KeyBindings[i];
90 void ConfigDialog::UpdateVJSettings(void)
92 // strcpy(vjs.jagBootPath, generalTab->edit1->text().toAscii().data());
93 // strcpy(vjs.CDBootPath, generalTab->edit2->text().toAscii().data());
94 strcpy(vjs.EEPROMPath, CheckForTrailingSlash(
95 generalTab->edit3->text()).toAscii().data());
96 strcpy(vjs.ROMPath, CheckForTrailingSlash(
97 generalTab->edit4->text()).toAscii().data());
99 vjs.useJaguarBIOS = generalTab->useBIOS->isChecked();
100 vjs.GPUEnabled = generalTab->useGPU->isChecked();
101 vjs.DSPEnabled = generalTab->useDSP->isChecked();
102 vjs.fullscreen = generalTab->useFullScreen->isChecked();
103 // vjs.audioEnabled = generalTab->useHostAudio->isChecked();
105 if (vjs.hardwareTypeAlpine)
107 strcpy(vjs.alpineROMPath, alpineTab->edit1->text().toAscii().data());
108 strcpy(vjs.absROMPath, alpineTab->edit2->text().toAscii().data());
109 vjs.allowWritesToROM = alpineTab->writeROM->isChecked();
112 for(int i=0; i<21; i++)
114 vjs.p1KeyBindings[i] = controllerTab1->controllerWidget->keys[i];
115 vjs.p2KeyBindings[i] = controllerTab2->controllerWidget->keys[i];
119 QString ConfigDialog::CheckForTrailingSlash(QString s)
121 if (!s.endsWith('/') && !s.endsWith('\\'))