MuseScore/mscore/musescore.h

654 lines
20 KiB
C
Raw Normal View History

2012-05-26 14:49:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
// $Id: musescore.h 5657 2012-05-21 15:46:06Z lasconic $
//
// Copyright (C) 2002-2011 Werner Schweer and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef __MUSESCORE_H__
#define __MUSESCORE_H__
#include "config.h"
#include "globals.h"
#include "ui_measuresdialog.h"
#include "ui_insertmeasuresdialog.h"
#include "ui_aboutbox.h"
#include "ui_aboutmusicxmlbox.h"
#include "ui_startdialog.h"
#include "singleapp/src/QtSingleApplication"
#include "updatechecker.h"
2012-12-10 09:15:50 +01:00
#include "musescoreCore.h"
2012-05-26 14:49:10 +02:00
class Shortcut;
class ScoreView;
class Element;
class ToolButton;
class PreferenceDialog;
class InstrumentsDialog;
class Instrument;
class MidiFile;
class TextStyleDialog;
class PlayPanel;
class InstrumentListEditor;
class Debugger;
class MeasureListEditor;
class Score;
class PageSettings;
class PaletteBox;
class Palette;
class PaletteScrollArea;
class Xml;
class MagBox;
class NewWizard;
class ExcerptsDialog;
class SynthControl;
class PianorollEditor;
class DrumrollEditor;
class Staff;
class ScoreTab;
class Drumset;
class TextTools;
class DrumTools;
class ScriptEngine;
class KeyEditor;
class ChordStyleEditor;
class Navigator;
class PianoTools;
class MediaDialog;
2013-02-06 16:43:25 +01:00
class Workspace;
2012-05-26 14:49:10 +02:00
class AlbumManager;
class WebPageDockWidget;
class ChordList;
class EditTempo;
class Capella;
class Inspector;
class OmrPanel;
class NScrollArea;
class EditTools;
class Sym;
class MasterPalette;
2012-07-02 18:05:10 +02:00
class PluginCreator;
class PluginManager;
2012-07-02 18:05:10 +02:00
2012-06-06 14:16:06 +02:00
struct PluginDescription;
2012-05-26 14:49:10 +02:00
extern QString mscoreGlobalShare;
static const int PROJECT_LIST_LEN = 6;
//---------------------------------------------------------
// IconActions
//---------------------------------------------------------
struct IconAction {
int subtype;
const char* action;
};
//---------------------------------------------------------
// LanguageItem
//---------------------------------------------------------
struct LanguageItem {
QString key;
QString name;
QString handbook;
LanguageItem(const QString k, const QString n) {
key = k;
name = n;
handbook = QString::null;
}
LanguageItem(const QString k, const QString n, const QString h) {
key = k;
name = n;
handbook = h;
}
};
//---------------------------------------------------------
// AboutBoxDialog
//---------------------------------------------------------
class AboutBoxDialog : public QDialog, Ui::AboutBox {
Q_OBJECT
public:
AboutBoxDialog();
private slots:
void copyRevisionToClipboard();
2012-05-26 14:49:10 +02:00
};
//---------------------------------------------------------
// AboutMusicXMLBoxDialog
//---------------------------------------------------------
class AboutMusicXMLBoxDialog : public QDialog, Ui::AboutMusicXMLBox {
Q_OBJECT
public:
AboutMusicXMLBoxDialog();
};
//---------------------------------------------------------
// InsertMeasuresDialog
// Added by DK, 05.08.07
//---------------------------------------------------------
class InsertMeasuresDialog : public QDialog, public Ui::InsertMeasuresDialogBase {
Q_OBJECT
private slots:
virtual void accept();
public:
InsertMeasuresDialog(QWidget* parent = 0);
};
//---------------------------------------------------------
// MeasuresDialog
//---------------------------------------------------------
class MeasuresDialog : public QDialog, public Ui::MeasuresDialogBase {
Q_OBJECT
private slots:
virtual void accept();
public:
MeasuresDialog(QWidget* parent = 0);
};
//---------------------------------------------------------
// StartDialog
//---------------------------------------------------------
class StartDialog : public QDialog, public Ui::StartDialog {
Q_OBJECT
private slots:
void createScoreClicked();
void loadScoreClicked();
public:
StartDialog(QWidget* parent = 0);
};
//---------------------------------------------------------
// MuseScoreApplication (mac only)
//---------------------------------------------------------
class MuseScoreApplication : public QtSingleApplication {
public:
QStringList paths;
MuseScoreApplication(const QString &id, int &argc, char **argv)
: QtSingleApplication(id, argc, argv) {
};
bool event(QEvent *ev);
};
//---------------------------------------------------------
// MuseScore
//---------------------------------------------------------
2012-12-10 09:15:50 +01:00
class MuseScore : public QMainWindow, public MuseScoreCore {
2012-05-26 14:49:10 +02:00
Q_OBJECT
2012-12-10 09:15:50 +01:00
ScoreView* cv;
2012-05-26 14:49:10 +02:00
ScoreState _sstate;
UpdateChecker* ucheck;
QVBoxLayout* layout; // main window layout
QSplitter* splitter;
ScoreTab* tab1;
ScoreTab* tab2;
NScrollArea* _navigator;
QSplitter* mainWindow;
QMenu* menuDisplay;
QMenu* openRecent;
MagBox* mag;
QComboBox* viewModeCombo;
QAction* playId;
QProgressBar* _progressBar;
PreferenceDialog* preferenceDialog;
QToolBar* cpitchTools;
QToolBar* fileTools;
QToolBar* transportTools;
QToolBar* entryTools;
TextTools* _textTools;
EditTools* _editTools;
PianoTools* _pianoTools;
WebPageDockWidget* _webPage;
MediaDialog* _mediaDialog;
DrumTools* _drumTools;
QToolBar* voiceTools;
InstrumentsDialog* instrList;
MeasuresDialog* measuresDialog;
InsertMeasuresDialog* insertMeasuresDialog;
MasterPalette* masterPalette;
2012-07-02 18:05:10 +02:00
PluginCreator* pluginCreator;
2012-05-26 14:49:10 +02:00
QMenu* _fileMenu;
QMenu* menuEdit;
QMenu* menuNotes;
QMenu* menuLayout;
QMenu* menuStyle;
AlbumManager* albumManager;
QWidget* searchDialog;
QComboBox* searchCombo;
PlayPanel* playPanel;
InstrumentListEditor* iledit;
SynthControl* synthControl;
Debugger* debugger;
MeasureListEditor* measureListEdit;
PageSettings* pageSettings;
QWidget* symbolDialog;
PaletteScrollArea* clefPalette;
PaletteScrollArea* keyPalette;
KeyEditor* keyEditor;
ChordStyleEditor* chordStyleEditor;
QStatusBar* _statusBar;
QLabel* _modeText;
QLabel* _positionLabel;
NewWizard* newWizard;
PaletteBox* paletteBox;
Inspector* inspector;
OmrPanel* omrPanel;
bool _midiinEnabled;
bool _speakerEnabled;
QString lastOpenPath;
QList<QString> plugins;
ScriptEngine* se;
QString pluginPath;
2012-07-02 18:05:10 +02:00
QDeclarativeEngine* _qml;
2012-06-06 14:16:06 +02:00
void createMenuEntry(PluginDescription*);
2012-05-26 14:49:10 +02:00
QTimer* autoSaveTimer;
QList<QAction*> qmlPluginActions;
2012-05-26 14:49:10 +02:00
QList<QAction*> pluginActions;
QSignalMapper* pluginMapper;
PianorollEditor* pianorollEditor;
DrumrollEditor* drumrollEditor;
bool _splitScreen;
bool _horizontalSplit;
QString rev;
int _midiRecordId;
bool _fullscreen;
QList<LanguageItem> _languages;
QFileDialog* loadScoreDialog;
QFileDialog* saveScoreDialog;
QFileDialog* loadStyleDialog;
QFileDialog* saveStyleDialog;
QFileDialog* saveImageDialog;
QFileDialog* loadChordStyleDialog;
QFileDialog* saveChordStyleDialog;
QFileDialog* loadSoundFontDialog;
QFileDialog* loadBackgroundDialog;
QFileDialog* loadScanDialog;
QFileDialog* loadAudioDialog;
QFileDialog* loadDrumsetDialog;
2012-07-02 18:05:10 +02:00
QFileDialog* loadPluginDialog;
2012-05-26 14:49:10 +02:00
QFileDialog* loadPaletteDialog;
QFileDialog* savePaletteDialog;
QFileDialog* saveDrumsetDialog;
2012-07-02 18:05:10 +02:00
QFileDialog* savePluginDialog;
2012-05-26 14:49:10 +02:00
QDialog* editRasterDialog;
QAction* hRasterAction;
QAction* vRasterAction;
2013-02-06 16:43:25 +01:00
QMenu* menuWorkspaces;
2013-02-08 11:36:50 +01:00
QActionGroup* workspaces;
2012-05-26 14:49:10 +02:00
bool inChordEditor;
QComboBox* layerSwitch;
QComboBox* playMode;
QNetworkAccessManager* networkManager;
QAction* lastCmd;
Shortcut* lastShortcut;
EditTempo* editTempo;
QAction* metronomeAction;
QAction* panAction;
QLabel* cornerLabel;
//---------------------
virtual void closeEvent(QCloseEvent*);
virtual void dragEnterEvent(QDragEnterEvent*);
virtual void dropEvent(QDropEvent*);
void playVisible(bool flag);
void launchBrowser(const QString whereTo);
void loadScoreList();
void editInstrList();
void symbolMenu();
void showKeyEditor();
void saveFile();
void fingeringMenu();
2012-06-06 14:16:06 +02:00
void registerPlugin(PluginDescription*);
2012-05-26 14:49:10 +02:00
int pluginIdxFromPath(QString pluginPath);
void startDebugger();
void midiinToggled(bool);
void speakerToggled(bool);
void undo();
void redo();
void showPalette(bool);
void showInspector(bool);
void showOmrPanel(bool);
void showPlayPanel(bool);
void showNavigator(bool);
void showMixer(bool);
void showSynthControl();
void helpBrowser() const;
void helpBrowser(const QUrl&) const;
2012-05-26 14:49:10 +02:00
void splitWindow(bool horizontal);
void removeSessionFile();
void editChordStyle();
void startExcerptsDialog();
void initOsc();
void editRaster();
void showPianoKeyboard(bool);
void showMediaDialog();
void showAlbumManager();
void showLayerManager();
void updateUndoRedo();
void cmdAddChordName2();
void changeScore(int);
virtual void resizeEvent(QResizeEvent*);
2012-07-12 15:35:35 +02:00
void updateInspector();
2012-05-26 14:49:10 +02:00
private slots:
2012-06-08 19:06:52 +02:00
void cmd(QAction* a, const QString& cmd);
2012-05-26 14:49:10 +02:00
void autoSaveTimerTimeout();
void helpBrowser1() const;
2012-05-26 14:49:10 +02:00
void about();
void aboutQt();
void aboutMusicXML();
void reportBug();
2012-05-26 14:49:10 +02:00
void openRecentMenu();
void selectScore(QAction*);
void startPreferenceDialog();
void preferencesChanged();
void seqStarted();
void seqStopped();
void closePlayPanel();
void cmdAppendMeasures();
void cmdInsertMeasures();
void magChanged(int);
void showPageSettings();
void removeTab(int);
void removeTab();
void clipboardChanged();
void endSearch();
void saveScoreDialogFilterSelected(const QString&);
#ifdef OSC
void oscIntMessage(int);
void oscPlay();
void oscStop();
void oscVolume(int val);
void oscTempo(int val);
void oscNext();
void oscNextMeasure();
void oscGoto(int m);
void oscSelectMeasure(int m);
void oscVolChannel(double val);
void oscPanChannel(double val);
void oscMuteChannel(double val);
void oscOpen(QString path);
void oscCloseAll();
void oscTriggerPlugin(QString list);
void oscColorNote(QVariantList list);
#endif
2013-02-06 16:43:25 +01:00
void createNewWorkspace();
void deleteWorkspace();
2013-02-08 11:36:50 +01:00
void undoWorkspace();
2013-02-06 16:43:25 +01:00
void showWorkspaceMenu();
void changeWorkspace(QAction*);
void changeWorkspace(Workspace* p);
2012-05-26 14:49:10 +02:00
void switchLayer(const QString&);
void switchPlayMode(int);
void networkFinished(QNetworkReply*);
void switchLayoutMode(int);
2012-07-02 18:05:10 +02:00
void closePluginCreator();
2012-05-26 14:49:10 +02:00
public slots:
2012-12-10 09:15:50 +01:00
virtual void cmd(QAction* a);
2012-05-26 14:49:10 +02:00
void dirtyChanged(Score*);
void setPos(int tick);
void searchTextChanged(const QString& s);
void pluginTriggered(int);
void handleMessage(const QString& message);
void setCurrentScoreView(ScoreView*);
void setCurrentScoreView(int);
void setNormalState() { changeState(STATE_NORMAL); }
void setPlayState() { changeState(STATE_PLAY); }
void setSearchState() { changeState(STATE_SEARCH); }
void checkForUpdate();
QMenu* fileMenu() const { return _fileMenu; }
void midiNoteReceived(int channel, int pitch, int velo);
void midiNoteReceived(int pitch, bool ctrl);
void instrumentChanged();
2013-02-07 17:34:44 +01:00
void showMasterPalette(const QString& = 0);
2012-05-26 14:49:10 +02:00
void selectionChanged(int);
public:
MuseScore();
~MuseScore();
bool checkDirty(Score*);
PlayPanel* getPlayPanel() const { return playPanel; }
QMenu* genCreateMenu(QWidget* parent = 0);
2012-12-10 09:15:50 +01:00
virtual int appendScore(Score*);
2012-05-26 14:49:10 +02:00
void midiCtrlReceived(int controller, int value);
void showElementContext(Element* el);
2012-06-08 19:06:52 +02:00
void cmdAppendMeasures(int);
2012-05-26 14:49:10 +02:00
bool midiinEnabled() const;
bool playEnabled() const;
void incMag();
void decMag();
void readSettings();
void writeSettings();
void play(Element* e) const;
void play(Element* e, int pitch) const;
bool loadPlugin(const QString& filename);
QString createDefaultName() const;
void startAutoSave();
double getMag(ScoreView*) const;
void setMag(double);
bool noScore() const { return scoreList.isEmpty(); }
TextTools* textTools();
EditTools* editTools();
void showDrumTools(Drumset*, Staff*);
void updateDrumTools();
2012-05-26 14:49:10 +02:00
void showWebPanel(bool on);
2012-07-02 18:05:10 +02:00
void showPluginCreator(QAction*);
2012-05-26 14:49:10 +02:00
void updateTabNames();
QProgressBar* showProgressBar();
void hideProgressBar();
void updateRecentScores(Score*);
QFileDialog* saveAsDialog();
QFileDialog* saveCopyDialog();
QString lastSaveCopyDirectory;
QString lastSaveDirectory;
SynthControl* getSynthControl() const { return synthControl; }
void editInPianoroll(Staff* staff);
void editInDrumroll(Staff* staff);
PianorollEditor* getPianorollEditor() const { return pianorollEditor; }
DrumrollEditor* getDrumrollEditor() const { return drumrollEditor; }
void writeSessionFile(bool);
bool restoreSession(bool);
bool splitScreen() const { return _splitScreen; }
2012-12-10 09:15:50 +01:00
virtual void setCurrentView(int tabIdx, int idx);
2012-05-26 14:49:10 +02:00
void loadPlugins();
void unloadPlugins();
2013-02-15 22:39:56 +01:00
2012-05-26 14:49:10 +02:00
ScoreState state() const { return _sstate; }
void changeState(ScoreState);
2013-02-15 22:39:56 +01:00
void updateInputState(Score*);
2012-05-26 14:49:10 +02:00
bool readLanguages(const QString& path);
2013-02-15 22:39:56 +01:00
void setRevision(QString& r) {rev = r;}
QString revision() {return rev;}
2012-05-26 14:49:10 +02:00
Q_INVOKABLE void newFile();
Q_INVOKABLE void loadFile(const QString& url);
void loadFile(const QUrl&);
2012-12-10 09:15:50 +01:00
virtual Score* openScore(const QString& fn);
2012-05-26 14:49:10 +02:00
bool hasToCheckForUpdate();
static bool unstable();
bool eventFilter(QObject *, QEvent *);
void setMidiRecordId(int id) { _midiRecordId = id; }
int midiRecordId() const { return _midiRecordId; }
void populatePalette();
void excerptsChanged(Score*);
bool processMidiRemote(MidiRemoteType type, int data);
ScoreTab* getTab1() const { return tab1; }
ScoreTab* getTab2() const { return tab2; }
QList<LanguageItem>& languages() { return _languages; }
QStringList getOpenScoreNames(QString& dir, const QString& filter, const QString& title);
2012-05-26 14:49:10 +02:00
QString getSaveScoreName(const QString& title,
QString& name, const QString& filter, QString* selectedFilter);
QString getSaveScoreName(const QString& title,
QString& name, const QString& filter, QString* selectedFilter, bool selectFolder);
QString getStyleFilename(bool open, const QString& title = QString());
QString getFotoFilename();
QString getChordStyleFilename(bool open);
QStringList getSoundFont(const QString&);
QString getScanFile(const QString&);
QString getAudioFile(const QString&);
QString getDrumsetFilename(bool open);
2012-07-02 18:05:10 +02:00
QString getPluginFilename(bool open);
2012-05-26 14:49:10 +02:00
QString getPaletteFilename(bool open);
QString getWallpaper(const QString& caption);
bool hRaster() const { return hRasterAction->isChecked(); }
bool vRaster() const { return vRasterAction->isChecked(); }
PaletteBox* getPaletteBox();
void disableCommands(bool val) { inChordEditor = val; }
void tupletDialog();
void selectSimilar(Element*, bool);
void selectElementDialog(Element* e);
void transpose();
Q_INVOKABLE void openExternalLink(const QString&);
Q_INVOKABLE void closeWebPanelPermanently();
void endCmd();
void printFile();
bool exportFile();
bool exportParts();
bool saveAs(Score*, bool saveCopy, const QString& path, const QString& ext);
bool savePsPdf(const QString& saveName, QPrinter::OutputFormat format);
bool savePsPdf(Score* cs, const QString& saveName, QPrinter::OutputFormat format);
2012-09-29 16:46:45 +02:00
Score* readScore(const QString& name);
2012-05-26 14:49:10 +02:00
bool saveAs(Score*, bool saveCopy = false);
bool saveSelection(Score*);
void addImage(Score*, Element*);
2012-09-29 16:46:45 +02:00
2012-05-26 14:49:10 +02:00
bool savePng(Score*, const QString& name, bool screenshot, bool transparent, double convDpi, QImage::Format format);
bool saveAudio(Score*, const QString& name, const QString& type);
bool saveMp3(Score*, const QString& name);
bool saveSvg(Score*, const QString& name);
bool savePng(Score*, const QString& name);
bool saveLilypond(Score*, const QString& name);
bool saveMidi(Score* score, const QString& name);
2012-05-26 14:49:10 +02:00
void closeScore(Score* score);
void addTempo();
void addMetronome();
Q_INVOKABLE QString getLocaleISOCode() const;
2012-05-26 14:49:10 +02:00
Navigator* navigator() const;
NScrollArea* navigatorScrollArea() const { return _navigator; }
void updateLayer();
void updatePlayMode();
bool metronome() const { return metronomeAction->isChecked(); }
bool panDuringPlayback() const { return panAction->isChecked(); }
void noteTooShortForTupletDialog();
void enableInputToolbar(bool enableInput);
void loadFiles();
static Palette* newTextPalette();
static Palette* newTimePalette();
2012-05-26 14:49:10 +02:00
static Palette* newRepeatsPalette();
static Palette* newBreaksPalette();
static Palette* newBeamPalette();
static Palette* newDynamicsPalette();
static Palette* newFramePalette();
static Palette* newFingeringPalette();
static Palette* newFallDoitPalette();
static Palette* newTremoloPalette();
static Palette* newNoteHeadsPalette();
static Palette* newArticulationsPalette();
static Palette* newBracketsPalette();
static Palette* newBreathPalette();
static Palette* newArpeggioPalette();
static Palette* newClefsPalette();
static Palette* newGraceNotePalette();
static Palette* newKeySigPalette();
static Palette* newAccidentalsPalette();
static Palette* newBarLinePalette();
static Palette* newLinesPalette();
Inspector* getInspector() { return inspector; }
2012-07-02 18:05:10 +02:00
QDeclarativeEngine* qml();
PluginCreator* getPluginCreator() { return pluginCreator; }
2012-12-10 09:15:50 +01:00
ScoreView* currentScoreView() const { return cv; }
2012-05-26 14:49:10 +02:00
};
extern MuseScore* mscore;
2012-12-10 09:15:50 +01:00
extern MuseScoreCore* mscoreCore;
2012-05-26 14:49:10 +02:00
extern QString dataPath;
extern QAction* getAction(const char*);
extern Shortcut* midiActionMap[128];
extern void setMscoreLocale(QString localeName);
extern QPixmap sym2pixmap(const Sym* s, qreal mag);
extern void convertMidi(Score*, MidiFile* mf);
2012-09-27 21:34:36 +02:00
extern bool saveMxl(Score*, const QString& name);
extern bool saveXml(Score*, const QString& name);
2012-05-26 14:49:10 +02:00
#endif