core: Fix libdwarf and Qt build failure
[clinton/Virtual-Jaguar-Rx.git] / src / gui / modelsbiostab.cpp
1 //
2 // modelsbiostab.cpp: Models & Bios tab on the settings dialog
3 //
4 // Part of the Virtual Jaguar Project
5 /// See the README and GPLv3 files for licensing and warranty information
6 //
7 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
8 //
9 // WHO WHEN WHAT
10 // --- ---------- ------------------------------------------------------------
11 // JPM 09/03/2018 Created this file
12 //
13
14 #include "configdialog.h"
15 #include "modelsbiostab.h"
16 #include "settings.h"
17
18
19 //
20 ModelsBiosTab::ModelsBiosTab(QWidget * parent/*= 0*/): QWidget(parent),
21 listJaguarModel(new QComboBox()),
22 listRetailBIOS(new QComboBox()),
23 listDevBIOS(new QComboBox()),
24 JaguarModel(JAG_NULL_SERIES),
25 UseRetailBIOS(0),
26 UseDevBIOS(0),
27 BIOSValue(BT_NULL)
28 {
29 #ifdef NEWMODELSBIOSHANDLER
30 // Jaguar model
31 QLabel *labelModel = new QLabel("Jaguar model");
32 QHBoxLayout *layoutModel = new QHBoxLayout;
33 layoutModel->addWidget(labelModel);
34 listJaguarModel->addItem("Model K", QVariant(JAG_K_SERIES));
35 listJaguarModel->addItem("Model M", QVariant(JAG_M_SERIES));
36 layoutModel->addWidget(listJaguarModel);
37 QVBoxLayout *layout1 = new QVBoxLayout;
38 layout1->addLayout(layoutModel);
39
40 // Retail BIOS select
41 QHBoxLayout *layoutRetailBIOS = new QHBoxLayout;
42 useRetailBIOS = new QCheckBox(tr("Retail BIOS"));
43 layoutRetailBIOS->addWidget(useRetailBIOS);
44 QVBoxLayout *layout2 = new QVBoxLayout;
45 layout2->addLayout(layoutRetailBIOS);
46 // BIOS selection
47 layoutRetailBIOS->addWidget(listRetailBIOS);
48
49 // Developer BIOS select
50 QHBoxLayout *layoutDevBIOS = new QHBoxLayout;
51 useDevBIOS = new QCheckBox(tr("Developer BIOS"));
52 layoutDevBIOS->addWidget(useDevBIOS);
53 QVBoxLayout *layout3 = new QVBoxLayout;
54 layout3->addLayout(layoutDevBIOS);
55 // BIOS selection
56 listDevBIOS->hide();
57 listDevBIOS->addItem("Stubulator '93", QVariant(BT_STUBULATOR_1));
58 listDevBIOS->addItem("Stubulator '94", QVariant(BT_STUBULATOR_2));
59 layoutDevBIOS->addWidget(listDevBIOS);
60
61 // Set layouts
62 layout1->addLayout(layout2);
63 layout1->addLayout(layout3);
64 setLayout(layout1);
65
66 // Connections
67 connect(useRetailBIOS, SIGNAL(stateChanged(int)), this, SLOT(stateChangedUseRetailBIOS(int)));
68 connect(useDevBIOS, SIGNAL(stateChanged(int)), this, SLOT(stateChangedUseDevBIOS(int)));
69 connect(listJaguarModel, SIGNAL(currentIndexChanged(int)), this, SLOT(CurrentIndexJaguarModel(int)));
70 connect(listDevBIOS, SIGNAL(currentIndexChanged(int)), this, SLOT(CurrentIndexDevBIOS(int)));
71 #endif
72 }
73
74
75 //
76 void ModelsBiosTab::stateChangedUseDevBIOS(int usedevbios)
77 {
78 #ifdef NEWMODELSBIOSHANDLER
79 if ((UseDevBIOS = usedevbios))
80 {
81 stateChangedUseRetailBIOS(0);
82 BIOSValue = listDevBIOS->itemData(listDevBIOS->currentIndex()).toInt();
83 listDevBIOS->show();
84 }
85 else
86 {
87 useDevBIOS->setChecked(false);
88 listDevBIOS->hide();
89 }
90 #endif
91 }
92
93
94 //
95 void ModelsBiosTab::stateChangedUseRetailBIOS(int useretailbios)
96 {
97 #ifdef NEWMODELSBIOSHANDLER
98 if ((UseRetailBIOS = useretailbios))
99 {
100 stateChangedUseDevBIOS(0);
101
102 switch (JaguarModel)
103 {
104 case JAG_K_SERIES:
105 listRetailBIOS->clear();
106 listRetailBIOS->addItem("Model K", QVariant(BT_K_SERIES));
107 BIOSValue = BT_K_SERIES;
108 break;
109
110 case JAG_M_SERIES:
111 listRetailBIOS->clear();
112 listRetailBIOS->addItem("Model M", QVariant(BT_M_SERIES));
113 BIOSValue = BT_M_SERIES;
114 break;
115
116 default:
117 break;
118 }
119
120 listRetailBIOS->show();
121 }
122 else
123 {
124 useRetailBIOS->setChecked(false);
125 listRetailBIOS->hide();
126 }
127 #endif
128 }
129
130
131 // Get the index from the Jaguar models list
132 void ModelsBiosTab::CurrentIndexJaguarModel(int index)
133 {
134 #ifdef NEWMODELSBIOSHANDLER
135 JaguarModel = listJaguarModel->itemData(index).toInt();
136 stateChangedUseRetailBIOS(UseRetailBIOS);
137 #endif
138 }
139
140
141 // Get the index from the developer BIOS list
142 void ModelsBiosTab::CurrentIndexDevBIOS(int index)
143 {
144 #ifdef NEWMODELSBIOSHANDLER
145 BIOSValue = listDevBIOS->itemData(index).toInt();
146 #endif
147 }
148
149
150 //
151 ModelsBiosTab::~ModelsBiosTab()
152 {
153 #ifdef NEWMODELSBIOSHANDLER
154 #endif
155 }
156
157
158 // Load & Update the tabs dialog from the settings
159 void ModelsBiosTab::GetSettings(void)
160 {
161 #ifdef NEWMODELSBIOSHANDLER
162 listJaguarModel->setCurrentIndex(listJaguarModel->findData((JaguarModel = vjs.jaguarModel)));
163 listDevBIOS->setCurrentIndex(listDevBIOS->findData((BIOSValue = vjs.biosType)));
164 useRetailBIOS->setChecked((UseRetailBIOS = vjs.useRetailBIOS));
165 useDevBIOS->setChecked((UseDevBIOS = vjs.useDevBIOS));
166 #endif
167 }
168
169
170 // Save & Update the settings from the tabs dialog
171 void ModelsBiosTab::SetSettings(void)
172 {
173 #ifdef NEWMODELSBIOSHANDLER
174 vjs.jaguarModel = JaguarModel;
175 if (!(vjs.useJaguarBIOS = (UseRetailBIOS | UseDevBIOS)))
176 {
177 vjs.biosType = 0;
178 }
179 else
180 {
181 vjs.biosType = BIOSValue;
182 }
183 vjs.useRetailBIOS = UseRetailBIOS;
184 vjs.useDevBIOS = UseDevBIOS;
185 #endif
186 }