1 /*
2  *  OpenSCAD (www.openscad.org)
3  *  Copyright (C) 2009-2014 Clifford Wolf <clifford@clifford.at> and
4  *                          Marius Kintel <marius@kintel.net>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  As a special exception, you have permission to link this program
12  *  with the CGAL library and distribute executables, as long as you
13  *  follow the requirements of the GNU GPL in regard to all of the
14  *  software in the executable aside from CGAL.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  *
25  */
26 
27 #include <QWidget>
28 #include "AxisConfigWidget.h"
29 
30 #include "settings.h"
31 #include "QSettingsCached.h"
32 #include "input/InputDriverManager.h"
33 #include "SettingsWriter.h"
34 #include "WheelIgnorer.h"
35 #include "initConfig.h"
36 
37 
AxisConfigWidget(QWidget * parent)38 AxisConfigWidget::AxisConfigWidget(QWidget *parent) : QWidget(parent)
39 {
40 	setupUi(this);
41 }
42 
~AxisConfigWidget()43 AxisConfigWidget::~AxisConfigWidget()
44 {
45 }
46 
AxesChanged(int nr,double val) const47 void AxisConfigWidget::AxesChanged(int nr, double val) const{
48 	QProgressBar* progressBar = this->findChild<QProgressBar *>(QString("progressBarAxis%1").arg(nr));
49 	if(progressBar==nullptr) return;
50 
51 	int value = val * 100;
52 	progressBar->setValue(value); //set where the bar is
53 
54 	//QProgressBar generates the shown string from the format string.
55 	//By setting a format string without a place holder,
56 	//we can set arbitrary text, like a custom formatted double.
57 	//(Note: QProgressBar internally works on int, so has no formating for double values)
58 	//(Note: The text of a QProgressBar can not be set directly)
59 	QString s =  QString::number(val, 'f', 2 );
60 	progressBar->setFormat(s);
61 
62 	QDoubleSpinBox* deadzone = this->findChild<QDoubleSpinBox *>(QString("doubleSpinBoxDeadzone%1").arg(nr));
63 	if(deadzone){
64 		bool active = deadzone->value() < std::abs(val);
65 		QString style;
66 		if(this->darkModeDetected){
67 			style = active ? ProgressbarStyleDarkActive : ProgressbarStyleDark;
68 		}else{
69 			style = active ? ProgressbarStyleLightActive : ProgressbarStyleLight;
70 		}
71 		progressBar->setStyleSheet(style);
72 	}
73 }
74 
init()75 void AxisConfigWidget::init() {
76 	connect(this->pushButtonAxisTrim, SIGNAL(clicked()), this, SLOT(on_AxisTrim()));
77 	connect(this->pushButtonAxisTrimReset, SIGNAL(clicked()), this, SLOT(on_AxisTrimReset()));
78 	connect(this->pushButtonUpdate, SIGNAL(clicked()), this, SLOT(updateStates()));
79 
80 	initComboBox(this->comboBoxTranslationX, Settings::Settings::inputTranslationX);
81 	initComboBox(this->comboBoxTranslationY, Settings::Settings::inputTranslationY);
82 	initComboBox(this->comboBoxTranslationZ, Settings::Settings::inputTranslationZ);
83 	initComboBox(this->comboBoxTranslationXVPRel, Settings::Settings::inputTranslationXVPRel);
84 	initComboBox(this->comboBoxTranslationYVPRel, Settings::Settings::inputTranslationYVPRel);
85 	initComboBox(this->comboBoxTranslationZVPRel, Settings::Settings::inputTranslationZVPRel);
86 	initComboBox(this->comboBoxRotationX, Settings::Settings::inputRotateX);
87 	initComboBox(this->comboBoxRotationY, Settings::Settings::inputRotateY);
88 	initComboBox(this->comboBoxRotationZ, Settings::Settings::inputRotateZ);
89 	initComboBox(this->comboBoxRotationXVPRel, Settings::Settings::inputRotateXVPRel);
90 	initComboBox(this->comboBoxRotationYVPRel, Settings::Settings::inputRotateYVPRel);
91 	initComboBox(this->comboBoxRotationZVPRel, Settings::Settings::inputRotateZVPRel);
92 	initComboBox(this->comboBoxZoom, Settings::Settings::inputZoom);
93 	initComboBox(this->comboBoxZoom2, Settings::Settings::inputZoom2);
94 
95 #ifdef ENABLE_HIDAPI
96 	this->checkBoxHIDAPI->setEnabled(true);
97 	this->checkBoxHIDAPI->setToolTip(HidApiInputDriverDescription);
98 #else
99 	this->checkBoxHIDAPI->setToolTip(HidApiInputDriverDescription + "\n\r" + NotEnabledDuringBuild);
100 #endif
101 
102 #ifdef ENABLE_SPNAV
103 	this->checkBoxSpaceNav->setEnabled(true);
104 	this->checkBoxSpaceNav->setToolTip(SpaceNavInputDriverDescription);
105 #else
106 	this->checkBoxSpaceNav->setToolTip(SpaceNavInputDriverDescription + "\n\r" + NotEnabledDuringBuild);
107 #endif
108 
109 #ifdef ENABLE_JOYSTICK
110 	this->checkBoxJoystick->setEnabled(true);
111 	this->checkBoxJoystick->setToolTip(JoystickInputDriverDescription);
112 #else
113 	this->checkBoxJoystick->setToolTip(JoystickInputDriverDescription + "\n\r" + NotEnabledDuringBuild);
114 #endif
115 
116 #ifdef ENABLE_QGAMEPAD
117 	this->checkBoxQGamepad->setEnabled(true);
118 	this->checkBoxQGamepad->setToolTip(QGamepadInputDriverDescription );
119 #else
120 	this->checkBoxQGamepad->setToolTip(QGamepadInputDriverDescription  + "\n\r" + NotEnabledDuringBuild);
121 #endif
122 
123 #ifdef ENABLE_DBUS
124 	this->checkBoxDBus->setEnabled(true);
125 	this->checkBoxDBus->setToolTip(DBusInputDriverDescription);
126 #else
127 	this->checkBoxDBus->setToolTip(DBusInputDriverDescription + "\n\r" + NotEnabledDuringBuild);
128 #endif
129 
130 	initCheckBox(this->checkBoxHIDAPI,   Settings::Settings::inputEnableDriverHIDAPI);
131 	initCheckBox(this->checkBoxSpaceNav, Settings::Settings::inputEnableDriverSPNAV);
132 	initCheckBox(this->checkBoxJoystick, Settings::Settings::inputEnableDriverJOYSTICK);
133 	initCheckBox(this->checkBoxQGamepad, Settings::Settings::inputEnableDriverQGAMEPAD);
134 	initCheckBox(this->checkBoxDBus,     Settings::Settings::inputEnableDriverDBUS);
135 
136 	auto *wheelIgnorer = new WheelIgnorer(this);
137 	auto comboBoxes = this->findChildren<QComboBox *>();
138 	for (auto comboBox : comboBoxes) {
139 		comboBox->installEventFilter(wheelIgnorer);
140 	}
141 
142 	for (int i = 0; i < InputEventMapper::getMaxAxis(); ++i ){
143 		std::string s = std::to_string(i);
144 
145 		auto spin = this->findChild<QDoubleSpinBox *>(QString("doubleSpinBoxTrim%1").arg(i));
146 		auto ent = Settings::Settings::inst()->getSettingEntryByName("axisTrim" +s);
147 		if(spin && ent){
148 			initDoubleSpinBox(spin,*ent);
149 		}
150 		spin = this->findChild<QDoubleSpinBox *>(QString("doubleSpinBoxDeadzone%1").arg(i));
151 		ent = Settings::Settings::inst()->getSettingEntryByName("axisDeadzone" +s);
152 		if(spin && ent){
153 			initDoubleSpinBox(spin,*ent);
154 		}
155 	}
156 
157 	initDoubleSpinBox(this->doubleSpinBoxTranslationGain, Settings::Settings::inputTranslationGain);
158 	initDoubleSpinBox(this->doubleSpinBoxTranslationVPRelGain, Settings::Settings::inputTranslationVPRelGain);
159 	initDoubleSpinBox(this->doubleSpinBoxRotateGain, Settings::Settings::inputRotateGain);
160 	initDoubleSpinBox(this->doubleSpinBoxZoomGain, Settings::Settings::inputZoomGain);
161 
162 	//use a custom style for the axis indicators,
163 	//to prevent getting operating system specific
164 	//(potentially animated) ProgressBars
165 	int textLightness = this->progressBarAxis0->palette().text().color().lightness();
166 	this->darkModeDetected = textLightness>165;
167 	QString style = (this->darkModeDetected) ? ProgressbarStyleDark : ProgressbarStyleLight;
168 
169 	auto progressbars = this->findChildren<QProgressBar *>();
170 	for (auto progressbar : progressbars) {
171 		progressbar->setStyleSheet(style);
172 		progressbar->setAlignment(Qt::AlignCenter);
173 	}
174 
175 	initialized = true;
176 }
177 
on_comboBoxTranslationX_activated(int val)178 void AxisConfigWidget::on_comboBoxTranslationX_activated(int val)
179 {
180 	applyComboBox(comboBoxTranslationX, val, Settings::Settings::inputTranslationX);
181         emit inputMappingChanged();
182 }
183 
on_comboBoxTranslationY_activated(int val)184 void AxisConfigWidget::on_comboBoxTranslationY_activated(int val)
185 {
186 	applyComboBox(comboBoxTranslationY, val, Settings::Settings::inputTranslationY);
187         emit inputMappingChanged();
188 }
189 
on_comboBoxTranslationZ_activated(int val)190 void AxisConfigWidget::on_comboBoxTranslationZ_activated(int val)
191 {
192 	applyComboBox(comboBoxTranslationZ, val, Settings::Settings::inputTranslationZ);
193         emit inputMappingChanged();
194 }
195 
on_comboBoxTranslationXVPRel_activated(int val)196 void AxisConfigWidget::on_comboBoxTranslationXVPRel_activated(int val)
197 {
198 	applyComboBox(comboBoxTranslationXVPRel, val, Settings::Settings::inputTranslationXVPRel);
199         emit inputMappingChanged();
200 }
201 
on_comboBoxTranslationYVPRel_activated(int val)202 void AxisConfigWidget::on_comboBoxTranslationYVPRel_activated(int val)
203 {
204 	applyComboBox(comboBoxTranslationYVPRel, val, Settings::Settings::inputTranslationYVPRel);
205         emit inputMappingChanged();
206 }
207 
on_comboBoxTranslationZVPRel_activated(int val)208 void AxisConfigWidget::on_comboBoxTranslationZVPRel_activated(int val)
209 {
210 	applyComboBox(comboBoxTranslationZVPRel, val, Settings::Settings::inputTranslationZVPRel);
211         emit inputMappingChanged();
212 }
on_comboBoxRotationX_activated(int val)213 void AxisConfigWidget::on_comboBoxRotationX_activated(int val)
214 {
215 	applyComboBox(comboBoxRotationX, val, Settings::Settings::inputRotateX);
216         emit inputMappingChanged();
217 }
218 
on_comboBoxRotationY_activated(int val)219 void AxisConfigWidget::on_comboBoxRotationY_activated(int val)
220 {
221 	applyComboBox(comboBoxRotationY, val, Settings::Settings::inputRotateY);
222         emit inputMappingChanged();
223 }
224 
on_comboBoxRotationZ_activated(int val)225 void AxisConfigWidget::on_comboBoxRotationZ_activated(int val)
226 {
227 	applyComboBox(comboBoxRotationZ, val, Settings::Settings::inputRotateZ);
228         emit inputMappingChanged();
229 }
230 
on_comboBoxRotationXVPRel_activated(int val)231 void AxisConfigWidget::on_comboBoxRotationXVPRel_activated(int val)
232 {
233 	applyComboBox(comboBoxRotationXVPRel, val, Settings::Settings::inputRotateXVPRel);
234         emit inputMappingChanged();
235 }
236 
on_comboBoxRotationYVPRel_activated(int val)237 void AxisConfigWidget::on_comboBoxRotationYVPRel_activated(int val)
238 {
239 	applyComboBox(comboBoxRotationYVPRel, val, Settings::Settings::inputRotateYVPRel);
240         emit inputMappingChanged();
241 }
242 
on_comboBoxRotationZVPRel_activated(int val)243 void AxisConfigWidget::on_comboBoxRotationZVPRel_activated(int val)
244 {
245 	applyComboBox(comboBoxRotationZVPRel, val, Settings::Settings::inputRotateZVPRel);
246         emit inputMappingChanged();
247 }
248 
on_comboBoxZoom_activated(int val)249 void AxisConfigWidget::on_comboBoxZoom_activated(int val)
250 {
251 	applyComboBox(comboBoxZoom, val, Settings::Settings::inputZoom);
252         emit inputMappingChanged();
253 }
254 
on_comboBoxZoom2_activated(int val)255 void AxisConfigWidget::on_comboBoxZoom2_activated(int val)
256 {
257 	applyComboBox(comboBoxZoom2, val, Settings::Settings::inputZoom2);
258         emit inputMappingChanged();
259 }
260 
on_doubleSpinBoxTrim0_valueChanged(double val)261 void AxisConfigWidget::on_doubleSpinBoxTrim0_valueChanged(double val)
262 {
263 	Settings::Settings::inst()->set(Settings::Settings::axisTrim0, Value(val));
264 	emit inputCalibrationChanged();
265 	writeSettings();
266 }
267 
on_doubleSpinBoxTrim1_valueChanged(double val)268 void AxisConfigWidget::on_doubleSpinBoxTrim1_valueChanged(double val)
269 {
270 	Settings::Settings::inst()->set(Settings::Settings::axisTrim1, Value(val));
271 	emit inputCalibrationChanged();
272 	writeSettings();
273 }
274 
on_doubleSpinBoxTrim2_valueChanged(double val)275 void AxisConfigWidget::on_doubleSpinBoxTrim2_valueChanged(double val)
276 {
277 	Settings::Settings::inst()->set(Settings::Settings::axisTrim2, Value(val));
278 	emit inputCalibrationChanged();
279 	writeSettings();
280 }
281 
on_doubleSpinBoxTrim3_valueChanged(double val)282 void AxisConfigWidget::on_doubleSpinBoxTrim3_valueChanged(double val)
283 {
284 	Settings::Settings::inst()->set(Settings::Settings::axisTrim3, Value(val));
285 	emit inputCalibrationChanged();
286 	writeSettings();
287 }
288 
on_doubleSpinBoxTrim4_valueChanged(double val)289 void AxisConfigWidget::on_doubleSpinBoxTrim4_valueChanged(double val)
290 {
291 	Settings::Settings::inst()->set(Settings::Settings::axisTrim4, Value(val));
292 	emit inputCalibrationChanged();
293 	writeSettings();
294 }
295 
on_doubleSpinBoxTrim5_valueChanged(double val)296 void AxisConfigWidget::on_doubleSpinBoxTrim5_valueChanged(double val)
297 {
298 	Settings::Settings::inst()->set(Settings::Settings::axisTrim5, Value(val));
299 	emit inputCalibrationChanged();
300 	writeSettings();
301 }
302 
on_doubleSpinBoxTrim6_valueChanged(double val)303 void AxisConfigWidget::on_doubleSpinBoxTrim6_valueChanged(double val)
304 {
305 	Settings::Settings::inst()->set(Settings::Settings::axisTrim6, Value(val));
306 	emit inputCalibrationChanged();
307 	writeSettings();
308 }
309 
on_doubleSpinBoxTrim7_valueChanged(double val)310 void AxisConfigWidget::on_doubleSpinBoxTrim7_valueChanged(double val)
311 {
312 	Settings::Settings::inst()->set(Settings::Settings::axisTrim7, Value(val));
313 	emit inputCalibrationChanged();
314 	writeSettings();
315 }
316 
on_doubleSpinBoxTrim8_valueChanged(double val)317 void AxisConfigWidget::on_doubleSpinBoxTrim8_valueChanged(double val)
318 {
319 	Settings::Settings::inst()->set(Settings::Settings::axisTrim8, Value(val));
320 	emit inputCalibrationChanged();
321 	writeSettings();
322 }
323 
on_doubleSpinBoxDeadzone0_valueChanged(double val)324 void AxisConfigWidget::on_doubleSpinBoxDeadzone0_valueChanged(double val)
325 {
326 	Settings::Settings::inst()->set(Settings::Settings::axisDeadzone0, Value(val));
327 	emit inputCalibrationChanged();
328 	writeSettings();
329 }
330 
on_doubleSpinBoxDeadzone1_valueChanged(double val)331 void AxisConfigWidget::on_doubleSpinBoxDeadzone1_valueChanged(double val)
332 {
333 	Settings::Settings::inst()->set(Settings::Settings::axisDeadzone1, Value(val));
334 	emit inputCalibrationChanged();
335 	writeSettings();
336 }
337 
on_doubleSpinBoxDeadzone2_valueChanged(double val)338 void AxisConfigWidget::on_doubleSpinBoxDeadzone2_valueChanged(double val)
339 {
340 	Settings::Settings::inst()->set(Settings::Settings::axisDeadzone2, Value(val));
341 	emit inputCalibrationChanged();
342 	writeSettings();
343 }
344 
on_doubleSpinBoxDeadzone3_valueChanged(double val)345 void AxisConfigWidget::on_doubleSpinBoxDeadzone3_valueChanged(double val)
346 {
347 	Settings::Settings::inst()->set(Settings::Settings::axisDeadzone3, Value(val));
348 	emit inputCalibrationChanged();
349 	writeSettings();
350 }
351 
on_doubleSpinBoxDeadzone4_valueChanged(double val)352 void AxisConfigWidget::on_doubleSpinBoxDeadzone4_valueChanged(double val)
353 {
354 	Settings::Settings::inst()->set(Settings::Settings::axisDeadzone4, Value(val));
355 	emit inputCalibrationChanged();
356 	writeSettings();
357 }
358 
on_doubleSpinBoxDeadzone5_valueChanged(double val)359 void AxisConfigWidget::on_doubleSpinBoxDeadzone5_valueChanged(double val)
360 {
361 	Settings::Settings::inst()->set(Settings::Settings::axisDeadzone5, Value(val));
362 	emit inputCalibrationChanged();
363 	writeSettings();
364 }
365 
on_doubleSpinBoxDeadzone6_valueChanged(double val)366 void AxisConfigWidget::on_doubleSpinBoxDeadzone6_valueChanged(double val)
367 {
368 	Settings::Settings::inst()->set(Settings::Settings::axisDeadzone6, Value(val));
369 	emit inputCalibrationChanged();
370 	writeSettings();
371 }
372 
on_doubleSpinBoxDeadzone7_valueChanged(double val)373 void AxisConfigWidget::on_doubleSpinBoxDeadzone7_valueChanged(double val)
374 {
375 	Settings::Settings::inst()->set(Settings::Settings::axisDeadzone7, Value(val));
376 	emit inputCalibrationChanged();
377 	writeSettings();
378 }
379 
on_doubleSpinBoxDeadzone8_valueChanged(double val)380 void AxisConfigWidget::on_doubleSpinBoxDeadzone8_valueChanged(double val)
381 {
382 	Settings::Settings::inst()->set(Settings::Settings::axisDeadzone8, Value(val));
383 	emit inputCalibrationChanged();
384 	writeSettings();
385 }
386 
on_doubleSpinBoxRotateGain_valueChanged(double val)387 void AxisConfigWidget::on_doubleSpinBoxRotateGain_valueChanged(double val)
388 {
389 	Settings::Settings::inst()->set(Settings::Settings::inputRotateGain, Value(val));
390 	emit inputGainChanged();
391 	writeSettings();
392 }
393 
on_doubleSpinBoxTranslationGain_valueChanged(double val)394 void AxisConfigWidget::on_doubleSpinBoxTranslationGain_valueChanged(double val)
395 {
396 	Settings::Settings::inst()->set(Settings::Settings::inputTranslationGain, Value(val));
397 	emit inputGainChanged();
398 	writeSettings();
399 }
400 
on_doubleSpinBoxTranslationVPRelGain_valueChanged(double val)401 void AxisConfigWidget::on_doubleSpinBoxTranslationVPRelGain_valueChanged(double val)
402 {
403 	Settings::Settings::inst()->set(Settings::Settings::inputTranslationVPRelGain, Value(val));
404 	emit inputGainChanged();
405 	writeSettings();
406 }
407 
on_doubleSpinBoxZoomGain_valueChanged(double val)408 void AxisConfigWidget::on_doubleSpinBoxZoomGain_valueChanged(double val)
409 {
410 	Settings::Settings::inst()->set(Settings::Settings::inputZoomGain, Value(val));
411 	emit inputGainChanged();
412 	writeSettings();
413 }
414 
on_AxisTrim()415 void AxisConfigWidget::on_AxisTrim()
416 {
417 	InputEventMapper::instance()->onAxisAutoTrim();
418 
419 	for (int i = 0; i < InputEventMapper::getMaxAxis(); ++i ){
420 		std::string s = std::to_string(i);
421 
422 		auto spin = this->findChild<QDoubleSpinBox *>(QString("doubleSpinBoxTrim%1").arg(i));
423 		auto ent = Settings::Settings::inst()->getSettingEntryByName("axisTrim" +s);
424 
425 		if(spin && ent){
426 			spin->setValue((double)Settings::Settings::inst()->get(*ent).toDouble());
427 		}
428 	}
429 	emit inputCalibrationChanged();
430 	writeSettings();
431 }
432 
on_AxisTrimReset()433 void AxisConfigWidget::on_AxisTrimReset()
434 {
435 	InputEventMapper::instance()->onAxisTrimReset();
436 	for (int i = 0; i < InputEventMapper::getMaxAxis(); ++i ){
437 		std::string s = std::to_string(i);
438 
439 		auto ent = Settings::Settings::inst()->getSettingEntryByName("axisTrim" +s);
440 		if(ent){
441 			Settings::Settings::inst()->set(*ent, 0.00);
442 		}
443 
444 		auto spin = this->findChild<QDoubleSpinBox *>(QString("doubleSpinBoxTrim%1").arg(i));
445 		if(spin){
446 			spin->setValue(0.00);
447 		}
448 	}
449 	emit inputCalibrationChanged();
450 	writeSettings();
451 }
452 
on_checkBoxHIDAPI_toggled(bool val)453 void AxisConfigWidget::on_checkBoxHIDAPI_toggled(bool val)
454 {
455 	if(initialized){
456 		Settings::Settings::inst()->set(Settings::Settings::inputEnableDriverHIDAPI, Value(val));
457 		writeSettings();
458 
459 		QFont font;
460 		font.setItalic(true);
461 		checkBoxHIDAPI->setFont(font);
462 	}
463 }
464 
on_checkBoxSpaceNav_toggled(bool val)465 void AxisConfigWidget::on_checkBoxSpaceNav_toggled(bool val)
466 {
467 	if(initialized){
468 		Settings::Settings::inst()->set(Settings::Settings::inputEnableDriverSPNAV, Value(val));
469 		writeSettings();
470 		QFont font;
471 		font.setItalic(true);
472 		checkBoxSpaceNav->setFont(font);
473 	}
474 }
475 
on_checkBoxJoystick_toggled(bool val)476 void AxisConfigWidget::on_checkBoxJoystick_toggled(bool val)
477 {
478 	if(initialized){
479 		Settings::Settings::inst()->set(Settings::Settings::inputEnableDriverJOYSTICK, Value(val));
480 		writeSettings();
481 		QFont font;
482 		font.setItalic(true);
483 		checkBoxJoystick->setFont(font);
484 	}
485 }
486 
on_checkBoxQGamepad_toggled(bool val)487 void AxisConfigWidget::on_checkBoxQGamepad_toggled(bool val)
488 {
489 	if(initialized){
490 		Settings::Settings::inst()->set(Settings::Settings::inputEnableDriverQGAMEPAD, Value(val));
491 		writeSettings();
492 		QFont font;
493 		font.setItalic(true);
494 		checkBoxQGamepad->setFont(font);
495 	}
496 }
497 
on_checkBoxDBus_toggled(bool val)498 void AxisConfigWidget::on_checkBoxDBus_toggled(bool val)
499 {
500 	if(initialized){
501 		Settings::Settings::inst()->set(Settings::Settings::inputEnableDriverDBUS, Value(val));
502 		writeSettings();
503 		QFont font;
504 		font.setItalic(true);
505 		checkBoxDBus->setFont(font);
506 	}
507 }
508 
applyComboBox(QComboBox * comboBox,int val,Settings::SettingsEntry & entry)509 void AxisConfigWidget::applyComboBox(QComboBox *comboBox, int val, Settings::SettingsEntry& entry)
510 {
511 	QString s = comboBox->itemData(val).toString();
512 	Settings::Settings::inst()->set(entry, Value(s.toStdString()));
513 	writeSettings();
514 }
515 
writeSettings()516 void AxisConfigWidget::writeSettings()
517 {
518 	SettingsWriter settingsWriter;
519 	Settings::Settings::inst()->visit(settingsWriter);
520 }
521 
522 
updateStates()523 void AxisConfigWidget::updateStates(){
524 	if(!initialized) return;
525 
526 	int cnt = InputDriverManager::instance()->getAxisCount();
527 	for (int i=0; i<InputEventMapper::getMaxAxis(); ++i) {
528 		auto progressbar = this->findChild<QProgressBar *>(QString("progressBarAxis%1").arg(i));
529 		if( cnt <= i){
530 			progressbar->setEnabled(false);
531 			progressbar->setMinimum(0);
532 		}else{
533 			progressbar->setEnabled(true);
534 			progressbar->setMinimum(-100);
535 		}
536 	}
537 
538 	auto manager = InputDriverManager::instance();
539 	std::string infos = manager->listDriverInfos();
540 	label_driverInfo->setText(QString::fromStdString(infos));
541 }
542