This repository has been archived by the owner on Aug 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdpadeditdialog.cpp
400 lines (339 loc) · 19.7 KB
/
dpadeditdialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
/* antimicro Gamepad to KB+M event mapper
* Copyright (C) 2015 Travis Nickles <nickles.travis@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//#include <QDebug>
#include <QHashIterator>
#include <QList>
#include "dpadeditdialog.h"
#include "ui_dpadeditdialog.h"
#include "mousedialog/mousedpadsettingsdialog.h"
#include "event.h"
#include "antkeymapper.h"
#include "setjoystick.h"
#include "inputdevice.h"
#include "common.h"
DPadEditDialog::DPadEditDialog(JoyDPad *dpad, QWidget *parent) :
QDialog(parent, Qt::Window),
ui(new Ui::DPadEditDialog),
helper(dpad)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
this->dpad = dpad;
helper.moveToThread(dpad->thread());
PadderCommon::inputDaemonMutex.lock();
updateWindowTitleDPadName();
if (dpad->getJoyMode() == JoyDPad::StandardMode)
{
ui->joyModeComboBox->setCurrentIndex(0);
}
else if (dpad->getJoyMode() == JoyDPad::EightWayMode)
{
ui->joyModeComboBox->setCurrentIndex(1);
}
else if (dpad->getJoyMode() == JoyDPad::FourWayCardinal)
{
ui->joyModeComboBox->setCurrentIndex(2);
}
else if (dpad->getJoyMode() == JoyDPad::FourWayDiagonal)
{
ui->joyModeComboBox->setCurrentIndex(3);
}
selectCurrentPreset();
ui->dpadNameLineEdit->setText(dpad->getDpadName());
unsigned int dpadDelay = dpad->getDPadDelay();
ui->dpadDelaySlider->setValue(dpadDelay * .1);
ui->dpadDelayDoubleSpinBox->setValue(dpadDelay * .001);
PadderCommon::inputDaemonMutex.unlock();
connect(ui->presetsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(implementPresets(int)));
connect(ui->joyModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(implementModes(int)));
connect(ui->mouseSettingsPushButton, SIGNAL(clicked()), this, SLOT(openMouseSettingsDialog()));
connect(ui->dpadNameLineEdit, SIGNAL(textEdited(QString)), dpad, SLOT(setDPadName(QString)));
connect(ui->dpadDelaySlider, SIGNAL(valueChanged(int)), &helper, SLOT(updateJoyDPadDelay(int)));
connect(dpad, SIGNAL(dpadDelayChanged(int)), this, SLOT(updateDPadDelaySpinBox(int)));
connect(ui->dpadDelayDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateDPadDelaySlider(double)));
connect(dpad, SIGNAL(dpadNameChanged()), this, SLOT(updateWindowTitleDPadName()));
}
DPadEditDialog::~DPadEditDialog()
{
delete ui;
}
void DPadEditDialog::implementPresets(int index)
{
JoyButtonSlot *upButtonSlot = 0;
JoyButtonSlot *downButtonSlot = 0;
JoyButtonSlot *leftButtonSlot = 0;
JoyButtonSlot *rightButtonSlot = 0;
JoyButtonSlot *upLeftButtonSlot = 0;
JoyButtonSlot *upRightButtonSlot = 0;
JoyButtonSlot *downLeftButtonSlot = 0;
JoyButtonSlot *downRightButtonSlot = 0;
if (index == 1)
{
PadderCommon::inputDaemonMutex.lock();
upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this);
downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this);
leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this);
rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this);
PadderCommon::inputDaemonMutex.unlock();
ui->joyModeComboBox->setCurrentIndex(0);
}
else if (index == 2)
{
PadderCommon::inputDaemonMutex.lock();
upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this);
downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this);
leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this);
rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this);
PadderCommon::inputDaemonMutex.unlock();
ui->joyModeComboBox->setCurrentIndex(0);
}
else if (index == 3)
{
PadderCommon::inputDaemonMutex.lock();
upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this);
downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this);
leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this);
rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this);
PadderCommon::inputDaemonMutex.unlock();
ui->joyModeComboBox->setCurrentIndex(0);
}
else if (index == 4)
{
PadderCommon::inputDaemonMutex.lock();
upButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseDown, JoyButtonSlot::JoyMouseMovement, this);
downButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseUp, JoyButtonSlot::JoyMouseMovement, this);
leftButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseRight, JoyButtonSlot::JoyMouseMovement, this);
rightButtonSlot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this);
PadderCommon::inputDaemonMutex.unlock();
ui->joyModeComboBox->setCurrentIndex(0);
}
else if (index == 5)
{
PadderCommon::inputDaemonMutex.lock();
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this);
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this);
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this);
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this);
PadderCommon::inputDaemonMutex.unlock();
ui->joyModeComboBox->setCurrentIndex(0);
}
else if (index == 6)
{
PadderCommon::inputDaemonMutex.lock();
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this);
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this);
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this);
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this);
PadderCommon::inputDaemonMutex.unlock();
ui->joyModeComboBox->setCurrentIndex(0);
}
else if (index == 7)
{
PadderCommon::inputDaemonMutex.lock();
if (ui->joyModeComboBox->currentIndex() == 0 ||
ui->joyModeComboBox->currentIndex() == 2)
{
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
}
else if (ui->joyModeComboBox->currentIndex() == 1)
{
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this);
upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this);
downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this);
downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this);
}
else if (ui->joyModeComboBox->currentIndex() == 3)
{
upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this);
upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this);
downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this);
downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this);
}
PadderCommon::inputDaemonMutex.unlock();
}
else if (index == 8)
{
QMetaObject::invokeMethod(&helper, "clearButtonsSlotsEventReset", Qt::BlockingQueuedConnection);
}
QHash<JoyDPadButton::JoyDPadDirections, JoyButtonSlot*> tempHash;
tempHash.insert(JoyDPadButton::DpadUp, upButtonSlot);
tempHash.insert(JoyDPadButton::DpadDown, downButtonSlot);
tempHash.insert(JoyDPadButton::DpadLeft, leftButtonSlot);
tempHash.insert(JoyDPadButton::DpadRight, rightButtonSlot);
tempHash.insert(JoyDPadButton::DpadLeftUp, upLeftButtonSlot);
tempHash.insert(JoyDPadButton::DpadRightUp, upRightButtonSlot);
tempHash.insert(JoyDPadButton::DpadLeftDown, downLeftButtonSlot);
tempHash.insert(JoyDPadButton::DpadRightDown, downRightButtonSlot);
helper.setPendingSlots(&tempHash);
QMetaObject::invokeMethod(&helper, "setFromPendingSlots", Qt::BlockingQueuedConnection);
}
void DPadEditDialog::implementModes(int index)
{
PadderCommon::inputDaemonMutex.lock();
dpad->releaseButtonEvents();
if (index == 0)
{
dpad->setJoyMode(JoyDPad::StandardMode);
}
else if (index == 1)
{
dpad->setJoyMode(JoyDPad::EightWayMode);
}
else if (index == 2)
{
dpad->setJoyMode(JoyDPad::FourWayCardinal);
}
else if (index == 3)
{
dpad->setJoyMode(JoyDPad::FourWayDiagonal);
}
PadderCommon::inputDaemonMutex.unlock();
}
void DPadEditDialog::selectCurrentPreset()
{
JoyDPadButton *upButton = dpad->getJoyButton(JoyDPadButton::DpadUp);
QList<JoyButtonSlot*> *upslots = upButton->getAssignedSlots();
JoyDPadButton *downButton = dpad->getJoyButton(JoyDPadButton::DpadDown);
QList<JoyButtonSlot*> *downslots = downButton->getAssignedSlots();
JoyDPadButton *leftButton = dpad->getJoyButton(JoyDPadButton::DpadLeft);
QList<JoyButtonSlot*> *leftslots = leftButton->getAssignedSlots();
JoyDPadButton *rightButton = dpad->getJoyButton(JoyDPadButton::DpadRight);
QList<JoyButtonSlot*> *rightslots = rightButton->getAssignedSlots();
if (upslots->length() == 1 && downslots->length() == 1 && leftslots->length() == 1 && rightslots->length() == 1)
{
JoyButtonSlot *upslot = upslots->at(0);
JoyButtonSlot *downslot = downslots->at(0);
JoyButtonSlot *leftslot = leftslots->at(0);
JoyButtonSlot *rightslot = rightslots->at(0);
if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseUp &&
downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseDown &&
leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseLeft &&
rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseRight)
{
ui->presetsComboBox->setCurrentIndex(1);
}
else if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseUp &&
downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseDown &&
leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseRight &&
rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseLeft)
{
ui->presetsComboBox->setCurrentIndex(2);
}
else if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseDown &&
downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseUp &&
leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseLeft &&
rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseRight)
{
ui->presetsComboBox->setCurrentIndex(3);
}
else if (upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && upslot->getSlotCode() == JoyButtonSlot::MouseDown &&
downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && downslot->getSlotCode() == JoyButtonSlot::MouseUp &&
leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && leftslot->getSlotCode() == JoyButtonSlot::MouseRight &&
rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement && rightslot->getSlotCode() == JoyButtonSlot::MouseLeft)
{
ui->presetsComboBox->setCurrentIndex(4);
}
else if (upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(upslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up) &&
downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(downslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down) &&
leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(leftslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left) &&
rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(rightslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right))
{
ui->presetsComboBox->setCurrentIndex(5);
}
else if (upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(upslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W) &&
downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(downslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S) &&
leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(leftslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A) &&
rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(rightslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D))
{
ui->presetsComboBox->setCurrentIndex(6);
}
else if (upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(upslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8) &&
downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(downslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2) &&
leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(leftslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4) &&
rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard && static_cast<unsigned int>(rightslot->getSlotCode()) == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6))
{
ui->presetsComboBox->setCurrentIndex(7);
}
}
else if (upslots->length() == 0 && downslots->length() == 0 &&
leftslots->length() == 0 && rightslots->length() == 0)
{
ui->presetsComboBox->setCurrentIndex(8);
}
}
void DPadEditDialog::openMouseSettingsDialog()
{
ui->mouseSettingsPushButton->setEnabled(false);
MouseDPadSettingsDialog *dialog = new MouseDPadSettingsDialog(this->dpad, this);
dialog->show();
connect(this, SIGNAL(finished(int)), dialog, SLOT(close()));
connect(dialog, SIGNAL(finished(int)), this, SLOT(enableMouseSettingButton()));
}
void DPadEditDialog::enableMouseSettingButton()
{
ui->mouseSettingsPushButton->setEnabled(true);
}
/**
* @brief Update QDoubleSpinBox value based on updated dpad delay value.
* @param Delay value obtained from JoyDPad.
*/
void DPadEditDialog::updateDPadDelaySpinBox(int value)
{
double temp = static_cast<double>(value * 0.001);
ui->dpadDelayDoubleSpinBox->setValue(temp);
}
/**
* @brief Update QSlider value based on value from QDoubleSpinBox.
* @param Value from QDoubleSpinBox.
*/
void DPadEditDialog::updateDPadDelaySlider(double value)
{
int temp = static_cast<int>(value * 100);
if (ui->dpadDelaySlider->value() != temp)
{
ui->dpadDelaySlider->setValue(temp);
}
}
void DPadEditDialog::updateWindowTitleDPadName()
{
QString temp = QString(tr("Set")).append(" ");
if (!dpad->getDpadName().isEmpty())
{
temp.append(dpad->getName(false, true));
}
else
{
temp.append(dpad->getName());
}
if (dpad->getParentSet()->getIndex() != 0)
{
unsigned int setIndex = dpad->getParentSet()->getRealIndex();
temp.append(" [").append(tr("Set %1").arg(setIndex));
QString setName = dpad->getParentSet()->getName();
if (!setName.isEmpty())
{
temp.append(": ").append(setName);
}
temp.append("]");
}
setWindowTitle(temp);
}