forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdlgprefcontrols.cpp
729 lines (612 loc) · 26.8 KB
/
dlgprefcontrols.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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
/***************************************************************************
dlgprefcontrols.cpp - description
-------------------
begin : Sat Jul 5 2003
copyright : (C) 2003 by Tue & Ken Haste Andersen
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <QList>
#include <QDir>
#include <QToolTip>
#include <QDoubleSpinBox>
#include <QWidget>
#include <QLocale>
#include <QDesktopWidget>
#include "dlgprefcontrols.h"
#include "configobject.h"
#include "controlobject.h"
#include "controlobjectslave.h"
#include "widget/wnumberpos.h"
#include "engine/enginebuffer.h"
#include "engine/ratecontrol.h"
#include "skin/skinloader.h"
#include "skin/legacyskinparser.h"
#include "playermanager.h"
#include "controlobject.h"
#include "mixxx.h"
#include "defs_urls.h"
DlgPrefControls::DlgPrefControls(QWidget * parent, MixxxMainWindow * mixxx,
SkinLoader* pSkinLoader,
PlayerManager* pPlayerManager,
ConfigObject<ConfigValue> * pConfig)
: DlgPreferencePage(parent),
m_pConfig(pConfig),
m_mixxx(mixxx),
m_pSkinLoader(pSkinLoader),
m_pPlayerManager(pPlayerManager),
m_iNumConfiguredDecks(0),
m_iNumConfiguredSamplers(0) {
setupUi(this);
m_pNumDecks = new ControlObjectSlave("[Master]", "num_decks", this);
m_pNumDecks->connectValueChanged(SLOT(slotNumDecksChanged(double)));
slotNumDecksChanged(m_pNumDecks->get());
m_pNumSamplers = new ControlObjectSlave("[Master]", "num_samplers", this);
m_pNumSamplers->connectValueChanged(SLOT(slotNumSamplersChanged(double)));
slotNumSamplersChanged(m_pNumSamplers->get());
// Position display configuration
m_pControlPositionDisplay = new ControlObject(
ConfigKey("[Controls]", "ShowDurationRemaining"));
connect(m_pControlPositionDisplay, SIGNAL(valueChanged(double)),
this, SLOT(slotSetPositionDisplay(double)));
ComboBoxPosition->addItem(tr("Position"));
ComboBoxPosition->addItem(tr("Remaining"));
if (m_pConfig->getValueString(ConfigKey("[Controls]","PositionDisplay")).length() == 0)
m_pConfig->set(ConfigKey("[Controls]","PositionDisplay"),ConfigValue(0));
if (m_pConfig->getValueString(ConfigKey("[Controls]","PositionDisplay")).toInt() == 1) {
ComboBoxPosition->setCurrentIndex(1);
m_pControlPositionDisplay->set(1.0);
} else {
ComboBoxPosition->setCurrentIndex(0);
m_pControlPositionDisplay->set(0.0);
}
connect(ComboBoxPosition, SIGNAL(activated(int)),
this, SLOT(slotSetPositionDisplay(int)));
// Set default direction as stored in config file
if (m_pConfig->getValueString(ConfigKey("[Controls]","RateDir")).length() == 0)
m_pConfig->set(ConfigKey("[Controls]","RateDir"),ConfigValue(0));
ComboBoxRateDir->clear();
ComboBoxRateDir->addItem(tr("Up increases speed"));
ComboBoxRateDir->addItem(tr("Down increases speed (Technics SL-1210)"));
connect(ComboBoxRateDir, SIGNAL(activated(int)),
this, SLOT(slotSetRateDir(int)));
// Set default range as stored in config file
if (m_pConfig->getValueString(ConfigKey("[Controls]","RateRange")).length() == 0)
m_pConfig->set(ConfigKey("[Controls]","RateRange"),ConfigValue(2));
ComboBoxRateRange->clear();
ComboBoxRateRange->addItem(tr("6%"));
ComboBoxRateRange->addItem(tr("8% (Technics SL-1210)"));
ComboBoxRateRange->addItem(tr("10%"));
ComboBoxRateRange->addItem(tr("20%"));
ComboBoxRateRange->addItem(tr("30%"));
ComboBoxRateRange->addItem(tr("40%"));
ComboBoxRateRange->addItem(tr("50%"));
ComboBoxRateRange->addItem(tr("60%"));
ComboBoxRateRange->addItem(tr("70%"));
ComboBoxRateRange->addItem(tr("80%"));
ComboBoxRateRange->addItem(tr("90%"));
connect(ComboBoxRateRange, SIGNAL(activated(int)),
this, SLOT(slotSetRateRange(int)));
//
// Rate buttons configuration
//
//NOTE: THESE DEFAULTS ARE A LIE! You'll need to hack the same values into the static variables
// at the top of enginebuffer.cpp
if (m_pConfig->getValueString(ConfigKey("[Controls]","RateTempLeft")).length() == 0)
m_pConfig->set(ConfigKey("[Controls]","RateTempLeft"),ConfigValue(QString("4.0")));
if (m_pConfig->getValueString(ConfigKey("[Controls]","RateTempRight")).length() == 0)
m_pConfig->set(ConfigKey("[Controls]","RateTempRight"),ConfigValue(QString("2.0")));
if (m_pConfig->getValueString(ConfigKey("[Controls]","RatePermLeft")).length() == 0)
m_pConfig->set(ConfigKey("[Controls]","RatePermLeft"),ConfigValue(QString("0.50")));
if (m_pConfig->getValueString(ConfigKey("[Controls]","RatePermRight")).length() == 0)
m_pConfig->set(ConfigKey("[Controls]","RatePermRight"),ConfigValue(QString("0.05")));
connect(spinBoxTempRateLeft, SIGNAL(valueChanged(double)),
this, SLOT(slotSetRateTempLeft(double)));
connect(spinBoxTempRateRight, SIGNAL(valueChanged(double)),
this, SLOT(slotSetRateTempRight(double)));
connect(spinBoxPermRateLeft, SIGNAL(valueChanged(double)),
this, SLOT(slotSetRatePermLeft(double)));
connect(spinBoxPermRateRight, SIGNAL(valueChanged(double)),
this, SLOT(slotSetRatePermRight(double)));
spinBoxTempRateLeft->setValue(m_pConfig->getValueString(
ConfigKey("[Controls]","RateTempLeft")).toDouble());
spinBoxTempRateRight->setValue(m_pConfig->getValueString(
ConfigKey("[Controls]","RateTempRight")).toDouble());
spinBoxPermRateLeft->setValue(m_pConfig->getValueString(
ConfigKey("[Controls]","RatePermLeft")).toDouble());
spinBoxPermRateRight->setValue(m_pConfig->getValueString(
ConfigKey("[Controls]","RatePermRight")).toDouble());
SliderRateRampSensitivity->setEnabled(true);
SpinBoxRateRampSensitivity->setEnabled(true);
//
// Override Playing Track on Track Load
//
ComboBoxAllowTrackLoadToPlayingDeck->addItem(tr("Don't load tracks into a playing deck"));
ComboBoxAllowTrackLoadToPlayingDeck->addItem(tr("Load tracks into a playing deck"));
ComboBoxAllowTrackLoadToPlayingDeck->setCurrentIndex(
m_pConfig->getValueString(ConfigKey("[Controls]", "AllowTrackLoadToPlayingDeck")).toInt());
connect(ComboBoxAllowTrackLoadToPlayingDeck, SIGNAL(activated(int)),
this, SLOT(slotSetAllowTrackLoadToPlayingDeck(int)));
//
// Locale setting
//
// Iterate through the available locales and add them to the combobox
// Borrowed following snippet from http://qt-project.org/wiki/How_to_create_a_multi_language_application
QString translationsFolder = m_pConfig->getResourcePath() + "translations/";
QString currentLocale = pConfig->getValueString(ConfigKey("[Config]", "Locale"));
QDir translationsDir(translationsFolder);
QStringList fileNames = translationsDir.entryList(QStringList("mixxx_*.qm"));
fileNames.push_back("mixxx_en_US.qm"); // add source language as a fake value
bool indexFlag = false; // it'll indicate if the selected index changed.
for (int i = 0; i < fileNames.size(); ++i) {
// Extract locale from filename
QString locale = fileNames[i];
locale.truncate(locale.lastIndexOf('.'));
locale.remove(0, locale.indexOf('_') + 1);
QLocale qlocale = QLocale(locale);
QString lang = QLocale::languageToString(qlocale.language());
QString country = QLocale::countryToString(qlocale.country());
if (lang == "C") { // Ugly hack to remove the non-resolving locales
continue;
}
lang = QString("%1 (%2)").arg(lang).arg(country);
ComboBoxLocale->addItem(lang, locale); // locale as userdata (for storing to config)
if (locale == currentLocale) { // Set the currently selected locale
ComboBoxLocale->setCurrentIndex(ComboBoxLocale->count() - 1);
indexFlag = true;
}
}
ComboBoxLocale->model()->sort(0); // Sort languages list
ComboBoxLocale->insertItem(0, "System", ""); // System default locale - insert at the top
if (!indexFlag) { // if selectedIndex didn't change - select system default
ComboBoxLocale->setCurrentIndex(0);
}
connect(ComboBoxLocale, SIGNAL(activated(int)),
this, SLOT(slotSetLocale(int)));
//
// Cue Mode
//
// Add "(?)" with a manual link to the label
labelCueMode->setText(
labelCueMode->text() +
" <a href=\"" +
MIXXX_MANUAL_URL +
"/chapters/user_interface.html#using-cue-modes\">(?)</a>");
// Set default value in config file and control objects, if not present
// Default is "0" = Mixxx Mode
QString cueDefault = m_pConfig->getValueString(ConfigKey("[Controls]", "CueDefault"), "0");
int cueDefaultValue = cueDefault.toInt();
// Update combo box
ComboBoxCueDefault->addItem(tr("Mixxx mode"));
ComboBoxCueDefault->addItem(tr("Pioneer mode"));
ComboBoxCueDefault->addItem(tr("Denon mode"));
ComboBoxCueDefault->addItem(tr("Numark mode"));
ComboBoxCueDefault->setCurrentIndex(cueDefaultValue);
slotSetCueDefault(cueDefaultValue);
connect(ComboBoxCueDefault, SIGNAL(activated(int)), this, SLOT(slotSetCueDefault(int)));
// Cue recall
ComboBoxCueRecall->addItem(tr("On"));
ComboBoxCueRecall->addItem(tr("Off"));
ComboBoxCueRecall->setCurrentIndex(m_pConfig->getValueString(
ConfigKey("[Controls]", "CueRecall")).toInt());
//NOTE: for CueRecall, 0 means ON....
connect(ComboBoxCueRecall, SIGNAL(activated(int)),
this, SLOT(slotSetCueRecall(int)));
//
// Skin configurations
//
QString warningString = "<img src=\":/images/preferences/ic_preferences_warning.png\") width=16 height=16 />"
+ tr("The minimum size of the selected skin is bigger than your screen resolution.");
warningLabel->setText(warningString);
ComboBoxSkinconf->clear();
QDir skinsDir(m_pConfig->getResourcePath() + "skins/");
skinsDir.setFilter(QDir::Dirs);
QList<QFileInfo> list = skinsDir.entryInfoList();
if (CmdlineArgs::Instance().getDeveloper()) {
// Show developer skins
QDir developerSkinsDir(m_pConfig->getResourcePath() + "developer_skins/");
developerSkinsDir.setFilter(QDir::Dirs);
list += developerSkinsDir.entryInfoList();
}
QString configuredSkinPath = m_pSkinLoader->getConfiguredSkinPath();
int j=0;
for (int i=0; i<list.size(); ++i)
{
if (list.at(i).fileName()!="." && list.at(i).fileName()!="..")
{
bool size_ok = checkSkinResolution(list.at(i).filePath());
if (size_ok) {
ComboBoxSkinconf->insertItem(i, list.at(i).fileName());
} else {
ComboBoxSkinconf->insertItem(i, QIcon(":/images/preferences/ic_preferences_warning.png"), list.at(i).fileName());
}
if (list.at(i).filePath() == configuredSkinPath) {
ComboBoxSkinconf->setCurrentIndex(j);
if (size_ok) {
warningLabel->hide();
} else {
warningLabel->show();
}
}
++j;
}
}
ComboBoxTabletSkinconf->clear();
QDir tabletSkinsDir(m_pConfig->getResourcePath() + "tablet_skins/");
tabletSkinsDir.setFilter(QDir::Dirs);
QList<QFileInfo> list2 = tabletSkinsDir.entryInfoList();
configuredSkinPath = m_pSkinLoader->getConfiguredSkinPath();
j=0;
for (int i=0; i<list2.size(); ++i)
{
if (list2.at(i).fileName()!="." && list2.at(i).fileName()!="..")
{
bool size_ok = checkSkinResolution(list2.at(i).filePath());
if (size_ok) {
ComboBoxTabletSkinconf->insertItem(i, list2.at(i).fileName());
} else {
ComboBoxTabletSkinconf->insertItem(i, QIcon(":/images/preferences/ic_preferences_warning.png"), list2.at(i).fileName());
}
if (list2.at(i).filePath() == configuredSkinPath) {
ComboBoxTabletSkinconf->setCurrentIndex(j);
/*if (size_ok) {
warningLabel->hide();
} else {
warningLabel->show();
}*/
}
++j;
}
}
connect(ComboBoxSkinconf, SIGNAL(activated(int)), this, SLOT(slotSetSkin(int)));
connect(ComboBoxTabletSkinconf, SIGNAL(activated(int)), this, SLOT(slotSetSkin(int)));
connect(ComboBoxSchemeconf, SIGNAL(activated(int)), this, SLOT(slotSetScheme(int)));
slotUpdateSchemes();
//
// Starts in fullscreen mode
//
ComboBoxStartInFullscreen->addItem(tr("Off")); // 0
ComboBoxStartInFullscreen->addItem(tr("On")); // 1
ComboBoxStartInFullscreen->setCurrentIndex(m_pConfig->getValueString(
ConfigKey("[Config]","StartInFullscreen"),"0").toInt());
connect(ComboBoxStartInFullscreen, SIGNAL(activated(int)),
this, SLOT(slotSetStartInFullscreen(int)));
//
// Tooltip configuration
//
ComboBoxTooltips->addItem(tr("On")); // 1
ComboBoxTooltips->addItem(tr("On (only in Library)")); // 2
ComboBoxTooltips->addItem(tr("Off")); // 0
// Update combo box
int configTooltips = m_mixxx->getToolTipsCgf();
// Add two mod-3 makes the on-disk order match up with the combo-box
// order.
ComboBoxTooltips->setCurrentIndex((configTooltips + 2) % 3);
connect(ComboBoxTooltips, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotSetTooltips(int)));
//
// Ramping Temporary Rate Change configuration
//
// Set Ramp Rate On or Off
connect(groupBoxRateRamp, SIGNAL(toggled(bool)),
this, SLOT(slotSetRateRamp(bool)));
groupBoxRateRamp->setChecked((bool)
m_pConfig->getValueString(ConfigKey("[Controls]","RateRamp")).toInt());
// Update Ramp Rate Sensitivity
connect(SliderRateRampSensitivity, SIGNAL(valueChanged(int)),
this, SLOT(slotSetRateRampSensitivity(int)));
SliderRateRampSensitivity->setValue(m_pConfig->getValueString(
ConfigKey("[Controls]", "RateRampSensitivity")).toInt());
slotUpdate();
tablet = false;
}
DlgPrefControls::~DlgPrefControls() {
delete m_pControlPositionDisplay;
qDeleteAll(m_rateControls);
qDeleteAll(m_rateDirControls);
qDeleteAll(m_cueControls);
qDeleteAll(m_rateRangeControls);
}
void DlgPrefControls::slotUpdateSchemes()
{
// Since this involves opening a file we won't do this as part of regular slotUpdate
QList<QString> schlist = LegacySkinParser::getSchemeList(
m_pSkinLoader->getConfiguredSkinPath());
ComboBoxSchemeconf->clear();
if (schlist.size() == 0) {
ComboBoxSchemeconf->setEnabled(false);
ComboBoxSchemeconf->addItem(tr("This skin does not support color schemes", 0));
ComboBoxSchemeconf->setCurrentIndex(0);
} else {
ComboBoxSchemeconf->setEnabled(true);
for (int i = 0; i < schlist.size(); i++) {
ComboBoxSchemeconf->addItem(schlist[i]);
if (schlist[i] == m_pConfig->getValueString(ConfigKey("[Config]","Scheme"))) {
ComboBoxSchemeconf->setCurrentIndex(i);
}
}
}
}
void DlgPrefControls::slotUpdate() {
double deck1RateRange = m_rateRangeControls[0]->get();
double deck1RateDir = m_rateDirControls[0]->get();
double idx = (10. * deck1RateRange) + 1;
if (deck1RateRange <= 0.07)
idx = 0.;
else if (deck1RateRange <= 0.09)
idx = 1.;
ComboBoxRateRange->setCurrentIndex((int)idx);
if (deck1RateDir == 1)
ComboBoxRateDir->setCurrentIndex(0);
else
ComboBoxRateDir->setCurrentIndex(1);
}
void DlgPrefControls::slotResetToDefaults() {
// Position mode
ComboBoxPosition->setCurrentIndex(0);
// Up increases speed.
ComboBoxRateDir->setCurrentIndex(0);
// 10% Rate Range
ComboBoxRateRange->setCurrentIndex(2);
// Don't load tracks into playing decks.
ComboBoxAllowTrackLoadToPlayingDeck->setCurrentIndex(0);
// Use System locale
ComboBoxLocale->setCurrentIndex(0);
// Mixxx cue mode
ComboBoxCueDefault->setCurrentIndex(0);
// Cue recall on.
ComboBoxCueRecall->setCurrentIndex(0);
// Don't start in full screen.
ComboBoxStartInFullscreen->setCurrentIndex(0);
// Tooltips on.
ComboBoxTooltips->setCurrentIndex(0);
// Rate-ramping default off.
groupBoxRateRamp->setChecked(false);
// 0 rate-ramp sensitivity
SliderRateRampSensitivity->setValue(0);
// Permanent and temporary pitch adjust fine/coarse.
spinBoxTempRateLeft->setValue(4.0);
spinBoxTempRateRight->setValue(2.0);
spinBoxPermRateLeft->setValue(0.50);
spinBoxPermRateRight->setValue(0.05);
}
void DlgPrefControls::slotSetLocale(int pos) {
QString newLocale = ComboBoxLocale->itemData(pos).toString();
m_pConfig->set(ConfigKey("[Config]","Locale"), ConfigValue(newLocale));
notifyRebootNecessary();
}
void DlgPrefControls::slotSetRateRange(int pos) {
double range = static_cast<double>(pos-1) / 10.0;
if (pos == 0)
range = 0.06;
if (pos == 1)
range = 0.08;
qDebug() << "slotSetRateRange" << pos << range;
// Set rate range for every group
foreach (ControlObjectThread* pControl, m_rateRangeControls) {
pControl->slotSet(range);
}
// Reset rate for every group
foreach (ControlObjectThread* pControl, m_rateControls) {
pControl->slotSet(0);
}
}
void DlgPrefControls::slotSetRateDir(int index) {
float dir = 1.;
if (index == 1)
dir = -1.;
float oldDir = m_rateDirControls[0]->get();
// Set rate direction for every group
foreach (ControlObjectThread* pControl, m_rateDirControls) {
pControl->slotSet(dir);
}
// If the setting was changed, ie the old direction is not equal to the new one,
// multiply the rate by -1 so the current sound does not change.
if(fabs(dir - oldDir) > 0.1) {
foreach (ControlObjectThread* pControl, m_rateControls) {
pControl->slotSet(-1 * pControl->get());
}
}
}
void DlgPrefControls::slotSetAllowTrackLoadToPlayingDeck(int) {
m_pConfig->set(ConfigKey("[Controls]","AllowTrackLoadToPlayingDeck"),
ConfigValue(ComboBoxAllowTrackLoadToPlayingDeck->currentIndex()));
}
void DlgPrefControls::slotSetCueDefault(int)
{
int cueIndex = ComboBoxCueDefault->currentIndex();
m_pConfig->set(ConfigKey("[Controls]","CueDefault"), ConfigValue(cueIndex));
// Set cue behavior for every group
foreach (ControlObjectThread* pControl, m_cueControls) {
pControl->slotSet(cueIndex);
}
}
void DlgPrefControls::slotSetCueRecall(int)
{
m_pConfig->set(ConfigKey("[Controls]","CueRecall"), ConfigValue(ComboBoxCueRecall->currentIndex()));
}
void DlgPrefControls::slotSetStartInFullscreen(int index) {
m_pConfig->set(ConfigKey("[Config]", "StartInFullscreen"), index);
}
void DlgPrefControls::slotSetTooltips(int) {
int configValue = (ComboBoxTooltips->currentIndex() + 1) % 3;
m_mixxx->setToolTipsCfg(configValue);
}
void DlgPrefControls::notifyRebootNecessary() {
// make the fact that you have to restart mixxx more obvious
QMessageBox::information(
this, tr("Information"),
tr("Mixxx must be restarted before the changes will take effect."));
}
void DlgPrefControls::slotSetScheme(int) {
m_pConfig->set(ConfigKey("[Config]", "Scheme"), ComboBoxSchemeconf->currentText());
m_mixxx->rebootMixxxView();
}
void DlgPrefControls::slotSetSkin(int) {
if(!tablet)
m_pConfig->set(ConfigKey("[Config]","Skin"), ComboBoxSkinconf->currentText());
else
m_pConfig->set(ConfigKey("[Config]","Skin"), ComboBoxTabletSkinconf->currentText());
//printf("TEST\n");
m_mixxx->rebootMixxxView();
if(!tablet)
checkSkinResolution(ComboBoxSkinconf->currentText())
? warningLabel->hide() : warningLabel->show();
slotUpdateSchemes();
}
void DlgPrefControls::slotSetPositionDisplay(int) {
int positionDisplay = ComboBoxPosition->currentIndex();
m_pConfig->set(ConfigKey("[Controls]","PositionDisplay"), ConfigValue(positionDisplay));
m_pControlPositionDisplay->set(positionDisplay);
}
void DlgPrefControls::slotSetPositionDisplay(double v) {
if (v > 0) {
// remaining
ComboBoxPosition->setCurrentIndex(1);
m_pConfig->set(ConfigKey("[Controls]","PositionDisplay"), ConfigValue(1));
} else {
// position
ComboBoxPosition->setCurrentIndex(0);
m_pConfig->set(ConfigKey("[Controls]","PositionDisplay"), ConfigValue(0));
}
}
void DlgPrefControls::slotSetRateTempLeft(double v) {
QString str;
str = str.setNum(v, 'f');
m_pConfig->set(ConfigKey("[Controls]","RateTempLeft"),ConfigValue(str));
RateControl::setTemp(v);
}
void DlgPrefControls::slotSetRateTempRight(double v) {
QString str;
str = str.setNum(v, 'f');
m_pConfig->set(ConfigKey("[Controls]","RateTempRight"),ConfigValue(str));
RateControl::setTempSmall(v);
}
void DlgPrefControls::slotSetRatePermLeft(double v) {
QString str;
str = str.setNum(v, 'f');
m_pConfig->set(ConfigKey("[Controls]","RatePermLeft"),ConfigValue(str));
RateControl::setPerm(v);
}
void DlgPrefControls::slotSetRatePermRight(double v) {
QString str;
str = str.setNum(v, 'f');
m_pConfig->set(ConfigKey("[Controls]","RatePermRight"),ConfigValue(str));
RateControl::setPermSmall(v);
}
void DlgPrefControls::slotSetRateRampSensitivity(int sense) {
m_pConfig->set(ConfigKey("[Controls]","RateRampSensitivity"),
ConfigValue(SliderRateRampSensitivity->value()));
RateControl::setRateRampSensitivity(sense);
}
void DlgPrefControls::slotSetRateRamp(bool mode) {
m_pConfig->set(ConfigKey("[Controls]", "RateRamp"),
ConfigValue(groupBoxRateRamp->isChecked()));
RateControl::setRateRamp(mode);
}
void DlgPrefControls::slotApply() {
double deck1RateRange = m_rateRangeControls[0]->get();
double deck1RateDir = m_rateDirControls[0]->get();
// Write rate range to config file
double idx = (10. * deck1RateRange) + 1;
if (deck1RateRange <= 0.07)
idx = 0.;
else if (deck1RateRange <= 0.09)
idx = 1.;
m_pConfig->set(ConfigKey("[Controls]","RateRange"), ConfigValue((int)idx));
// Write rate direction to config file
if (deck1RateDir == 1)
m_pConfig->set(ConfigKey("[Controls]","RateDir"), ConfigValue(0));
else
m_pConfig->set(ConfigKey("[Controls]","RateDir"), ConfigValue(1));
}
//Returns TRUE if skin fits to screen resolution, FALSE otherwise
bool DlgPrefControls::checkSkinResolution(QString skin)
{
int screenWidth = QApplication::desktop()->width();
int screenHeight = QApplication::desktop()->height();
const QRegExp min_size_regex("<MinimumSize>(\\d+), *(\\d+)<");
QFile skinfile(skin + "/skin.xml");
if (skinfile.open(QFile::ReadOnly | QFile::Text)) {
QTextStream in(&skinfile);
bool found_size = false;
while (!in.atEnd()) {
if (min_size_regex.indexIn(in.readLine()) != -1) {
found_size = true;
break;
}
}
if (found_size) {
return !(min_size_regex.cap(1).toInt() > screenWidth ||
min_size_regex.cap(2).toInt() > screenHeight);
}
}
// If regex failed, fall back to skin name parsing.
QString skinName = skin.left(skin.indexOf(QRegExp("\\d")));
QString resName = skin.right(skin.count()-skinName.count());
QString res = resName.left(resName.lastIndexOf(QRegExp("\\d"))+1);
QString skinWidth = res.left(res.indexOf("x"));
QString skinHeight = res.right(res.count()-skinWidth.count()-1);
return !(skinWidth.toInt() > screenWidth || skinHeight.toInt() > screenHeight);
}
void DlgPrefControls::slotNumDecksChanged(double new_count) {
int numdecks = static_cast<int>(new_count);
if (numdecks <= m_iNumConfiguredDecks) {
// TODO(owilliams): If we implement deck deletion, shrink the size of configured decks.
return;
}
for (int i = m_iNumConfiguredDecks; i < numdecks; ++i) {
QString group = PlayerManager::groupForDeck(i);
m_rateControls.push_back(new ControlObjectThread(
group, "rate"));
m_rateRangeControls.push_back(new ControlObjectThread(
group, "rateRange"));
m_rateDirControls.push_back(new ControlObjectThread(
group, "rate_dir"));
m_cueControls.push_back(new ControlObjectThread(
group, "cue_mode"));
}
m_iNumConfiguredDecks = numdecks;
slotSetRateDir(m_pConfig->getValueString(ConfigKey("[Controls]","RateDir")).toInt());
slotSetRateRange(m_pConfig->getValueString(ConfigKey("[Controls]","RateRange")).toInt());
}
void DlgPrefControls::slotNumSamplersChanged(double new_count) {
int numsamplers = static_cast<int>(new_count);
if (numsamplers <= m_iNumConfiguredSamplers) {
return;
}
for (int i = m_iNumConfiguredSamplers; i < numsamplers; ++i) {
QString group = PlayerManager::groupForSampler(i);
m_rateControls.push_back(new ControlObjectThread(
group, "rate"));
m_rateRangeControls.push_back(new ControlObjectThread(
group, "rateRange"));
m_rateDirControls.push_back(new ControlObjectThread(
group, "rate_dir"));
m_cueControls.push_back(new ControlObjectThread(
group, "cue_mode"));
}
m_iNumConfiguredSamplers = numsamplers;
slotSetRateDir(m_pConfig->getValueString(ConfigKey("[Controls]","RateDir")).toInt());
slotSetRateRange(m_pConfig->getValueString(ConfigKey("[Controls]","RateRange")).toInt());
}
void DlgPrefControls::skinChangeControl(bool tabletMode) {
/*if (tabletMode)
{
ComboBoxSkinconf->setItemText(ComboBoxSkinconf->currentIndex(), "UCLA1920x1080");
}
else
{
ComboBoxSkinconf->setItemText(ComboBoxSkinconf->currentIndex(), "LateNight");
}*/
tablet = tabletMode;
/*QMetaObject::invokeMethod( this, "slotSetSkin", Q_ARG( int, ComboBoxSkinconf->currentIndex() ));*/
QMetaObject::invokeMethod( this, "slotSetSkin", Q_ARG( int, 0));
}