1218bb4c7fd5c63d6744d3a6fadd355ba9eb9a3c
[clinton/Virtual-Jaguar-Rx.git] / 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 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
9 //
10 // Who When What
11 // --- ---------- ------------------------------------------------------------
12 // JLH 01/29/2010 Created this file
13 // JLH 06/23/2011 Added initial implementation
14 // JLH 10/14/2011 Fixed possibly missing final slash in paths
15 // JPM 06/06/2016 Visual Studio support
16 // JPM 06/19/2016 Soft debugger support
17 // JPM 09/ /2017 Added a Keybindings tab
18 // JPM 09/03/2018 Added a Models & Bios tab
19 //
20
21 #include "configdialog.h"
22 #include "alpinetab.h"
23 #include "debugger/debuggertab.h"
24 #include "controllertab.h"
25 #include "controllerwidget.h"
26 #include "generaltab.h"
27 #include "modelsbiostab.h"
28 #include "KeyBindingsTab.h"
29 #include "settings.h"
30
31
32 ConfigDialog::ConfigDialog(QWidget * parent/*= 0*/) : QDialog(parent),
33 tabWidget(new QTabWidget),
34 generalTab(new GeneralTab(this)),
35 #ifdef NEWMODELSBIOSHANDLER
36 modelsbiosTab(new ModelsBiosTab),
37 #endif
38 controllerTab1(new ControllerTab(this)),
39 keybindingsTab(new KeyBindingsTab(this))
40 {
41 // tabWidget = new QTabWidget;
42 // generalTab = new GeneralTab(this);
43 // controllerTab1 = new ControllerTab(this);
44 //// controllerTab2 = new ControllerTab(this);
45
46 // if (vjs.hardwareTypeAlpine)
47 // alpineTab = new AlpineTab(this);
48
49 tabWidget->addTab(generalTab, tr("General"));
50 #ifdef NEWMODELSBIOSHANDLER
51 tabWidget->addTab(modelsbiosTab, tr("Models and BIOS"));
52 #endif
53 tabWidget->addTab(controllerTab1, tr("Controllers"));
54 // tabWidget->addTab(controllerTab2, tr("Controller #2"));
55 tabWidget->addTab(keybindingsTab, tr("Key Bindings"));
56
57 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
58 {
59 alpineTab = new AlpineTab(this);
60 tabWidget->addTab(alpineTab, tr("Alpine"));
61 }
62
63 if (vjs.softTypeDebugger)
64 {
65 debuggerTab = new DebuggerTab(this);
66 tabWidget->addTab(debuggerTab, tr("Debugger"));
67 }
68
69 buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
70
71 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
72 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
73
74 QVBoxLayout * mainLayout = new QVBoxLayout;
75 mainLayout->addWidget(tabWidget);
76 mainLayout->addWidget(buttonBox);
77 setLayout(mainLayout);
78
79 setWindowTitle(tr("Virtual Jaguar Settings"));
80 LoadDialogFromSettings();
81 }
82
83
84 ConfigDialog::~ConfigDialog()
85 {
86 }
87
88
89 // Load & Update the tabs dialog from the settings
90 void ConfigDialog::LoadDialogFromSettings(void)
91 {
92 // General & Keybindings tab settings
93 generalTab->GetSettings();
94 keybindingsTab->GetSettings();
95 #ifdef NEWMODELSBIOSHANDLER
96 modelsbiosTab->GetSettings();
97 #endif
98
99 // Alpine tab settings (also needed by the Debugger)
100 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
101 {
102 alpineTab->GetSettings();
103 }
104
105 // Debugger tab settings
106 if (vjs.softTypeDebugger)
107 {
108 debuggerTab->GetSettings();
109 }
110
111 #ifdef _MSC_VER
112 #pragma message("Warning: !!! Need to load settings from controller profile !!!")
113 #else
114 #warning "!!! Need to load settings from controller profile !!!"
115 #endif // _MSC_VER
116 // We do this now, but not here. Need to fix this...
117 #if 0
118 for(int i=0; i<21; i++)
119 {
120 // We need to find the right profile and load it up here...
121 controllerTab1->controllerWidget->keys[i] = vjs.p1KeyBindings[i];
122 // controllerTab2->controllerWidget->keys[i] = vjs.p2KeyBindings[i];
123 }
124 #endif
125 }
126
127
128 // Save & Update the settings from the tabs dialog
129 void ConfigDialog::UpdateVJSettings(void)
130 {
131 generalTab->SetSettings();
132 keybindingsTab->SetSettings();
133 #ifdef NEWMODELSBIOSHANDLER
134 modelsbiosTab->SetSettings();
135 #endif
136
137 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
138 {
139 alpineTab->SetSettings();
140 }
141
142 if (vjs.softTypeDebugger)
143 {
144 debuggerTab->SetSettings();
145 }
146
147 #ifdef _MSC_VER
148 #pragma message("Warning: !!! Need to save settings to controller profile !!!")
149 #else
150 #warning "!!! Need to save settings to controller profile !!!"
151 #endif // _MSC_VER
152 // We do this now, but not here. Need to fix this...
153 #if 0
154 for(int i=0; i<21; i++)
155 {
156 // We need to find the right profile and load it up here...
157 vjs.p1KeyBindings[i] = controllerTab1->controllerWidget->keys[i];
158 // vjs.p2KeyBindings[i] = controllerTab2->controllerWidget->keys[i];
159 }
160 #endif
161 }
162