* Added a Keybindings dialog tabs.
[clinton/Virtual-Jaguar-Rx.git] / src / gui / configdialog.cpp
CommitLineData
cf76e892
JPM
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
024bfc46 17// JPM 09/ /2017 Added the Keybindings tab
cf76e892
JPM
18//
19
20#include "configdialog.h"
cf76e892 21#include "alpinetab.h"
5fe21518 22#include "debugger/debuggertab.h"
cf76e892
JPM
23#include "controllertab.h"
24#include "controllerwidget.h"
25#include "generaltab.h"
024bfc46 26#include "KeyBindingsTab.h"
cf76e892
JPM
27#include "settings.h"
28
29
024bfc46
JPM
30ConfigDialog::ConfigDialog(QWidget * parent/*= 0*/) : QDialog(parent),
31tabWidget(new QTabWidget),
32generalTab(new GeneralTab(this)),
33controllerTab1(new ControllerTab(this)),
34keybindingsTab(new KeyBindingsTab(this))
cf76e892
JPM
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"));
024bfc46 47 tabWidget->addTab(keybindingsTab, tr("Keybindings"));
cf76e892
JPM
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
76ConfigDialog::~ConfigDialog()
77{
78}
79
80
024bfc46 81// Load / Update the tabs dialog from the settings
cf76e892
JPM
82void ConfigDialog::LoadDialogFromSettings(void)
83{
024bfc46
JPM
84 // General & Keybindings tab settings
85 generalTab->GetSettings();
86 keybindingsTab->GetSettings();
cf76e892 87
024bfc46 88 // Alpine tab settings (also needed by the Debugger)
cf76e892
JPM
89 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
90 {
024bfc46 91 alpineTab->GetSettings();
cf76e892
JPM
92 }
93
024bfc46 94 // Debugger tab settings
cf76e892
JPM
95 if (vjs.softTypeDebugger)
96 {
024bfc46 97 debuggerTab->GetSettings();
cf76e892
JPM
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
024bfc46 117// Save / Update the settings from the tabs dialog
cf76e892
JPM
118void ConfigDialog::UpdateVJSettings(void)
119{
024bfc46
JPM
120 generalTab->SetSettings();
121 keybindingsTab->SetSettings();
cf76e892
JPM
122
123 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
124 {
024bfc46 125 alpineTab->SetSettings();
cf76e892
JPM
126 }
127
128 if (vjs.softTypeDebugger)
129 {
024bfc46 130 debuggerTab->SetSettings();
cf76e892
JPM
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