]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/configdialog.cpp
QString no longer supports toAscii, use toUtf8 instead
[virtualjaguar] / src / gui / configdialog.cpp
1 //
2 // configdialog.cpp - Configuration dialog
3 //
4 // by James Hammons
5 // (C) 2010 Underground Software
6 //
7 // JLH = James Hammons <jlhamm@acm.org>
8 //
9 // Who  When        What
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
14 //
15
16 #include "configdialog.h"
17
18 #include "alpinetab.h"
19 #include "controllertab.h"
20 #include "controllerwidget.h"
21 #include "generaltab.h"
22 #include "settings.h"
23
24
25 ConfigDialog::ConfigDialog(QWidget * parent/*= 0*/): QDialog(parent),
26         tabWidget(new QTabWidget),
27         generalTab(new GeneralTab(this)),
28         controllerTab1(new ControllerTab(this))
29 {
30 //      tabWidget = new QTabWidget;
31 //      generalTab = new GeneralTab(this);
32 //      controllerTab1 = new ControllerTab(this);
33 ////    controllerTab2 = new ControllerTab(this);
34
35 //      if (vjs.hardwareTypeAlpine)
36 //              alpineTab = new AlpineTab(this);
37
38         tabWidget->addTab(generalTab, tr("General"));
39         tabWidget->addTab(controllerTab1, tr("Controllers"));
40 //      tabWidget->addTab(controllerTab2, tr("Controller #2"));
41
42         if (vjs.hardwareTypeAlpine)
43         {
44                 alpineTab = new AlpineTab(this);
45                 tabWidget->addTab(alpineTab, tr("Alpine"));
46         }
47
48         buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
49
50         connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
51         connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
52
53         QVBoxLayout * mainLayout = new QVBoxLayout;
54         mainLayout->addWidget(tabWidget);
55         mainLayout->addWidget(buttonBox);
56         setLayout(mainLayout);
57
58         setWindowTitle(tr("Virtual Jaguar Settings"));
59         LoadDialogFromSettings();
60 }
61
62
63 ConfigDialog::~ConfigDialog()
64 {
65 }
66
67
68 void ConfigDialog::LoadDialogFromSettings(void)
69 {
70 //      generalTab->edit1->setText(vjs.jagBootPath);
71 //      generalTab->edit2->setText(vjs.CDBootPath);
72         generalTab->edit3->setText(vjs.EEPROMPath);
73         generalTab->edit4->setText(vjs.ROMPath);
74
75         generalTab->useBIOS->setChecked(vjs.useJaguarBIOS);
76         generalTab->useGPU->setChecked(vjs.GPUEnabled);
77         generalTab->useDSP->setChecked(vjs.DSPEnabled);
78         generalTab->useFullScreen->setChecked(vjs.fullscreen);
79 //      generalTab->useHostAudio->setChecked(vjs.audioEnabled);
80         generalTab->useFastBlitter->setChecked(vjs.useFastBlitter);
81
82         if (vjs.hardwareTypeAlpine)
83         {
84                 alpineTab->edit1->setText(vjs.alpineROMPath);
85                 alpineTab->edit2->setText(vjs.absROMPath);
86                 alpineTab->writeROM->setChecked(vjs.allowWritesToROM);
87         }
88
89 #warning "!!! Need to load settings from controller profile !!!"
90 // We do this now, but not here. Need to fix this...
91 #if 0
92         for(int i=0; i<21; i++)
93         {
94 // We need to find the right profile and load it up here...
95                 controllerTab1->controllerWidget->keys[i] = vjs.p1KeyBindings[i];
96 //              controllerTab2->controllerWidget->keys[i] = vjs.p2KeyBindings[i];
97         }
98 #endif
99 }
100
101
102 void ConfigDialog::UpdateVJSettings(void)
103 {
104 //      strcpy(vjs.jagBootPath, generalTab->edit1->text().toAscii().data());
105 //      strcpy(vjs.CDBootPath,  generalTab->edit2->text().toAscii().data());
106         strcpy(vjs.EEPROMPath,  CheckForTrailingSlash(
107                 generalTab->edit3->text()).toUtf8().data());
108         strcpy(vjs.ROMPath,     CheckForTrailingSlash(
109                 generalTab->edit4->text()).toUtf8().data());
110
111         vjs.useJaguarBIOS  = generalTab->useBIOS->isChecked();
112         vjs.GPUEnabled     = generalTab->useGPU->isChecked();
113         vjs.DSPEnabled     = generalTab->useDSP->isChecked();
114         vjs.fullscreen     = generalTab->useFullScreen->isChecked();
115 //      vjs.audioEnabled   = generalTab->useHostAudio->isChecked();
116         vjs.useFastBlitter = generalTab->useFastBlitter->isChecked();
117
118         if (vjs.hardwareTypeAlpine)
119         {
120                 strcpy(vjs.alpineROMPath, alpineTab->edit1->text().toUtf8().data());
121                 strcpy(vjs.absROMPath,    alpineTab->edit2->text().toUtf8().data());
122                 vjs.allowWritesToROM = alpineTab->writeROM->isChecked();
123         }
124
125 #warning "!!! Need to save settings to controller profile !!!"
126 // We do this now, but not here. Need to fix this...
127 #if 0
128         for(int i=0; i<21; i++)
129         {
130 // We need to find the right profile and load it up here...
131                 vjs.p1KeyBindings[i] = controllerTab1->controllerWidget->keys[i];
132 //              vjs.p2KeyBindings[i] = controllerTab2->controllerWidget->keys[i];
133         }
134 #endif
135 }
136
137
138 QString ConfigDialog::CheckForTrailingSlash(QString s)
139 {
140         if (!s.endsWith('/') && !s.endsWith('\\'))
141                 s.append('/');
142
143         return s;
144 }