-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathwmainmenubar.cpp
More file actions
1017 lines (910 loc) · 42.5 KB
/
Copy pathwmainmenubar.cpp
File metadata and controls
1017 lines (910 loc) · 42.5 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
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "widget/wmainmenubar.h"
#ifndef __APPLE__
#include <QApplication>
#include <QWindow>
#endif
#include <QUrl>
#include "config.h"
#include "control/controlproxy.h"
#include "controllers/keyboard/keyboardeventfilter.h"
#include "defs_urls.h"
#include "moc_wmainmenubar.cpp"
#include "util/cmdlineargs.h"
#include "util/desktophelper.h"
#include "util/experiment.h"
#include "vinylcontrol/defs_vinylcontrol.h"
namespace {
constexpr int kMaxLoadToDeckActions = 4;
const QString kSkinGroup = QStringLiteral("[Skin]");
const QString kKbdShortcutsGroup = QStringLiteral("[KeyboardShortcuts]");
const ConfigKey kHideMenuCfgKey =
ConfigKey(QStringLiteral("[Config]"), QStringLiteral("hide_menubar"));
QString buildWhatsThis(const QString& title, const QString& text) {
QString preparedTitle = title;
return QStringLiteral("%1\n\n%2").arg(preparedTitle.remove("&"), text);
}
#ifdef __VINYLCONTROL__
QString vinylControlDefaultKeyBinding(int deck) {
// More bindings need to be defined if you increment
// kMaximumVinylControlInputs.
DEBUG_ASSERT(deck < kMaximumVinylControlInputs);
switch (deck) {
case 0:
return QStringLiteral("Ctrl+t");
case 1:
return QStringLiteral("Ctrl+y");
case 2:
return QStringLiteral("Ctrl+u");
case 3:
return QStringLiteral("Ctrl+i");
default:
return QString();
}
}
#endif // __VINYLCONTROL__
QString loadToDeckDefaultKeyBinding(int deck) {
switch (deck) {
case 0:
return QStringLiteral("Ctrl+o");
case 1:
return QStringLiteral("Ctrl+Shift+O");
default:
return QString();
}
}
QString showPreferencesKeyBinding() {
#ifdef __APPLE__
return QStringLiteral("Ctrl+,");
#else
return QStringLiteral("Ctrl+P");
#endif
}
QUrl documentationUrl(
const QString& resourcePath, const QString& fileName, const QString& docUrl) {
QDir resourceDir(resourcePath);
// Documentation PDFs are included on Windows and Linux only,
// so on macOS this always returns the web URL.
#if defined(MIXXX_INSTALL_DOCDIR_RELATIVE_TO_DATADIR)
if (!resourceDir.exists(fileName)) {
resourceDir.cd(MIXXX_INSTALL_DOCDIR_RELATIVE_TO_DATADIR);
}
#endif
if (resourceDir.exists(fileName)) {
return QUrl::fromLocalFile(resourceDir.absoluteFilePath(fileName));
} else {
return QUrl(docUrl);
}
}
} // namespace
WMainMenuBar::WMainMenuBar(QWidget* pParent,
UserSettingsPointer pConfig,
std::shared_ptr<KeyboardEventFilter> pKbd)
: QMenuBar(pParent),
m_pConfig(pConfig),
m_pKeyboard(std::move(pKbd)) {
setObjectName(QStringLiteral("MainMenu"));
initialize();
}
void WMainMenuBar::initialize() {
// Clear hash of previous actions
m_pKeyboard->clearMenuBarActions();
// FILE MENU
QMenu* pFileMenu = new QMenu(tr("&File"), this);
#ifndef __APPLE__
connectMenuToSlotShowMenuBar(pFileMenu);
#endif
QString loadTrackText = tr("Load Track to Deck &%1");
QString loadTrackStatusText = tr("Loads a track in deck %1");
QString openText = tr("Open");
for (unsigned int deck = 0; deck < kMaxLoadToDeckActions; ++deck) {
QString playerLoadStatusText = loadTrackStatusText.arg(QString::number(deck + 1));
QAction* pFileLoadSongToPlayer = new QAction(
loadTrackText.arg(QString::number(deck + 1)), this);
m_pKeyboard->registerMenuBarActionSetShortcut(pFileLoadSongToPlayer,
ConfigKey(kKbdShortcutsGroup,
QStringLiteral("FileMenu_LoadDeck%1").arg(deck + 1)),
loadToDeckDefaultKeyBinding(deck));
pFileLoadSongToPlayer->setStatusTip(playerLoadStatusText);
pFileLoadSongToPlayer->setWhatsThis(
buildWhatsThis(openText, playerLoadStatusText));
// Visibility of load to deck actions is set in
// WMainMenuBar::onNumberOfDecksChanged.
pFileLoadSongToPlayer->setVisible(false);
connect(pFileLoadSongToPlayer, &QAction::triggered,
this, [this, deck] { emit loadTrackToDeck(deck + 1); });
pFileMenu->addAction(pFileLoadSongToPlayer);
m_loadToDeckActions.push_back(pFileLoadSongToPlayer);
}
pFileMenu->addSeparator();
QString quitTitle = tr("&Exit");
QString quitText = tr("Quits Mixxx");
auto* pFileQuit = new QAction(quitTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pFileQuit,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("FileMenu_Quit")),
QStringLiteral("Ctrl+q"));
pFileQuit->setStatusTip(quitText);
pFileQuit->setWhatsThis(buildWhatsThis(quitTitle, quitText));
pFileQuit->setMenuRole(QAction::QuitRole);
connect(pFileQuit, &QAction::triggered, this, &WMainMenuBar::quit);
pFileMenu->addAction(pFileQuit);
addMenu(pFileMenu);
// LIBRARY MENU
QMenu* pLibraryMenu = new QMenu(tr("&Library"), this);
#ifndef __APPLE__
connectMenuToSlotShowMenuBar(pLibraryMenu);
#endif
QString rescanTitle = tr("&Rescan Library");
QString rescanText = tr("Rescans library folders for changes to tracks.");
auto* pLibraryRescan = new QAction(rescanTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pLibraryRescan,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("LibraryMenu_Rescan")),
QStringLiteral("Ctrl+Shift+L"));
pLibraryRescan->setStatusTip(rescanText);
pLibraryRescan->setWhatsThis(buildWhatsThis(rescanTitle, rescanText));
pLibraryRescan->setCheckable(false);
connect(pLibraryRescan, &QAction::triggered, this, &WMainMenuBar::rescanLibrary);
// Disable the action when a scan is active.
connect(this, &WMainMenuBar::internalLibraryScanActive, pLibraryRescan, &QAction::setDisabled);
pLibraryMenu->addAction(pLibraryRescan);
#ifdef __ENGINEPRIME__
//: "Engine DJ" must not be translated
QString exportTitle = tr("E&xport Library to Engine DJ");
QString exportText = tr("Export the library to the Engine DJ format");
auto* pLibraryExport = new QAction(exportTitle, this);
pLibraryExport->setStatusTip(exportText);
pLibraryExport->setWhatsThis(buildWhatsThis(exportTitle, exportText));
pLibraryExport->setCheckable(false);
connect(pLibraryExport, &QAction::triggered, this, &WMainMenuBar::exportLibrary);
pLibraryMenu->addAction(pLibraryExport);
#endif
pLibraryMenu->addSeparator();
QString searchHereTitle = tr("Search in Current View...");
QString searchHereText = tr("Search for tracks in the current library view");
auto* pSearchHere = new QAction(searchHereTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pSearchHere,
ConfigKey("[KeyboardShortcuts]", "LibraryMenu_SearchInCurrentView"),
QStringLiteral("Ctrl+f"));
pSearchHere->setStatusTip(searchHereText);
pSearchHere->setWhatsThis(buildWhatsThis(searchHereTitle, searchHereText));
connect(pSearchHere, &QAction::triggered, this, &WMainMenuBar::searchInCurrentView);
pLibraryMenu->addAction(pSearchHere);
QString searchAllTitle = tr("Search in Tracks Library...");
QString searchAllText =
tr("Search in the internal track collection under \"Tracks\" in "
"the library");
auto* pSearchAll = new QAction(searchAllTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pSearchAll,
ConfigKey("[KeyboardShortcuts]", "LibraryMenu_SearchInAllTracks"),
QStringLiteral("Ctrl+Shift+F"));
pSearchAll->setStatusTip(searchAllText);
pSearchAll->setWhatsThis(buildWhatsThis(searchAllText, searchAllText));
connect(pSearchAll, &QAction::triggered, this, &WMainMenuBar::searchInAllTracks);
pLibraryMenu->addAction(pSearchAll);
pLibraryMenu->addSeparator();
QString createPlaylistTitle = tr("Create &New Playlist");
QString createPlaylistText = tr("Create a new playlist");
auto* pLibraryCreatePlaylist = new QAction(createPlaylistTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pLibraryCreatePlaylist,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("LibraryMenu_NewPlaylist")),
QStringLiteral("Ctrl+n"));
pLibraryCreatePlaylist->setStatusTip(createPlaylistText);
pLibraryCreatePlaylist->setWhatsThis(buildWhatsThis(createPlaylistTitle, createPlaylistText));
connect(pLibraryCreatePlaylist, &QAction::triggered, this, &WMainMenuBar::createPlaylist);
pLibraryMenu->addAction(pLibraryCreatePlaylist);
QString createCrateTitle = tr("Create New &Crate");
QString createCrateText = tr("Create a new crate");
auto* pLibraryCreateCrate = new QAction(createCrateTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pLibraryCreateCrate,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("LibraryMenu_NewCrate")),
QStringLiteral("Ctrl+Shift+N"));
pLibraryCreateCrate->setStatusTip(createCrateText);
pLibraryCreateCrate->setWhatsThis(buildWhatsThis(createCrateTitle, createCrateText));
connect(pLibraryCreateCrate, &QAction::triggered, this, &WMainMenuBar::createCrate);
pLibraryMenu->addAction(pLibraryCreateCrate);
addMenu(pLibraryMenu);
#if defined(__APPLE__)
// Note: On macOS 10.11 ff. we have to deal with "automagic" menu items,
// when ever a menu "View" is present. QT (as of 5.12.3) does not handle this for us.
// Add an invisible suffix to the View item string so it doesn't string-equal "View" ,
// and the magic menu items won't get injected.
// https://github.com/mixxxdj/mixxx/issues/8442
QMenu* pViewMenu = new QMenu(tr("&View") + QStringLiteral("\u200C"), this);
#else
QMenu* pViewMenu = new QMenu(tr("&View"), this);
connectMenuToSlotShowMenuBar(pViewMenu);
#endif
#ifndef __APPLE__
// Show menu bar
QString showMenuBarTitle = tr("Auto-hide menu bar");
QString showMenuBarText = tr("Auto-hide the main menu bar when it's not used.");
auto* pViewAutoHideMenuBar = new QAction(showMenuBarTitle, this);
pViewAutoHideMenuBar->setCheckable(true);
pViewAutoHideMenuBar->setStatusTip(showMenuBarText);
pViewAutoHideMenuBar->setWhatsThis(buildWhatsThis(showMenuBarTitle, showMenuBarText));
connect(pViewAutoHideMenuBar,
&QAction::triggered,
this,
&WMainMenuBar::slotAutoHideMenuBarToggled);
// update checked state from config each time the menu is shown
connect(pViewMenu,
&QMenu::aboutToShow,
this,
[this, pViewAutoHideMenuBar]() {
bool autoHide = m_pConfig->getValue<bool>(kHideMenuCfgKey, false);
pViewAutoHideMenuBar->setChecked(autoHide);
});
pViewMenu->addAction(pViewAutoHideMenuBar);
pViewMenu->addSeparator();
#endif
// Skin Settings Menu
QString mayNotBeSupported = tr("May not be supported on all skins.");
QString showSkinSettingsTitle = tr("Show Skin Settings Menu");
QString showSkinSettingsText = tr("Show the Skin Settings Menu of the currently selected Skin") +
" " + mayNotBeSupported;
auto* pViewShowSkinSettings = new QAction(showSkinSettingsTitle, this);
pViewShowSkinSettings->setCheckable(true);
m_pKeyboard->registerMenuBarActionSetShortcut(
pViewShowSkinSettings,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("ViewMenu_ShowSkinSettings")),
QStringLiteral("Ctrl+1"));
pViewShowSkinSettings->setStatusTip(showSkinSettingsText);
pViewShowSkinSettings->setWhatsThis(buildWhatsThis(showSkinSettingsTitle, showSkinSettingsText));
createVisibilityControl(pViewShowSkinSettings,
ConfigKey(kSkinGroup, QStringLiteral("show_settings")));
pViewMenu->addAction(pViewShowSkinSettings);
// Microphone Section
QString showMicrophoneTitle = tr("Show Microphone Section");
QString showMicrophoneText = tr("Show the microphone section of the Mixxx interface.") +
" " + mayNotBeSupported;
auto* pViewShowMicrophone = new QAction(showMicrophoneTitle, this);
pViewShowMicrophone->setCheckable(true);
m_pKeyboard->registerMenuBarActionSetShortcut(
pViewShowMicrophone,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("ViewMenu_ShowMicrophone")),
QStringLiteral("Ctrl+2"));
pViewShowMicrophone->setStatusTip(showMicrophoneText);
pViewShowMicrophone->setWhatsThis(buildWhatsThis(showMicrophoneTitle, showMicrophoneText));
createVisibilityControl(pViewShowMicrophone,
ConfigKey(kSkinGroup, QStringLiteral("show_microphones")));
pViewMenu->addAction(pViewShowMicrophone);
#ifdef __VINYLCONTROL__
QString showVinylControlTitle = tr("Show Vinyl Control Section");
QString showVinylControlText = tr("Show the vinyl control section of the Mixxx interface.") +
" " + mayNotBeSupported;
auto* pViewVinylControl = new QAction(showVinylControlTitle, this);
pViewVinylControl->setCheckable(true);
m_pKeyboard->registerMenuBarActionSetShortcut(
pViewVinylControl,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("ViewMenu_ShowVinylControl")),
QStringLiteral("Ctrl+3"));
pViewVinylControl->setStatusTip(showVinylControlText);
pViewVinylControl->setWhatsThis(buildWhatsThis(showVinylControlTitle, showVinylControlText));
createVisibilityControl(pViewVinylControl,
ConfigKey(kSkinGroup, QStringLiteral("show_vinylcontrol")));
pViewMenu->addAction(pViewVinylControl);
#endif
QString showPreviewDeckTitle = tr("Show Preview Deck");
QString showPreviewDeckText = tr("Show the preview deck in the Mixxx interface.") +
" " + mayNotBeSupported;
auto* pViewShowPreviewDeck = new QAction(showPreviewDeckTitle, this);
pViewShowPreviewDeck->setCheckable(true);
m_pKeyboard->registerMenuBarActionSetShortcut(
pViewShowPreviewDeck,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("ViewMenu_ShowPreviewDeck")),
QStringLiteral("Ctrl+4"));
pViewShowPreviewDeck->setStatusTip(showPreviewDeckText);
pViewShowPreviewDeck->setWhatsThis(buildWhatsThis(showPreviewDeckTitle, showPreviewDeckText));
createVisibilityControl(pViewShowPreviewDeck,
ConfigKey(kSkinGroup, QStringLiteral("show_preview_decks")));
pViewMenu->addAction(pViewShowPreviewDeck);
QString showCoverArtTitle = tr("Show Cover Art");
QString showCoverArtText = tr("Show cover art in the Mixxx interface.") +
" " + mayNotBeSupported;
auto* pViewShowCoverArt = new QAction(showCoverArtTitle, this);
pViewShowCoverArt->setCheckable(true);
m_pKeyboard->registerMenuBarActionSetShortcut(
pViewShowCoverArt,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("ViewMenu_ShowCoverArt")),
QStringLiteral("Ctrl+6"));
pViewShowCoverArt->setStatusTip(showCoverArtText);
pViewShowCoverArt->setWhatsThis(buildWhatsThis(showCoverArtTitle, showCoverArtText));
createVisibilityControl(pViewShowCoverArt,
ConfigKey(kSkinGroup, QStringLiteral("show_library_coverart")));
pViewMenu->addAction(pViewShowCoverArt);
//: menu title
QString keywheelTitle = tr("Show Keywheel");
//: tooltip text
QString keywheelText = tr("Show keywheel");
m_pViewKeywheel = new QAction(keywheelTitle, this);
m_pViewKeywheel->setCheckable(true);
m_pKeyboard->registerMenuBarActionSetShortcut(
m_pViewKeywheel,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("ViewMenu_ShowKeywheel")),
QStringLiteral("F12"));
m_pViewKeywheel->setShortcutContext(Qt::ApplicationShortcut);
m_pViewKeywheel->setStatusTip(keywheelText);
m_pViewKeywheel->setWhatsThis(buildWhatsThis(keywheelTitle, keywheelText));
connect(m_pViewKeywheel, &QAction::triggered, this, &WMainMenuBar::showKeywheel);
pViewMenu->addAction(m_pViewKeywheel);
QString maximizeLibraryTitle = tr("Maximize Library");
QString maximizeLibraryText = tr("Maximize the track library to take up all the available screen space.") +
" " + mayNotBeSupported;
auto* pViewMaximizeLibrary = new QAction(maximizeLibraryTitle, this);
pViewMaximizeLibrary->setCheckable(true);
m_pKeyboard->registerMenuBarActionSetShortcut(
pViewMaximizeLibrary,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("ViewMenu_MaximizeLibrary")),
QStringLiteral("Space"));
pViewMaximizeLibrary->setStatusTip(maximizeLibraryText);
pViewMaximizeLibrary->setWhatsThis(buildWhatsThis(maximizeLibraryTitle, maximizeLibraryText));
createVisibilityControl(pViewMaximizeLibrary,
ConfigKey(kSkinGroup, QStringLiteral("show_maximized_library")));
pViewMenu->addAction(pViewMaximizeLibrary);
pViewMenu->addSeparator();
QString autoDJTitle = tr("Show Auto DJ");
QString autoDJText = tr("Switch to the Auto DJ view.");
auto* pViewAutoDJ = new QAction(autoDJTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pViewAutoDJ,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("ViewMenu_ShowAutoDJ")),
QStringLiteral("Ctrl+9"));
pViewAutoDJ->setStatusTip(autoDJText);
pViewAutoDJ->setWhatsThis(buildWhatsThis(autoDJTitle, autoDJText));
pViewAutoDJ->setCheckable(false);
connect(pViewAutoDJ, &QAction::triggered, this, &WMainMenuBar::showAutoDJ);
pViewMenu->addAction(pViewAutoDJ);
pViewMenu->addSeparator();
QString fullScreenTitle = tr("&Full Screen");
QString fullScreenText = tr("Display Mixxx using the full screen");
auto* pViewFullScreen = new QAction(fullScreenTitle, this);
QList<QKeySequence> shortcuts;
// We use F11 _AND_ the OS shortcut only on Linux and Windows because on
// newer macOS versions there might be issues with getting F11 working.
// https://github.com/mixxxdj/mixxx/pull/3011#issuecomment-678678328
#ifndef __APPLE__
shortcuts << QStringLiteral("F11");
#endif
QKeySequence osShortcut = QKeySequence::FullScreen;
// Note(ronso0) Only add the OS shortcut if it's not empty and not F11.
// In some Linux distros the window managers doesn't pass the OS fullscreen
// key sequence to Mixxx for some reason.
// Both adding an empty key sequence or the same sequence twice can render
// the fullscreen shortcut nonfunctional.
// https://github.com/mixxxdj/mixxx/issues/10005 PR #3011
if (!osShortcut.isEmpty() && !shortcuts.contains(osShortcut)) {
shortcuts << osShortcut;
}
pViewFullScreen->setShortcuts(shortcuts);
pViewFullScreen->setCheckable(true);
pViewFullScreen->setChecked(false);
pViewFullScreen->setStatusTip(fullScreenText);
pViewFullScreen->setWhatsThis(buildWhatsThis(fullScreenTitle, fullScreenText));
connect(pViewFullScreen, &QAction::triggered, this, &WMainMenuBar::toggleFullScreen);
connect(this,
&WMainMenuBar::internalFullScreenStateChange,
pViewFullScreen,
&QAction::setChecked);
pViewMenu->addAction(pViewFullScreen);
addMenu(pViewMenu);
// OPTIONS MENU
QMenu* pOptionsMenu = new QMenu(tr("&Options"), this);
#ifndef __APPLE__
connectMenuToSlotShowMenuBar(pOptionsMenu);
#endif
#ifdef __VINYLCONTROL__
QMenu* pVinylControlMenu = new QMenu(tr("&Vinyl Control"), this);
QString vinylControlText = tr(
"Use timecoded vinyls on external turntables to control Mixxx");
for (int i = 0; i < kMaximumVinylControlInputs; ++i) {
QString vinylControlTitle = tr("Enable Vinyl Control &%1").arg(i + 1);
auto* vc_checkbox = new QAction(vinylControlTitle, this);
m_vinylControlEnabledActions.push_back(vc_checkbox);
m_pKeyboard->registerMenuBarActionSetShortcut(
vc_checkbox,
ConfigKey(QStringLiteral("[KeyboardShortcuts]"),
QStringLiteral("OptionsMenu_EnableVinyl%1").arg(i + 1)),
vinylControlDefaultKeyBinding(i));
// Either check or uncheck the vinyl control menu item depending on what
// it was saved as.
vc_checkbox->setCheckable(true);
vc_checkbox->setChecked(false);
// The visibility of these actions is set in
// WMainMenuBar::onNumberOfDecksChanged.
vc_checkbox->setVisible(false);
vc_checkbox->setStatusTip(vinylControlText);
vc_checkbox->setWhatsThis(buildWhatsThis(vinylControlTitle,
vinylControlText));
connect(vc_checkbox, &QAction::triggered,
this, [this, i] { emit toggleVinylControl(i); });
pVinylControlMenu->addAction(vc_checkbox);
}
pOptionsMenu->addMenu(pVinylControlMenu);
pOptionsMenu->addSeparator();
#endif
QString recordTitle = tr("&Record Mix");
QString recordText = tr("Record your mix to a file");
auto* pOptionsRecord = new QAction(recordTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pOptionsRecord,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("OptionsMenu_RecordMix")),
QStringLiteral("Ctrl+R"));
pOptionsRecord->setCheckable(true);
pOptionsRecord->setStatusTip(recordText);
pOptionsRecord->setWhatsThis(buildWhatsThis(recordTitle, recordText));
connect(pOptionsRecord, &QAction::triggered, this, &WMainMenuBar::toggleRecording);
connect(this,
&WMainMenuBar::internalRecordingStateChange,
pOptionsRecord,
&QAction::setChecked);
pOptionsMenu->addAction(pOptionsRecord);
#ifdef __BROADCAST__
QString broadcastingTitle = tr("Enable Live &Broadcasting");
QString broadcastingText = tr("Stream your mixes to a shoutcast or icecast server");
auto* pOptionsBroadcasting = new QAction(broadcastingTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pOptionsBroadcasting,
ConfigKey(kKbdShortcutsGroup,
QStringLiteral("OptionsMenu_EnableLiveBroadcasting")),
tr("Ctrl+L"));
pOptionsBroadcasting->setCheckable(true);
pOptionsBroadcasting->setStatusTip(broadcastingText);
pOptionsBroadcasting->setWhatsThis(buildWhatsThis(broadcastingTitle, broadcastingText));
connect(pOptionsBroadcasting, &QAction::triggered, this, &WMainMenuBar::toggleBroadcasting);
connect(this,
&WMainMenuBar::internalBroadcastingStateChange,
pOptionsBroadcasting,
&QAction::setChecked);
pOptionsMenu->addAction(pOptionsBroadcasting);
#endif
pOptionsMenu->addSeparator();
QString keyboardShortcutTitle = tr("Enable &Keyboard Shortcuts");
QString keyboardShortcutText = tr("Toggles keyboard shortcuts on or off");
// Note: use the same default value in KeyboardEventFilter ctor so that this
// action and KeyboardEventFilter are in sync.
bool keyboardShortcutsEnabled =
m_pConfig->getValue(ConfigKey(QStringLiteral("[Keyboard]"),
QStringLiteral("Enabled")),
true);
auto* pOptionsKeyboard = new QAction(keyboardShortcutTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pOptionsKeyboard,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("OptionsMenu_EnableShortcuts")),
QStringLiteral("Ctrl+`"));
pOptionsKeyboard->setCheckable(true);
pOptionsKeyboard->setChecked(keyboardShortcutsEnabled);
pOptionsKeyboard->setStatusTip(keyboardShortcutText);
pOptionsKeyboard->setWhatsThis(buildWhatsThis(keyboardShortcutTitle, keyboardShortcutText));
connect(pOptionsKeyboard,
&QAction::triggered,
m_pKeyboard.get(),
&KeyboardEventFilter::setEnabled);
pOptionsMenu->addAction(pOptionsKeyboard);
pOptionsMenu->addSeparator();
QString repairDatabaseTitle = tr("Repair Database");
QString repairDatabaseText = tr("Restart Mixxx & repair database inconsistencies");
auto* pOptionsRepairDatabase = new QAction(repairDatabaseTitle, this);
pOptionsRepairDatabase->setStatusTip(repairDatabaseText);
pOptionsRepairDatabase->setWhatsThis(buildWhatsThis(repairDatabaseTitle, repairDatabaseText));
connect(pOptionsRepairDatabase, &QAction::triggered, this, &WMainMenuBar::repairDatabase);
pOptionsMenu->addAction(pOptionsRepairDatabase);
QString preferencesTitle = tr("&Preferences");
QString preferencesText = tr("Change Mixxx settings (e.g. playback, MIDI, controls)");
auto* pOptionsPreferences = new QAction(preferencesTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pOptionsPreferences,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("OptionsMenu_Preferences")),
showPreferencesKeyBinding());
pOptionsPreferences->setStatusTip(preferencesText);
pOptionsPreferences->setWhatsThis(buildWhatsThis(preferencesTitle, preferencesText));
pOptionsPreferences->setMenuRole(QAction::PreferencesRole);
connect(pOptionsPreferences, &QAction::triggered, this, &WMainMenuBar::showPreferences);
pOptionsMenu->addAction(pOptionsPreferences);
addMenu(pOptionsMenu);
// DEVELOPER MENU
if (CmdlineArgs::Instance().getDeveloper()) {
QMenu* pDeveloperMenu = new QMenu(tr("&Developer"), this);
#ifndef __APPLE__
connectMenuToSlotShowMenuBar(pDeveloperMenu);
#endif
QString reloadSkinTitle = tr("&Reload Skin");
QString reloadSkinText = tr("Reload the skin");
auto* pDeveloperReloadSkin = new QAction(reloadSkinTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pDeveloperReloadSkin,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("OptionsMenu_ReloadSkin")),
QStringLiteral("Ctrl+Shift+R"));
pDeveloperReloadSkin->setShortcutContext(Qt::ApplicationShortcut);
pDeveloperReloadSkin->setStatusTip(reloadSkinText);
pDeveloperReloadSkin->setWhatsThis(buildWhatsThis(reloadSkinTitle, reloadSkinText));
connect(pDeveloperReloadSkin, &QAction::triggered, this, &WMainMenuBar::reloadSkin);
pDeveloperMenu->addAction(pDeveloperReloadSkin);
QString developerToolsTitle = tr("Developer &Tools");
QString developerToolsText = tr("Opens the developer tools dialog");
auto* pDeveloperTools = new QAction(developerToolsTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pDeveloperTools,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("OptionsMenu_DeveloperTools")),
QStringLiteral("Ctrl+Shift+T"));
pDeveloperTools->setShortcutContext(Qt::ApplicationShortcut);
pDeveloperTools->setCheckable(true);
pDeveloperTools->setChecked(false);
pDeveloperTools->setStatusTip(developerToolsText);
pDeveloperTools->setWhatsThis(buildWhatsThis(developerToolsTitle, developerToolsText));
connect(pDeveloperTools, &QAction::triggered, this, &WMainMenuBar::toggleDeveloperTools);
connect(this,
&WMainMenuBar::internalDeveloperToolsStateChange,
pDeveloperTools,
&QAction::setChecked);
pDeveloperMenu->addAction(pDeveloperTools);
QString enableExperimentTitle = tr("Stats: &Experiment Bucket");
QString enableExperimentToolsText = tr(
"Enables experiment mode. Collects stats in the EXPERIMENT tracking bucket.");
auto* pDeveloperStatsExperiment = new QAction(enableExperimentTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(pDeveloperStatsExperiment,
ConfigKey(kKbdShortcutsGroup,
QStringLiteral("OptionsMenu_DeveloperStatsExperiment")),
QStringLiteral("Ctrl+Shift+E"));
pDeveloperStatsExperiment->setShortcutContext(Qt::ApplicationShortcut);
pDeveloperStatsExperiment->setStatusTip(enableExperimentToolsText);
pDeveloperStatsExperiment->setWhatsThis(buildWhatsThis(
enableExperimentTitle, enableExperimentToolsText));
pDeveloperStatsExperiment->setCheckable(true);
pDeveloperStatsExperiment->setChecked(Experiment::isExperiment());
connect(pDeveloperStatsExperiment,
&QAction::triggered,
this,
&WMainMenuBar::slotDeveloperStatsExperiment);
pDeveloperMenu->addAction(pDeveloperStatsExperiment);
QString enableBaseTitle = tr("Stats: &Base Bucket");
QString enableBaseToolsText = tr(
"Enables base mode. Collects stats in the BASE tracking bucket.");
auto* pDeveloperStatsBase = new QAction(enableBaseTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pDeveloperStatsBase,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("OptionsMenu_DeveloperStatsBase")),
QStringLiteral("Ctrl+Shift+B"));
pDeveloperStatsBase->setShortcutContext(Qt::ApplicationShortcut);
pDeveloperStatsBase->setStatusTip(enableBaseToolsText);
pDeveloperStatsBase->setWhatsThis(buildWhatsThis(
enableBaseTitle, enableBaseToolsText));
pDeveloperStatsBase->setCheckable(true);
pDeveloperStatsBase->setChecked(Experiment::isBase());
connect(pDeveloperStatsBase,
&QAction::triggered,
this,
&WMainMenuBar::slotDeveloperStatsBase);
pDeveloperMenu->addAction(pDeveloperStatsBase);
// "D" cannot be used with Alt here as it is already by the Developer menu
QString scriptDebuggerTitle = tr("Deb&ugger Enabled");
QString scriptDebuggerText = tr("Enables the debugger during skin parsing");
bool scriptDebuggerEnabled = m_pConfig->getValue<bool>(ConfigKey(
QStringLiteral("[ScriptDebugger]"),
QStringLiteral("Enabled")));
auto* pDeveloperDebugger = new QAction(scriptDebuggerTitle, this);
m_pKeyboard->registerMenuBarActionSetShortcut(
pDeveloperDebugger,
ConfigKey(kKbdShortcutsGroup, QStringLiteral("DeveloperMenu_EnableDebugger")),
QStringLiteral("Ctrl+Shift+D"));
pDeveloperDebugger->setShortcutContext(Qt::ApplicationShortcut);
pDeveloperDebugger->setWhatsThis(buildWhatsThis(keyboardShortcutTitle, keyboardShortcutText));
pDeveloperDebugger->setCheckable(true);
pDeveloperDebugger->setStatusTip(scriptDebuggerText);
pDeveloperDebugger->setChecked(scriptDebuggerEnabled);
connect(pDeveloperDebugger,
&QAction::triggered,
this,
&WMainMenuBar::slotDeveloperDebugger);
pDeveloperMenu->addAction(pDeveloperDebugger);
addMenu(pDeveloperMenu);
}
addSeparator();
// HELP MENU
QMenu* pHelpMenu = new QMenu(tr("&Help"), this);
#ifndef __APPLE__
connectMenuToSlotShowMenuBar(pHelpMenu);
#endif
QString externalLinkSuffix;
#ifndef __APPLE__
// According to Apple's Human Interface Guidelines devs are encouraged
// to not use custom icons in menus.
// https://developer.apple.com/design/human-interface-guidelines/macos/menus/menu-anatomy/
externalLinkSuffix = QChar(' ') + QChar(0x2197); // north-east arrow
#endif
// Community Support
QString supportTitle = tr("&Community Support") + externalLinkSuffix;
QString supportText = tr("Get help with Mixxx");
auto* pHelpSupport = new QAction(supportTitle, this);
pHelpSupport->setStatusTip(supportText);
pHelpSupport->setWhatsThis(buildWhatsThis(supportTitle, supportText));
connect(pHelpSupport, &QAction::triggered, this, [this] {
slotVisitUrl(QUrl(MIXXX_SUPPORT_URL));
});
pHelpMenu->addAction(pHelpSupport);
// User Manual
QUrl manualUrl = documentationUrl(m_pConfig->getResourcePath(),
MIXXX_MANUAL_FILENAME,
MIXXX_MANUAL_URL);
QString manualSuffix = manualUrl.isLocalFile() ? QString() : externalLinkSuffix;
QString manualTitle = tr("&User Manual") + manualSuffix;
QString manualText = tr("Read the Mixxx user manual.");
auto* pHelpManual = new QAction(manualTitle, this);
pHelpManual->setStatusTip(manualText);
pHelpManual->setWhatsThis(buildWhatsThis(manualTitle, manualText));
connect(pHelpManual, &QAction::triggered, this, [this, manualUrl] {
slotVisitUrl(manualUrl);
});
pHelpMenu->addAction(pHelpManual);
// Keyboard Shortcuts
QUrl keyboardShortcutsUrl = documentationUrl(m_pConfig->getResourcePath(),
MIXXX_KBD_SHORTCUTS_FILENAME,
MIXXX_MANUAL_SHORTCUTS_URL);
QString keyboardShortcutsSuffix =
keyboardShortcutsUrl.isLocalFile() ? QString() : externalLinkSuffix;
QString shortcutsTitle = tr("&Keyboard Shortcuts") + keyboardShortcutsSuffix;
QString shortcutsText = tr("Speed up your workflow with keyboard shortcuts.");
auto* pHelpKbdShortcuts = new QAction(shortcutsTitle, this);
pHelpKbdShortcuts->setStatusTip(shortcutsText);
pHelpKbdShortcuts->setWhatsThis(buildWhatsThis(shortcutsTitle, shortcutsText));
connect(pHelpKbdShortcuts,
&QAction::triggered,
this,
[this, keyboardShortcutsUrl] {
slotVisitUrl(keyboardShortcutsUrl);
});
pHelpMenu->addAction(pHelpKbdShortcuts);
// User Settings Directory
const QString& settingsDirPath = m_pConfig->getSettingsPath();
QString settingsDirTitle = tr("&Settings directory");
QString settingsDirText = tr("Open the Mixxx user settings directory.");
auto* pHelpSettingsDir = new QAction(settingsDirTitle, this);
pHelpSettingsDir->setMenuRole(QAction::NoRole);
pHelpSettingsDir->setStatusTip(settingsDirText);
pHelpSettingsDir->setWhatsThis(buildWhatsThis(settingsDirTitle, settingsDirText));
connect(pHelpSettingsDir, &QAction::triggered, this, [this, settingsDirPath] {
slotVisitUrl(QUrl::fromLocalFile(settingsDirPath));
});
pHelpMenu->addAction(pHelpSettingsDir);
// Translate This Application
QString translateTitle = tr("&Translate This Application") + externalLinkSuffix;
QString translateText = tr("Help translate this application into your language.");
auto* pHelpTranslation = new QAction(translateTitle, this);
pHelpTranslation->setStatusTip(translateText);
pHelpTranslation->setWhatsThis(buildWhatsThis(translateTitle, translateText));
connect(pHelpTranslation, &QAction::triggered, this, [this] {
slotVisitUrl(QUrl(MIXXX_TRANSLATION_URL));
});
pHelpMenu->addAction(pHelpTranslation);
pHelpMenu->addSeparator();
QString aboutTitle = tr("&About");
QString aboutText = tr("About the application");
auto* pHelpAboutApp = new QAction(aboutTitle, this);
pHelpAboutApp->setStatusTip(aboutText);
pHelpAboutApp->setWhatsThis(buildWhatsThis(aboutTitle, aboutText));
pHelpAboutApp->setMenuRole(QAction::AboutRole);
connect(pHelpAboutApp, &QAction::triggered, this, &WMainMenuBar::showAbout);
pHelpMenu->addAction(pHelpAboutApp);
addMenu(pHelpMenu);
#ifndef __APPLE__
// Watch focus changes to hide the menubar as soon as all menus are closed,
// e.g. when an action was triggered or when all menus are closed by pressing
// Escape or clicking anywhere else
connect(qApp,
&QApplication::focusWindowChanged,
this,
[this]() {
if (!isNativeMenuBar() && height() > 0 && !activeAction()) {
hideMenuBar();
}
});
// ... and when the focus widget changes (main window or dialogs)
connect(qApp,
// This would work, too, but unfortunately this is also emitted on
// leaveEvent of WStarRating in the library.
// &QApplication::focusObjectChanged,
&QApplication::focusChanged,
this,
[this]() {
if (!isNativeMenuBar() && height() > 0 && !activeAction()) {
hideMenuBar();
}
});
#endif
}
void WMainMenuBar::onKeywheelChange(int state) {
Q_UNUSED(state);
m_pViewKeywheel->setChecked(false);
}
void WMainMenuBar::onLibraryScanStarted() {
emit internalLibraryScanActive(true);
}
void WMainMenuBar::onLibraryScanFinished() {
emit internalLibraryScanActive(false);
}
void WMainMenuBar::onNewSkinLoaded() {
emit internalOnNewSkinLoaded();
}
void WMainMenuBar::onNewSkinAboutToLoad() {
emit internalOnNewSkinAboutToLoad();
}
void WMainMenuBar::onRecordingStateChange(bool recording) {
emit internalRecordingStateChange(recording);
}
void WMainMenuBar::onBroadcastingStateChange(bool broadcasting) {
emit internalBroadcastingStateChange(broadcasting);
}
void WMainMenuBar::onDeveloperToolsShown() {
emit internalDeveloperToolsStateChange(true);
}
void WMainMenuBar::onDeveloperToolsHidden() {
emit internalDeveloperToolsStateChange(false);
}
void WMainMenuBar::onFullScreenStateChange(bool fullscreen) {
#ifndef __APPLE__
// always try to hide the menubar when we switched
hideMenuBar();
#endif
emit internalFullScreenStateChange(fullscreen);
}
#ifndef __APPLE__
void WMainMenuBar::connectMenuToSlotShowMenuBar(const QMenu* pMenu) {
// If a menu hotkey like Alt+F(ile) is pressed while the menubar is hidden,
// show the menubar and open the requested menu. See showMenuBar() for details.
// NOTE(ronso0) Test with xfwm4 and other window managers if you change this
// code or think you found alternative ways to toggle the menubar!
// In Gnome for example, when highlighting (pressed Alt only) or activating
// menus (Alt combos), the menubar receives focusIn events (even while it is
// hidden), and focusOut events respectively when closing menus. Hence we
// could simply show/hide the menubar in QMenuBar::focusInEvent() and focusoutEvent().
// However, with xfwm4 for example, menus are activated directly, i.e. the
// menubar doesn't receive focus change events.
connect(pMenu,
&QMenu::aboutToShow,
this,
[this]() {
if (!isNativeMenuBar() && height() <= 0) {
showMenuBar();
}
});
}
void WMainMenuBar::slotToggleMenuBar() {
if (isNativeMenuBar()) {
return;
}
if (height() > 0) {
hideMenuBar();
} else {
showMenuBar();
}
}
void WMainMenuBar::showMenuBar() {
if (isNativeMenuBar()) {
return;
}
// Note: the resulting resizeEvent() calls QMenuBarPrivate::updateGeometries
// which resets currentAction() to nullptr. So in case the menubar is shown
// in response to a specific menu hotkey (Alt-F), or pressing Alt opens the
// first menu (File) (depends on OS / window manager), the current action
// will be reset to null and menus can't be switched with Left/Right keys
// anymore, i.e. we'd be stuck in the triggered menu.
// Workaround: reselect the active action after unhiding. It can be none,
// user-requested (hotkey) or auto-selected (first menu's first action).
QAction* pAct = activeAction();
setMinimumHeight(sizeHint().height());
// If there was a menu selected before, reselect that.
// Note: with nullptr this would be a no-op. Though, even if no menu is
// selected, hovering a menu would instantly open that (no click required).
if (pAct) {
setActiveAction(pAct);
}
// TODO Alternatively, activate the first menu?
// setActiveAction(pAct ? pAct : actions().first());
}
void WMainMenuBar::hideMenuBar() {
if (isNativeMenuBar()) {
return;
}
if (m_pConfig->getValue<bool>(kHideMenuCfgKey, false)) {
// don't use setHidden(true) because Alt hotkeys wouldn't work anymore
setFixedHeight(0);
}
}
void WMainMenuBar::slotAutoHideMenuBarToggled(bool autoHide) {
m_pConfig->setValue(kHideMenuCfgKey, autoHide);
// Trigger slotUpdateMenuBarAltKeyConnection() inorder to get Alt work immediately
emit menubarAutoHideChanged(autoHide);
// Just in case it was hidden after toggling the menu action
if (!autoHide) {
showMenuBar();
}
}
#endif
void WMainMenuBar::onVinylControlDeckEnabledStateChange(int deck, bool enabled) {
VERIFY_OR_DEBUG_ASSERT(deck >= 0 && deck < m_vinylControlEnabledActions.size()) {
return;
}
m_vinylControlEnabledActions.at(deck)->setChecked(enabled);
}
void WMainMenuBar::slotDeveloperStatsBase(bool enable) {
if (enable) {
Experiment::setBase();
} else {
Experiment::disable();
}
}
void WMainMenuBar::slotDeveloperStatsExperiment(bool enable) {
if (enable) {
Experiment::setExperiment();
} else {
Experiment::disable();
}
}
void WMainMenuBar::slotDeveloperDebugger(bool toggle) {
m_pConfig->setValue(ConfigKey(QStringLiteral("[ScriptDebugger]"), QStringLiteral("Enabled")),
toggle);
}
void WMainMenuBar::slotVisitUrl(const QUrl& url) {
mixxx::DesktopHelper::openUrl(url);
}
void WMainMenuBar::createVisibilityControl(QAction* pAction,
const ConfigKey& key) {
auto* pConnection = new VisibilityControlConnection(this, pAction, key);
connect(this,
&WMainMenuBar::internalOnNewSkinLoaded,
pConnection,
&VisibilityControlConnection::slotReconnectControl);
#ifdef __LINUX__
// reconnect when menu bar was recreated after toggling fullscreen
// so all hotkeys and menu actions continue to work
connect(this,
&WMainMenuBar::internalFullScreenStateChange,
pConnection,
&VisibilityControlConnection::slotReconnectControl);
#endif
connect(this,
&WMainMenuBar::internalOnNewSkinAboutToLoad,
pConnection,
&VisibilityControlConnection::slotClearControl);
}
void WMainMenuBar::onNumberOfDecksChanged(int decks) {
int deck = 0;
for (QAction* pVinylControlEnabled : std::as_const(m_vinylControlEnabledActions)) {
pVinylControlEnabled->setVisible(deck++ < decks);
}
deck = 0;
for (QAction* pLoadToDeck : std::as_const(m_loadToDeckActions)) {
pLoadToDeck->setVisible(deck++ < decks);
}
}
VisibilityControlConnection::VisibilityControlConnection(
QObject* pParent, QAction* pAction, const ConfigKey& key)
: QObject(pParent),
m_key(key),
m_pAction(pAction) {
connect(m_pAction, &QAction::triggered, this, &VisibilityControlConnection::slotActionToggled);
}
void VisibilityControlConnection::slotClearControl() {
m_pControl.reset();
m_pAction->setEnabled(false);
}
void VisibilityControlConnection::slotReconnectControl() {