1 //=============================================================================
2 //  MuseScore
3 //  Music Composition & Notation
4 //
5 //  Copyright (C) 2002-2016 Werner Schweer and others
6 //
7 //  This program is free software; you can redistribute it and/or modify
8 //  it under the terms of the GNU General Public License version 2.
9 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //=============================================================================
19 
20 #ifndef __MUSESCORE_H__
21 #define __MUSESCORE_H__
22 
23 #include "config.h"
24 #include "globals.h"
25 #include "singleapp/src/QtSingleApplication"
26 #include "updatechecker.h"
27 #include "libmscore/musescoreCore.h"
28 #include "libmscore/score.h"
29 #include "sessionstatusobserver.h"
30 
31 namespace Ms {
32 
33 class UploadScoreDialog;
34 class LoginManager;
35 class AboutBoxDialog;
36 class AboutMusicXMLBoxDialog;
37 class InsertMeasuresDialog;
38 class MeasuresDialog;
39 class Shortcut;
40 class ScoreView;
41 class Element;
42 class PreferenceDialog;
43 class InstrumentsDialog;
44 class Instrument;
45 class MidiFile;
46 class TextStyleDialog;
47 class PlayPanel;
48 class IPlayPanel;
49 class Mixer;
50 class Debugger;
51 class MeasureListEditor;
52 class MasterScore;
53 class Score;
54 class Tuplet;
55 class PageSettings;
56 class Palette;
57 class PaletteScrollArea;
58 class SelectionWindow;
59 class XmlWriter;
60 class ZoomBox;
61 class NewWizard;
62 class ExcerptsDialog;
63 class ExportDialog;
64 class SynthControl;
65 class PianorollEditor;
66 class DrumrollEditor;
67 class Staff;
68 class ScoreTab;
69 class Drumset;
70 class TextTools;
71 class DrumTools;
72 class KeyEditor;
73 class ChordStyleEditor;
74 class Navigator;
75 class Timeline;
76 class PianoTools;
77 class MediaDialog;
78 class Workspace;
79 class WorkspaceDialog;
80 class AlbumManager;
81 class WebPageDockWidget;
82 class ChordList;
83 class Capella;
84 class Inspector;
85 class OmrPanel;
86 class NScrollArea;
87 class TDockWidget;
88 class Sym;
89 class MasterPalette;
90 class PluginCreator;
91 class MsQmlEngine;
92 #ifdef SCRIPT_INTERFACE
93 class PluginManager;
94 class QmlPluginEngine;
95 #endif
96 class MasterSynthesizer;
97 class SynthesizerState;
98 class Driver;
99 class Seq;
100 class ImportMidiPanel;
101 class ScoreComparisonTool;
102 class ScriptRecorder;
103 class ScriptRecorderWidget;
104 class Startcenter;
105 class HelpBrowser;
106 class ToolbarEditor;
107 class TourHandler;
108 class GeneralAutoUpdater;
109 class EditStyle;
110 
111 class PalettePanel;
112 struct PaletteTree;
113 class PaletteWidget;
114 class PaletteWorkspace;
115 class QmlDockWidget;
116 
117 struct PluginDescription;
118 enum class SelState : char;
119 enum class IconType : signed char;
120 enum class ZoomIndex : char;
121 
122 extern QString mscoreGlobalShare;
123 extern QString revision;
124 static const int PROJECT_LIST_LEN = 6;
125 extern const char* voiceActions[];
126 extern bool mscoreFirstStart;
127 
128 QString localeName();
129 
130 using NotesColors = QHash<int /* noteIndex */, QColor>;
131 
132 //---------------------------------------------------------
133 //   IconActions
134 //---------------------------------------------------------
135 
136 struct IconAction {
137       IconType subtype;
138       const char* action;
139       };
140 
141 //---------------------------------------------------------
142 //   LanguageItem
143 //---------------------------------------------------------
144 
145 struct LanguageItem {
146       QString key;
147       QString name;
148       QString handbook;
LanguageItemLanguageItem149       LanguageItem(const QString k, const QString n) {
150             key = k;
151             name = n;
152             handbook = QString();
153             }
LanguageItemLanguageItem154       LanguageItem(const QString k, const QString n, const QString h) {
155             key = k;
156             name = n;
157             handbook = h;
158             }
159       };
160 
161 //---------------------------------------------------------
162 //   SaveReplacePolicy
163 //---------------------------------------------------------
164 
165 enum class SaveReplacePolicy {
166       NO_CHOICE,
167       SKIP_ALL,
168       REPLACE_ALL
169       };
170 
171 //---------------------------------------------------------
172 //   MuseScoreApplication (mac only)
173 //---------------------------------------------------------
174 
175 class MuseScoreApplication : public QtSingleApplication {
176    public:
177       QStringList paths;
MuseScoreApplication(const QString & id,int & argc,char ** argv)178       MuseScoreApplication(const QString& id, int &argc, char **argv)
179          : QtSingleApplication(id, argc, argv) {
180             };
181       virtual bool event(QEvent *ev) override;
182 
183       struct CommandLineParseResult {
184             QStringList argv;
185             bool exit = false;
186             };
187       static CommandLineParseResult parseCommandLineArguments(MuseScoreApplication* app);
188       static MuseScoreApplication* initApplication(int& argc, char** argv);
189 
190       static bool setCustomConfigFolder(const QString& path);
191       };
192 
193 
194 //---------------------------------------------------------
195 //   MuseScore
196 //---------------------------------------------------------
197 
198 class MuseScore : public QMainWindow, public MuseScoreCore {
199       Q_OBJECT
200 
201       QSettings settings;
202       ScoreView* cv                        { 0 };
203       ScoreTab* ctab                       { 0 };
204       QMap<MasterScore*, bool> scoreWasShown; // whether each score in scoreList has ever been shown
205       ScoreState _sstate;
206       UpdateChecker* ucheck;
207       ExtensionsUpdateChecker* packUChecker = nullptr;
208 
209       static const std::list<const char*> _allNoteInputMenuEntries;
210       std::list<const char*> _noteInputMenuEntries { _allNoteInputMenuEntries };
211 
212       static const std::list<const char*> _allFileOperationEntries;
213       std::list<const char*> _fileOperationEntries { _allFileOperationEntries };
214 
215       static const std::list<const char*> _allPlaybackControlEntries;
216       std::list<const char*> _playbackControlEntries { _allPlaybackControlEntries };
217 
218       bool _playPartOnly = true; // play part only vs. full score
219 
220       QVBoxLayout* layout;    // main window layout
221       QSplitter* splitter;
222       ScoreTab* tab1;
223       ScoreTab* tab2;
224       NScrollArea* _navigator;
225       TDockWidget* _timeline;
226       ImportMidiPanel* importmidiPanel     { 0 };
227       QFrame* importmidiShowPanel;
228       QSplitter* mainWindow;
229 
230       ScoreComparisonTool* scoreCmpTool    { 0 };
231       ScriptRecorderWidget* scriptRecorder { nullptr };
232 
233       ZoomBox* zoomBox                     { nullptr };
234       QComboBox* viewModeCombo             { nullptr };
235       QAction* playId;
236 
237       QAction* pref;
238       QAction* onlineHandbookAction;
239       QAction* aboutAction;
240       QAction* aboutQtAction;
241       QAction* aboutMusicXMLAction;
242       QAction* checkForUpdateAction        { 0 };
243       QAction* askForHelpAction;
244       QAction* reportBugAction;
245       QAction* leaveFeedbackAction;
246       QAction* revertToFactoryAction;
247 
248       QProgressBar* _progressBar           { 0 };
249       PreferenceDialog* preferenceDialog   { 0 };
250       QToolBar* cpitchTools;
251       QToolBar* fotoTools;
252       QToolBar* fileTools;
253       QToolBar* transportTools;
254       QToolBar* entryTools;
255       QToolBar* feedbackTools;
256       QToolBar* workspacesTools;
257       TextTools* _textTools                { 0 };
258       PianoTools* _pianoTools              { 0 };
259       MediaDialog* _mediaDialog            { 0 };
260       DrumTools* _drumTools                { 0 };
261       QToolBar* voiceTools;
262       InstrumentsDialog* instrList         { 0 };
263       MeasuresDialog* measuresDialog       { 0 };
264       InsertMeasuresDialog* insertMeasuresDialog { 0 };
265       MasterPalette* masterPalette         { 0 };
266       PluginCreator* _pluginCreator        { 0 };
267 #ifdef SCRIPT_INTERFACE
268       PluginManager* pluginManager         { 0 };
269       QmlPluginEngine* _qmlEngine          { 0 };
270 #endif
271       MsQmlEngine* _qmlUiEngine            { 0 };
272       SelectionWindow* selectionWindow     { 0 };
273 
274       QMenu* menuFile;
275       QMenu* openRecent;
276       QMenu* menuEdit;
277       QMenu* menuView;
278       QMenu* menuToolbars;
279       QMenu* menuWorkspaces;
280 
281       QMenu* menuAdd;
282       QMenu* menuAddMeasures;
283       QMenu* menuAddFrames;
284       QMenu* menuAddText;
285       QMenu* menuAddLines;
286       QMenu* menuAddPitch;
287       QMenu* menuAddInterval;
288       QMenu* menuTuplet;
289 
290       QMenu* menuFormat;
291       QMenu* menuStretch;
292       QMenu* menuTools;
293       QMenu* menuVoices;
294       QMenu* menuMeasure;
295 
296       QMenu* menuPlugins;
297       QMenu* menuHelp;
298       QMenu* menuTours;
299 #ifndef NDEBUG
300       QMenu* menuDebug;
301 #endif
302       AlbumManager* albumManager           { 0 };
303       ExportDialog* exportDialog           { 0 };
304 
305       QWidget* _searchDialog               { 0 };
306       QComboBox* searchCombo;
307 
308       PlayPanel* playPanel                 { 0 };
309       Mixer* mixer                         { 0 };
310       SynthControl* synthControl           { 0 };
311       Debugger* debugger                   { 0 };
312       MeasureListEditor* measureListEdit   { 0 };
313       PageSettings* pageSettings           { 0 };
314 
315       QWidget* symbolDialog                { 0 };
316 
317       PaletteScrollArea* clefPalette       { 0 };
318       PaletteScrollArea* keyPalette        { 0 };
319       KeyEditor* keyEditor                 { 0 };
320       ChordStyleEditor* chordStyleEditor   { 0 };
321       QStatusBar* _statusBar;
322       QLabel* _modeText;
323       QLabel* _positionLabel;
324       NewWizard* newWizard           { 0 };
325       HelpBrowser* helpBrowser       { 0 };
326       QDockWidget* manualDock        { 0 };
327 
328       PaletteWorkspace* paletteWorkspace { nullptr };
329       PaletteWidget* paletteWidget { nullptr };
330 
331       Inspector* _inspector          { 0 };
332       OmrPanel* omrPanel             { 0 };
333       QWidget* lastFocusWidget       { 0 };
334 
335       QPushButton* showMidiImportButton {0};
336 
337       QList<QString> plugins;
338       QString pluginPath;
339 
340 #ifdef SCRIPT_INTERFACE
341       void createMenuEntry(PluginDescription*);
342       void removeMenuEntry(PluginDescription*);
343 #endif
344 
345       QTimer* autoSaveTimer;
346       QList<QAction*> pluginActions;
347 
348       PianorollEditor* pianorollEditor   { 0 };
349       DrumrollEditor* drumrollEditor     { 0 };
350       bool _splitScreen                  { false };
351       bool _horizontalSplit              { true  };
352 
353       QString rev;
354 
355       int _midiRecordId                  { -1 };
356 
357       bool _fullscreen                   { false };
358       QList<LanguageItem> _languages;
359 
360       Startcenter* startcenter             { 0 };
361       QWidget* loginDialog                 { 0 };
362       UploadScoreDialog* uploadScoreDialog { 0 };
363       LoginManager* _loginManager        { 0 };
364       QFileDialog* loadScoreDialog       { 0 };
365       QFileDialog* saveScoreDialog       { 0 };
366       QFileDialog* loadStyleDialog       { 0 };
367       QFileDialog* saveStyleDialog       { 0 };
368       QFileDialog* saveImageDialog       { 0 };
369       QFileDialog* loadChordStyleDialog  { 0 };
370       QFileDialog* saveChordStyleDialog  { 0 };
371       QFileDialog* loadSfzFileDialog     { 0 };
372       QFileDialog* loadBackgroundDialog  { 0 };
373       QFileDialog* loadScanDialog        { 0 };
374       QFileDialog* loadAudioDialog       { 0 };
375       QFileDialog* loadDrumsetDialog     { 0 };
376       QFileDialog* loadPluginDialog      { 0 };
377       QFileDialog* loadPaletteDialog     { 0 };
378       QFileDialog* savePaletteDialog     { 0 };
379       QFileDialog* saveDrumsetDialog     { 0 };
380       QFileDialog* savePluginDialog      { 0 };
381 
382       WorkspaceDialog* _workspaceDialog  { 0 };
383 
384       EditStyle* _styleDlg                { nullptr };
385 
386       QDialog* editRasterDialog          { 0 };
387 
388       QAction* hRasterAction;
389       QAction* vRasterAction;
390 
391       ToolbarEditor* editToolbars        { 0 };
392       QActionGroup* workspaces           { 0 };
393 
394       bool inChordEditor                 { false };
395 
396       QComboBox* layerSwitch;
397       QComboBox* playMode;
398       QNetworkAccessManager* _networkManager { 0 };
399       QAction* lastCmd                       { 0 };
400       const Shortcut* lastShortcut           { 0 };
401       QHelpEngine* _helpEngine               { 0 };
402       int globalX, globalY;       // current mouse position
403 
404       QAction* countInAction;
405       QAction* metronomeAction;
406       QAction* loopAction;
407       QAction* loopInAction;
408       QAction* loopOutAction;
409       QAction* panAction;
410 
411       QLabel* cornerLabel;
412       QStringList _recentScores;
413       QToolButton* _playButton;
414 
415       qreal _physicalDotsPerInch;
416 
417       QMessageBox* infoMsgBox;
418       TourHandler* _tourHandler { 0 };
419 
420       QWindow* _lastFocusWindow { nullptr };
421       bool _lastFocusWindowIsQQuickView { false };
422 
423       std::unique_ptr<GeneralAutoUpdater> autoUpdater;
424 
425       SessionStatusObserver sessionStatusObserver;
426 
427       //---------------------
428 
429       virtual void closeEvent(QCloseEvent*);
430       virtual void dragEnterEvent(QDragEnterEvent*);
431       virtual void dropEvent(QDropEvent*);
432       virtual void changeEvent(QEvent *e);
433       virtual void showEvent(QShowEvent *event);
434 
435       void retranslate();
436       void setMenuTitles();
437       void updateMenu(QMenu*& menu, QString menu_id, QString objectName);
438 
439       void playVisible(bool flag);
440       void launchBrowser(const QString whereTo);
441 
442       void loadScoreList();
443       void editInstrList();
444       void symbolMenu();
445       void showKeyEditor();
446       bool saveFile(MasterScore* score);
447       void fingeringMenu();
448 
449 #ifdef SCRIPT_INTERFACE
450       int  pluginIdxFromPath(QString pluginPath);
451 #endif
452       void startDebugger();
453       void enableMidiIn(bool);
454       void undoRedo(bool undo);
455       void showPalette(bool);
456       void showInspector(bool);
457       void showOmrPanel(bool);
458       void showNavigator(bool);
459       void showTimeline(bool);
460       void showSelectionWindow(bool);
461       void showSearchDialog();
462       void showToolbarEditor();
463       void splitWindow(bool horizontal);
464       void removeSessionFile();
465       void editChordStyle();
466       void startExcerptsDialog();
467       void showExportDialog(const QString& type = "");
468       void initOsc();
469       void editRaster();
470       void showPianoKeyboard(bool);
471       void showMediaDialog();
472       void showAlbumManager();
473       void showLayerManager();
474       void updateUndoRedo();
475       void changeScore(int);
476       virtual void resizeEvent(QResizeEvent*);
477       void showModeText(const QString& s, bool informScreenReader = true);
478       void addRecentScore(const QString& scorePath);
479 
480       void setZoom(const ZoomIndex, const qreal logicalFreeZoomLevel = 0.0);
481       void setZoomWithToggle(const ZoomIndex index);
482       void zoomBySteps(const qreal numSteps);
483       void zoomAndSavePrevious(const std::function<void(void)>& zoomFunction);
484 
485       void updateViewModeCombo();
486 
487       void switchLayoutMode(LayoutMode);
488       void setPlayRepeats(bool repeat);
489       void setPanPlayback(bool pan);
490 
491       void createPlayPanel();
492 
493       ScoreTab* createScoreTab();
494       void askMigrateScore(Score* score);
495 
496       QString getUtmParameters(QString medium) const;
497 
498       void checkForUpdatesNoUI();
499 
500       void doLoadFiles(const QStringList& filter, bool switchTab, bool singleFile);
501 
502       void askAboutApplyingEdwinIfNeed(const QString& fileSuffix);
503 
504    signals:
505       void windowSplit(bool);
506       void musescoreWindowWasShown();
507       void workspacesChanged();
508       void scoreStateChanged(ScoreState state);
509 
510    private slots:
511       void cmd(QAction* a, const QString& cmd);
512       void autoSaveTimerTimeout();
513       void helpBrowser1() const;
514       void resetAndRestart();
515       void about();
516       void aboutQt();
517       void aboutMusicXML();
518       void reportBug(QString medium);
519       void askForHelp();
520       void leaveFeedback(QString medium);
521       void openRecentMenu();
522       void selectScore(QAction*);
523       void startPreferenceDialog();
524       void preferencesChanged(bool fromWorkspace = false, bool changeUI = true);
525       void seqStarted();
526       void seqStopped();
527       void cmdAppendMeasures();
528       void cmdInsertMeasures();
529       void zoomBoxChanged(const ZoomIndex, const qreal);
530       void showPageSettings();
531       void removeTab(int);
532       void removeTab();
533       void clipboardChanged();
534       void inputMethodAnchorRectangleChanged();
535       void inputMethodAnimatingChanged();
536       void inputMethodCursorRectangleChanged();
537       void inputMethodInputDirectionChanged(Qt::LayoutDirection newDirection);
538       void inputMethodInputItemClipRectangleChanged();
539       void inputMethodKeyboardRectangleChanged();
540       void inputMethodLocaleChanged();
541       void inputMethodVisibleChanged();
542       void endSearch();
543       void saveScoreDialogFilterSelected(const QString&);
544 #ifdef OSC
545       void oscIntMessage(int);
546       void oscVolume(int val);
547       void oscTempo(int val);
548       void oscGoto(int m);
549       void oscSelectMeasure(int m);
550       void oscVolChannel(double val);
551       void oscPanChannel(double val);
552       void oscMuteChannel(double val);
553       void oscOpen(QString path);
554       void oscCloseAll();
555       void oscTriggerPlugin(QString list);
556       void oscColorNote(QVariantList list);
557       void oscAction();
558 #endif
559       void deleteWorkspace();
560       void resetWorkspace();
561       void showWorkspaceMenu();
562       void switchLayer(const QString&);
563       void switchPlayMode(int);
564       void networkFinished();
565       void switchLayoutMode(int);
566       void showMidiImportPanel();
567       void changeWorkspace(QAction*);
568       void onLongOperationFinished();
569 
570       void onFocusWindowChanged(QWindow*);
571 
572       virtual QMenu* createPopupMenu() override;
573 
574       QByteArray exportMsczAsJSON(Score*);
575       QByteArray exportPdfAsJSON(Score*);
576 
577    public slots:
578       virtual void cmd(QAction* a);
579       void dirtyChanged(Score*);
580       void setPos(const Fraction& tick);
581       void pluginTriggered(int);
582       void pluginTriggered(QString path);
583       void handleMessage(const QString& message);
584       void setCurrentScoreView(ScoreView*);
585       void setCurrentScoreView(int);
586       void setCurrentScores(Score* s1, Score* s2 = nullptr);
setNormalState()587       void setNormalState()    { changeState(STATE_NORMAL); }
setPlayState()588       void setPlayState()      { changeState(STATE_PLAY); }
setNoteEntryState()589       void setNoteEntryState() { changeState(STATE_NOTE_ENTRY); }
590       void checkForUpdatesUI();
591       void checkForExtensionsUpdate();
592       void midiNoteReceived(int channel, int pitch, int velo);
593       void midiNoteReceived(int pitch, bool ctrl, int velo);
594       void instrumentChanged();
595       void showMasterPalette(const QString& = 0);
596       void selectionChanged(SelState);
597       void createNewWorkspace();
598       void editWorkspace();
599       void changeWorkspace(Workspace* p, bool first=false);
600       void mixerPreferencesChanged(bool showMidiControls);
601       void checkForUpdates();
602       void restartAudioEngine();
603 
604    public:
605       MuseScore();
606       ~MuseScore();
607       bool checkDirty(MasterScore*);
608       IPlayPanel* playPanelInterface() const;
getPlayPanel()609       PlayPanel* getPlayPanel() const { return playPanel; }
getMixer()610       Mixer* getMixer() const { return mixer; }
611       QMenu* genCreateMenu(QWidget* parent = 0);
612       virtual int appendScore(MasterScore*);
613       void midiCtrlReceived(int controller, int value);
614       void showElementContext(Element* el);
615       void cmdAppendMeasures(int);
616       bool isMidiInEnabled() const;
617 
618       void readSettings();
619       void writeSettings();
620       void play(Element* e) const;
621       void play(Element* e, int pitch) const;
622       void moveControlCursor();
623       bool loadPlugin(const QString& filename);
624       QString createDefaultName() const;
625       void startAutoSave();
626       void updateZoomBox(const ZoomIndex, const qreal logicalLevel);
noScore()627       bool noScore() const { return scoreList.isEmpty(); }
628 
629       TextTools* textTools();
630       void showDrumTools(const Drumset*, Staff*);
631       void updateDrumTools(const Drumset* ds);
632       void showPluginCreator(QAction*);
633       void showPluginManager();
634 
635 //      void updateTabNames();
636       void updatePaletteBeamMode();
637       QProgressBar* showProgressBar();
638       void hideProgressBar();
639       void addRecentScore(Score*);
640       QFileDialog* saveAsDialog();
641       QFileDialog* saveCopyDialog();
642       void showStyleDialog(Element* e = nullptr);
643 
644       QString lastSaveCopyDirectory;
645       QString lastSaveCopyFormat;
646       QString lastSaveDirectory;
647       QString lastSaveCaptureName;
648       bool saveFile();
getSynthControl()649       SynthControl* getSynthControl() const       { return synthControl; }
650       void editInPianoroll(Staff* staff, Position* p = 0);
651       void editInDrumroll(Staff* staff);
getPianorollEditor()652       PianorollEditor* getPianorollEditor() const { return pianorollEditor; }
getDrumrollEditor()653       DrumrollEditor* getDrumrollEditor() const   { return drumrollEditor; }
pianoTools()654       PianoTools* pianoTools() const              { return _pianoTools; }
655 #ifdef SCRIPT_INTERFACE
getPluginManager()656       PluginManager* getPluginManager() const     { return pluginManager; }
657       QmlPluginEngine* getPluginEngine();
658 #endif
659       MsQmlEngine* getQmlUiEngine();
660       void writeSessionFile(bool);
661       bool restoreSession(bool);
splitScreen()662       bool splitScreen() const { return _splitScreen; }
663       void setSplitScreen(bool val);
664       virtual void setCurrentView(int tabIdx, int idx);
665       void loadPlugins();
666       void unloadPlugins();
667 #ifdef SCRIPT_INTERFACE
668       void addPluginMenuEntries();
669 #endif
670 
state()671       ScoreState state() const { return _sstate; }
672       void changeState(ScoreState);
673       void updateInputState(Score*);
674       void updateShadowNote();
675 
676       bool readLanguages(const QString& path);
setRevision(QString & r)677       void setRevision(QString& r)  {rev = r;}
revision()678       Q_INVOKABLE QString revision()            {return rev;}
version()679       Q_INVOKABLE QString version()            {return VERSION;}
680       static QString fullVersion();
681       Q_INVOKABLE void newFile();
682       MasterScore* getNewFile();
683       Q_INVOKABLE void loadFile(const QString& url);
684       void loadFile(const QUrl&);
685       QTemporaryFile* getTemporaryScoreFileCopy(const QFileInfo& info, const QString& baseNameTemplate);
686       QNetworkAccessManager* networkManager();
687       virtual Score* openScore(const QString& fn, bool switchTab = true, const bool appendToExistingTabs = true, const QString& withFilename = "") override;
688       bool hasToCheckForUpdate();
689       bool hasToCheckForExtensionsUpdate();
690       static bool unstable();
691       bool eventFilter(QObject *, QEvent *);
setMidiRecordId(int id)692       void setMidiRecordId(int id) { _midiRecordId = id; }
midiRecordId()693       int midiRecordId() const { return _midiRecordId; }
694       void setDefaultPalette();
695       void scorePageLayoutChanged();
696       bool processMidiRemote(MidiRemoteType type, int data, int value);
getTab1()697       ScoreTab* getTab1() const { return tab1; }
getTab2()698       ScoreTab* getTab2() const { return tab2; }
languages()699       QList<LanguageItem>& languages() { return _languages; }
700 
701       QStringList getOpenScoreNames(const QString& filter, const QString& title, bool singleFile = false);
702       QString getSaveScoreName(const QString& title, QString& name, const QString& filter, bool folder = false, bool askOverwrite = true);
703       QString getStyleFilename(bool open, const QString& title = QString());
704       QString getFotoFilename(QString& filter, QString *selectedFilter);
705       QString getChordStyleFilename(bool open);
706       QString getScanFile(const QString&);
707       QString getAudioFile(const QString&);
708       QString getDrumsetFilename(bool open);
709       QString getPluginFilename(bool open);
710       QString getPaletteFilename(bool open, const QString& name = "");
711       QString getWallpaper(const QString& caption);
712 
713       int askOverwriteAll(QString&);
714 
hRaster()715       bool hRaster() const { return hRasterAction->isChecked(); }
vRaster()716       bool vRaster() const { return vRasterAction->isChecked(); }
717 
718       PaletteWorkspace* getPaletteWorkspace();
getPaletteWidget()719       PaletteWidget* getPaletteWidget() { return paletteWidget; }
720       std::vector<QmlDockWidget*> qmlDockWidgets();
721       void changeWorkspace(const QString& name);
722 
disableCommands(bool val)723       void disableCommands(bool val) { inChordEditor = val; }
724 
725       Tuplet* tupletDialog();
726       void selectSimilar(Element*, bool);
727       void selectSimilarInRange(Element* e);
728       void selectElementDialog(Element* e);
729       void transpose();
730       void realizeChordSymbols();
731 
732       Q_INVOKABLE void openExternalLink(const QString&);
733 
734       void endCmd(bool undoRedo);
endCmd()735       void endCmd() override { endCmd(false); };
736       void printFile();
737       virtual bool saveAs(Score*, bool saveCopy, const QString& path, const QString& ext, SaveReplacePolicy* replacePolicy = nullptr);
738       QString saveFilename(QString fn);
739       bool savePdf(const QString& saveName);
740       bool savePdf(Score* cs, const QString& saveName);
741       bool savePdf(QList<Score*> cs, const QString& saveName);
742       bool savePdf(Score* cs, QPrinter& printer);
743 
744 
745       MasterScore* readScore(const QString& name);
746       NotesColors readNotesColors(const QString& filePath) const;
747 
748       bool saveAs(Score*, bool saveCopy = false);
749       bool saveSelection(Score*);
750       void addImage(Score*, Element*);
751 
752       bool saveAudio(Score*, QIODevice*, std::function<bool(float)> updateProgress = nullptr);
753       bool saveAudio(Score*, const QString& name);
754       bool canSaveMp3();
755       bool saveMp3(Score*, const QString& name);
756       bool saveMp3(Score*, QIODevice*, bool& wasCanceled);
757       bool saveSvg(Score*, const QString& name, const NotesColors& notesColors = NotesColors(), SaveReplacePolicy* replacePolicy = nullptr);
758       bool saveSvg(Score*, QIODevice*, int pageNum = 0, bool drawPageBackground = false, const NotesColors& notesColors = NotesColors());
759       bool savePng(Score*, const QString& name, SaveReplacePolicy* replacePolicy = nullptr);
760       bool savePng(Score*, QIODevice*, int pageNum = 0, bool drawPageBackground = false);
761       bool saveMidi(Score*, const QString& name);
762       bool saveMidi(Score*, QIODevice*);
763       bool savePositions(Score*, const QString& name, bool segments);
764       bool savePositions(Score*, QIODevice*, bool segments);
765       bool saveMetadataJSON(Score*, const QString& name);
766       QJsonObject saveMetadataJSON(Score*);
767       bool saveOnline(const QStringList& inFilePaths);
768 
769       /////The methods are used in the musescore.com backend
770       bool exportAllMediaFiles(const QString& inFilePath, const QString& highlightConfigPath, const QString& outFilePath = "/dev/stdout");
771       bool exportScoreMetadata(const QString& inFilePath, const QString& outFilePath = "/dev/stdout");
772       bool exportMp3AsJSON(const QString& inFilePath, const QString& outFilePath = "/dev/stdout");
773       bool saveScoreParts(const QString& inFilePath, const QString& outFilePath = "/dev/stdout");
774       bool exportPartsPdfsToJSON(const QString& inFilePath, const QString& outFilePath = "/dev/stdout");
775       bool exportTransposedScoreToJSON(const QString& inFilePath, const QString& transposeOptions, const QString& outFilePath = "/dev/stdout");
776       bool updateSource(const QString& scorePath, const QString& newSource);
777       /////////////////////////////////////////////////
778 
779       void scoreUnrolled(MasterScore* original);
780 
781       virtual void closeScore(Score* score);
782 
783       void addTempo();
784       void addMetronome();
785 
786       void editInstrumentList();
787 
788       SynthesizerState synthesizerState() const;
789       static Synthesizer* synthesizer(const QString& name);
790 
791       Q_INVOKABLE QString getLocaleISOCode() const;
792       Navigator* navigator() const;
navigatorScrollArea()793       NScrollArea* navigatorScrollArea() const { return _navigator; }
794       Timeline* timeline() const;
timelineScrollArea()795       TDockWidget* timelineScrollArea() const { return _timeline; }
796       QWidget*   searchDialog() const;
getSelectionWindow()797       SelectionWindow* getSelectionWindow() const { return selectionWindow; }
798       void updateLayer();
799       void updatePlayMode();
loop()800       bool loop() const              { return loopAction->isChecked(); }
metronome()801       bool metronome() const         { return metronomeAction->isChecked(); }
countIn()802       bool countIn() const           { return countInAction->isChecked(); }
panDuringPlayback()803       bool panDuringPlayback() const { return panAction->isChecked(); }
804       void noteTooShortForTupletDialog();
805       void openFiles(bool switchTab = true, bool singleFile = false);
806       void importScore(bool switchTab = true, bool singleFile = false);
807                   // midi panel functions
808       void midiPanelOnSwitchToFile(const QString &file);
809       void midiPanelOnCloseFile(const QString &file);
810       void allowShowMidiPanel(const QString &file);
811       void setMidiReopenInProgress(const QString &file);
812 
813       static Palette* newTempoPalette(bool defaultPalette = false);
814       static Palette* newTextPalette(bool defaultPalette = false);
815       static Palette* newTimePalette();
816       static Palette* newRepeatsPalette();
817       static Palette* newBreaksPalette();
818       static Palette* newBeamPalette();
819       static Palette* newDynamicsPalette(bool defaultPalette = false);
820       static Palette* newFramePalette();
821       static Palette* newFingeringPalette();
822       static Palette* newTremoloPalette();
823       static Palette* newNoteHeadsPalette();
824       static Palette* newArticulationsPalette();
825       static Palette* newOrnamentsPalette();
826       static Palette* newAccordionPalette();
827       static Palette* newBracketsPalette();
828       static Palette* newBreathPalette();
829       static Palette* newArpeggioPalette();
830       static Palette* newClefsPalette(bool defaultPalette = false);
831       static Palette* newGraceNotePalette();
832       static Palette* newBagpipeEmbellishmentPalette();
833       static Palette* newKeySigPalette();
834       static Palette* newAccidentalsPalette(bool defaultPalette = false);
835       static Palette* newBarLinePalette();
836       static Palette* newLinesPalette();
837       static Palette* newFretboardDiagramPalette();
838 
839       static PalettePanel* newTempoPalettePanel(bool defaultPalette = false);
840       static PalettePanel* newTextPalettePanel(bool defaultPalette = false);
841       static PalettePanel* newTimePalettePanel();
842       static PalettePanel* newRepeatsPalettePanel();
843       static PalettePanel* newBreaksPalettePanel();
844       static PalettePanel* newBeamPalettePanel();
845       static PalettePanel* newDynamicsPalettePanel(bool defaultPalette = false);
846       static PalettePanel* newFramePalettePanel();
847       static PalettePanel* newFingeringPalettePanel();
848       static PalettePanel* newTremoloPalettePanel();
849       static PalettePanel* newNoteHeadsPalettePanel();
850       static PalettePanel* newArticulationsPalettePanel();
851       static PalettePanel* newOrnamentsPalettePanel();
852       static PalettePanel* newAccordionPalettePanel();
853       static PalettePanel* newBracketsPalettePanel();
854       static PalettePanel* newBreathPalettePanel();
855       static PalettePanel* newArpeggioPalettePanel();
856       static PalettePanel* newClefsPalettePanel(bool defaultPalette = false);
857       static PalettePanel* newGraceNotePalettePanel();
858       static PalettePanel* newBagpipeEmbellishmentPalettePanel();
859       static PalettePanel* newKeySigPalettePanel();
860       static PalettePanel* newAccidentalsPalettePanel(bool defaultPalette = false);
861       static PalettePanel* newBarLinePalettePanel();
862       static PalettePanel* newLinesPalettePanel();
863       static PalettePanel* newFretboardDiagramPalettePanel();
864       static PaletteTree* newMasterPaletteTree();
865 
workspaceDialog()866       WorkspaceDialog* workspaceDialog() { return _workspaceDialog; }
867       void updateIcons();
868       void updateMenus();
869 
inspector()870       Inspector* inspector()           { return _inspector; }
pluginCreator()871       PluginCreator* pluginCreator()   { return _pluginCreator; }
currentScoreView()872       ScoreView* currentScoreView() const { return cv; }
currentScoreTab()873       ScoreTab* currentScoreTab() const { return ctab; }
playButton()874       QToolButton* playButton()        { return _playButton;    }
875       void showMessage(const QString& s, int timeout);
876       void showHelp(QString);
877       void showContextHelp();
878       void showHelp(const QUrl&);
879 
tourHandler()880       TourHandler* tourHandler()       { return _tourHandler; }
881 
882 #ifdef SCRIPT_INTERFACE
883       void registerPlugin(PluginDescription*);
884       void unregisterPlugin(PluginDescription*);
885 #endif
886 
887       Q_INVOKABLE void showStartcenter(bool);
888       void reDisplayDockWidget(QDockWidget* widget, bool visible);
889       void showPlayPanel(bool);
890 
891       QFileInfoList recentScores() const;
892       void saveDialogState(const char* name, QFileDialog* d);
893       void restoreDialogState(const char* name, QFileDialog* d);
894 
895       QPixmap extractThumbnail(const QString& name);
896 
897       void showLoginDialog();
898       void showUploadScoreDialog();
loginManager()899       LoginManager* loginManager()     { return _loginManager; }
helpEngine()900       QHelpEngine*  helpEngine() const { return _helpEngine;   }
901 
902       virtual void updateInspector() override;
903       void updateInstrumentDialog();
904       void reloadInstrumentTemplates();
905       void showSynthControl(bool);
906       void showMixer(bool);
907 
physicalDotsPerInch()908       qreal physicalDotsPerInch() const                              { return _physicalDotsPerInch; }
allNoteInputMenuEntries()909       static const std::list<const char*>& allNoteInputMenuEntries() { return _allNoteInputMenuEntries; }
noteInputMenuEntries()910       std::list<const char*>* noteInputMenuEntries()                 { return &_noteInputMenuEntries; }
setNoteInputMenuEntries(std::list<const char * > l)911       void setNoteInputMenuEntries(std::list<const char*> l)         { _noteInputMenuEntries = l; }
912       void populateNoteInputMenu();
913 
allFileOperationEntries()914       static const std::list<const char*>& allFileOperationEntries() { return _allFileOperationEntries; }
fileOperationEntries()915       std::list<const char*>* fileOperationEntries()                 { return &_fileOperationEntries; }
setFileOperationEntries(std::list<const char * > l)916       void setFileOperationEntries(std::list<const char*> l)         { _fileOperationEntries = l; }
917       void populateFileOperations();
918 
allPlaybackControlEntries()919       static const std::list<const char*>& allPlaybackControlEntries() { return _allPlaybackControlEntries; }
playbackControlEntries()920       std::list<const char*>* playbackControlEntries()               { return &_playbackControlEntries; }
setPlaybackControlEntries(std::list<const char * > l)921       void setPlaybackControlEntries(std::list<const char*> l)       { _playbackControlEntries = l; }
922       void populatePlaybackControls();
923 
playPartOnly()924       bool playPartOnly() const { return _playPartOnly; }
925       void setPlayPartOnly(bool val);
926 
927       static void updateUiStyleAndTheme();
928 
929       void showError();
930 
931       static void saveGeometry(QWidget const*const qw);
932       static void restoreGeometry(QWidget*const qw);
933 
934       void updateWindowTitle(Score* score);
935       bool importExtension(QString path);
936       bool uninstallExtension(QString extensionId);
937       Q_INVOKABLE bool isInstalledExtension(QString extensionId);
938 
939       void focusScoreView();
940 
941       void notifyElementDraggedToScoreView();
942 
943       ScriptRecorder* getScriptRecorder();
944       bool runTestScripts(const QStringList& scripts);
945 
946       static void init(QStringList& argv);
947 
948       friend class TestWorkspaces;
949       };
950 
951 extern MuseScore* mscore;
952 extern QStringList recentScores;
953 extern QString dataPath;
954 extern MasterSynthesizer* synti;
955 MasterSynthesizer* synthesizerFactory();
956 Driver* driverFactory(Seq*, QString driver);
957 
958 extern QAction* getAction(const char*);
959 extern Shortcut* midiActionMap[128];
960 extern void loadTranslation(QString fileName, QString localeName);
961 extern void setMscoreLocale(QString localeName);
962 extern bool saveMxl(Score*, const QString& name);
963 extern bool saveMxl(Score*, QIODevice*);
964 extern bool saveXml(Score*, QIODevice*);
965 extern bool saveXml(Score*, const QString& name);
966 
967 extern QString getSharePath();
968 
969 #ifdef AVSOMR
970 extern Score::FileError importMSMR(MasterScore*, const QString& name);
971 extern Score::FileError loadAndImportMSMR(MasterScore*, const QString& name);
972 #endif
973 extern Score::FileError importMidi(MasterScore*, const QString& name);
974 extern Score::FileError importGTP(MasterScore*, const QString& name);
975 extern Score::FileError importBww(MasterScore*, const QString& path);
976 extern Score::FileError importMusicXml(MasterScore*, const QString&);
977 extern Score::FileError importCompressedMusicXml(MasterScore*, const QString&);
978 extern Score::FileError importMuseData(MasterScore*, const QString& name);
979 extern Score::FileError importLilypond(MasterScore*, const QString& name);
980 extern Score::FileError importBB(MasterScore*, const QString& name);
981 extern Score::FileError importCapella(MasterScore*, const QString& name);
982 extern Score::FileError importCapXml(MasterScore*, const QString& name);
983 extern Score::FileError readScore(MasterScore* score, QString name, bool ignoreVersionError);
984 
985 int runApplication(int& argc, char** argv);
986 } // namespace Ms
987 
988 extern Ms::Score::FileError importOve(Ms::MasterScore*, const QString& name);
989 
990 #endif
991