e4bcbad4556cdb1271583eba20a32d99b2f8c029
[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 the Keybindings tab
18 //
19
20 #include "configdialog.h"
21 #include "alpinetab.h"
22 #include "debugger/debuggertab.h"
23 #include "controllertab.h"
24 #include "controllerwidget.h"
25 #include "generaltab.h"
26 #include "KeyBindingsTab.h"
27 #include "settings.h"
28
29
30 ConfigDialog::ConfigDialog(QWidget * parent/*= 0*/) : QDialog(parent),
31 tabWidget(new QTabWidget),
32 generalTab(new GeneralTab(this)),
33 controllerTab1(new ControllerTab(this)),
34 keybindingsTab(new KeyBindingsTab(this))
35 {
36 // tabWidget = new QTabWidget;
37 // generalTab = new GeneralTab(this);
38 // controllerTab1 = new ControllerTab(this);
39 //// controllerTab2 = new ControllerTab(this);
40
41 // if (vjs.hardwareTypeAlpine)
42 // alpineTab = new AlpineTab(this);
43
44 tabWidget->addTab(generalTab, tr("General"));
45 tabWidget->addTab(controllerTab1, tr("Controllers"));
46 // tabWidget->addTab(controllerTab2, tr("Controller #2"));
47 tabWidget->addTab(keybindingsTab, tr("Keybindings"));
48
49 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
50 {
51 alpineTab = new AlpineTab(this);
52 tabWidget->addTab(alpineTab, tr("Alpine"));
53 }
54
55 if (vjs.softTypeDebugger)
56 {
57 debuggerTab = new DebuggerTab(this);
58 tabWidget->addTab(debuggerTab, tr("Debugger"));
59 }
60
61 buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
62
63 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
64 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
65
66 QVBoxLayout * mainLayout = new QVBoxLayout;
67 mainLayout->addWidget(tabWidget);
68 mainLayout->addWidget(buttonBox);
69 setLayout(mainLayout);
70
71 setWindowTitle(tr("Virtual Jaguar Settings"));
72 LoadDialogFromSettings();
73 }
74
75
76 ConfigDialog::~ConfigDialog()
77 {
78 }
79
80
81 // Load / Update the tabs dialog from the settings
82 void ConfigDialog::LoadDialogFromSettings(void)
83 {
84 // General & Keybindings tab settings
85 generalTab->GetSettings();
86 keybindingsTab->GetSettings();
87
88 // Alpine tab settings (also needed by the Debugger)
89 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
90 {
91 alpineTab->GetSettings();
92 }
93
94 // Debugger tab settings
95 if (vjs.softTypeDebugger)
96 {
97 debuggerTab->GetSettings();
98 }
99
100 #ifdef _MSC_VER
101 #pragma message("Warning: !!! Need to load settings from controller profile !!!")
102 #else
103 #warning "!!! Need to load settings from controller profile !!!"
104 #endif // _MSC_VER
105 // We do this now, but not here. Need to fix this...
106 #if 0
107 for(int i=0; i<21; i++)
108 {
109 // We need to find the right profile and load it up here...
110 controllerTab1->controllerWidget->keys[i] = vjs.p1KeyBindings[i];
111 // controllerTab2->controllerWidget->keys[i] = vjs.p2KeyBindings[i];
112 }
113 #endif
114 }
115
116
117 // Save / Update the settings from the tabs dialog
118 void ConfigDialog::UpdateVJSettings(void)
119 {
120 generalTab->SetSettings();
121 keybindingsTab->SetSettings();
122
123 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
124 {
125 alpineTab->SetSettings();
126 }
127
128 if (vjs.softTypeDebugger)
129 {
130 debuggerTab->SetSettings();
131 }
132
133 #ifdef _MSC_VER
134 #pragma message("Warning: !!! Need to save settings to controller profile !!!")
135 #else
136 #warning "!!! Need to save settings to controller profile !!!"
137 #endif // _MSC_VER
138 // We do this now, but not here. Need to fix this...
139 #if 0
140 for(int i=0; i<21; i++)
141 {
142 // We need to find the right profile and load it up here...
143 vjs.p1KeyBindings[i] = controllerTab1->controllerWidget->keys[i];
144 // vjs.p2KeyBindings[i] = controllerTab2->controllerWidget->keys[i];
145 }
146 #endif
147 }
148