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