/
musescore.cpp
5107 lines (4508 loc) · 180 KB
/
musescore.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
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
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2002-2012 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include <fenv.h>
#include "palettebox.h"
#include "config.h"
#include "musescore.h"
#include "scoreview.h"
#include "libmscore/style.h"
#include "libmscore/score.h"
#include "instrdialog.h"
#include "preferences.h"
#include "prefsdialog.h"
#include "icons.h"
#include "textstyle.h"
#include "libmscore/xml.h"
#include "seq.h"
#include "libmscore/tempo.h"
#include "libmscore/sym.h"
#include "pagesettings.h"
#include "debugger/debugger.h"
#include "editstyle.h"
#include "playpanel.h"
#include "libmscore/page.h"
#include "mixer.h"
#include "selectionwindow.h"
#include "palette.h"
#include "palettebox.h"
#include "libmscore/part.h"
#include "libmscore/drumset.h"
#include "libmscore/instrtemplate.h"
#include "libmscore/note.h"
#include "libmscore/staff.h"
#include "driver.h"
#include "libmscore/harmony.h"
#include "magbox.h"
#include "libmscore/sig.h"
#include "libmscore/undo.h"
#include "synthcontrol.h"
#include "pianoroll.h"
#include "drumroll.h"
#include "scoretab.h"
#include "timedialog.h"
#include "keyedit.h"
#include "harmonyedit.h"
#include "navigator.h"
#include "importmidi/importmidi_panel.h"
#include "libmscore/chord.h"
#include "mstyle/mstyle.h"
#include "mstyle/mconfig.h"
#include "libmscore/segment.h"
#include "editraster.h"
#include "pianotools.h"
#include "mediadialog.h"
#include "workspace.h"
#include "selectdialog.h"
#include "transposedialog.h"
#include "metaedit.h"
#include "inspector/inspector.h"
#ifdef OMR
#include "omrpanel.h"
#endif
#include "shortcut.h"
#ifdef SCRIPT_INTERFACE
#include "pluginCreator.h"
#include "pluginManager.h"
#endif
#include "helpBrowser.h"
#include "drumtools.h"
#include "editstafftype.h"
#include "texttools.h"
#include "textpalette.h"
#include "resourceManager.h"
#include "scoreaccessibility.h"
#include "libmscore/mscore.h"
#include "libmscore/system.h"
#include "libmscore/measure.h"
#include "libmscore/chordlist.h"
#include "libmscore/volta.h"
#include "libmscore/lasso.h"
#include "libmscore/excerpt.h"
#include "driver.h"
#include "effects/zita1/zita.h"
#include "effects/compressor/compressor.h"
#include "effects/noeffect/noeffect.h"
#include "synthesizer/synthesizer.h"
#include "synthesizer/synthesizergui.h"
#include "synthesizer/msynthesizer.h"
#include "fluid/fluid.h"
#include "qmlplugin.h"
#include "accessibletoolbutton.h"
#include "searchComboBox.h"
#include "startcenter.h"
#include "help.h"
#include "awl/aslider.h"
#ifdef AEOLUS
extern Ms::Synthesizer* createAeolus();
#endif
#ifdef ZERBERUS
extern Ms::Synthesizer* createZerberus();
#endif
namespace Ms {
MuseScore* mscore;
MasterSynthesizer* synti;
bool enableExperimental = false;
bool enableTestMode = false;
QString dataPath;
QString iconPath;
bool converterMode = false;
bool externalIcons = false;
bool pluginMode = false;
static bool startWithNewScore = false;
double converterDpi = 0;
double guiScaling = 1.0;
int trimMargin = -1;
bool noWebView = false;
bool exportScoreParts = false;
QString mscoreGlobalShare;
static QString outFileName;
static QString audioDriver;
static QString pluginName;
static QString styleFile;
static bool scoresOnCommandline { false };
QString localeName;
bool useFactorySettings = false;
bool deletePreferences = false;
QString styleName;
QString revision;
QErrorMessage* errorMessage;
const char* voiceActions[] = { "voice-1", "voice-2", "voice-3", "voice-4" };
extern bool savePositions(Score*, const QString& name, bool segments );
extern TextPalette* textPalette;
static constexpr double SCALE_MAX = 16.0;
static constexpr double SCALE_MIN = 0.05;
static constexpr double SCALE_STEP = 1.7;
//---------------------------------------------------------
// cmdInsertMeasure
//---------------------------------------------------------
void MuseScore::cmdInsertMeasures()
{
if (cs) {
if (cs->selection().isNone() && !cs->selection().findMeasure()) {
QMessageBox::warning(0, "MuseScore",
tr("No measure selected:\n" "Please select a measure and try again"));
}
else {
insertMeasuresDialog = new InsertMeasuresDialog;
insertMeasuresDialog->show();
}
}
}
//---------------------------------------------------------
// InsertMeasuresDialog
//---------------------------------------------------------
InsertMeasuresDialog::InsertMeasuresDialog(QWidget* parent)
: QDialog(parent)
{
setupUi(this);
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
insmeasures->selectAll();
}
//---------------------------------------------------------
// Insert Measure --> accept
//---------------------------------------------------------
void InsertMeasuresDialog::accept()
{
int n = insmeasures->value();
if (mscore->currentScore())
mscore->currentScoreView()->cmdInsertMeasures(n, Element::Type::MEASURE);
done(1);
}
//---------------------------------------------------------
// getSharePath
//---------------------------------------------------------
QString getSharePath()
{
#ifdef Q_OS_WIN
QDir dir(QCoreApplication::applicationDirPath() + QString("/../" INSTALL_NAME));
return dir.absolutePath() + "/";
#else
#ifdef Q_OS_MAC
QDir dir(QCoreApplication::applicationDirPath() + QString("/../Resources"));
return dir.absolutePath() + "/";
#else
return QString( INSTPREFIX "/share/" INSTALL_NAME);
#endif
#endif
}
//---------------------------------------------------------
// printVersion
//---------------------------------------------------------
static void printVersion(const char* prog)
{
if (MuseScore::unstable())
fprintf(stderr, "%s: Music Score Editor\nUnstable Prerelease for Version %s; Build %s\n",
prog, VERSION, qPrintable(revision));
else
fprintf(stderr, "%s: Music Score Editor; Version %s; Build %s\n", prog, VERSION, qPrintable(revision));
}
static const int RECENT_LIST_SIZE = 20;
//---------------------------------------------------------
// closeEvent
//---------------------------------------------------------
void MuseScore::closeEvent(QCloseEvent* ev)
{
unloadPlugins();
QList<Score*> removeList;
foreach(Score* score, scoreList) {
if (score->created() && !score->dirty())
removeList.append(score);
else {
if (checkDirty(score)) { // ask user if file is dirty
ev->ignore();
return;
}
//
// if score is still dirty, then the user has discarded the
// score and we can remove it from the list
//
if (score->created() && score->dirty())
removeList.append(score);
}
}
// remove all new created/not save score so they are
// note saved as session data
foreach(Score* score, removeList)
scoreList.removeAll(score);
writeSessionFile(true);
foreach(Score* score, scoreList) {
if (!score->tmpName().isEmpty()) {
QFile f(score->tmpName());
f.remove();
}
}
writeSettings();
_loginManager->save();
ev->accept();
if (preferences.dirty)
preferences.write();
this->deleteLater(); //this is necessary on windows http://musescore.org/node/16713
qApp->quit();
}
//---------------------------------------------------------
// preferencesChanged
//---------------------------------------------------------
void MuseScore::preferencesChanged()
{
for (int i = 0; i < tab1->count(); ++i) {
ScoreView* canvas = tab1->view(i);
if (canvas == 0)
continue;
if (preferences.bgUseColor)
canvas->setBackground(MScore::bgColor);
else {
QPixmap* pm = new QPixmap(preferences.bgWallpaper);
canvas->setBackground(pm);
}
if (preferences.fgUseColor)
canvas->setForeground(preferences.fgColor);
else {
QPixmap* pm = new QPixmap(preferences.fgWallpaper);
if (pm == 0 || pm->isNull())
qDebug("no valid pixmap %s", preferences.fgWallpaper.toLatin1().data());
canvas->setForeground(pm);
}
}
if (tab2) {
for (int i = 0; i < tab2->count(); ++i) {
ScoreView* canvas = tab2->view(i);
if (canvas == 0)
continue;
if (preferences.bgUseColor)
canvas->setBackground(MScore::bgColor);
else {
QPixmap* pm = new QPixmap(preferences.bgWallpaper);
canvas->setBackground(pm);
}
if (preferences.fgUseColor)
canvas->setForeground(preferences.fgColor);
else {
QPixmap* pm = new QPixmap(preferences.fgWallpaper);
if (pm == 0 || pm->isNull())
qDebug("no valid pixmap %s", preferences.fgWallpaper.toLatin1().data());
canvas->setForeground(pm);
}
}
}
transportTools->setEnabled(!noSeq && seq && seq->isRunning());
playId->setEnabled(!noSeq && seq && seq->isRunning());
getAction("midi-on")->setEnabled(preferences.enableMidiInput);
_statusBar->setVisible(preferences.showStatusBar);
updateNewWizard();
}
//---------------------------------------------------------
// MuseScore
//---------------------------------------------------------
MuseScore::MuseScore()
: QMainWindow()
{
QScreen* screen = QGuiApplication::primaryScreen();
_physicalDotsPerInch = screen->physicalDotsPerInch(); // physical resolution
_physicalDotsPerInch *= guiScaling;
_sstate = STATE_INIT;
setWindowTitle(QString(MUSESCORE_NAME_VERSION));
setIconSize(QSize(preferences.iconWidth * guiScaling, preferences.iconHeight * guiScaling));
ucheck = new UpdateChecker();
setAcceptDrops(true);
setFocusPolicy(Qt::NoFocus);
if (!preferences.styleName.isEmpty()) {
QFile f(preferences.styleName);
if (f.open(QIODevice::ReadOnly)) {
MScore::defaultStyle()->load(&f);
f.close();
}
}
if (!converterMode && !pluginMode) {
_loginManager = new LoginManager(this);
// initialize help engine
QString lang = mscore->getLocaleISOCode();
if (lang == "en_US") // HACK
lang = "en";
QString s = getSharePath() + "manual/doc_" + lang + ".qhc";
qDebug("init Help from: <%s>", qPrintable(s));
_helpEngine = new QHelpEngine(s, this);
if (!_helpEngine->setupData()) {
qDebug("cannot setup data for help engine: %s", qPrintable(_helpEngine->error()));
delete _helpEngine;
_helpEngine = 0;
}
}
_positionLabel = new QLabel;
_positionLabel->setObjectName("decoration widget"); // this prevents animations
_positionLabel->setToolTip(tr("Measure:Beat:Tick"));
_modeText = new QLabel;
_modeText->setAutoFillBackground(false);
_modeText->setObjectName("modeLabel");
_statusBar = new QStatusBar;
hRasterAction = getAction("hraster");
vRasterAction = getAction("vraster");
loopAction = getAction("loop");
loopInAction = getAction("loop-in");
loopOutAction = getAction("loop-out");
metronomeAction = getAction("metronome");
countInAction = getAction("countin");
panAction = getAction("pan");
_statusBar->addPermanentWidget(new QWidget(this), 2);
_statusBar->addPermanentWidget(new QWidget(this), 100);
_statusBar->addPermanentWidget(_modeText, 0);
if (enableExperimental) {
layerSwitch = new QComboBox(this);
layerSwitch->setToolTip(tr("Switch layer"));
connect(layerSwitch, SIGNAL(activated(const QString&)), SLOT(switchLayer(const QString&)));
playMode = new QComboBox(this);
playMode->addItem(tr("synthesizer"));
playMode->addItem(tr("audio track"));
playMode->setToolTip(tr("Switch play mode"));
connect(playMode, SIGNAL(activated(int)), SLOT(switchPlayMode(int)));
_statusBar->addPermanentWidget(playMode);
_statusBar->addPermanentWidget(layerSwitch);
}
_statusBar->addPermanentWidget(_positionLabel, 0);
setStatusBar(_statusBar);
ScoreAccessibility::createInstance(this);
// otherwise unused actions:
// must be added somewere to work
QActionGroup* ag = Shortcut::getActionGroupForWidget(MsWidget::MAIN_WINDOW);
ag->setParent(this);
addActions(ag->actions());
connect(ag, SIGNAL(triggered(QAction*)), SLOT(cmd(QAction*)));
mainWindow = new QSplitter;
mainWindow->setChildrenCollapsible(false);
mainWindow->setOrientation(Qt::Vertical);
QWidget* mainScore = new QWidget;
mainScore->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
mainWindow->addWidget(mainScore);
layout = new QVBoxLayout;
layout->setMargin(0);
layout->setSpacing(0);
mainScore->setLayout(layout);
_navigator = new NScrollArea;
_navigator->setFocusPolicy(Qt::NoFocus);
mainWindow->addWidget(_navigator);
showNavigator(preferences.showNavigator);
mainWindow->setStretchFactor(0, 1);
mainWindow->setStretchFactor(1, 0);
mainWindow->setSizes(QList<int>({500, 50}));
QSplitter* envelope = new QSplitter;
envelope->setChildrenCollapsible(false);
envelope->setOrientation(Qt::Vertical);
envelope->addWidget(mainWindow);
importmidiPanel = new ImportMidiPanel(this);
importmidiPanel->setVisible(false);
envelope->addWidget(importmidiPanel);
{
importmidiShowPanel = new QFrame;
QHBoxLayout *hl = new QHBoxLayout;
hl->setMargin(0);
hl->setSpacing(0);
importmidiShowPanel->setLayout(hl);
QPushButton *b = new QPushButton(tr("Show MIDI import panel"));
b->setFocusPolicy(Qt::ClickFocus);
importmidiShowPanel->setVisible(false);
connect(b, SIGNAL(clicked()), SLOT(showMidiImportPanel()));
connect(importmidiPanel, SIGNAL(closeClicked()), importmidiShowPanel, SLOT(show()));
hl->addWidget(b);
QSpacerItem *item = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed);
hl->addSpacerItem(item);
envelope->addWidget(importmidiShowPanel);
}
envelope->setSizes(QList<int>({550, 180}));
splitter = new QSplitter;
tab1 = new ScoreTab(&scoreList, this);
tab1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
connect(tab1, SIGNAL(currentScoreViewChanged(ScoreView*)), SLOT(setCurrentScoreView(ScoreView*)));
connect(tab1, SIGNAL(tabCloseRequested(int)), SLOT(removeTab(int)));
connect(tab1, SIGNAL(actionTriggered(QAction*)), SLOT(cmd(QAction*)));
splitter->addWidget(tab1);
if (splitScreen()) {
tab2 = new ScoreTab(&scoreList, this);
tab2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
connect(tab2, SIGNAL(currentScoreViewChanged(ScoreView*)), SLOT(setCurrentScoreView(ScoreView*)));
connect(tab2, SIGNAL(tabCloseRequested(int)), SLOT(removeTab(int)));
connect(tab2, SIGNAL(actionTriggered(QAction*)), SLOT(cmd(QAction*)));
splitter->addWidget(tab2);
tab2->setVisible(false);
}
else
tab2 = 0;
layout->addWidget(splitter);
//---------------------------------------------------
// Transport Action
//---------------------------------------------------
QAction* a;
#ifdef HAS_MIDI
a = getAction("midi-on");
a->setEnabled(preferences.enableMidiInput);
a->setChecked(_midiinEnabled);
#endif
getAction("undo")->setEnabled(false);
getAction("redo")->setEnabled(false);
getAction("paste")->setEnabled(false);
selectionChanged(SelState::NONE);
//---------------------------------------------------
// File Action
//---------------------------------------------------
//---------------------
// Tool Bar
//---------------------
fileTools = addToolBar(tr("File Operations"));
fileTools->setObjectName("file-operations");
for (auto i : { "file-new", "file-open", "file-save", "print", "undo", "redo"})
fileTools->addWidget(new AccessibleToolButton(fileTools, getAction(i)));
fileTools->addSeparator();
mag = new MagBox;
connect(mag, SIGNAL(magChanged(MagIdx)), SLOT(magChanged(MagIdx)));
fileTools->addWidget(mag);
viewModeCombo = new QComboBox(this);
#if defined(Q_OS_MAC)
viewModeCombo->setFocusPolicy(Qt::StrongFocus);
#else
viewModeCombo->setFocusPolicy(Qt::TabFocus);
#endif
viewModeCombo->setAccessibleName(tr("View Mode"));
viewModeCombo->setFixedHeight(preferences.iconHeight + 8); // hack
viewModeCombo->addItem(tr("Page View"), int(LayoutMode::PAGE));
viewModeCombo->addItem(tr("Continuous View"), int(LayoutMode::LINE));
if (enableExperimental)
viewModeCombo->addItem(tr("Single Page"), int(LayoutMode::SYSTEM));
connect(viewModeCombo, SIGNAL(activated(int)), SLOT(switchLayoutMode(int)));
fileTools->addWidget(viewModeCombo);
transportTools = addToolBar(tr("Transport Tools"));
transportTools->setObjectName("transport-tools");
#ifdef HAS_MIDI
transportTools->addWidget(new AccessibleToolButton(transportTools, getAction("midi-on")));
transportTools->addSeparator();
#endif
transportTools->addWidget(new AccessibleToolButton(transportTools, getAction("rewind")));
_playButton = new AccessibleToolButton(transportTools, getAction("play"));
transportTools->addWidget(_playButton);
transportTools->addWidget(new AccessibleToolButton(transportTools, getAction("loop")));
transportTools->addSeparator();
QAction* repeatAction = getAction("repeat");
repeatAction->setChecked(MScore::playRepeats);
transportTools->addWidget(new AccessibleToolButton(transportTools, repeatAction));
transportTools->addWidget(new AccessibleToolButton(transportTools, getAction("pan")));
transportTools->addWidget(new AccessibleToolButton(transportTools, metronomeAction));
cpitchTools = addToolBar(tr("Concert Pitch"));
cpitchTools->setObjectName("pitch-tools");
cpitchTools->addWidget(new AccessibleToolButton( cpitchTools, getAction("concert-pitch")));
QToolBar* foto = addToolBar(tr("Image Capture"));
foto->setObjectName("foto-tools");
foto->addWidget(new AccessibleToolButton(foto, getAction("fotomode")));
addToolBarBreak();
//-------------------------------
// Note Input Tool Bar
//-------------------------------
entryTools = addToolBar(tr("Note Input"));
entryTools->setObjectName("entry-tools");
static const char* sl1[] = {
"note-input",
"repitch", "pad-note-128", "pad-note-64", "pad-note-32", "pad-note-16",
"pad-note-8",
"pad-note-4", "pad-note-2", "pad-note-1", "note-breve", "note-longa",
"pad-dot",
"pad-dotdot", "tie", "", "pad-rest", "",
"sharp2", "sharp", "nat", "flat", "flat2", "flip", ""
};
for (auto s : sl1) {
if (!*s)
entryTools->addSeparator();
else
entryTools->addAction(getAction(s));
}
static const char* vbsh { "QToolButton:checked, QToolButton:pressed { color: white;}" };
for (int i = 0; i < VOICES; ++i) {
QToolButton* tb = new QToolButton(this);
if (preferences.globalStyle == MuseScoreStyleType::LIGHT)
tb->setStyleSheet(vbsh);
tb->setToolButtonStyle(Qt::ToolButtonTextOnly);
QPalette p(tb->palette());
p.setColor(QPalette::Base, MScore::selectColor[i]);
tb->setPalette(p);
QAction* a = getAction(voiceActions[i]);
a->setCheckable(true);
tb->setDefaultAction(a);
tb->setFocusPolicy(Qt::ClickFocus);
entryTools->addWidget(tb);
}
//---------------------
// Menus
//---------------------
QMenuBar* mb = menuBar();
//---------------------
// Menu File
//---------------------
_fileMenu = mb->addMenu(tr("&File"));
_fileMenu->setObjectName("File");
_fileMenu->addAction(getAction("file-new"));
_fileMenu->addAction(getAction("file-open"));
openRecent = _fileMenu->addMenu(tr("Open &Recent"));
connect(openRecent, SIGNAL(aboutToShow()), SLOT(openRecentMenu()));
connect(openRecent, SIGNAL(triggered(QAction*)), SLOT(selectScore(QAction*)));
for (auto i : {
"", "file-save", "file-save-as", "file-save-a-copy",
"file-save-selection", "file-save-online", "file-export", "file-part-export", "file-import-pdf",
"", "file-close", "", "parts", "album" }) {
if (!*i)
_fileMenu->addSeparator();
else
_fileMenu->addAction(getAction(i));
}
if (enableExperimental)
_fileMenu->addAction(getAction("layer"));
_fileMenu->addSeparator();
_fileMenu->addAction(getAction("edit-info"));
if (enableExperimental)
_fileMenu->addAction(getAction("media"));
_fileMenu->addSeparator();
_fileMenu->addAction(getAction("print"));
#ifndef Q_OS_MAC
_fileMenu->addSeparator();
_fileMenu->addAction(getAction("quit"));
#endif
//---------------------
// Menu Edit
//---------------------
menuEdit = mb->addMenu(tr("&Edit"));
menuEdit->setObjectName("Edit");
menuEdit->addAction(getAction("undo"));
menuEdit->addAction(getAction("redo"));
menuEdit->addSeparator();
menuEdit->addAction(getAction("cut"));
menuEdit->addAction(getAction("copy"));
menuEdit->addAction(getAction("paste"));
menuEdit->addSeparator();
menuEdit->addAction(getAction("select-all"));
menuEdit->addAction(getAction("select-section"));
menuEdit->addAction(getAction("find"));
menuEdit->addSeparator();
menuEdit->addAction(getAction("instruments"));
QMenu* menuMeasure = new QMenu(tr("&Measure"));
for (auto i : { "delete-measures", "split-measure", "join-measure" })
menuMeasure->addAction(getAction(i));
menuEdit->addMenu(menuMeasure);
QMenu* menuTools = new QMenu(tr("&Tools"));
for (auto i : { "add-remove-breaks", "explode", "implode", "slash-fill", "slash-rhythm", "resequence-rehearsal-marks", "copy-lyrics-to-clipboard" })
menuTools->addAction(getAction(i));
menuEdit->addMenu(menuTools);
QMenu* menuVoices = new QMenu(tr("&Voices"));
for (auto i : { "voice-x12", "voice-x13", "voice-x14", "voice-x23", "voice-x24", "voice-x34" })
menuVoices->addAction(getAction(i));
menuEdit->addMenu(menuVoices);
#ifdef NDEBUG
if (enableExperimental) {
#endif
menuEdit->addSeparator();
menuEdit->addAction(getAction("debugger"));
#ifdef NDEBUG
}
#endif
menuEdit->addSeparator();
menuWorkspaces = new QMenu(tr("W&orkspaces"));
connect(menuWorkspaces, SIGNAL(aboutToShow()), SLOT(showWorkspaceMenu()));
menuEdit->addMenu(menuWorkspaces);
QAction* pref = menuEdit->addAction(tr("&Preferences..."), this, SLOT(startPreferenceDialog()));
pref->setMenuRole(QAction::PreferencesRole);
//---------------------
// Menu View
//---------------------
menuView = mb->addMenu(tr("&View"));
menuView->setObjectName("View");
a = getAction("startcenter");
a->setCheckable(true);
menuView->addAction(a);
a = getAction("toggle-palette");
a->setCheckable(true);
menuView->addAction(a);
a = getAction("masterpalette");
a->setCheckable(true);
menuView->addAction(a);
a = getAction("inspector");
a->setCheckable(true);
menuView->addAction(a);
#ifdef OMR
a = getAction("omr");
a->setCheckable(true);
menuView->addAction(a);
#endif
playId = getAction("toggle-playpanel");
playId->setCheckable(true);
menuView->addAction(playId);
a = getAction("toggle-navigator");
a->setCheckable(true);
a->setChecked(preferences.showNavigator);
menuView->addAction(a);
a = getAction("toggle-mixer");
a->setCheckable(true);
menuView->addAction(a);
a = getAction("synth-control");
a->setCheckable(true);
menuView->addAction(a);
a = getAction("toggle-selection-window");
a->setCheckable(true);
menuView->addAction(a);
a = getAction("toggle-piano");
a->setCheckable(true);
menuView->addAction(a);
menuView->addSeparator();
menuView->addAction(getAction("zoomin"));
menuView->addAction(getAction("zoomout"));
menuView->addSeparator();
// a = getAction("toggle-transport");
// a->setCheckable(true);
// a->setChecked(transportTools->isVisible());
// connect(transportTools, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool)));
// menuView->addAction(a);
// a = getAction("toggle-noteinput");
// a->setCheckable(true);
// a->setChecked(true);
// menuView->addAction(a);
a = getAction("toggle-statusbar");
a->setCheckable(true);
a->setChecked(true);
menuView->addAction(a);
menuView->addSeparator();
a = getAction("split-h");
a->setCheckable(true);
menuView->addAction(a);
a = getAction("split-v");
a->setCheckable(true);
menuView->addAction(a);
menuView->addSeparator();
menuView->addAction(getAction("show-invisible"));
menuView->addAction(getAction("show-unprintable"));
menuView->addAction(getAction("show-frames"));
menuView->addAction(getAction("show-pageborders"));
menuView->addSeparator();
a = getAction("fullscreen");
a->setCheckable(true);
a->setChecked(false);
menuView->addAction(a);
//---------------------
// Menu Create
//---------------------
mb->addMenu(genCreateMenu(mb));
//---------------------
// Menu Notes
//---------------------
menuNotes = mb->addMenu(qApp->translate("MenuNotes", "&Notes"));
menuNotes->setObjectName("Notes");
menuNotes->addAction(getAction("note-input"));
menuNotes->addAction(getAction("pitch-spell"));
menuNotes->addSeparator();
QMenu* menuAddPitch = new QMenu(tr("Add N&ote"));
for (int i = 0; i < 7; ++i) {
char buffer[8];
sprintf(buffer, "note-%c", "cdefgab"[i]);
a = getAction(buffer);
menuAddPitch->addAction(a);
}
menuNotes->addMenu(menuAddPitch);
for (int i = 0; i < 7; ++i) {
char buffer[8];
sprintf(buffer, "chord-%c", "cdefgab"[i]);
a = getAction(buffer);
menuAddPitch->addAction(a);
}
QMenu* menuAddInterval = new QMenu(tr("Add &Interval"));
for (int i = 1; i < 10; ++i) {
char buffer[16];
sprintf(buffer, "interval%d", i);
a = getAction(buffer);
menuAddInterval->addAction(a);
}
menuAddInterval->addSeparator();
for (int i = 2; i < 10; ++i) {
char buffer[16];
sprintf(buffer, "interval-%d", i);
a = getAction(buffer);
menuAddInterval->addAction(a);
}
menuNotes->addMenu(menuAddInterval);
QMenu* menuNtole = new QMenu(tr("T&uplets"));
for (auto i : { "duplet", "triplet", "quadruplet", "quintuplet", "sextuplet",
"septuplet", "octuplet", "nonuplet", "tuplet-dialog" })
menuNtole->addAction(getAction(i));
menuNotes->addMenu(menuNtole);
menuNotes->addSeparator();
menuNotes->addAction(getAction("transpose"));
a = getAction("concert-pitch");
a->setCheckable(true);
menuNotes->addAction(a);
//---------------------
// Menu Layout
//---------------------
menuLayout = mb->addMenu(tr("&Layout"));
menuLayout->setObjectName("Layout");
for (auto i : { "page-settings", "reset", "stretch+", "stretch-", "reset-stretch", "reset-beammode" }) {
QAction* action = getAction(i);
action->setMenuRole(QAction::NoRole);
menuLayout->addAction(action);
}
//---------------------
// Menu Style
//---------------------
menuStyle = mb->addMenu(tr("&Style"));
menuStyle->setObjectName("Style");
menuStyle->addAction(getAction("edit-style"));
menuStyle->addAction(getAction("edit-text-style"));
if (enableExperimental)
menuStyle->addAction(getAction("edit-harmony"));
menuStyle->addSeparator();
menuStyle->addAction(getAction("load-style"));
menuStyle->addAction(getAction("save-style"));
//---------------------
// Menu Plugins
//---------------------
QMenu* menuPlugins = mb->addMenu(tr("&Plugins"));
menuPlugins->setObjectName("Plugins");
menuPlugins->addAction(getAction("plugin-manager"));
a = getAction("plugin-creator");
a->setCheckable(true);
menuPlugins->addAction(a);
menuPlugins->addSeparator();
//---------------------
// Menu Help
//---------------------
mb->addSeparator();
QMenu* menuHelp = mb->addMenu(tr("&Help"));
menuHelp->setObjectName("Help");
#if 0
if (_helpEngine) {
HelpQuery* hw = new HelpQuery(menuHelp);
menuHelp->addAction(hw);
connect(menuHelp, SIGNAL(aboutToShow()), hw, SLOT(setFocus()));
}
#endif
//menuHelp->addAction(getAction("local-help"));
menuHelp->addAction(tr("&Online Handbook"), this, SLOT(helpBrowser1()));
menuHelp->addSeparator();
QAction* aboutAction = new QAction(tr("&About..."), 0);
aboutAction->setMenuRole(QAction::AboutRole);
connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
menuHelp->addAction(aboutAction);
QAction* aboutQtAction = new QAction(tr("About &Qt..."), 0);
aboutQtAction->setMenuRole(QAction::AboutQtRole);
connect(aboutQtAction, SIGNAL(triggered()), this, SLOT(aboutQt()));
menuHelp->addAction(aboutQtAction);
QAction* aboutMusicXMLAction = new QAction(tr("About &MusicXML..."), 0);
aboutMusicXMLAction->setMenuRole(QAction::ApplicationSpecificRole);
connect(aboutMusicXMLAction, SIGNAL(triggered()), this, SLOT(aboutMusicXML()));
menuHelp->addAction(aboutMusicXMLAction);
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
menuHelp->addAction(tr("Check for &Update"), this, SLOT(checkForUpdate()));
#endif
menuHelp->addSeparator();
menuHelp->addAction(tr("Ask for Help"), this, SLOT(askForHelp()));
menuHelp->addAction(tr("Report a Bug"), this, SLOT(reportBug()));
menuHelp->addSeparator();
menuHelp->addAction(getAction("resource-manager"));
//accessibility for menus
foreach (QMenu* menu, mb->findChildren<QMenu*>()) {
menu->setAccessibleName(menu->objectName());
menu->setAccessibleDescription(Shortcut::getMenuShortcutString(menu));
}
setCentralWidget(envelope);
// load cascading instrument templates
loadInstrumentTemplates(preferences.instrumentList1);
if (!preferences.instrumentList2.isEmpty())
loadInstrumentTemplates(preferences.instrumentList2);
preferencesChanged();
if (seq) {
connect(seq, SIGNAL(started()), SLOT(seqStarted()));
connect(seq, SIGNAL(stopped()), SLOT(seqStopped()));
}
loadScoreList();
QClipboard* cb = QApplication::clipboard();
connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged()));
connect(cb, SIGNAL(selectionChanged()), SLOT(clipboardChanged()));
autoSaveTimer = new QTimer(this);
autoSaveTimer->setSingleShot(true);
connect(autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSaveTimerTimeout()));
initOsc();
startAutoSave();