-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathdlgpreflibrary.cpp
More file actions
726 lines (643 loc) · 29.4 KB
/
Copy pathdlgpreflibrary.cpp
File metadata and controls
726 lines (643 loc) · 29.4 KB
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
#include "preferences/dialog/dlgpreflibrary.h"
#include <QApplication>
#include <QDir>
#include <QFileDialog>
#include <QFontDialog>
#include <QFontMetrics>
#include <QMessageBox>
#include <QStandardPaths>
#include <QUrl>
#include <QtGlobal>
#include "control/controlproxy.h"
#include "defs_urls.h"
#include "library/basetracktablemodel.h"
#include "library/dlgtrackmetadataexport.h"
#include "library/library.h"
#include "library/library_prefs.h"
#include "library/searchquery.h"
#include "library/trackcollection.h"
#include "library/trackcollectionmanager.h"
#include "moc_dlgpreflibrary.cpp"
#include "util/desktophelper.h"
#include "widget/wsearchlineedit.h"
namespace {
constexpr int kDefaultFuzzyRateRangePercent = 75;
} // namespace
using namespace mixxx::library::prefs;
DlgPrefLibrary::DlgPrefLibrary(
QWidget* pParent,
UserSettingsPointer pConfig,
std::shared_ptr<Library> pLibrary)
: DlgPreferencePage(pParent),
m_dirListModel(),
m_pConfig(pConfig),
m_pLibrary(pLibrary),
m_bAddedDirectory(false),
m_iOriginalTrackTableRowHeight(Library::kDefaultRowHeightPx),
m_pRateRangeDeck1(make_parented<ControlProxy>(
QStringLiteral("[Channel1]"), QStringLiteral("rateRange"), this)) {
setupUi(this);
connect(pushButton_add_dir,
&QPushButton::clicked,
this,
&DlgPrefLibrary::slotAddDir);
connect(pushButton_remove_dir,
&QPushButton::clicked,
this,
&DlgPrefLibrary::slotRemoveDir);
connect(pushButton_relocate_dir,
&QPushButton::clicked,
this,
&DlgPrefLibrary::slotRelocateDir);
connect(checkBox_serato_metadata_export,
&QAbstractButton::clicked,
this,
&DlgPrefLibrary::slotSeratoMetadataExportClicked);
const QString& settingsDir = m_pConfig->getSettingsPath();
connect(pushButton_open_settings_dir,
&QPushButton::clicked,
[settingsDir] {
mixxx::DesktopHelper::openUrl(QUrl::fromLocalFile(settingsDir));
});
// Set default direction as stored in config file
int rowHeight = m_pLibrary->getTrackTableRowHeight();
spinBox_row_height->setValue(rowHeight);
connect(spinBox_row_height,
QOverload<int>::of(&QSpinBox::valueChanged),
this,
&DlgPrefLibrary::slotRowHeightValueChanged);
spinbox_bpm_precision->setMinimum(BaseTrackTableModel::kBpmColumnPrecisionMinimum);
spinbox_bpm_precision->setMaximum(BaseTrackTableModel::kBpmColumnPrecisionMaximum);
connect(spinbox_bpm_precision,
QOverload<int>::of(&QSpinBox::valueChanged),
this,
&DlgPrefLibrary::slotBpmColumnPrecisionChanged);
spinBox_search_debouncing_timeout->setMinimum(WSearchLineEdit::kMinDebouncingTimeoutMillis);
spinBox_search_debouncing_timeout->setMaximum(WSearchLineEdit::kMaxDebouncingTimeoutMillis);
connect(spinBox_search_debouncing_timeout,
QOverload<int>::of(&QSpinBox::valueChanged),
this,
&DlgPrefLibrary::slotSearchDebouncingTimeoutMillisChanged);
#ifdef Q_OS_IOS
checkBox_edit_metadata_selected_clicked->setEnabled(false);
#endif
comboBox_search_bpm_fuzzy_range->clear();
comboBox_search_bpm_fuzzy_range->addItem("25 %", 25);
comboBox_search_bpm_fuzzy_range->addItem("50 %", 50);
comboBox_search_bpm_fuzzy_range->addItem("75 %", 75);
comboBox_search_bpm_fuzzy_range->addItem("100 %", 100);
connect(comboBox_search_bpm_fuzzy_range,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefLibrary::slotBpmRangeSelected);
// Also listen to rate range changes (e.g. made in DlgPrefDecks) and
// adjust the fuzzy range accordingly
m_pRateRangeDeck1->connectValueChanged(
this,
[this]() {
slotBpmRangeSelected(comboBox_search_bpm_fuzzy_range->currentIndex());
});
updateSearchLineEditHistoryOptions();
connect(btn_library_font, &QAbstractButton::clicked, this, &DlgPrefLibrary::slotSelectFont);
// TODO(XXX) this string should be extracted from the soundsources
QString builtInFormatsStr = "Ogg Vorbis, FLAC, WAVE, AIFF";
#if defined(__MAD__) || defined(__COREAUDIO__)
builtInFormatsStr += ", MP3";
#endif
#if defined(__MEDIAFOUNDATION__) || defined(__COREAUDIO__) || defined(__FAAD__)
builtInFormatsStr += ", M4A/MP4";
#endif
#ifdef __OPUS__
builtInFormatsStr += ", Opus";
#endif
#ifdef __MODPLUG__
builtInFormatsStr += ", ModPlug";
#endif
#ifdef __WV__
builtInFormatsStr += ", WavPack";
#endif
builtInFormats->setText(builtInFormatsStr);
// Create text color manual links
createLinkColor();
// Add link to the manual where configuration files are explained in detail
label_settingsManualLink->setText(coloredLinkString(
m_pLinkColor,
tr("See the manual for details"),
MIXXX_MANUAL_SETTINGS_DIRECTORY_URL));
// TODO It seems this isnot required anymore with Qt 6.2.3
connect(label_settingsManualLink,
&QLabel::linkActivated,
[](const QString& url) {
mixxx::DesktopHelper::openUrl(url);
});
// Add link to the track search documentation
label_searchBpmFuzzyRangeInfo->setText(
label_searchBpmFuzzyRangeInfo->text() + QStringLiteral(" ") +
coloredLinkString(m_pLinkColor,
QStringLiteral("(?)"),
MIXXX_MANUAL_SETTINGS_DIRECTORY_URL));
connect(label_searchBpmFuzzyRangeInfo,
&QLabel::linkActivated,
[](const QString& url) {
mixxx::DesktopHelper::openUrl(url);
});
connect(checkBox_sync_track_metadata,
&QCheckBox::toggled,
this,
&DlgPrefLibrary::slotSyncTrackMetadataToggled);
setScrollSafeGuardForAllInputWidgets(this);
// Initialize the controls after all slots have been connected
slotUpdate();
}
DlgPrefLibrary::~DlgPrefLibrary() = default;
void DlgPrefLibrary::slotShow() {
m_bAddedDirectory = false;
}
void DlgPrefLibrary::slotHide() {
resetLibraryFont();
if (!m_bAddedDirectory) {
return;
}
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("Music Directory Added"));
msgBox.setText(tr("You added one or more music directories. The tracks in "
"these directories won't be available until you rescan "
"your library. Would you like to rescan now?"));
QPushButton* scanButton = msgBox.addButton(
tr("Scan"), QMessageBox::AcceptRole);
msgBox.addButton(QMessageBox::Cancel);
msgBox.setDefaultButton(scanButton);
msgBox.exec();
if (msgBox.clickedButton() == scanButton) {
emit scanLibrary();
return;
}
}
QUrl DlgPrefLibrary::helpUrl() const {
return QUrl(MIXXX_MANUAL_LIBRARY_URL);
}
void DlgPrefLibrary::populateDirList() {
// save which index was selected
const QString selected = dirList->currentIndex().data().toString();
// clear and fill model
m_dirListModel.clear();
const auto rootDirs = m_pLibrary->trackCollectionManager()
->internalCollection()
->getRootDirStrings();
for (const QString& rootDir : rootDirs) {
auto* pDirItem = new QStandardItem(rootDir);
// Note: constructing a FileInfo from a path string added in another
// will create issues: on Windows, if that path doesn't start with
// '[drive letter]:' it'll get prefixed with 'C:'; if on Linux the path
// starts with '[drive letter]:' the working dir's path is prepended.
// In both cases this is obviously wrong and directory/track relocation
// will fail since the database has no tracks with constructed prefix.
// Let's use QStrings for the roundtrip. The FileInfo is just for
// validation and eventually adding the warning icon.
const mixxx::FileInfo fileInfo(rootDir);
if (!fileInfo.exists() || !fileInfo.isDir()) {
pDirItem->setIcon(QIcon(kWarningIconPath));
pDirItem->setToolTip(tr("Item is not a directory or directory is missing"));
}
m_dirListModel.appendRow(pDirItem);
}
dirList->setModel(&m_dirListModel);
dirList->setCurrentIndex(m_dirListModel.index(0, 0));
// reselect index if it still exists
for (int i=0 ; i<m_dirListModel.rowCount() ; ++i) {
const QModelIndex index = m_dirListModel.index(i, 0);
if (index.data().toString() == selected) {
dirList->setCurrentIndex(index);
break;
}
}
}
void DlgPrefLibrary::slotResetToDefaults() {
checkBox_library_scan->setChecked(false);
spinbox_history_track_duplicate_distance->setValue(
kHistoryTrackDuplicateDistanceDefault);
spinbox_history_min_tracks_to_keep->setValue(1);
checkBox_sync_track_metadata->setChecked(false);
checkBox_serato_metadata_export->setChecked(false);
checkBox_rating_export->setChecked(false);
checkBox_rating_import->setChecked(false);
checkBox_use_relative_path->setChecked(false);
checkBox_edit_metadata_selected_clicked->setChecked(kEditMetadataSelectedClickDefault);
radioButton_dbclick_deck->setChecked(true);
spinbox_bpm_precision->setValue(BaseTrackTableModel::kBpmColumnPrecisionDefault);
checkbox_played_track_color->setChecked(
BaseTrackTableModel::kApplyPlayedTrackColorDefault);
radioButton_cover_art_fetcher_medium->setChecked(true);
spinBox_row_height->setValue(Library::kDefaultRowHeightPx);
setLibraryFont(QApplication::font());
spinBox_search_debouncing_timeout->setValue(
WSearchLineEdit::kDefaultDebouncingTimeoutMillis);
checkBox_enable_search_completions->setChecked(
WSearchLineEdit::kCompletionsEnabledDefault);
checkBox_enable_search_history_shortcuts->setChecked(
WSearchLineEdit::kHistoryShortcutsEnabledDefault);
comboBox_search_bpm_fuzzy_range->setCurrentIndex(
comboBox_search_bpm_fuzzy_range->findData(kDefaultFuzzyRateRangePercent));
checkBox_show_rhythmbox->setChecked(true);
checkBox_show_banshee->setChecked(true);
checkBox_show_itunes->setChecked(true);
checkBox_show_traktor->setChecked(true);
checkBox_show_rekordbox->setChecked(true);
}
void DlgPrefLibrary::slotUpdate() {
populateDirList();
checkBox_library_scan->setChecked(m_pConfig->getValue(
kRescanOnStartupConfigKey, false));
checkBox_library_scan_summary->setChecked(m_pConfig->getValue(
kShowScanSummaryConfigKey, true));
spinbox_history_track_duplicate_distance->setValue(m_pConfig->getValue(
kHistoryTrackDuplicateDistanceConfigKey,
kHistoryTrackDuplicateDistanceDefault));
spinbox_history_min_tracks_to_keep->setValue(m_pConfig->getValue(
kHistoryMinTracksToKeepConfigKey,
kHistoryMinTracksToKeepDefault));
checkBox_sync_track_metadata->setChecked(
m_pConfig->getValue(kSyncTrackMetadataConfigKey, false));
checkBox_serato_metadata_export->setChecked(
m_pConfig->getValue(kSyncSeratoMetadataConfigKey, false));
setSeratoMetadataEnabled(checkBox_sync_track_metadata->isChecked());
checkBox_rating_export->setChecked(
m_pConfig->getValue(kExportRatingToFileTagsConfigKey, false));
checkBox_rating_import->setChecked(
m_pConfig->getValue(kImportRatingFromFileTagsConfigKey, false));
checkBox_use_relative_path->setChecked(m_pConfig->getValue(
kUseRelativePathOnExportConfigKey, false));
checkBox_show_rhythmbox->setChecked(m_pConfig->getValue(
ConfigKey("[Library]","ShowRhythmboxLibrary"), true));
checkBox_show_banshee->setChecked(m_pConfig->getValue(
ConfigKey("[Library]","ShowBansheeLibrary"), true));
checkBox_show_itunes->setChecked(m_pConfig->getValue(
ConfigKey("[Library]","ShowITunesLibrary"), true));
checkBox_show_traktor->setChecked(m_pConfig->getValue(
ConfigKey("[Library]","ShowTraktorLibrary"), true));
checkBox_show_rekordbox->setChecked(m_pConfig->getValue(
ConfigKey("[Library]","ShowRekordboxLibrary"), true));
checkBox_show_serato->setChecked(m_pConfig->getValue(
ConfigKey("[Library]", "ShowSeratoLibrary"), true));
switch (m_pConfig->getValue<int>(
kTrackDoubleClickActionConfigKey,
static_cast<int>(TrackDoubleClickAction::LoadToDeck))) {
case static_cast<int>(TrackDoubleClickAction::AddToAutoDJBottom):
radioButton_dbclick_bottom->setChecked(true);
break;
case static_cast<int>(TrackDoubleClickAction::AddToAutoDJTop):
radioButton_dbclick_top->setChecked(true);
break;
case static_cast<int>(TrackDoubleClickAction::Ignore):
radioButton_dbclick_ignore->setChecked(true);
break;
default:
radioButton_dbclick_deck->setChecked(true);
break;
}
switch (m_pConfig->getValue<int>(
kCoverArtFetcherQualityConfigKey,
static_cast<int>(CoverArtFetcherQuality::Low))) {
case static_cast<int>(CoverArtFetcherQuality::Highest):
radioButton_cover_art_fetcher_highest->setChecked(true);
break;
case static_cast<int>(CoverArtFetcherQuality::High):
radioButton_cover_art_fetcher_high->setChecked(true);
break;
case static_cast<int>(CoverArtFetcherQuality::Medium):
radioButton_cover_art_fetcher_medium->setChecked(true);
break;
default:
radioButton_cover_art_fetcher_lowest->setChecked(true);
break;
}
bool editMetadataSelectedClick = m_pConfig->getValue(
kEditMetadataSelectedClickConfigKey,
kEditMetadataSelectedClickDefault);
checkBox_edit_metadata_selected_clicked->setChecked(editMetadataSelectedClick);
m_pLibrary->setEditMetadataSelectedClick(editMetadataSelectedClick);
checkBox_enable_search_completions->setChecked(m_pConfig->getValue(
kEnableSearchCompletionsConfigKey,
WSearchLineEdit::kCompletionsEnabledDefault));
checkBox_enable_search_history_shortcuts->setChecked(m_pConfig->getValue(
kEnableSearchHistoryShortcutsConfigKey,
WSearchLineEdit::kHistoryShortcutsEnabledDefault));
// Library reads font from config during construction
m_originalTrackTableFont = m_pLibrary->getTrackTableFont();
m_iOriginalTrackTableRowHeight = m_pLibrary->getTrackTableRowHeight();
spinBox_row_height->setValue(m_iOriginalTrackTableRowHeight);
setLibraryFont(m_originalTrackTableFont);
const auto searchDebouncingTimeoutMillis =
m_pConfig->getValue(
kSearchDebouncingTimeoutMillisConfigKey,
WSearchLineEdit::kDefaultDebouncingTimeoutMillis);
spinBox_search_debouncing_timeout->setValue(searchDebouncingTimeoutMillis);
const auto searchBpmFuzzyRange =
m_pConfig->getValue(
kSearchBpmFuzzyRangeConfigKey,
BpmFilterNode::kRelativeRangeDefault);
int index = comboBox_search_bpm_fuzzy_range->findData(static_cast<int>(searchBpmFuzzyRange));
if (index == -1) {
index = comboBox_search_bpm_fuzzy_range->findData(kDefaultFuzzyRateRangePercent);
}
comboBox_search_bpm_fuzzy_range->setCurrentIndex(index);
slotBpmRangeSelected(index);
const auto bpmColumnPrecision =
m_pConfig->getValue(
kBpmColumnPrecisionConfigKey,
BaseTrackTableModel::kBpmColumnPrecisionDefault);
spinbox_bpm_precision->setValue(bpmColumnPrecision);
const auto applyPlayedTrackColor =
m_pConfig->getValue(
mixxx::library::prefs::kApplyPlayedTrackColorConfigKey,
BaseTrackTableModel::kApplyPlayedTrackColorDefault);
checkbox_played_track_color->setChecked(applyPlayedTrackColor);
}
void DlgPrefLibrary::slotCancel() {
resetLibraryFont();
}
void DlgPrefLibrary::resetLibraryFont() {
// Undo any changes in the library font or row height.
m_pLibrary->setFont(m_originalTrackTableFont);
m_pLibrary->setRowHeight(m_iOriginalTrackTableRowHeight);
}
void DlgPrefLibrary::slotAddDir() {
QString fd = QFileDialog::getExistingDirectory(
this, tr("Choose a music directory"),
QStandardPaths::writableLocation(QStandardPaths::MusicLocation));
if (!fd.isEmpty()) {
if (m_pLibrary->requestAddDir(fd)) {
populateDirList();
m_bAddedDirectory = true;
}
}
}
void DlgPrefLibrary::slotRemoveDir() {
QModelIndex index = dirList->currentIndex();
QString fd = index.data().toString();
QMessageBox removeMsgBox;
removeMsgBox.setIcon(QMessageBox::Warning);
removeMsgBox.setWindowTitle(tr("Confirm Directory Removal"));
removeMsgBox.setText(tr(
"Mixxx will no longer watch this directory for new tracks. "
"What would you like to do with the tracks from this directory and "
"subdirectories?"
"<ul>"
"<li>Hide all tracks from this directory and subdirectories.</li>"
"<li>Delete all metadata for these tracks from Mixxx permanently.</li>"
"<li>Leave the tracks unchanged in your library.</li>"
"</ul>"
"Hiding tracks saves their metadata in case you re-add them in the "
"future."));
removeMsgBox.setInformativeText(tr(
"Metadata means all track details (artist, title, playcount, etc.) as "
"well as beatgrids, hotcues, and loops. This choice only affects the "
"Mixxx library. No files on disk will be changed or deleted."));
QPushButton* cancelButton =
removeMsgBox.addButton(QMessageBox::Cancel);
QPushButton* hideAllButton = removeMsgBox.addButton(
tr("Hide Tracks"), QMessageBox::AcceptRole);
QPushButton* deleteAllButton = removeMsgBox.addButton(
tr("Delete Track Metadata"), QMessageBox::AcceptRole);
QPushButton* leaveUnchangedButton = removeMsgBox.addButton(
tr("Leave Tracks Unchanged"), QMessageBox::AcceptRole);
Q_UNUSED(leaveUnchangedButton); // Only used in DEBUG_ASSERT
removeMsgBox.setDefaultButton(cancelButton);
removeMsgBox.exec();
if (removeMsgBox.clickedButton() == cancelButton) {
return;
}
LibraryRemovalType removalType;
if (removeMsgBox.clickedButton() == hideAllButton) {
removalType = LibraryRemovalType::HideTracks;
} else if (removeMsgBox.clickedButton() == deleteAllButton) {
removalType = LibraryRemovalType::PurgeTracks;
} else {
// Only used in DEBUG_ASSERT
Q_UNUSED(leaveUnchangedButton);
DEBUG_ASSERT(removeMsgBox.clickedButton() == leaveUnchangedButton);
removalType = LibraryRemovalType::KeepTracks;
}
if (m_pLibrary->requestRemoveDir(fd, removalType)) {
populateDirList();
}
}
void DlgPrefLibrary::slotRelocateDir() {
QModelIndex index = dirList->currentIndex();
QString currentFd = index.data().toString();
// If the selected directory exists, use it. If not, go up one directory (if
// that directory exists). If neither exist, use the default music
// directory.
QString startDir = currentFd;
QDir dir(startDir);
if (!dir.exists() && dir.cdUp()) {
startDir = dir.absolutePath();
} else if (!dir.exists()) {
startDir = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
}
QString fd = QFileDialog::getExistingDirectory(
this, tr("Relink music directory to new location"), startDir);
if (!fd.isEmpty() && m_pLibrary->requestRelocateDir(currentFd, fd)) {
populateDirList();
}
}
void DlgPrefLibrary::slotSeratoMetadataExportClicked(bool checked) {
if (checked) {
if (QMessageBox::warning(this,
QStringLiteral("Serato Metadata Export"),
QStringLiteral(
"Exporting Serato Metadata from Mixxx is "
"experimental. There is no official documentation "
"of the format. Existing Serato Metadata might be "
"lost and files with Serato metadata written by "
"Mixxx could potentially crash Serato DJ, "
"therefore caution is advised and backups are "
"recommended. Are you sure you want to enable this "
"option?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
checkBox_serato_metadata_export->setChecked(false);
}
}
}
void DlgPrefLibrary::slotApply() {
m_pConfig->set(kRescanOnStartupConfigKey,
ConfigValue((int)checkBox_library_scan->isChecked()));
m_pConfig->set(kShowScanSummaryConfigKey,
ConfigValue((int)checkBox_library_scan_summary->isChecked()));
m_pConfig->set(kHistoryTrackDuplicateDistanceConfigKey,
ConfigValue(spinbox_history_track_duplicate_distance->value()));
m_pConfig->set(kHistoryMinTracksToKeepConfigKey,
ConfigValue(spinbox_history_min_tracks_to_keep->value()));
m_pConfig->set(
kSyncTrackMetadataConfigKey,
ConfigValue{checkBox_sync_track_metadata->isChecked()});
m_pConfig->set(
kSyncSeratoMetadataConfigKey,
ConfigValue{checkBox_serato_metadata_export->isChecked()});
m_pConfig->set(
kExportRatingToFileTagsConfigKey,
ConfigValue{checkBox_rating_export->isChecked()});
m_pConfig->set(
kImportRatingFromFileTagsConfigKey,
ConfigValue{checkBox_rating_import->isChecked()});
m_pConfig->set(kUseRelativePathOnExportConfigKey,
ConfigValue((int)checkBox_use_relative_path->isChecked()));
m_pConfig->set(kEnableSearchCompletionsConfigKey,
ConfigValue(checkBox_enable_search_completions->isChecked()));
m_pConfig->set(kEnableSearchHistoryShortcutsConfigKey,
ConfigValue(checkBox_enable_search_history_shortcuts->isChecked()));
updateSearchLineEditHistoryOptions();
m_pConfig->set(ConfigKey("[Library]","ShowRhythmboxLibrary"),
ConfigValue((int)checkBox_show_rhythmbox->isChecked()));
m_pConfig->set(ConfigKey("[Library]","ShowBansheeLibrary"),
ConfigValue((int)checkBox_show_banshee->isChecked()));
m_pConfig->set(ConfigKey("[Library]","ShowITunesLibrary"),
ConfigValue((int)checkBox_show_itunes->isChecked()));
m_pConfig->set(ConfigKey("[Library]","ShowTraktorLibrary"),
ConfigValue((int)checkBox_show_traktor->isChecked()));
m_pConfig->set(ConfigKey("[Library]","ShowRekordboxLibrary"),
ConfigValue((int)checkBox_show_rekordbox->isChecked()));
m_pConfig->set(ConfigKey("[Library]", "ShowSeratoLibrary"),
ConfigValue((int)checkBox_show_serato->isChecked()));
int coverartfetcherquality_status;
if (radioButton_cover_art_fetcher_highest->isChecked()) {
coverartfetcherquality_status = static_cast<int>(CoverArtFetcherQuality::Highest);
} else if (radioButton_cover_art_fetcher_high->isChecked()) {
coverartfetcherquality_status = static_cast<int>(CoverArtFetcherQuality::High);
} else if (radioButton_cover_art_fetcher_medium->isChecked()) {
coverartfetcherquality_status = static_cast<int>(CoverArtFetcherQuality::Medium);
} else {
coverartfetcherquality_status = static_cast<int>(CoverArtFetcherQuality::Low);
}
m_pConfig->set(kCoverArtFetcherQualityConfigKey, ConfigValue(coverartfetcherquality_status));
int dbclick_status;
if (radioButton_dbclick_bottom->isChecked()) {
dbclick_status = static_cast<int>(TrackDoubleClickAction::AddToAutoDJBottom);
} else if (radioButton_dbclick_top->isChecked()) {
dbclick_status = static_cast<int>(TrackDoubleClickAction::AddToAutoDJTop);
} else if (radioButton_dbclick_deck->isChecked()) {
dbclick_status = static_cast<int>(TrackDoubleClickAction::LoadToDeck);
} else { // radioButton_dbclick_ignore
dbclick_status = static_cast<int>(TrackDoubleClickAction::Ignore);
}
m_pConfig->set(kTrackDoubleClickActionConfigKey,
ConfigValue(dbclick_status));
m_pConfig->set(kEditMetadataSelectedClickConfigKey,
ConfigValue(checkBox_edit_metadata_selected_clicked->checkState()));
m_pLibrary->setEditMetadataSelectedClick(
checkBox_edit_metadata_selected_clicked->checkState());
QFont font = m_pLibrary->getTrackTableFont();
if (m_originalTrackTableFont != font) {
m_pConfig->set(ConfigKey("[Library]", "Font"),
ConfigValue(font.toString()));
m_originalTrackTableFont = font;
}
int rowHeight = spinBox_row_height->value();
if (m_iOriginalTrackTableRowHeight != rowHeight) {
m_pConfig->set(ConfigKey("[Library]","RowHeight"),
ConfigValue(rowHeight));
m_iOriginalTrackTableRowHeight = rowHeight;
}
BaseTrackTableModel::setApplyPlayedTrackColor(
checkbox_played_track_color->isChecked());
m_pConfig->set(
mixxx::library::prefs::kApplyPlayedTrackColorConfigKey,
ConfigValue(checkbox_played_track_color->isChecked()));
// TODO(rryan): Don't save here.
m_pConfig->save();
}
void DlgPrefLibrary::slotRowHeightValueChanged(int height) {
m_pLibrary->setRowHeight(height);
}
void DlgPrefLibrary::setLibraryFont(const QFont& font) {
// Update the font name/style/size display
QString fontDescription = font.family();
const QString style = font.styleName();
if (!style.isEmpty()) {
// Use the style name if available, likely it's translated
fontDescription += ' ' + style;
} else {
// Else we compose the "style" string from weight and italic.
// It's not possible to access the translations used in QFontDialog,
// but let's can add them to the user translations
const auto weight = font.weight();
if (weight >= QFont::Bold) {
if (weight >= QFont::Black) {
fontDescription += ' ' + tr("Black");
} else if (weight >= QFont::ExtraBold) {
fontDescription += ' ' + tr("ExtraBold");
} else if (weight >= QFont::Bold) {
fontDescription += ' ' + tr("Bold");
}
} else if (weight >= QFont::DemiBold) {
fontDescription += ' ' + tr("SemiBold");
} else if (weight >= QFont::Medium) {
fontDescription += ' ' + tr("Medium");
} else if (weight >= QFont::Normal) {
// Skip "Normal" as it's implied
} else {
fontDescription += ' ' + tr("Light");
}
}
fontDescription += ' ' + QString::number(font.pointSizeF()) + QStringLiteral("pt");
lineEdit_library_font->setText(fontDescription);
// Apply the font
m_pLibrary->setFont(font);
// Don't let the font height exceed the row height.
QFontMetrics metrics(font);
int fontHeight = metrics.height();
spinBox_row_height->setMinimum(fontHeight);
// library.cpp takes care of setting the new row height according to the
// previous font height/ row height ratio
spinBox_row_height->setValue(m_pLibrary->getTrackTableRowHeight());
}
void DlgPrefLibrary::slotSelectFont() {
// False if the user cancels font selection.
bool ok = false;
QFont font = QFontDialog::getFont(&ok, m_pLibrary->getTrackTableFont(),
this, tr("Select Library Font"));
if (ok) {
setLibraryFont(font);
}
}
void DlgPrefLibrary::slotSearchDebouncingTimeoutMillisChanged(int searchDebouncingTimeoutMillis) {
m_pConfig->setValue(
kSearchDebouncingTimeoutMillisConfigKey,
searchDebouncingTimeoutMillis);
WSearchLineEdit::setDebouncingTimeoutMillis(searchDebouncingTimeoutMillis);
}
void DlgPrefLibrary::slotBpmRangeSelected(int index) {
const int bpmRange = comboBox_search_bpm_fuzzy_range->itemData(index).toInt();
m_pConfig->set(kSearchBpmFuzzyRangeConfigKey, ConfigValue{bpmRange});
const int rateRangePercent =
m_pConfig->getValue(ConfigKey("[Controls]", "RateRangePercent"), 8);
BpmFilterNode::setBpmRelativeRange(bpmRange * rateRangePercent / 10000.0);
}
void DlgPrefLibrary::updateSearchLineEditHistoryOptions() {
WSearchLineEdit::setSearchCompletionsEnabled(m_pConfig->getValue<bool>(
kEnableSearchCompletionsConfigKey,
WSearchLineEdit::kCompletionsEnabledDefault));
WSearchLineEdit::setSearchHistoryShortcutsEnabled(m_pConfig->getValue<bool>(
kEnableSearchHistoryShortcutsConfigKey,
WSearchLineEdit::kHistoryShortcutsEnabledDefault));
}
void DlgPrefLibrary::slotBpmColumnPrecisionChanged(int bpmPrecision) {
m_pConfig->setValue(
kBpmColumnPrecisionConfigKey,
bpmPrecision);
BaseTrackTableModel::setBpmColumnPrecision(bpmPrecision);
}
void DlgPrefLibrary::slotSyncTrackMetadataToggled() {
bool shouldSyncTrackMetadata = checkBox_sync_track_metadata->isChecked();
if (isVisible() && shouldSyncTrackMetadata) {
mixxx::DlgTrackMetadataExport::showMessageBoxOncePerSession();
}
setSeratoMetadataEnabled(shouldSyncTrackMetadata);
}
void DlgPrefLibrary::setSeratoMetadataEnabled(bool shouldSyncTrackMetadata) {
checkBox_serato_metadata_export->setEnabled(shouldSyncTrackMetadata);
if (!shouldSyncTrackMetadata) {
checkBox_serato_metadata_export->setChecked(false);
}
}