2012-05-26 14:49:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
2016-06-30 15:34:02 +02:00
// Copyright (C) 2002-2016 Werner Schweer
2012-05-26 14:49:10 +02:00
//
// This program is free software; you can redistribute it and/or modify
2012-12-06 14:21:53 +01:00
// 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
2012-05-26 14:49:10 +02:00
//=============================================================================
# include <fenv.h>
2017-02-08 15:34:53 +01:00
# include "loginmanager.h"
# include "uploadscoredialog.h"
2016-09-29 22:27:31 +02:00
# include <QStyleFactory>
2014-05-24 18:11:51 +02:00
# include "palettebox.h"
2013-02-21 11:04:41 +01:00
# include "config.h"
2012-05-26 14:49:10 +02:00
# 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 "libmscore/xml.h"
# include "seq.h"
# include "libmscore/tempo.h"
# include "libmscore/sym.h"
# include "pagesettings.h"
2013-06-10 11:03:34 +02:00
# include "debugger/debugger.h"
2012-05-26 14:49:10 +02:00
# include "editstyle.h"
# include "playpanel.h"
# include "libmscore/page.h"
# include "mixer.h"
2014-06-02 12:12:53 +02:00
# include "selectionwindow.h"
2012-05-26 14:49:10 +02:00
# include "palette.h"
2013-02-10 14:50:18 +01:00
# include "palettebox.h"
2012-05-26 14:49:10 +02:00
# 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"
2017-07-06 07:10:27 +02:00
# include "timeline.h"
2014-11-11 20:48:57 +01:00
# include "importmidi/importmidi_panel.h"
2017-11-29 08:21:36 +01:00
# include "importmidi/importmidi_operations.h"
2012-05-26 14:49:10 +02:00
# include "libmscore/chord.h"
# include "libmscore/segment.h"
# include "editraster.h"
# include "pianotools.h"
# include "mediadialog.h"
2013-02-06 16:43:25 +01:00
# include "workspace.h"
2012-05-26 14:49:10 +02:00
# include "selectdialog.h"
2016-09-22 16:07:47 +02:00
# include "selectnotedialog.h"
2012-05-26 14:49:10 +02:00
# include "transposedialog.h"
# include "metaedit.h"
2013-06-10 11:03:34 +02:00
# include "inspector/inspector.h"
2015-02-19 23:17:14 +01:00
# ifdef OMR
2012-05-26 14:49:10 +02:00
# include "omrpanel.h"
2015-02-19 23:17:14 +01:00
# endif
2012-05-26 14:49:10 +02:00
# include "shortcut.h"
2015-01-07 13:47:03 +01:00
# ifdef SCRIPT_INTERFACE
2012-07-02 18:05:10 +02:00
# include "pluginCreator.h"
2013-02-11 14:13:38 +01:00
# include "pluginManager.h"
2015-01-07 13:47:03 +01:00
# endif
2012-07-12 18:46:15 +02:00
# include "helpBrowser.h"
2012-08-15 17:43:31 +02:00
# include "drumtools.h"
2012-08-31 14:03:36 +02:00
# include "editstafftype.h"
2013-02-15 22:39:56 +01:00
# include "texttools.h"
2013-09-30 18:38:05 +02:00
# include "textpalette.h"
# include "resourceManager.h"
2014-07-10 14:13:37 +02:00
# include "scoreaccessibility.h"
2017-07-06 13:22:22 +02:00
# include "startupWizard.h"
2012-05-26 14:49:10 +02:00
# include "libmscore/mscore.h"
# include "libmscore/system.h"
2014-12-18 01:20:52 +01:00
# include "libmscore/measure.h"
2012-05-26 14:49:10 +02:00
# include "libmscore/chordlist.h"
# include "libmscore/volta.h"
2012-07-12 15:35:35 +02:00
# include "libmscore/lasso.h"
2015-05-06 09:08:20 +02:00
# include "libmscore/excerpt.h"
2017-03-17 09:58:02 +01:00
# include "libmscore/synthesizerstate.h"
2013-09-30 18:38:05 +02:00
2013-04-02 20:46:07 +02:00
# include "driver.h"
2012-05-26 14:49:10 +02:00
2013-04-02 20:46:07 +02:00
# include "effects/zita1/zita.h"
2015-09-08 15:39:04 +02:00
# include "effects/compressor/compressor.h"
2013-04-02 20:46:07 +02:00
# include "effects/noeffect/noeffect.h"
2013-03-26 19:59:51 +01:00
# include "synthesizer/synthesizer.h"
2013-04-03 12:13:23 +02:00
# include "synthesizer/synthesizergui.h"
2013-04-02 20:46:07 +02:00
# include "synthesizer/msynthesizer.h"
# include "fluid/fluid.h"
2014-04-25 19:26:22 +02:00
# include "qmlplugin.h"
2014-05-15 19:28:25 +02:00
# include "accessibletoolbutton.h"
2016-07-04 09:32:43 +02:00
# include "toolbuttonmenu.h"
2015-02-01 20:50:01 +01:00
# include "searchComboBox.h"
2014-11-12 16:36:40 +01:00
# include "startcenter.h"
2015-02-02 09:30:17 +01:00
# include "help.h"
2014-11-24 20:23:01 +01:00
# include "awl/aslider.h"
2014-11-12 16:36:40 +01:00
2017-05-16 05:01:10 +02:00
# ifdef USE_LAME
# include "exportmp3.h"
# endif
2018-02-12 11:34:54 +01:00
# ifdef Q_OS_MAC
# include "macos/cocoabridge.h"
# endif
2013-05-13 18:49:17 +02:00
# ifdef AEOLUS
extern Ms : : Synthesizer * createAeolus ( ) ;
# endif
# ifdef ZERBERUS
extern Ms : : Synthesizer * createZerberus ( ) ;
# endif
2016-03-23 12:23:02 +01:00
# ifdef QT_NO_DEBUG
Q_LOGGING_CATEGORY ( undoRedo , " undoRedo " , QtCriticalMsg )
# else
2016-10-25 17:30:55 +02:00
Q_LOGGING_CATEGORY ( undoRedo , " undoRedo " , QtCriticalMsg )
// Q_LOGGING_CATEGORY(undoRedo, "undoRedo")
2016-03-23 12:23:02 +01:00
# endif
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:49:10 +02:00
MuseScore * mscore ;
2013-03-26 19:59:51 +01:00
MasterSynthesizer * synti ;
2012-05-26 14:49:10 +02:00
bool enableExperimental = false ;
QString dataPath ;
2013-07-05 18:54:11 +02:00
QString iconPath ;
2012-05-26 14:49:10 +02:00
bool converterMode = false ;
2016-05-14 13:11:41 +02:00
bool processJob = false ;
2012-05-26 14:49:10 +02:00
bool externalIcons = false ;
2015-03-04 16:44:03 +01:00
bool pluginMode = false ;
2012-05-26 14:49:10 +02:00
static bool startWithNewScore = false ;
2015-11-21 17:01:14 +01:00
double guiScaling = 0.0 ;
2016-05-28 22:56:06 +02:00
static double userDPI = 0.0 ;
2014-12-07 17:46:57 +01:00
int trimMargin = - 1 ;
2015-05-04 11:50:03 +02:00
bool noWebView = false ;
2015-05-06 09:08:20 +02:00
bool exportScoreParts = false ;
2016-05-03 14:23:09 +02:00
bool ignoreWarnings = false ;
2012-05-26 14:49:10 +02:00
QString mscoreGlobalShare ;
2014-11-12 15:01:08 +01:00
2012-05-26 14:49:10 +02:00
static QString outFileName ;
2016-05-14 13:11:41 +02:00
static QString jsonFileName ;
2013-04-15 19:56:59 +02:00
static QString audioDriver ;
2012-05-26 14:49:10 +02:00
static QString pluginName ;
static QString styleFile ;
2014-11-20 12:49:51 +01:00
static bool scoresOnCommandline { false } ;
2016-06-30 15:34:02 +02:00
static QList < QTranslator * > translatorList ;
2012-12-05 08:45:47 +01:00
QString localeName ;
2012-05-26 14:49:10 +02:00
bool useFactorySettings = false ;
2014-05-13 14:47:18 +02:00
bool deletePreferences = false ;
2012-05-26 14:49:10 +02:00
QString styleName ;
QString revision ;
2013-07-17 14:36:34 +02:00
QErrorMessage * errorMessage ;
2014-03-27 11:34:12 +01:00
const char * voiceActions [ ] = { " voice-1 " , " voice-2 " , " voice-3 " , " voice-4 " } ;
2012-05-26 14:49:10 +02:00
2016-05-31 17:44:39 +02:00
const std : : list < const char * > MuseScore : : _allNoteInputMenuEntries {
" note-input " ,
" 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 " ,
2016-05-31 19:48:28 +02:00
" pad-dot3 " ,
" pad-dot4 " ,
2016-05-31 17:44:39 +02:00
" tie " ,
" " ,
" pad-rest " ,
" " ,
" sharp2 " ,
" sharp " ,
" nat " ,
" flat " ,
" flat2 " ,
" flip " ,
" " ,
" voice-1 " ,
" voice-2 " ,
" voice-3 " ,
" voice-4 "
} ;
const std : : list < const char * > MuseScore : : _advancedNoteInputMenuEntries {
" note-input " ,
" 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 " ,
2016-05-31 19:48:28 +02:00
" pad-dot3 " ,
" pad-dot4 " ,
2016-05-31 17:44:39 +02:00
" tie " ,
" " ,
" pad-rest " ,
" " ,
" sharp2 " ,
" sharp " ,
" nat " ,
" flat " ,
" flat2 " ,
" flip " ,
" " ,
" voice-1 " ,
" voice-2 " ,
" voice-3 " ,
" voice-4 "
} ;
const std : : list < const char * > MuseScore : : _basicNoteInputMenuEntries {
" note-input " ,
" pad-note-32 " ,
" pad-note-16 " ,
" pad-note-8 " ,
" pad-note-4 " ,
" pad-note-2 " ,
" pad-note-1 " ,
" pad-dot " ,
" tie " ,
" " ,
" pad-rest " ,
" " ,
" sharp " ,
" nat " ,
" flat " ,
" flip " ,
" " ,
" voice-1 " ,
" voice-2 " ,
" voice-3 " ,
" voice-4 "
} ;
2017-07-18 09:45:00 +02:00
const std : : list < const char * > MuseScore : : _allFileOperationEntries {
" file-new " ,
" file-open " ,
" file-save " ,
" print " ,
" redo " ,
" undo "
} ;
const std : : list < const char * > MuseScore : : _allPlaybackControlEntries {
" midi-on " ,
" rewind " ,
" play " ,
" loop " ,
" repeat " ,
" pan " ,
" metronome "
} ;
2016-05-31 17:44:39 +02:00
2014-07-13 18:33:26 +02:00
extern bool savePositions ( Score * , const QString & name , bool segments ) ;
2013-02-25 21:57:11 +01:00
extern TextPalette * textPalette ;
2012-05-26 14:49:10 +02:00
2015-11-23 16:02:33 +01:00
static constexpr double SCALE_MAX = 16.0 ;
static constexpr double SCALE_MIN = 0.05 ;
static constexpr double SCALE_STEP = 1.7 ;
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// cmdInsertMeasure
//---------------------------------------------------------
void MuseScore : : cmdInsertMeasures ( )
{
2015-02-03 13:42:37 +01:00
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 ( ) ;
}
2013-04-13 23:53:44 +02:00
}
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// InsertMeasuresDialog
//---------------------------------------------------------
InsertMeasuresDialog : : InsertMeasuresDialog ( QWidget * parent )
: QDialog ( parent )
{
2016-09-26 20:44:20 +02:00
setObjectName ( " InsertMeasuresDialog " ) ;
2013-02-07 13:10:46 +01:00
setupUi ( this ) ;
setWindowFlags ( this - > windowFlags ( ) & ~ Qt : : WindowContextHelpButtonHint ) ;
2013-11-28 21:39:17 +01:00
insmeasures - > selectAll ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// Insert Measure --> accept
//---------------------------------------------------------
void InsertMeasuresDialog : : accept ( )
{
2013-04-28 21:29:12 +02:00
int n = insmeasures - > value ( ) ;
if ( mscore - > currentScore ( ) )
2017-01-18 14:16:33 +01:00
mscore - > currentScoreView ( ) - > cmdInsertMeasures ( n , ElementType : : MEASURE ) ;
2013-04-28 21:29:12 +02:00
done ( 1 ) ;
2012-05-26 14:49:10 +02:00
}
2016-09-26 20:44:20 +02:00
//---------------------------------------------------------
// InsertMeasuresDialog hideEvent
//---------------------------------------------------------
void InsertMeasuresDialog : : hideEvent ( QHideEvent * event )
{
MuseScore : : saveGeometry ( this ) ;
QDialog : : hideEvent ( event ) ;
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// getSharePath
//---------------------------------------------------------
2015-02-02 09:30:17 +01:00
QString getSharePath ( )
2012-05-26 14:49:10 +02:00
{
2013-05-16 16:12:22 +02:00
# ifdef Q_OS_WIN
2012-05-26 14:49:10 +02:00
QDir dir ( QCoreApplication : : applicationDirPath ( ) + QString ( " /../ " INSTALL_NAME ) ) ;
return dir . absolutePath ( ) + " / " ;
# else
2013-05-16 16:12:22 +02:00
# ifdef Q_OS_MAC
2012-05-26 14:49:10 +02:00
QDir dir ( QCoreApplication : : applicationDirPath ( ) + QString ( " /../Resources " ) ) ;
return dir . absolutePath ( ) + " / " ;
# else
2016-01-04 02:36:36 +01:00
// Try relative path (needed for portable AppImage and non-standard installations)
QDir dir ( QCoreApplication : : applicationDirPath ( ) + QString ( " /../share/ " INSTALL_NAME ) ) ;
if ( dir . exists ( ) )
return dir . absolutePath ( ) + " / " ;
// Otherwise fall back to default location (e.g. if binary has moved relative to share)
2012-05-26 14:49:10 +02:00
return QString ( INSTPREFIX " /share/ " INSTALL_NAME ) ;
# endif
# endif
}
//---------------------------------------------------------
// printVersion
//---------------------------------------------------------
static void printVersion ( const char * prog )
{
2015-05-06 17:38:18 +02:00
if ( MuseScore : : unstable ( ) )
fprintf ( stderr , " %s: Music Score Editor \n Unstable Prerelease for Version %s; Build %s \n " ,
2012-05-26 14:49:10 +02:00
prog , VERSION , qPrintable ( revision ) ) ;
2015-05-06 17:38:18 +02:00
else
fprintf ( stderr , " %s: Music Score Editor; Version %s; Build %s \n " , prog , VERSION , qPrintable ( revision ) ) ;
2012-05-26 14:49:10 +02:00
}
2014-11-13 09:52:12 +01:00
static const int RECENT_LIST_SIZE = 20 ;
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// closeEvent
//---------------------------------------------------------
void MuseScore : : closeEvent ( QCloseEvent * ev )
{
unloadPlugins ( ) ;
2016-03-11 12:18:46 +01:00
QList < MasterScore * > removeList ;
for ( MasterScore * score : scoreList ) {
2012-05-26 14:49:10 +02:00
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
2016-03-11 12:18:46 +01:00
for ( MasterScore * score : removeList )
2012-05-26 14:49:10 +02:00
scoreList . removeAll ( score ) ;
writeSessionFile ( true ) ;
2016-03-11 12:18:46 +01:00
for ( MasterScore * score : scoreList ) {
2012-05-26 14:49:10 +02:00
if ( ! score - > tmpName ( ) . isEmpty ( ) ) {
QFile f ( score - > tmpName ( ) ) ;
f . remove ( ) ;
}
}
writeSettings ( ) ;
2014-11-17 13:06:34 +01:00
2014-11-14 21:03:46 +01:00
_loginManager - > save ( ) ;
2013-04-12 10:56:17 +02:00
2012-05-26 14:49:10 +02:00
ev - > accept ( ) ;
2017-11-29 08:21:36 +01:00
if ( Shortcut : : dirty )
Shortcut : : save ( ) ;
2012-06-11 16:26:37 +02:00
this - > deleteLater ( ) ; //this is necessary on windows http://musescore.org/node/16713
2012-05-26 14:49:10 +02:00
qApp - > quit ( ) ;
}
2017-11-29 08:21:36 +01:00
void updateExternalValuesFromPreferences ( ) {
// set values in libmscore
MScore : : bgColor = preferences . getColor ( PREF_UI_CANVAS_BG_COLOR ) ;
MScore : : dropColor = preferences . getColor ( PREF_UI_SCORE_NOTE_DROPCOLOR ) ;
MScore : : defaultColor = preferences . getColor ( PREF_UI_SCORE_DEFAULTCOLOR ) ;
MScore : : defaultPlayDuration = preferences . getInt ( PREF_SCORE_NOTE_DEFAULTPLAYDURATION ) ;
MScore : : panPlayback = preferences . getBool ( PREF_APP_PLAYBACK_PANPLAYBACK ) ;
MScore : : playRepeats = preferences . getBool ( PREF_APP_PLAYBACK_PLAYREPEATS ) ;
MScore : : warnPitchRange = preferences . getBool ( PREF_SCORE_NOTE_WARNPITCHRANGE ) ;
MScore : : layoutBreakColor = preferences . getColor ( PREF_UI_SCORE_LAYOUTBREAKCOLOR ) ;
MScore : : frameMarginColor = preferences . getColor ( PREF_UI_SCORE_FRAMEMARGINCOLOR ) ;
MScore : : setVerticalOrientation ( preferences . getBool ( PREF_UI_CANVAS_SCROLL_VERTICALORIENTATION ) ) ;
MScore : : selectColor [ 0 ] = preferences . getColor ( PREF_UI_SCORE_VOICE1_COLOR ) ;
MScore : : selectColor [ 1 ] = preferences . getColor ( PREF_UI_SCORE_VOICE2_COLOR ) ;
MScore : : selectColor [ 2 ] = preferences . getColor ( PREF_UI_SCORE_VOICE3_COLOR ) ;
MScore : : selectColor [ 3 ] = preferences . getColor ( PREF_UI_SCORE_VOICE4_COLOR ) ;
MScore : : setHRaster ( preferences . getInt ( PREF_UI_APP_RASTER_HORIZONTAL ) ) ;
MScore : : setVRaster ( preferences . getInt ( PREF_UI_APP_RASTER_VERTICAL ) ) ;
MScore : : setNudgeStep ( .1 ) ; // cursor key (default 0.1)
MScore : : setNudgeStep10 ( 1.0 ) ; // Ctrl + cursor key (default 1.0)
MScore : : setNudgeStep50 ( 0.01 ) ; // Alt + cursor key (default 0.01)
//Create directories if they are missing
QDir dir ;
dir . mkpath ( preferences . getString ( PREF_APP_PATHS_MYSCORES ) ) ;
dir . mkpath ( preferences . getString ( PREF_APP_PATHS_MYSTYLES ) ) ;
dir . mkpath ( preferences . getString ( PREF_APP_PATHS_MYIMAGES ) ) ;
dir . mkpath ( preferences . getString ( PREF_APP_PATHS_MYTEMPLATES ) ) ;
dir . mkpath ( preferences . getString ( PREF_APP_PATHS_MYPLUGINS ) ) ;
foreach ( QString path , preferences . getString ( PREF_APP_PATHS_MYSOUNDFONTS ) . split ( " ; " ) )
dir . mkpath ( path ) ;
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// preferencesChanged
//---------------------------------------------------------
void MuseScore : : preferencesChanged ( )
{
2017-11-29 08:21:36 +01:00
updateExternalValuesFromPreferences ( ) ;
2018-02-15 11:33:44 +01:00
setPlayRepeats ( MScore : : playRepeats ) ;
getAction ( " pan " ) - > setChecked ( MScore : : panPlayback ) ;
getAction ( " follow " ) - > setChecked ( preferences . getBool ( PREF_APP_PLAYBACK_FOLLOWSONG ) ) ;
getAction ( " midi-on " ) - > setEnabled ( preferences . getBool ( PREF_IO_MIDI_ENABLEINPUT ) ) ;
getAction ( " toggle-statusbar " ) - > setChecked ( preferences . getBool ( PREF_UI_APP_SHOWSTATUSBAR ) ) ;
_statusBar - > setVisible ( preferences . getBool ( PREF_UI_APP_SHOWSTATUSBAR ) ) ;
MuseScore : : updateUiStyleAndTheme ( ) ;
2017-11-29 08:21:36 +01:00
QString fgWallpaper = preferences . getString ( PREF_UI_CANVAS_FG_WALLPAPER ) ;
2012-05-26 14:49:10 +02:00
for ( int i = 0 ; i < tab1 - > count ( ) ; + + i ) {
ScoreView * canvas = tab1 - > view ( i ) ;
if ( canvas = = 0 )
continue ;
2017-11-29 08:21:36 +01:00
if ( preferences . getBool ( PREF_UI_CANVAS_BG_USECOLOR ) )
canvas - > setBackground ( preferences . getColor ( PREF_UI_CANVAS_BG_COLOR ) ) ;
2012-05-26 14:49:10 +02:00
else {
2017-11-29 08:21:36 +01:00
QPixmap * pm = new QPixmap ( preferences . getString ( PREF_UI_CANVAS_BG_WALLPAPER ) ) ;
2012-05-26 14:49:10 +02:00
canvas - > setBackground ( pm ) ;
}
2017-11-29 08:21:36 +01:00
if ( preferences . getBool ( PREF_UI_CANVAS_FG_USECOLOR ) )
canvas - > setForeground ( preferences . getColor ( PREF_UI_CANVAS_FG_COLOR ) ) ;
2012-05-26 14:49:10 +02:00
else {
2017-11-29 08:21:36 +01:00
QPixmap * pm = new QPixmap ( fgWallpaper ) ;
2012-05-26 14:49:10 +02:00
if ( pm = = 0 | | pm - > isNull ( ) )
2017-11-29 08:21:36 +01:00
qDebug ( " no valid pixmap %s " , fgWallpaper . toLatin1 ( ) . data ( ) ) ;
2012-05-26 14:49:10 +02:00
canvas - > setForeground ( pm ) ;
}
}
if ( tab2 ) {
for ( int i = 0 ; i < tab2 - > count ( ) ; + + i ) {
ScoreView * canvas = tab2 - > view ( i ) ;
if ( canvas = = 0 )
continue ;
2017-11-29 08:21:36 +01:00
if ( preferences . getBool ( PREF_UI_CANVAS_BG_USECOLOR ) )
canvas - > setBackground ( preferences . getColor ( PREF_UI_CANVAS_BG_COLOR ) ) ;
2012-05-26 14:49:10 +02:00
else {
2017-11-29 08:21:36 +01:00
QPixmap * pm = new QPixmap ( preferences . getString ( PREF_UI_CANVAS_BG_WALLPAPER ) ) ;
2012-05-26 14:49:10 +02:00
canvas - > setBackground ( pm ) ;
}
2017-11-29 08:21:36 +01:00
if ( preferences . getBool ( PREF_UI_CANVAS_FG_USECOLOR ) )
canvas - > setForeground ( preferences . getColor ( PREF_UI_CANVAS_FG_COLOR ) ) ;
2012-05-26 14:49:10 +02:00
else {
2017-11-29 08:21:36 +01:00
QPixmap * pm = new QPixmap ( fgWallpaper ) ;
2012-05-26 14:49:10 +02:00
if ( pm = = 0 | | pm - > isNull ( ) )
2017-11-29 08:21:36 +01:00
qDebug ( " no valid pixmap %s " , fgWallpaper . toLatin1 ( ) . data ( ) ) ;
2012-05-26 14:49:10 +02:00
canvas - > setForeground ( pm ) ;
}
}
}
2014-10-11 15:32:34 +02:00
transportTools - > setEnabled ( ! noSeq & & seq & & seq - > isRunning ( ) ) ;
playId - > setEnabled ( ! noSeq & & seq & & seq - > isRunning ( ) ) ;
2012-05-26 14:49:10 +02:00
2018-02-15 11:33:44 +01:00
// change workspace
if ( preferences . getString ( PREF_APP_WORKSPACE ) ! = Workspace : : currentWorkspace - > name ( ) ) {
Workspace * workspace = 0 ;
for ( Workspace * w : Workspace : : workspaces ( ) ) {
if ( w - > name ( ) = = preferences . getString ( PREF_APP_WORKSPACE ) ) {
workspace = w ;
break ;
}
}
if ( workspace ! = 0 ) {
mscore - > changeWorkspace ( workspace ) ;
mscore - > getPaletteBox ( ) - > updateWorkspaces ( ) ;
}
}
2015-01-12 00:55:47 +01:00
2016-10-08 16:56:19 +02:00
delete newWizard ;
newWizard = 0 ;
2012-05-26 14:49:10 +02:00
}
2016-05-31 17:44:39 +02:00
//---------------------------------------------------------
// populateNoteInputMenu
//---------------------------------------------------------
void MuseScore : : populateNoteInputMenu ( )
{
entryTools - > clear ( ) ;
for ( const auto s : _noteInputMenuEntries ) {
if ( ! * s )
entryTools - > addSeparator ( ) ;
else {
QAction * a = getAction ( s ) ;
2016-08-03 17:29:52 +02:00
QWidget * w ;
2016-07-04 09:32:43 +02:00
if ( strcmp ( s , " note-input " ) = = 0 ) {
//-----------------------------------------------------------------
// Note Entry Modes menu
// ToolButtonMenu to swap between Note Entry Methods
//-----------------------------------------------------------------
QActionGroup * noteEntryMethods = new QActionGroup ( entryTools ) ;
noteEntryMethods - > addAction ( getAction ( " note-input-steptime " ) ) ;
noteEntryMethods - > addAction ( getAction ( " note-input-repitch " ) ) ;
noteEntryMethods - > addAction ( getAction ( " note-input-rhythm " ) ) ;
noteEntryMethods - > addAction ( getAction ( " note-input-realtime-auto " ) ) ;
noteEntryMethods - > addAction ( getAction ( " note-input-realtime-manual " ) ) ;
2018-03-21 01:26:40 +01:00
connect ( noteEntryMethods , SIGNAL ( triggered ( QAction * ) ) , this , SLOT ( cmd ( QAction * ) ) ) ;
2016-08-19 22:58:23 +02:00
2016-08-03 17:29:52 +02:00
w = new ToolButtonMenu ( tr ( " Note Entry Methods " ) ,
ToolButtonMenu : : TYPES : : ICON_CHANGED ,
getAction ( " note-input " ) ,
noteEntryMethods ,
this ) ;
2016-07-04 09:32:43 +02:00
}
else if ( strncmp ( s , " voice- " , 6 ) = = 0 ) {
2016-06-03 13:40:18 +02:00
AccessibleToolButton * tb = new AccessibleToolButton ( this , a ) ;
2016-10-03 12:05:37 +02:00
tb - > setObjectName ( " voice " ) ;
2016-05-31 17:44:39 +02:00
tb - > setFocusPolicy ( Qt : : ClickFocus ) ;
tb - > setToolButtonStyle ( Qt : : ToolButtonTextOnly ) ;
2016-10-03 15:28:58 +02:00
tb - > setProperty ( ( QString ( " voice%1 " ) . arg ( atoi ( s + 6 ) ) ) . toUtf8 ( ) . data ( ) , true ) ;
2016-05-31 17:44:39 +02:00
QPalette p ( tb - > palette ( ) ) ;
2016-06-01 14:47:51 +02:00
int i = atoi ( s + 6 ) - 1 ;
2016-05-31 17:44:39 +02:00
p . setColor ( QPalette : : Base , MScore : : selectColor [ i ] ) ;
tb - > setPalette ( p ) ;
a - > setCheckable ( true ) ;
2016-06-03 13:40:18 +02:00
// tb->setDefaultAction(a);
2016-08-03 17:29:52 +02:00
w = tb ;
2016-05-31 17:44:39 +02:00
}
else
2016-08-03 17:29:52 +02:00
w = new AccessibleToolButton ( entryTools , a ) ;
entryTools - > addWidget ( w ) ;
2016-05-31 17:44:39 +02:00
}
}
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// MuseScore
//---------------------------------------------------------
MuseScore : : MuseScore ( )
: QMainWindow ( )
{
2017-05-02 14:17:31 +02:00
QScreen * screen = QGuiApplication : : primaryScreen ( ) ;
2016-05-28 22:56:06 +02:00
if ( userDPI = = 0.0 ) {
2015-11-24 20:51:10 +01:00
# if defined(Q_OS_WIN)
if ( QSysInfo : : WindowsVersion < = QSysInfo : : WV_WINDOWS7 )
_physicalDotsPerInch = screen - > logicalDotsPerInch ( ) * screen - > devicePixelRatio ( ) ;
else
_physicalDotsPerInch = screen - > physicalDotsPerInch ( ) ; // physical resolution
# else
2015-11-16 14:24:47 +01:00
_physicalDotsPerInch = screen - > physicalDotsPerInch ( ) ; // physical resolution
2015-11-24 20:51:10 +01:00
# endif
2016-05-28 22:56:06 +02:00
}
else {
_physicalDotsPerInch = userDPI ;
}
2015-11-21 17:01:14 +01:00
if ( guiScaling = = 0.0 ) {
// set scale for icons, palette elements, window sizes, etc
// the default values are hard coded in pixel sizes and assume ~96 DPI
if ( qAbs ( _physicalDotsPerInch - DPI_DISPLAY ) > 6.0 )
guiScaling = _physicalDotsPerInch / DPI_DISPLAY ;
else
guiScaling = 1.0 ;
}
2015-11-16 14:24:47 +01:00
2016-09-03 17:45:59 +02:00
MScore : : pixelRatio = DPI / screen - > logicalDotsPerInch ( ) ;
2016-07-31 00:36:05 +02:00
setObjectName ( " MuseScore " ) ;
2012-05-26 14:49:10 +02:00
_sstate = STATE_INIT ;
2015-07-25 01:26:54 +02:00
setWindowTitle ( QString ( MUSESCORE_NAME_VERSION ) ) ;
2017-11-29 08:21:36 +01:00
setIconSize ( QSize ( preferences . getInt ( PREF_UI_THEME_ICONWIDTH ) * guiScaling , preferences . getInt ( PREF_UI_THEME_ICONHEIGHT ) * guiScaling ) ) ;
2012-05-26 14:49:10 +02:00
2014-11-12 18:57:15 +01:00
ucheck = new UpdateChecker ( ) ;
2012-05-26 14:49:10 +02:00
setAcceptDrops ( true ) ;
2014-11-12 18:57:15 +01:00
setFocusPolicy ( Qt : : NoFocus ) ;
2012-05-26 14:49:10 +02:00
2017-11-29 08:21:36 +01:00
# ifdef SCRIPT_INTERFACE
pluginManager = new PluginManager ( 0 ) ;
# endif
2015-03-04 15:54:50 +01:00
if ( ! converterMode & & ! pluginMode ) {
2015-02-19 17:29:30 +01:00
_loginManager = new LoginManager ( this ) ;
2016-03-09 07:02:06 +01:00
#if 0
2015-02-19 17:29:30 +01:00
// initialize help engine
QString lang = mscore - > getLocaleISOCode ( ) ;
if ( lang = = " en_US " ) // HACK
lang = " en " ;
QString s = getSharePath ( ) + " manual/doc_ " + lang + " .qhc " ;
_helpEngine = new QHelpEngine ( s , this ) ;
if ( ! _helpEngine - > setupData ( ) ) {
qDebug ( " cannot setup data for help engine: %s " , qPrintable ( _helpEngine - > error ( ) ) ) ;
delete _helpEngine ;
_helpEngine = 0 ;
}
2016-03-09 07:02:06 +01:00
# endif
2015-02-19 17:29:30 +01:00
}
2012-05-26 14:49:10 +02:00
_positionLabel = new QLabel ;
_positionLabel - > setObjectName ( " decoration widget " ) ; // this prevents animations
_modeText = new QLabel ;
2013-07-04 21:07:38 +02:00
_modeText - > setAutoFillBackground ( false ) ;
_modeText - > setObjectName ( " modeLabel " ) ;
2014-07-10 14:13:37 +02:00
2014-11-14 11:44:48 +01:00
hRasterAction = getAction ( " hraster " ) ;
vRasterAction = getAction ( " vraster " ) ;
loopAction = getAction ( " loop " ) ;
loopInAction = getAction ( " loop-in " ) ;
loopOutAction = getAction ( " loop-out " ) ;
2012-05-26 14:49:10 +02:00
metronomeAction = getAction ( " metronome " ) ;
2014-11-14 11:44:48 +01:00
countInAction = getAction ( " countin " ) ;
panAction = getAction ( " pan " ) ;
2013-10-15 09:36:17 +02:00
2017-05-02 14:17:31 +02:00
_statusBar = new QStatusBar ;
2012-05-26 14:49:10 +02:00
_statusBar - > addPermanentWidget ( new QWidget ( this ) , 2 ) ;
_statusBar - > addPermanentWidget ( new QWidget ( this ) , 100 ) ;
_statusBar - > addPermanentWidget ( _modeText , 0 ) ;
2014-08-26 16:38:33 +02:00
2014-08-12 21:28:40 +02:00
if ( enableExperimental ) {
layerSwitch = new QComboBox ( this ) ;
2014-10-15 20:43:06 +02:00
layerSwitch - > setToolTip ( tr ( " Switch layer " ) ) ;
2014-08-12 21:28:40 +02:00
connect ( layerSwitch , SIGNAL ( activated ( const QString & ) ) , SLOT ( switchLayer ( const QString & ) ) ) ;
playMode = new QComboBox ( this ) ;
2016-06-30 15:34:02 +02:00
playMode - > addItem ( tr ( " Synthesizer " ) ) ;
playMode - > addItem ( tr ( " Audio track " ) ) ;
2014-10-15 20:43:06 +02:00
playMode - > setToolTip ( tr ( " Switch play mode " ) ) ;
2014-08-12 21:28:40 +02:00
connect ( playMode , SIGNAL ( activated ( int ) ) , SLOT ( switchPlayMode ( int ) ) ) ;
_statusBar - > addPermanentWidget ( playMode ) ;
_statusBar - > addPermanentWidget ( layerSwitch ) ;
}
2017-05-02 14:17:31 +02:00
2012-05-26 14:49:10 +02:00
_statusBar - > addPermanentWidget ( _positionLabel , 0 ) ;
setStatusBar ( _statusBar ) ;
2014-07-10 14:13:37 +02:00
ScoreAccessibility : : createInstance ( this ) ;
2012-05-26 14:49:10 +02:00
// otherwise unused actions:
// must be added somewere to work
2014-06-10 23:41:30 +02:00
QActionGroup * ag = Shortcut : : getActionGroupForWidget ( MsWidget : : MAIN_WINDOW ) ;
ag - > setParent ( this ) ;
2014-11-14 11:44:48 +01:00
addActions ( ag - > actions ( ) ) ;
2012-05-26 14:49:10 +02:00
connect ( ag , SIGNAL ( triggered ( QAction * ) ) , SLOT ( cmd ( QAction * ) ) ) ;
mainWindow = new QSplitter ;
2013-05-08 10:54:06 +02:00
mainWindow - > setChildrenCollapsible ( false ) ;
2012-05-26 14:49:10 +02:00
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 ;
2014-06-15 20:52:21 +02:00
_navigator - > setFocusPolicy ( Qt : : NoFocus ) ;
2012-05-26 14:49:10 +02:00
mainWindow - > addWidget ( _navigator ) ;
2016-01-29 12:28:45 +01:00
scorePageLayoutChanged ( ) ;
2017-11-29 08:21:36 +01:00
showNavigator ( preferences . getBool ( PREF_UI_APP_STARTUP_SHOWNAVIGATOR ) ) ;
2012-05-26 14:49:10 +02:00
2017-07-06 07:10:27 +02:00
_timeline = new TDockWidget ;
_timeline - > setFocusPolicy ( Qt : : NoFocus ) ;
addDockWidget ( Qt : : BottomDockWidgetArea , _timeline ) ;
scorePageLayoutChanged ( ) ;
showTimeline ( false ) ;
2013-05-09 18:46:51 +02:00
mainWindow - > setStretchFactor ( 0 , 1 ) ;
mainWindow - > setStretchFactor ( 1 , 0 ) ;
2014-11-12 18:57:15 +01:00
mainWindow - > setSizes ( QList < int > ( { 500 , 50 } ) ) ;
2013-05-09 18:46:51 +02:00
QSplitter * envelope = new QSplitter ;
envelope - > setChildrenCollapsible ( false ) ;
envelope - > setOrientation ( Qt : : Vertical ) ;
envelope - > addWidget ( mainWindow ) ;
2015-01-13 17:27:58 +01:00
2013-09-25 21:53:52 +02:00
importmidiPanel = new ImportMidiPanel ( this ) ;
importmidiPanel - > setVisible ( false ) ;
envelope - > addWidget ( importmidiPanel ) ;
2013-07-22 01:33:56 +02:00
2013-09-25 21:53:52 +02:00
{
importmidiShowPanel = new QFrame ;
QHBoxLayout * hl = new QHBoxLayout ;
hl - > setMargin ( 0 ) ;
hl - > setSpacing ( 0 ) ;
importmidiShowPanel - > setLayout ( hl ) ;
2016-06-30 15:34:02 +02:00
showMidiImportButton = new QPushButton ( ) ;
showMidiImportButton - > setFocusPolicy ( Qt : : ClickFocus ) ;
2013-09-25 21:53:52 +02:00
importmidiShowPanel - > setVisible ( false ) ;
2016-06-30 15:34:02 +02:00
connect ( showMidiImportButton , SIGNAL ( clicked ( ) ) , SLOT ( showMidiImportPanel ( ) ) ) ;
2013-09-25 21:53:52 +02:00
connect ( importmidiPanel , SIGNAL ( closeClicked ( ) ) , importmidiShowPanel , SLOT ( show ( ) ) ) ;
2016-06-30 15:34:02 +02:00
hl - > addWidget ( showMidiImportButton ) ;
2013-09-25 21:53:52 +02:00
QSpacerItem * item = new QSpacerItem ( 1 , 1 , QSizePolicy : : Expanding , QSizePolicy : : Fixed ) ;
hl - > addSpacerItem ( item ) ;
envelope - > addWidget ( importmidiShowPanel ) ;
}
2015-01-13 17:27:58 +01:00
2014-11-12 18:57:15 +01:00
envelope - > setSizes ( QList < int > ( { 550 , 180 } ) ) ;
2012-05-26 14:49:10 +02:00
splitter = new QSplitter ;
2014-05-28 22:35:23 +02:00
tab1 = new ScoreTab ( & scoreList , this ) ;
2012-05-26 14:49:10 +02:00
tab1 - > setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Expanding ) ;
connect ( tab1 , SIGNAL ( currentScoreViewChanged ( ScoreView * ) ) , SLOT ( setCurrentScoreView ( ScoreView * ) ) ) ;
connect ( tab1 , SIGNAL ( tabCloseRequested ( int ) ) , SLOT ( removeTab ( int ) ) ) ;
2014-06-10 23:41:30 +02:00
connect ( tab1 , SIGNAL ( actionTriggered ( QAction * ) ) , SLOT ( cmd ( QAction * ) ) ) ;
2012-05-26 14:49:10 +02:00
splitter - > addWidget ( tab1 ) ;
if ( splitScreen ( ) ) {
2014-05-28 22:35:23 +02:00
tab2 = new ScoreTab ( & scoreList , this ) ;
2012-05-26 14:49:10 +02:00
tab2 - > setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Expanding ) ;
connect ( tab2 , SIGNAL ( currentScoreViewChanged ( ScoreView * ) ) , SLOT ( setCurrentScoreView ( ScoreView * ) ) ) ;
2014-06-18 17:36:28 +02:00
connect ( tab2 , SIGNAL ( tabCloseRequested ( int ) ) , SLOT ( removeTab ( int ) ) ) ;
2014-06-10 23:41:30 +02:00
connect ( tab2 , SIGNAL ( actionTriggered ( QAction * ) ) , SLOT ( cmd ( QAction * ) ) ) ;
2012-05-26 14:49:10 +02:00
splitter - > addWidget ( tab2 ) ;
tab2 - > setVisible ( false ) ;
}
else
tab2 = 0 ;
layout - > addWidget ( splitter ) ;
//---------------------------------------------------
// Transport Action
//---------------------------------------------------
QAction * a ;
# ifdef HAS_MIDI
a = getAction ( " midi-on " ) ;
2017-11-29 08:21:36 +01:00
a - > setEnabled ( preferences . getBool ( PREF_IO_MIDI_ENABLEINPUT ) ) ;
2012-05-26 14:49:10 +02:00
a - > setChecked ( _midiinEnabled ) ;
# endif
2014-11-14 11:44:48 +01:00
getAction ( " undo " ) - > setEnabled ( false ) ;
getAction ( " redo " ) - > setEnabled ( false ) ;
getAction ( " paste " ) - > setEnabled ( false ) ;
2016-04-12 14:47:44 +02:00
getAction ( " swap " ) - > setEnabled ( false ) ;
2014-11-14 11:44:48 +01:00
selectionChanged ( SelState : : NONE ) ;
2012-05-26 14:49:10 +02:00
//---------------------------------------------------
2016-06-03 13:40:18 +02:00
// File Tool Bar
2012-05-26 14:49:10 +02:00
//---------------------------------------------------
2016-06-30 15:34:02 +02:00
fileTools = addToolBar ( " " ) ;
2012-05-26 14:49:10 +02:00
fileTools - > setObjectName ( " file-operations " ) ;
2016-10-04 16:26:58 +02:00
if ( qApp - > layoutDirection ( ) = = Qt : : LayoutDirection : : LeftToRight ) {
for ( auto i : { " file-new " , " file-open " , " file-save " , " print " , " undo " , " redo " } )
fileTools - > addWidget ( new AccessibleToolButton ( fileTools , getAction ( i ) ) ) ;
}
else {
2017-11-20 11:06:56 +01:00
for ( auto i : { " undo " , " redo " , " print " , " file-save " , " file-open " , " file-new " } )
2016-10-04 16:26:58 +02:00
fileTools - > addWidget ( new AccessibleToolButton ( fileTools , getAction ( i ) ) ) ;
}
2012-05-26 14:49:10 +02:00
fileTools - > addSeparator ( ) ;
2014-06-06 14:17:19 +02:00
mag = new MagBox ;
2015-11-23 16:02:33 +01:00
connect ( mag , SIGNAL ( magChanged ( MagIdx ) ) , SLOT ( magChanged ( MagIdx ) ) ) ;
2014-06-06 14:17:19 +02:00
fileTools - > addWidget ( mag ) ;
viewModeCombo = new QComboBox ( this ) ;
2014-08-12 15:49:18 +02:00
# if defined(Q_OS_MAC)
viewModeCombo - > setFocusPolicy ( Qt : : StrongFocus ) ;
# else
2014-06-15 20:52:21 +02:00
viewModeCombo - > setFocusPolicy ( Qt : : TabFocus ) ;
2014-08-12 15:49:18 +02:00
# endif
2017-11-29 08:21:36 +01:00
viewModeCombo - > setFixedHeight ( preferences . getInt ( PREF_UI_THEME_ICONHEIGHT ) + 8 ) ; // hack
2016-06-30 15:34:02 +02:00
viewModeCombo - > addItem ( " " , int ( LayoutMode : : PAGE ) ) ;
viewModeCombo - > addItem ( " " , int ( LayoutMode : : LINE ) ) ;
viewModeCombo - > addItem ( " " , int ( LayoutMode : : SYSTEM ) ) ;
2014-06-06 14:17:19 +02:00
connect ( viewModeCombo , SIGNAL ( activated ( int ) ) , SLOT ( switchLayoutMode ( int ) ) ) ;
fileTools - > addWidget ( viewModeCombo ) ;
2012-05-26 14:49:10 +02:00
2016-06-03 13:40:18 +02:00
//---------------------
// Transport Tool Bar
//---------------------
2016-06-30 15:34:02 +02:00
transportTools = addToolBar ( " " ) ;
2012-05-26 14:49:10 +02:00
transportTools - > setObjectName ( " transport-tools " ) ;
# ifdef HAS_MIDI
2014-05-15 19:28:25 +02:00
transportTools - > addWidget ( new AccessibleToolButton ( transportTools , getAction ( " midi-on " ) ) ) ;
2012-05-26 14:49:10 +02:00
transportTools - > addSeparator ( ) ;
2014-11-14 11:44:48 +01:00
# endif
2014-05-15 19:28:25 +02:00
transportTools - > addWidget ( new AccessibleToolButton ( transportTools , getAction ( " rewind " ) ) ) ;
2014-11-24 20:23:01 +01:00
_playButton = new AccessibleToolButton ( transportTools , getAction ( " play " ) ) ;
transportTools - > addWidget ( _playButton ) ;
2014-05-15 19:28:25 +02:00
transportTools - > addWidget ( new AccessibleToolButton ( transportTools , getAction ( " loop " ) ) ) ;
2012-05-26 14:49:10 +02:00
transportTools - > addSeparator ( ) ;
2015-07-08 21:43:07 +02:00
QAction * repeatAction = getAction ( " repeat " ) ;
2017-11-29 08:21:36 +01:00
repeatAction - > setChecked ( preferences . getBool ( PREF_APP_PLAYBACK_PLAYREPEATS ) ) ;
2015-07-08 21:43:07 +02:00
transportTools - > addWidget ( new AccessibleToolButton ( transportTools , repeatAction ) ) ;
2014-11-14 11:44:48 +01:00
transportTools - > addWidget ( new AccessibleToolButton ( transportTools , getAction ( " pan " ) ) ) ;
2014-05-15 19:28:25 +02:00
transportTools - > addWidget ( new AccessibleToolButton ( transportTools , metronomeAction ) ) ;
2012-05-26 14:49:10 +02:00
2016-06-03 13:40:18 +02:00
//-------------------------------
// Concert Pitch Tool Bar
//-------------------------------
2016-06-30 15:34:02 +02:00
cpitchTools = addToolBar ( " " ) ;
2012-05-26 14:49:10 +02:00
cpitchTools - > setObjectName ( " pitch-tools " ) ;
2016-07-04 09:27:43 +02:00
a = getAction ( " concert-pitch " ) ;
a - > setCheckable ( true ) ;
cpitchTools - > addWidget ( new AccessibleToolButton ( cpitchTools , a ) ) ;
2012-05-26 14:49:10 +02:00
2016-06-03 13:40:18 +02:00
//-------------------------------
// Image Capture Tool Bar
//-------------------------------
2016-06-30 15:34:02 +02:00
fotoTools = addToolBar ( " " ) ;
fotoTools - > setObjectName ( " foto-tools " ) ;
fotoTools - > addWidget ( new AccessibleToolButton ( fotoTools , getAction ( " fotomode " ) ) ) ;
2012-05-26 14:49:10 +02:00
2013-07-04 21:07:38 +02:00
addToolBarBreak ( ) ;
2012-05-26 14:49:10 +02:00
//-------------------------------
2015-03-03 11:28:54 +01:00
// Note Input Tool Bar
2012-05-26 14:49:10 +02:00
//-------------------------------
2016-06-30 15:34:02 +02:00
entryTools = addToolBar ( " " ) ;
2012-05-26 14:49:10 +02:00
entryTools - > setObjectName ( " entry-tools " ) ;
2016-05-31 17:44:39 +02:00
populateNoteInputMenu ( ) ;
2015-02-02 09:30:17 +01:00
2012-05-26 14:49:10 +02:00
//---------------------
// Menus
//---------------------
QMenuBar * mb = menuBar ( ) ;
//---------------------
// Menu File
//---------------------
2016-06-30 15:34:02 +02:00
menuFile = mb - > addMenu ( " " ) ;
menuFile - > setObjectName ( " File " ) ;
2012-05-26 14:49:10 +02:00
2016-06-29 17:13:23 +02:00
a = getAction ( " startcenter " ) ;
a - > setCheckable ( true ) ;
2016-06-30 15:34:02 +02:00
menuFile - > addAction ( a ) ;
menuFile - > addAction ( getAction ( " file-new " ) ) ;
menuFile - > addAction ( getAction ( " file-open " ) ) ;
2014-11-14 11:44:48 +01:00
2016-06-30 15:34:02 +02:00
openRecent = menuFile - > addMenu ( " " ) ;
2014-11-14 11:44:48 +01:00
2012-05-26 14:49:10 +02:00
connect ( openRecent , SIGNAL ( aboutToShow ( ) ) , SLOT ( openRecentMenu ( ) ) ) ;
connect ( openRecent , SIGNAL ( triggered ( QAction * ) ) , SLOT ( selectScore ( QAction * ) ) ) ;
2014-08-12 21:28:40 +02:00
2014-11-14 11:44:48 +01:00
for ( auto i : {
2017-01-31 12:21:44 +01:00
" " ,
" 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 " } ) {
2014-11-14 11:44:48 +01:00
if ( ! * i )
2016-06-30 15:34:02 +02:00
menuFile - > addSeparator ( ) ;
2016-09-19 08:17:08 +02:00
else if ( enableExperimental | | strcmp ( i , " file-save-online " ) ! = 0 )
2016-06-30 15:34:02 +02:00
menuFile - > addAction ( getAction ( i ) ) ;
2014-11-14 11:44:48 +01:00
}
2014-08-12 21:28:40 +02:00
if ( enableExperimental )
2016-06-30 15:34:02 +02:00
menuFile - > addAction ( getAction ( " layer " ) ) ;
menuFile - > addSeparator ( ) ;
menuFile - > addAction ( getAction ( " edit-info " ) ) ;
2013-05-24 16:35:48 +02:00
if ( enableExperimental )
2016-06-30 15:34:02 +02:00
menuFile - > addAction ( getAction ( " media " ) ) ;
menuFile - > addSeparator ( ) ;
menuFile - > addAction ( getAction ( " print " ) ) ;
2013-07-18 10:54:38 +02:00
# ifndef Q_OS_MAC
2016-06-30 15:34:02 +02:00
menuFile - > addSeparator ( ) ;
menuFile - > addAction ( getAction ( " quit " ) ) ;
2013-07-18 10:54:38 +02:00
# endif
2014-11-14 11:44:48 +01:00
2012-05-26 14:49:10 +02:00
//---------------------
// Menu Edit
//---------------------
2016-06-30 15:34:02 +02:00
menuEdit = mb - > addMenu ( " " ) ;
2012-05-26 14:49:10 +02:00
menuEdit - > setObjectName ( " Edit " ) ;
menuEdit - > addAction ( getAction ( " undo " ) ) ;
menuEdit - > addAction ( getAction ( " redo " ) ) ;
menuEdit - > addSeparator ( ) ;
menuEdit - > addAction ( getAction ( " cut " ) ) ;
menuEdit - > addAction ( getAction ( " copy " ) ) ;
2014-11-14 11:44:48 +01:00
menuEdit - > addAction ( getAction ( " paste " ) ) ;
2016-04-12 14:47:44 +02:00
menuEdit - > addAction ( getAction ( " swap " ) ) ;
2017-05-30 11:38:40 +02:00
menuEdit - > addAction ( getAction ( " delete " ) ) ;
2014-11-14 11:44:48 +01:00
2012-05-26 14:49:10 +02:00
menuEdit - > addSeparator ( ) ;
menuEdit - > addAction ( getAction ( " select-all " ) ) ;
menuEdit - > addAction ( getAction ( " select-section " ) ) ;
menuEdit - > addAction ( getAction ( " find " ) ) ;
2012-09-12 16:19:03 +02:00
menuEdit - > addSeparator ( ) ;
2014-11-09 02:02:37 +01:00
2015-02-10 15:45:31 +01:00
menuEdit - > addAction ( getAction ( " instruments " ) ) ;
2014-10-31 14:11:53 +01:00
# ifdef NDEBUG
2014-10-30 15:32:37 +01:00
if ( enableExperimental ) {
2014-10-31 14:11:53 +01:00
# endif
2014-10-30 15:32:37 +01:00
menuEdit - > addSeparator ( ) ;
menuEdit - > addAction ( getAction ( " debugger " ) ) ;
2014-10-31 14:11:53 +01:00
# ifdef NDEBUG
2014-10-30 15:32:37 +01:00
}
2014-10-31 14:11:53 +01:00
# endif
2012-05-26 14:49:10 +02:00
2012-09-12 16:19:03 +02:00
menuEdit - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
pref = menuEdit - > addAction ( " " , this , SLOT ( startPreferenceDialog ( ) ) ) ;
2012-05-26 14:49:10 +02:00
pref - > setMenuRole ( QAction : : PreferencesRole ) ;
2013-06-18 13:10:50 +02:00
//---------------------
// Menu View
//---------------------
2016-06-30 15:34:02 +02:00
menuView = mb - > addMenu ( " " ) ;
2013-06-18 13:10:50 +02:00
menuView - > setObjectName ( " View " ) ;
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 ) ;
2017-11-29 08:21:36 +01:00
a - > setChecked ( preferences . getBool ( PREF_UI_APP_STARTUP_SHOWNAVIGATOR ) ) ;
2013-06-18 13:10:50 +02:00
menuView - > addAction ( a ) ;
2017-07-06 07:10:27 +02:00
a = getAction ( " toggle-timeline " ) ;
a - > setCheckable ( true ) ;
menuView - > addAction ( a ) ;
2013-06-18 13:10:50 +02:00
a = getAction ( " toggle-mixer " ) ;
a - > setCheckable ( true ) ;
menuView - > addAction ( a ) ;
a = getAction ( " synth-control " ) ;
a - > setCheckable ( true ) ;
menuView - > addAction ( a ) ;
2014-06-02 12:12:53 +02:00
a = getAction ( " toggle-selection-window " ) ;
a - > setCheckable ( true ) ;
menuView - > addAction ( a ) ;
2014-12-22 09:56:39 +01:00
a = getAction ( " toggle-piano " ) ;
2013-06-18 13:10:50 +02:00
a - > setCheckable ( true ) ;
menuView - > addAction ( a ) ;
menuView - > addSeparator ( ) ;
menuView - > addAction ( getAction ( " zoomin " ) ) ;
menuView - > addAction ( getAction ( " zoomout " ) ) ;
menuView - > addSeparator ( ) ;
2016-12-27 00:51:10 +01:00
menuToolbars = new QMenu ( ) ;
2017-01-16 20:51:12 +01:00
2016-12-27 00:51:10 +01:00
a = getAction ( " toggle-fileoperations " ) ;
a - > setCheckable ( true ) ;
a - > setChecked ( fileTools - > isVisible ( ) ) ;
connect ( fileTools , SIGNAL ( visibilityChanged ( bool ) ) , a , SLOT ( setChecked ( bool ) ) ) ;
menuToolbars - > addAction ( a ) ;
a = getAction ( " toggle-transport " ) ;
a - > setCheckable ( true ) ;
a - > setChecked ( transportTools - > isVisible ( ) ) ;
connect ( transportTools , SIGNAL ( visibilityChanged ( bool ) ) , a , SLOT ( setChecked ( bool ) ) ) ;
menuToolbars - > addAction ( a ) ;
a = getAction ( " toggle-concertpitch " ) ;
a - > setCheckable ( true ) ;
a - > setChecked ( cpitchTools - > isVisible ( ) ) ;
connect ( cpitchTools , SIGNAL ( visibilityChanged ( bool ) ) , a , SLOT ( setChecked ( bool ) ) ) ;
menuToolbars - > addAction ( a ) ;
a = getAction ( " toggle-imagecapture " ) ;
a - > setCheckable ( true ) ;
a - > setChecked ( fotoTools - > isVisible ( ) ) ;
connect ( fotoTools , SIGNAL ( visibilityChanged ( bool ) ) , a , SLOT ( setChecked ( bool ) ) ) ;
menuToolbars - > addAction ( a ) ;
a = getAction ( " toggle-noteinput " ) ;
a - > setCheckable ( true ) ;
a - > setChecked ( entryTools - > isVisible ( ) ) ;
connect ( entryTools , SIGNAL ( visibilityChanged ( bool ) ) , a , SLOT ( setChecked ( bool ) ) ) ;
menuToolbars - > addAction ( a ) ;
menuToolbars - > addSeparator ( ) ;
menuToolbars - > addAction ( getAction ( " edit-toolbars " ) ) ;
menuView - > addMenu ( menuToolbars ) ;
2016-06-30 15:34:02 +02:00
menuWorkspaces = new QMenu ( ) ;
2016-06-29 17:13:23 +02:00
connect ( menuWorkspaces , SIGNAL ( aboutToShow ( ) ) , SLOT ( showWorkspaceMenu ( ) ) ) ;
menuView - > addMenu ( menuWorkspaces ) ;
2013-06-18 13:10:50 +02:00
a = getAction ( " toggle-statusbar " ) ;
a - > setCheckable ( true ) ;
2017-11-29 08:21:36 +01:00
a - > setChecked ( preferences . getBool ( PREF_UI_APP_SHOWSTATUSBAR ) ) ;
2013-06-18 13:10:50 +02:00
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 " ) ) ;
2016-08-06 11:36:51 +02:00
menuView - > addAction ( getAction ( " mark-irregular " ) ) ;
2013-06-18 13:10:50 +02:00
menuView - > addSeparator ( ) ;
2016-03-02 13:20:19 +01:00
2013-06-18 13:10:50 +02:00
a = getAction ( " fullscreen " ) ;
a - > setCheckable ( true ) ;
a - > setChecked ( false ) ;
2016-05-12 16:17:20 +02:00
# ifndef Q_OS_MAC
2013-06-18 13:10:50 +02:00
menuView - > addAction ( a ) ;
2016-02-07 03:37:57 +01:00
# endif
2013-06-18 13:10:50 +02:00
2012-05-26 14:49:10 +02:00
//---------------------
2016-06-30 15:34:02 +02:00
// Menu Add
2012-05-26 14:49:10 +02:00
//---------------------
2016-06-30 15:34:02 +02:00
menuAdd = mb - > addMenu ( " " ) ;
menuAdd - > setObjectName ( " Add " ) ;
menuAddPitch = new QMenu ( ) ;
2016-06-29 17:13:23 +02:00
menuAddPitch - > addAction ( getAction ( " note-input " ) ) ;
menuAddPitch - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
2012-05-26 14:49:10 +02:00
for ( int i = 0 ; i < 7 ; + + i ) {
char buffer [ 8 ] ;
sprintf ( buffer , " note-%c " , " cdefgab " [ i ] ) ;
a = getAction ( buffer ) ;
menuAddPitch - > addAction ( a ) ;
}
2016-06-29 17:13:23 +02:00
menuAddPitch - > addSeparator ( ) ;
2012-05-26 14:49:10 +02:00
for ( int i = 0 ; i < 7 ; + + i ) {
char buffer [ 8 ] ;
sprintf ( buffer , " chord-%c " , " cdefgab " [ i ] ) ;
a = getAction ( buffer ) ;
menuAddPitch - > addAction ( a ) ;
}
2016-06-30 15:34:02 +02:00
menuAdd - > addMenu ( menuAddPitch ) ;
menuAddInterval = new QMenu ( ) ;
2012-05-26 14:49:10 +02:00
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 ) ;
}
2016-06-30 15:34:02 +02:00
menuAdd - > addMenu ( menuAddInterval ) ;
2012-05-26 14:49:10 +02:00
2016-06-30 15:34:02 +02:00
menuTuplet = new QMenu ( ) ;
2014-11-14 11:44:48 +01:00
for ( auto i : { " duplet " , " triplet " , " quadruplet " , " quintuplet " , " sextuplet " ,
2016-06-29 17:13:23 +02:00
" septuplet " , " octuplet " , " nonuplet " , " tuplet-dialog " } )
menuTuplet - > addAction ( getAction ( i ) ) ;
2016-06-30 15:34:02 +02:00
menuAdd - > addMenu ( menuTuplet ) ;
menuAdd - > addSeparator ( ) ;
menuAddMeasures = new QMenu ( " " ) ;
2016-06-29 17:13:23 +02:00
menuAddMeasures - > addAction ( getAction ( " insert-measure " ) ) ;
menuAddMeasures - > addAction ( getAction ( " insert-measures " ) ) ;
menuAddMeasures - > addSeparator ( ) ;
menuAddMeasures - > addAction ( getAction ( " append-measure " ) ) ;
menuAddMeasures - > addAction ( getAction ( " append-measures " ) ) ;
2016-06-30 15:34:02 +02:00
menuAdd - > addMenu ( menuAddMeasures ) ;
menuAddFrames = new QMenu ( ) ;
2016-06-29 17:13:23 +02:00
menuAddFrames - > addAction ( getAction ( " insert-hbox " ) ) ;
menuAddFrames - > addAction ( getAction ( " insert-vbox " ) ) ;
menuAddFrames - > addAction ( getAction ( " insert-textframe " ) ) ;
if ( enableExperimental )
menuAddFrames - > addAction ( getAction ( " insert-fretframe " ) ) ;
menuAddFrames - > addSeparator ( ) ;
menuAddFrames - > addAction ( getAction ( " append-hbox " ) ) ;
menuAddFrames - > addAction ( getAction ( " append-vbox " ) ) ;
menuAddFrames - > addAction ( getAction ( " append-textframe " ) ) ;
2016-06-30 15:34:02 +02:00
menuAdd - > addMenu ( menuAddFrames ) ;
menuAddText = new QMenu ( ) ;
2016-06-29 17:13:23 +02:00
menuAddText - > addAction ( getAction ( " title-text " ) ) ;
menuAddText - > addAction ( getAction ( " subtitle-text " ) ) ;
menuAddText - > addAction ( getAction ( " composer-text " ) ) ;
menuAddText - > addAction ( getAction ( " poet-text " ) ) ;
menuAddText - > addAction ( getAction ( " part-text " ) ) ;
menuAddText - > addSeparator ( ) ;
menuAddText - > addAction ( getAction ( " system-text " ) ) ;
menuAddText - > addAction ( getAction ( " staff-text " ) ) ;
2016-10-08 19:06:54 +02:00
menuAddText - > addAction ( getAction ( " expression-text " ) ) ;
2016-06-29 17:13:23 +02:00
menuAddText - > addAction ( getAction ( " chord-text " ) ) ;
menuAddText - > addAction ( getAction ( " rehearsalmark-text " ) ) ;
menuAddText - > addAction ( getAction ( " instrument-change-text " ) ) ;
2017-02-15 15:32:58 +01:00
menuAddText - > addAction ( getAction ( " fingering-text " ) ) ;
2016-06-29 17:13:23 +02:00
menuAddText - > addSeparator ( ) ;
menuAddText - > addAction ( getAction ( " lyrics " ) ) ;
menuAddText - > addAction ( getAction ( " figured-bass " ) ) ;
menuAddText - > addAction ( getAction ( " tempo " ) ) ;
2016-06-30 15:34:02 +02:00
menuAdd - > addMenu ( menuAddText ) ;
menuAddLines = new QMenu ( ) ;
2016-06-29 17:13:23 +02:00
menuAddLines - > addAction ( getAction ( " add-slur " ) ) ;
menuAddLines - > addAction ( getAction ( " add-hairpin " ) ) ;
menuAddLines - > addAction ( getAction ( " add-hairpin-reverse " ) ) ;
menuAddLines - > addAction ( getAction ( " add-8va " ) ) ;
menuAddLines - > addAction ( getAction ( " add-8vb " ) ) ;
menuAddLines - > addAction ( getAction ( " add-noteline " ) ) ;
2016-06-30 15:34:02 +02:00
menuAdd - > addMenu ( menuAddLines ) ;
2012-05-26 14:49:10 +02:00
//---------------------
2016-06-29 17:13:23 +02:00
// Menu Format
2012-05-26 14:49:10 +02:00
//---------------------
2016-06-30 15:34:02 +02:00
menuFormat = mb - > addMenu ( " " ) ;
2016-06-29 17:13:23 +02:00
menuFormat - > setObjectName ( " Format " ) ;
menuFormat - > addAction ( getAction ( " edit-style " ) ) ;
2017-08-17 22:08:09 +02:00
QAction * pageSettingsAction = getAction ( " page-settings " ) ;
// in some locale (fr), page settings ends up in Application menu on mac
// this line prevents it.
pageSettingsAction - > setMenuRole ( QAction : : NoRole ) ;
menuFormat - > addAction ( pageSettingsAction ) ;
2016-06-29 17:13:23 +02:00
menuFormat - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
2016-06-29 17:13:23 +02:00
menuFormat - > addAction ( getAction ( " add-remove-breaks " ) ) ;
2016-06-30 15:34:02 +02:00
2016-06-29 17:13:23 +02:00
QMenu * menuStretch = new QMenu ( tr ( " &Stretch " ) ) ;
for ( auto i : { " stretch+ " , " stretch- " , " reset-stretch " } )
menuStretch - > addAction ( getAction ( i ) ) ;
menuFormat - > addMenu ( menuStretch ) ;
menuFormat - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
2016-06-29 17:13:23 +02:00
menuFormat - > addAction ( getAction ( " reset-beammode " ) ) ;
menuFormat - > addAction ( getAction ( " reset " ) ) ;
menuFormat - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
2016-06-29 17:13:23 +02:00
if ( enableExperimental )
menuFormat - > addAction ( getAction ( " edit-harmony " ) ) ;
2012-05-26 14:49:10 +02:00
2016-06-29 17:13:23 +02:00
menuFormat - > addSeparator ( ) ;
menuFormat - > addAction ( getAction ( " load-style " ) ) ;
menuFormat - > addAction ( getAction ( " save-style " ) ) ;
2016-06-30 15:34:02 +02:00
2012-05-26 14:49:10 +02:00
//---------------------
2016-06-29 17:13:23 +02:00
// Menu Tools
2012-05-26 14:49:10 +02:00
//---------------------
2016-06-30 15:34:02 +02:00
menuTools = mb - > addMenu ( " " ) ;
2016-06-29 17:13:23 +02:00
menuTools - > setObjectName ( " Tools " ) ;
2016-06-30 15:34:02 +02:00
2016-06-29 17:13:23 +02:00
menuTools - > addAction ( getAction ( " transpose " ) ) ;
menuTools - > addSeparator ( ) ;
menuTools - > addAction ( getAction ( " explode " ) ) ;
menuTools - > addAction ( getAction ( " implode " ) ) ;
2016-06-30 15:34:02 +02:00
menuVoices = new QMenu ( " " ) ;
2016-06-29 17:13:23 +02:00
for ( auto i : { " voice-x12 " , " voice-x13 " , " voice-x14 " , " voice-x23 " , " voice-x24 " , " voice-x34 " } )
menuVoices - > addAction ( getAction ( i ) ) ;
menuTools - > addMenu ( menuVoices ) ;
menuTools - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
2016-06-29 17:13:23 +02:00
menuTools - > addAction ( getAction ( " slash-fill " ) ) ;
menuTools - > addAction ( getAction ( " slash-rhythm " ) ) ;
menuTools - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
2016-06-29 17:13:23 +02:00
menuTools - > addAction ( getAction ( " pitch-spell " ) ) ;
2016-12-29 21:06:12 +01:00
menuTools - > addAction ( getAction ( " reset-groupings " ) ) ;
2016-06-29 17:13:23 +02:00
menuTools - > addAction ( getAction ( " resequence-rehearsal-marks " ) ) ;
menuTools - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
2016-06-29 17:13:23 +02:00
menuTools - > addAction ( getAction ( " copy-lyrics-to-clipboard " ) ) ;
menuTools - > addAction ( getAction ( " fotomode " ) ) ;
2012-05-26 14:49:10 +02:00
2016-09-30 12:44:27 +02:00
menuTools - > addAction ( getAction ( " del-empty-measures " ) ) ;
2012-07-13 13:08:54 +02:00
//---------------------
// Menu Plugins
//---------------------
2016-06-30 15:34:02 +02:00
menuPlugins = mb - > addMenu ( " " ) ;
2012-07-13 13:08:54 +02:00
menuPlugins - > setObjectName ( " Plugins " ) ;
2013-10-05 12:03:30 +02:00
2014-07-20 20:47:18 +02:00
menuPlugins - > addAction ( getAction ( " plugin-manager " ) ) ;
2013-02-11 14:13:38 +01:00
2012-07-13 13:08:54 +02:00
a = getAction ( " plugin-creator " ) ;
a - > setCheckable ( true ) ;
menuPlugins - > addAction ( a ) ;
2013-02-11 14:13:38 +01:00
2012-07-13 13:08:54 +02:00
menuPlugins - > addSeparator ( ) ;
2012-07-19 16:47:23 +02:00
2016-06-02 12:12:40 +02:00
//---------------------
// Menu Debug
//---------------------
# ifndef NDEBUG
2016-12-08 12:38:05 +01:00
QMenu * menuDebug = mb - > addMenu ( " Debug " ) ;
2016-06-02 12:12:40 +02:00
menuDebug - > setObjectName ( " Debug " ) ;
a = getAction ( " no-horizontal-stretch " ) ;
a - > setCheckable ( true ) ;
menuDebug - > addAction ( a ) ;
a = getAction ( " no-vertical-stretch " ) ;
a - > setCheckable ( true ) ;
menuDebug - > addAction ( a ) ;
menuDebug - > addSeparator ( ) ;
a = getAction ( " show-segment-shapes " ) ;
a - > setCheckable ( true ) ;
menuDebug - > addAction ( a ) ;
a = getAction ( " show-measure-shapes " ) ;
a - > setCheckable ( true ) ;
menuDebug - > addAction ( a ) ;
2016-06-03 17:54:21 +02:00
a = getAction ( " show-bounding-rect " ) ;
a - > setCheckable ( true ) ;
menuDebug - > addAction ( a ) ;
2016-06-03 18:26:51 +02:00
a = getAction ( " show-corrupted-measures " ) ;
a - > setCheckable ( true ) ;
a - > setChecked ( true ) ;
menuDebug - > addAction ( a ) ;
2017-07-17 16:11:21 +02:00
a = getAction ( " relayout " ) ;
menuDebug - > addAction ( a ) ;
2017-08-16 16:56:34 +02:00
a = getAction ( " autoplace-slurs " ) ;
a - > setCheckable ( true ) ;
a - > setChecked ( MScore : : autoplaceSlurs ) ;
menuDebug - > addAction ( a ) ;
2016-06-02 12:12:40 +02:00
# endif
2013-09-30 18:38:05 +02:00
2012-05-26 14:49:10 +02:00
//---------------------
// Menu Help
//---------------------
mb - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
menuHelp = mb - > addMenu ( " " ) ;
2012-05-26 14:49:10 +02:00
menuHelp - > setObjectName ( " Help " ) ;
2015-02-20 14:01:22 +01:00
#if 0
2015-02-19 17:29:30 +01:00
if ( _helpEngine ) {
HelpQuery * hw = new HelpQuery ( menuHelp ) ;
menuHelp - > addAction ( hw ) ;
connect ( menuHelp , SIGNAL ( aboutToShow ( ) ) , hw , SLOT ( setFocus ( ) ) ) ;
}
2015-02-09 10:54:12 +01:00
# endif
2016-08-08 11:12:32 +02:00
//menuHelp->addAction(getAction("help"));
2016-06-30 15:34:02 +02:00
onlineHandbookAction = menuHelp - > addAction ( " " , this , SLOT ( helpBrowser1 ( ) ) ) ;
2012-05-26 14:49:10 +02:00
menuHelp - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
aboutAction = new QAction ( " " , 0 ) ;
2014-04-29 17:30:14 +02:00
2012-05-26 14:49:10 +02:00
aboutAction - > setMenuRole ( QAction : : AboutRole ) ;
connect ( aboutAction , SIGNAL ( triggered ( ) ) , this , SLOT ( about ( ) ) ) ;
menuHelp - > addAction ( aboutAction ) ;
2016-06-30 15:34:02 +02:00
aboutQtAction = new QAction ( " " , 0 ) ;
2013-07-20 18:22:44 +02:00
aboutQtAction - > setMenuRole ( QAction : : AboutQtRole ) ;
connect ( aboutQtAction , SIGNAL ( triggered ( ) ) , this , SLOT ( aboutQt ( ) ) ) ;
menuHelp - > addAction ( aboutQtAction ) ;
2012-05-26 14:49:10 +02:00
2016-06-30 15:34:02 +02:00
aboutMusicXMLAction = new QAction ( " " , 0 ) ;
2012-05-26 14:49:10 +02:00
aboutMusicXMLAction - > setMenuRole ( QAction : : ApplicationSpecificRole ) ;
connect ( aboutMusicXMLAction , SIGNAL ( triggered ( ) ) , this , SLOT ( aboutMusicXML ( ) ) ) ;
menuHelp - > addAction ( aboutMusicXMLAction ) ;
2013-05-16 16:12:22 +02:00
# if defined(Q_OS_MAC) || defined(Q_OS_WIN)
2017-06-04 16:26:55 +02:00
# if not defined(FOR_WINSTORE)
2016-06-30 15:34:02 +02:00
checkForUpdateAction = menuHelp - > addAction ( " " , this , SLOT ( checkForUpdate ( ) ) ) ;
2017-06-04 16:26:55 +02:00
# endif
2012-05-26 14:49:10 +02:00
# endif
2012-05-30 00:54:53 +02:00
menuHelp - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
askForHelpAction = menuHelp - > addAction ( " " , this , SLOT ( askForHelp ( ) ) ) ;
reportBugAction = menuHelp - > addAction ( " " , this , SLOT ( reportBug ( ) ) ) ;
2012-05-30 00:54:53 +02:00
2013-09-30 18:38:05 +02:00
menuHelp - > addSeparator ( ) ;
menuHelp - > addAction ( getAction ( " resource-manager " ) ) ;
2016-02-03 19:20:45 +01:00
menuHelp - > addSeparator ( ) ;
2016-06-30 15:34:02 +02:00
revertToFactoryAction = menuHelp - > addAction ( " " , this , SLOT ( resetAndRestart ( ) ) ) ;
2016-07-26 22:28:48 +02:00
if ( ! MScore : : noGui ) {
2016-06-30 15:34:02 +02:00
retranslate ( true ) ;
2016-07-26 22:28:48 +02:00
//accessibility for menus
for ( QMenu * menu : mb - > findChildren < QMenu * > ( ) ) {
menu - > setAccessibleName ( menu - > objectName ( ) ) ;
menu - > setAccessibleDescription ( Shortcut : : getMenuShortcutString ( menu ) ) ;
}
2014-04-29 17:30:14 +02:00
}
2013-05-09 18:46:51 +02:00
setCentralWidget ( envelope ) ;
2014-05-28 23:20:01 +02:00
2012-07-26 14:35:13 +02:00
// load cascading instrument templates
2017-11-29 08:21:36 +01:00
loadInstrumentTemplates ( preferences . getString ( PREF_APP_PATHS_INSTRUMENTLIST1 ) ) ;
QString instrList2 = preferences . getString ( PREF_APP_PATHS_INSTRUMENTLIST2 ) ;
if ( ! instrList2 . isEmpty ( ) )
loadInstrumentTemplates ( instrList2 ) ;
2012-07-26 14:35:13 +02:00
2012-05-26 14:49:10 +02:00
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 ( ) ) ) ;
2017-05-02 14:17:31 +02:00
2012-05-26 14:49:10 +02:00
autoSaveTimer = new QTimer ( this ) ;
autoSaveTimer - > setSingleShot ( true ) ;
connect ( autoSaveTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( autoSaveTimerTimeout ( ) ) ) ;
initOsc ( ) ;
startAutoSave ( ) ;
2015-02-12 11:55:43 +01:00
2017-02-24 21:23:41 +01:00
QInputMethod * im = QGuiApplication : : inputMethod ( ) ;
connect ( im , SIGNAL ( localeChanged ( ) ) , SLOT ( inputMethodLocaleChanged ( ) ) ) ;
2012-05-26 14:49:10 +02:00
if ( enableExperimental ) {
cornerLabel = new QLabel ( this ) ;
cornerLabel - > setScaledContents ( true ) ;
cornerLabel - > setPixmap ( QPixmap ( " :/data/mscore.png " ) ) ;
cornerLabel - > setGeometry ( width ( ) - 48 , 0 , 48 , 48 ) ;
}
}
2014-12-11 12:01:30 +01:00
MuseScore : : ~ MuseScore ( )
{
delete synti ;
}
2016-11-28 17:25:26 +01:00
//---------------------------------------------------------
// showError
//---------------------------------------------------------
void MuseScore : : showError ( )
{
static QErrorMessage * msg = 0 ;
if ( msg = = 0 )
msg = new QErrorMessage ( this ) ;
msg - > showMessage ( tr ( MScore : : errorMessage ( ) ) , MScore : : errorGroup ( ) ) ;
2016-11-28 18:25:27 +01:00
MScore : : setError ( MS_NO_ERROR ) ;
2016-11-28 17:25:26 +01:00
}
//---------------------------------------------------------
// retranslate
//---------------------------------------------------------
2016-06-30 15:34:02 +02:00
void MuseScore : : retranslate ( bool firstStart )
{
_positionLabel - > setToolTip ( tr ( " Measure:Beat:Tick " ) ) ;
// retranslate the menu
menuFile - > setTitle ( tr ( " &File " ) ) ;
openRecent - > setTitle ( tr ( " Open &Recent " ) ) ;
menuEdit - > setTitle ( tr ( " &Edit " ) ) ;
menuView - > setTitle ( tr ( " &View " ) ) ;
2016-12-27 00:51:10 +01:00
menuToolbars - > setTitle ( tr ( " &Toolbars " ) ) ;
2016-06-30 15:34:02 +02:00
menuWorkspaces - > setTitle ( tr ( " W&orkspaces " ) ) ;
pref - > setText ( tr ( " &Preferences... " ) ) ;
menuAdd - > setTitle ( tr ( " &Add " ) ) ;
menuAddMeasures - > setTitle ( tr ( " &Measures " ) ) ;
menuAddFrames - > setTitle ( tr ( " &Frames " ) ) ;
menuAddText - > setTitle ( tr ( " &Text " ) ) ;
menuAddLines - > setTitle ( tr ( " &Lines " ) ) ;
2016-07-03 05:39:04 +02:00
menuAddPitch - > setTitle ( tr ( " N&otes " ) ) ;
menuAddInterval - > setTitle ( tr ( " &Intervals " ) ) ;
2016-06-30 15:34:02 +02:00
menuTuplet - > setTitle ( tr ( " T&uplets " ) ) ;
2016-09-12 21:23:30 +02:00
menuFormat - > setTitle ( tr ( " F&ormat " ) ) ;
2016-06-30 15:34:02 +02:00
menuTools - > setTitle ( tr ( " &Tools " ) ) ;
menuVoices - > setTitle ( tr ( " &Voices " ) ) ;
menuPlugins - > setTitle ( tr ( " &Plugins " ) ) ;
menuHelp - > setTitle ( tr ( " &Help " ) ) ;
aboutAction - > setText ( tr ( " &About... " ) ) ;
aboutQtAction - > setText ( tr ( " About &Qt... " ) ) ;
aboutMusicXMLAction - > setText ( tr ( " About &MusicXML... " ) ) ;
onlineHandbookAction - > setText ( tr ( " &Online Handbook " ) ) ;
if ( checkForUpdateAction )
checkForUpdateAction - > setText ( tr ( " Check for &Update " ) ) ;
askForHelpAction - > setText ( tr ( " Ask for Help " ) ) ;
reportBugAction - > setText ( tr ( " Report a Bug " ) ) ;
revertToFactoryAction - > setText ( tr ( " Revert to Factory Settings " ) ) ;
fileTools - > setWindowTitle ( tr ( " File Operations " ) ) ;
2016-12-27 00:51:10 +01:00
transportTools - > setWindowTitle ( tr ( " Playback Controls " ) ) ;
2016-06-30 15:34:02 +02:00
cpitchTools - > setWindowTitle ( tr ( " Concert Pitch " ) ) ;
fotoTools - > setWindowTitle ( tr ( " Image Capture " ) ) ;
entryTools - > setWindowTitle ( tr ( " Note Input " ) ) ;
viewModeCombo - > setAccessibleName ( tr ( " View Mode " ) ) ;
viewModeCombo - > setItemText ( viewModeCombo - > findData ( int ( LayoutMode : : PAGE ) ) , tr ( " Page View " ) ) ;
viewModeCombo - > setItemText ( viewModeCombo - > findData ( int ( LayoutMode : : LINE ) ) , tr ( " Continuous View " ) ) ;
viewModeCombo - > setItemText ( viewModeCombo - > findData ( int ( LayoutMode : : SYSTEM ) ) , tr ( " Single Page " ) ) ;
2016-07-04 09:27:43 +02:00
2016-06-30 15:34:02 +02:00
showMidiImportButton - > setText ( tr ( " Show MIDI import panel " ) ) ;
2016-07-04 09:27:43 +02:00
2016-06-30 15:34:02 +02:00
Shortcut : : retranslate ( ) ;
if ( ! firstStart & & Workspace : : currentWorkspace - > readOnly ( ) ) {
changeWorkspace ( Workspace : : currentWorkspace ) ;
}
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// resizeEvent
//---------------------------------------------------------
void MuseScore : : resizeEvent ( QResizeEvent * )
{
if ( enableExperimental ) {
cornerLabel - > setGeometry ( width ( ) - 48 , 0 , 48 , 48 ) ;
}
}
//---------------------------------------------------------
// startAutoSave
//---------------------------------------------------------
void MuseScore : : startAutoSave ( )
{
2017-11-29 08:21:36 +01:00
if ( preferences . getBool ( PREF_APP_AUTOSAVE_USEAUTOSAVE ) ) {
int t = preferences . getInt ( PREF_APP_AUTOSAVE_AUTOSAVETIME ) * 60 * 1000 ;
2012-05-26 14:49:10 +02:00
autoSaveTimer - > start ( t ) ;
}
else
autoSaveTimer - > stop ( ) ;
}
//---------------------------------------------------------
// getLocaleISOCode
//---------------------------------------------------------
2012-07-12 18:46:15 +02:00
QString MuseScore : : getLocaleISOCode ( ) const
2012-05-26 14:49:10 +02:00
{
QString lang ;
if ( localeName . toLower ( ) = = " system " )
lang = QLocale : : system ( ) . name ( ) ;
else
lang = localeName ;
return lang ;
}
//---------------------------------------------------------
// helpBrowser1
// show online help
//---------------------------------------------------------
2012-07-12 18:46:15 +02:00
void MuseScore : : helpBrowser1 ( ) const
2012-05-26 14:49:10 +02:00
{
QString lang = getLocaleISOCode ( ) ;
if ( MScore : : debugMode )
qDebug ( " open online handbook for language <%s> " , qPrintable ( lang ) ) ;
2015-03-13 09:27:35 +01:00
QString help = QString ( " https://musescore.org/redirect/help?tag=handbook&locale=%1 " ) . arg ( getLocaleISOCode ( ) ) ;
2012-05-26 14:49:10 +02:00
//try to find an exact match
bool found = false ;
foreach ( LanguageItem item , _languages ) {
2012-07-12 18:46:15 +02:00
if ( item . key = = lang ) {
2012-05-26 14:49:10 +02:00
QString handbook = item . handbook ;
if ( ! handbook . isNull ( ) ) {
help = item . handbook ;
found = true ;
}
break ;
}
}
//try a to find a match on first two letters
if ( ! found & & lang . size ( ) > 2 ) {
lang = lang . left ( 2 ) ;
foreach ( LanguageItem item , _languages ) {
if ( item . key = = lang ) {
QString handbook = item . handbook ;
if ( ! handbook . isNull ( ) )
help = item . handbook ;
break ;
}
}
}
//track visits. see: http://www.google.com/support/googleanalytics/bin/answer.py?answer=55578
2015-03-13 09:27:35 +01:00
help + = QString ( " &utm_source=desktop&utm_medium=menu&utm_content=%1&utm_campaign=MuseScore%2 " ) . arg ( rev . trimmed ( ) ) . arg ( QString ( VERSION ) ) ;
2015-02-06 16:36:43 +01:00
QDesktopServices : : openUrl ( QUrl ( help ) ) ;
2012-05-26 14:49:10 +02:00
}
2016-02-03 19:20:45 +01:00
//---------------------------------------------------------
// resetAndRestart
//---------------------------------------------------------
void MuseScore : : resetAndRestart ( )
{
int ret = QMessageBox : : question ( 0 , tr ( " Are you sure? " ) ,
tr ( " This will reset all your preferences. \n "
" Custom palettes, custom shortcuts, and the list of recent scores will be deleted. "
" MuseScore will restart with its default settings. \n "
" Reverting will not remove any scores from your computer. \n "
" Are you sure you want to proceed? " ) ,
2016-02-04 08:37:44 +01:00
QMessageBox : : Yes | QMessageBox : : No , QMessageBox : : No ) ;
2016-02-03 19:20:45 +01:00
if ( ret = = QMessageBox : : Yes ) {
close ( ) ;
QStringList args ( " -F " ) ;
QProcess : : startDetached ( qApp - > arguments ( ) [ 0 ] , args ) ;
}
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// aboutQt
//---------------------------------------------------------
void MuseScore : : aboutQt ( )
{
QMessageBox : : aboutQt ( this , QString ( " About Qt " ) ) ;
}
//---------------------------------------------------------
// aboutMusicXML
//---------------------------------------------------------
void MuseScore : : aboutMusicXML ( )
{
AboutMusicXMLBoxDialog ab ;
ab . show ( ) ;
ab . exec ( ) ;
}
//---------------------------------------------------------
// selectScore
// "open recent"
//---------------------------------------------------------
void MuseScore : : selectScore ( QAction * action )
{
QString a = action - > data ( ) . toString ( ) ;
if ( ! a . isEmpty ( ) ) {
2014-04-16 18:46:25 +02:00
if ( a = = " clear-recent " ) {
2014-11-13 10:22:05 +01:00
_recentScores . clear ( ) ;
2016-04-19 13:55:55 +02:00
if ( startcenter )
startcenter - > updateRecentScores ( ) ;
2014-04-16 18:46:25 +02:00
}
else {
2016-03-11 12:18:46 +01:00
MasterScore * score = readScore ( a ) ;
2014-04-16 18:46:25 +02:00
if ( score ) {
setCurrentScoreView ( appendScore ( score ) ) ;
2014-12-08 14:41:36 +01:00
addRecentScore ( score ) ;
2014-04-16 18:46:25 +02:00
writeSessionFile ( false ) ;
}
2012-07-05 11:54:45 +02:00
}
2012-05-26 14:49:10 +02:00
}
}
//---------------------------------------------------------
// selectionChanged
//---------------------------------------------------------
2014-05-26 20:21:45 +02:00
void MuseScore : : selectionChanged ( SelState selectionState )
2012-05-26 14:49:10 +02:00
{
2014-05-26 13:21:04 +02:00
bool enable = selectionState ! = SelState : : NONE ;
2012-05-26 14:49:10 +02:00
getAction ( " cut " ) - > setEnabled ( enable ) ;
getAction ( " copy " ) - > setEnabled ( enable ) ;
2014-07-14 13:24:47 +02:00
getAction ( " select-similar-range " ) - > setEnabled ( selectionState = = SelState : : RANGE ) ;
2012-05-26 14:49:10 +02:00
if ( pianorollEditor )
2012-06-04 12:57:26 +02:00
pianorollEditor - > changeSelection ( selectionState ) ;
2012-05-26 14:49:10 +02:00
if ( drumrollEditor )
2012-06-04 12:57:26 +02:00
drumrollEditor - > changeSelection ( selectionState ) ;
2017-07-06 07:10:27 +02:00
if ( timeline ( ) )
timeline ( ) - > changeSelection ( selectionState ) ;
2018-05-21 15:04:01 +02:00
if ( _pianoTools & & _pianoTools - > isVisible ( ) ) {
if ( cs )
_pianoTools - > changeSelection ( cs - > selection ( ) ) ;
else
_pianoTools - > clearSelection ( ) ;
}
if ( _inspector )
updateInspector ( ) ;
2012-07-12 15:35:35 +02:00
}
//---------------------------------------------------------
// updateInspector
//---------------------------------------------------------
void MuseScore : : updateInspector ( )
{
2017-03-31 13:03:15 +02:00
if ( _inspector )
_inspector - > update ( cs ) ;
2012-05-26 14:49:10 +02:00
}
2015-10-28 14:11:29 +01:00
//---------------------------------------------------------
// updateShadowNote
// update the shadow note in the current ScoreView
//---------------------------------------------------------
void MuseScore : : updateShadowNote ( )
{
currentScoreView ( ) - > updateShadowNotes ( ) ;
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// appendScore
// append score to project list
//---------------------------------------------------------
2016-03-11 12:18:46 +01:00
int MuseScore : : appendScore ( MasterScore * score )
2012-05-26 14:49:10 +02:00
{
int index = scoreList . size ( ) ;
for ( int i = 0 ; i < scoreList . size ( ) ; + + i ) {
2014-12-01 10:04:56 +01:00
if ( ( ! score - > importedFilePath ( ) . isEmpty ( )
& & scoreList [ i ] - > importedFilePath ( ) = = score - > importedFilePath ( ) )
2016-03-11 12:18:46 +01:00
| | ( scoreList [ i ] - > fileInfo ( ) - > canonicalFilePath ( ) = = score - > fileInfo ( ) - > canonicalFilePath ( ) & & score - > fileInfo ( ) - > exists ( ) ) ) {
2012-05-26 14:49:10 +02:00
removeTab ( i ) ;
index = i ;
break ;
}
}
scoreList . insert ( index , score ) ;
tab1 - > blockSignals ( true ) ;
if ( tab2 )
tab2 - > blockSignals ( true ) ;
tab1 - > insertTab ( score ) ;
if ( tab2 )
tab2 - > insertTab ( score ) ;
tab1 - > blockSignals ( false ) ;
if ( tab2 )
tab2 - > blockSignals ( false ) ;
return index ;
}
//---------------------------------------------------------
2014-12-08 14:41:36 +01:00
// addRecentScore
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2014-12-08 14:41:36 +01:00
void MuseScore : : addRecentScore ( Score * score )
2012-05-26 14:49:10 +02:00
{
2014-12-01 13:17:55 +01:00
QString path = score - > importedFilePath ( ) ; // defined for scores imported from e.g. MIDI files
addRecentScore ( path ) ;
2016-03-10 10:41:31 +01:00
path = score - > masterScore ( ) - > fileInfo ( ) - > absoluteFilePath ( ) ;
2014-12-01 13:17:55 +01:00
addRecentScore ( path ) ;
2016-04-19 13:55:55 +02:00
if ( startcenter )
startcenter - > updateRecentScores ( ) ;
2014-12-01 13:17:55 +01:00
}
void MuseScore : : addRecentScore ( const QString & scorePath )
{
2014-12-08 14:41:36 +01:00
if ( scorePath . isEmpty ( ) )
2014-12-01 13:17:55 +01:00
return ;
2015-03-17 14:23:36 +01:00
QFileInfo fi ( scorePath ) ;
QString absoluteFilePath = fi . absoluteFilePath ( ) ;
_recentScores . removeAll ( absoluteFilePath ) ;
_recentScores . prepend ( absoluteFilePath ) ;
2014-11-14 12:29:17 +01:00
if ( _recentScores . size ( ) > RECENT_LIST_SIZE )
2014-11-13 10:22:05 +01:00
_recentScores . removeLast ( ) ;
2012-05-26 14:49:10 +02:00
}
2016-10-10 18:37:28 +02:00
#if 0
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// updateTabNames
//---------------------------------------------------------
void MuseScore : : updateTabNames ( )
{
for ( int i = 0 ; i < tab1 - > count ( ) ; + + i ) {
ScoreView * view = tab1 - > view ( i ) ;
if ( view )
2016-10-10 18:37:28 +02:00
tab1 - > setTabText ( i , view - > score ( ) - > masterScore ( ) - > fileInfo ( ) - > completeBaseName ( ) ) ;
2012-05-26 14:49:10 +02:00
}
if ( tab2 ) {
for ( int i = 0 ; i < tab2 - > count ( ) ; + + i ) {
ScoreView * view = tab2 - > view ( i ) ;
if ( view )
2016-10-10 18:37:28 +02:00
tab2 - > setTabText ( i , view - > score ( ) - > masterScore ( ) - > fileInfo ( ) - > completeBaseName ( ) ) ;
2012-05-26 14:49:10 +02:00
}
}
}
2016-10-10 18:37:28 +02:00
# endif
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// loadScoreList
// read list of "Recent Scores"
//---------------------------------------------------------
void MuseScore : : loadScoreList ( )
{
if ( useFactorySettings )
return ;
QSettings s ;
for ( int i = RECENT_LIST_SIZE - 1 ; i > = 0 ; - - i ) {
QString path = s . value ( QString ( " recent-%1 " ) . arg ( i ) , " " ) . toString ( ) ;
if ( ! path . isEmpty ( ) & & QFileInfo ( path ) . exists ( ) ) {
2014-11-13 10:22:05 +01:00
_recentScores . removeAll ( path ) ;
_recentScores . prepend ( path ) ;
2012-05-26 14:49:10 +02:00
}
}
}
//---------------------------------------------------------
// openRecentMenu
//---------------------------------------------------------
void MuseScore : : openRecentMenu ( )
{
openRecent - > clear ( ) ;
2014-04-16 18:46:25 +02:00
bool one = false ;
2014-11-13 10:22:05 +01:00
for ( const QFileInfo & fi : recentScores ( ) ) {
QAction * action = openRecent - > addAction ( fi . fileName ( ) . replace ( " & " , " && " ) ) ; // show filename only
QString data ( fi . canonicalFilePath ( ) ) ;
action - > setData ( data ) ;
action - > setToolTip ( data ) ;
one = true ;
2014-04-16 18:46:25 +02:00
}
if ( one ) {
openRecent - > addSeparator ( ) ;
QAction * action = openRecent - > addAction ( tr ( " Clear Recent Files " ) ) ;
action - > setData ( " clear-recent " ) ;
2012-05-26 14:49:10 +02:00
}
}
//---------------------------------------------------------
// setCurrentView
//---------------------------------------------------------
void MuseScore : : setCurrentScoreView ( int idx )
{
setCurrentView ( 0 , idx ) ;
2014-09-12 10:19:28 +02:00
if ( tab2 )
setCurrentView ( 1 , idx ) ;
2012-05-26 14:49:10 +02:00
}
void MuseScore : : setCurrentView ( int tabIdx , int idx )
{
if ( idx = = - 1 )
2013-02-15 22:39:56 +01:00
setCurrentScoreView ( nullptr ) ;
2012-05-26 14:49:10 +02:00
else {
ScoreTab * tab = tabIdx ? tab2 : tab1 ;
2013-02-15 22:39:56 +01:00
if ( tab )
2012-05-26 14:49:10 +02:00
tab - > setCurrentIndex ( idx ) ;
}
}
//---------------------------------------------------------
// setCurrentScoreView
//---------------------------------------------------------
void MuseScore : : setCurrentScoreView ( ScoreView * view )
{
cv = view ;
if ( cv ) {
2017-08-11 19:05:19 +02:00
if ( timeline ( ) )
timeline ( ) - > setScoreView ( cv ) ;
2014-07-28 10:56:50 +02:00
if ( cv - > score ( ) & & ( cs ! = cv - > score ( ) ) ) {
// exit note entry mode
if ( cv - > noteEntryMode ( ) ) {
cv - > cmd ( getAction ( " escape " ) ) ;
qApp - > processEvents ( ) ;
}
2012-05-26 14:49:10 +02:00
updateInputState ( cv - > score ( ) ) ;
2014-07-28 10:56:50 +02:00
}
2012-05-26 14:49:10 +02:00
cs = cv - > score ( ) ;
2015-11-23 16:02:33 +01:00
cv - > setFocusRect ( ) ;
2012-05-26 14:49:10 +02:00
}
else
cs = 0 ;
2013-07-22 01:33:56 +02:00
// set midi import panel
2014-11-01 10:52:35 +01:00
QString fileName = cs ? cs - > importedFilePath ( ) : " " ;
2013-07-22 01:33:56 +02:00
midiPanelOnSwitchToFile ( fileName ) ;
2014-08-26 16:38:33 +02:00
2014-08-12 21:28:40 +02:00
if ( enableExperimental ) {
updateLayer ( ) ;
updatePlayMode ( ) ;
}
2013-07-22 01:33:56 +02:00
2012-05-26 14:49:10 +02:00
if ( seq )
seq - > setScoreView ( cv ) ;
if ( playPanel )
playPanel - > setScore ( cs ) ;
if ( synthControl )
synthControl - > setScore ( cs ) ;
2014-06-26 22:55:07 +02:00
if ( selectionWindow )
selectionWindow - > setScore ( cs ) ;
2013-04-03 12:13:23 +02:00
if ( mixer )
2016-04-26 10:01:50 +02:00
mixer - > updateAll ( cs ? cs - > masterScore ( ) : nullptr ) ;
2012-05-26 14:49:10 +02:00
# ifdef OMR
if ( omrPanel ) {
if ( cv & & cv - > omrView ( ) )
omrPanel - > setOmrView ( cv - > omrView ( ) ) ;
else
omrPanel - > setOmrView ( 0 ) ;
}
# endif
if ( ! cs ) {
2015-07-25 01:26:54 +02:00
setWindowTitle ( MUSESCORE_NAME_VERSION ) ;
2014-05-19 13:57:37 +02:00
if ( _navigator & & _navigator - > widget ( ) ) {
2015-11-23 16:02:33 +01:00
navigator ( ) - > setScoreView ( cv ) ;
2013-05-08 10:54:06 +02:00
navigator ( ) - > setScore ( 0 ) ;
2014-05-19 13:57:37 +02:00
}
2017-07-11 21:36:05 +02:00
if ( timeline ( ) ) {
2017-07-06 07:10:27 +02:00
timeline ( ) - > setScoreView ( cv ) ;
timeline ( ) - > setScore ( 0 ) ;
}
2014-08-29 19:18:39 +02:00
if ( _inspector )
2017-03-31 13:03:15 +02:00
_inspector - > update ( 0 ) ;
2012-05-26 14:49:10 +02:00
viewModeCombo - > setEnabled ( false ) ;
2013-02-25 21:57:11 +01:00
if ( _textTools ) {
2013-02-15 22:39:56 +01:00
_textTools - > hide ( ) ;
2013-02-25 21:57:11 +01:00
if ( textPalette )
textPalette - > hide ( ) ;
}
2013-02-15 22:39:56 +01:00
if ( _pianoTools )
_pianoTools - > hide ( ) ;
if ( _drumTools )
_drumTools - > hide ( ) ;
2014-05-19 13:57:37 +02:00
changeState ( STATE_DISABLED ) ;
2012-05-26 14:49:10 +02:00
return ;
}
2015-11-04 11:40:06 +01:00
2012-05-26 14:49:10 +02:00
viewModeCombo - > setEnabled ( true ) ;
2015-11-04 11:40:06 +01:00
updateViewModeCombo ( ) ;
2012-05-26 14:49:10 +02:00
selectionChanged ( cs - > selection ( ) . state ( ) ) ;
2013-02-15 22:39:56 +01:00
_sstate = STATE_DISABLED ; // defeat optimization
2015-11-23 16:02:33 +01:00
changeState ( cv - > mscoreState ( ) ) ;
2012-05-26 14:49:10 +02:00
2015-11-23 16:02:33 +01:00
cv - > setFocus ( Qt : : OtherFocusReason ) ;
setFocusProxy ( cv ) ;
2012-05-26 14:49:10 +02:00
2016-03-10 10:41:31 +01:00
getAction ( " file-save " ) - > setEnabled ( cs - > masterScore ( ) - > isSavable ( ) ) ;
getAction ( " file-part-export " ) - > setEnabled ( cs - > masterScore ( ) - > excerpts ( ) . size ( ) > 0 ) ;
2012-05-26 14:49:10 +02:00
getAction ( " show-invisible " ) - > setChecked ( cs - > showInvisible ( ) ) ;
getAction ( " show-unprintable " ) - > setChecked ( cs - > showUnprintable ( ) ) ;
getAction ( " show-frames " ) - > setChecked ( cs - > showFrames ( ) ) ;
getAction ( " show-pageborders " ) - > setChecked ( cs - > showPageborders ( ) ) ;
2016-08-06 11:36:51 +02:00
getAction ( " mark-irregular " ) - > setChecked ( cs - > markIrregularMeasures ( ) ) ;
2015-03-04 12:59:21 +01:00
getAction ( " fotomode " ) - > setChecked ( cv - > fotoMode ( ) ) ;
2016-06-09 09:16:37 +02:00
getAction ( " join-measures " ) - > setEnabled ( cs - > masterScore ( ) - > excerpts ( ) . size ( ) = = 0 ) ;
2016-03-10 10:41:31 +01:00
getAction ( " split-measure " ) - > setEnabled ( cs - > masterScore ( ) - > excerpts ( ) . size ( ) = = 0 ) ;
2012-05-26 14:49:10 +02:00
updateUndoRedo ( ) ;
2015-11-23 16:02:33 +01:00
MagIdx midx = cv - > magIdx ( ) ;
if ( midx = = MagIdx : : MAG_FREE )
2015-11-18 18:09:42 +01:00
mag - > setMag ( view - > lmag ( ) ) ;
2015-11-19 22:54:37 +01:00
else {
2015-11-23 16:02:33 +01:00
mag - > setMagIdx ( midx ) ;
magChanged ( midx ) ;
2015-11-19 22:54:37 +01:00
}
2012-05-26 14:49:10 +02:00
2018-03-31 06:57:32 +02:00
updateWindowTitle ( cs ) ;
setWindowModified ( cs - > dirty ( ) ) ;
2012-05-26 14:49:10 +02:00
QAction * a = getAction ( " concert-pitch " ) ;
2018-03-27 15:36:00 +02:00
a - > setChecked ( cs - > styleB ( Sid : : concertPitch ) ) ;
2012-05-26 14:49:10 +02:00
setPos ( cs - > inputPos ( ) ) ;
2014-07-10 14:13:37 +02:00
//showMessage(cs->filePath(), 2000);
2016-05-31 10:23:14 +02:00
if ( _navigator & & _navigator - > widget ( ) ) {
navigator ( ) - > setScore ( cs ) ;
2017-02-20 16:54:01 +01:00
navigator ( ) - > setScoreView ( view ) ;
2016-05-31 10:23:14 +02:00
}
2017-07-11 21:36:05 +02:00
if ( timeline ( ) ) {
timeline ( ) - > setScore ( cs ) ;
timeline ( ) - > setScoreView ( view ) ;
2017-07-06 07:10:27 +02:00
}
2014-07-10 14:13:37 +02:00
ScoreAccessibility : : instance ( ) - > updateAccessibilityInfo ( ) ;
2012-05-26 14:49:10 +02:00
}
2015-11-04 11:40:06 +01:00
//---------------------------------------------------------
// updateViewModeCombo
//---------------------------------------------------------
void MuseScore : : updateViewModeCombo ( )
{
int idx ;
switch ( cs - > layoutMode ( ) ) {
case LayoutMode : : PAGE :
case LayoutMode : : FLOAT :
idx = 0 ;
break ;
case LayoutMode : : LINE :
idx = 1 ;
break ;
case LayoutMode : : SYSTEM :
idx = 2 ;
break ;
fix #96971 suppress benign make release warnings
This commit removes some -Wempty-body, -Wmaybe-uninitialized, -Wunused-variable, and -Wstrict-overflow compiler warnings that arise on my x86-64 and ARM arch linux machines when compiling release.
These compiler warnings don't seem to cause any bugs, but since they pollute the build output, they make it harder to spot potentially important warnings that might arise, so I'm making these small changes to keep the build output clean.
The "empty-body" warnings occur because the Q_ASSERT statements are removed for release compiles, causing the else blocks to be empty. Surrounding the Q_ASSERT with brackets will let the compiler know we aren't unintentionally having an empty else body.
The "maybe-uninitialized" warnings are handled by assigning the variables to 0 either at initialization or in a switch default block.
The "unused-variable" warning is due to PeriodItem updatePeriods[] in preferences.cpp being defined but never used, so I've removed PeriodItem. Also a recent commit has an unused "int staves", which I've removed.
The "strict-overflow" warning is due to compiler wanting to perform an optimization which would cause signed overflow during a comparison operation. I've made the compiler happy by casting the barIndex'es into unsigned ints, so it doesn't have to worry.
2016-02-04 13:57:50 +01:00
default :
idx = 0 ;
break ;
2015-11-04 11:40:06 +01:00
}
viewModeCombo - > setCurrentIndex ( idx ) ;
}
2013-05-24 18:40:15 +02:00
//---------------------------------------------------------
// showMessage
//---------------------------------------------------------
void MuseScore : : showMessage ( const QString & s , int timeout )
{
_statusBar - > showMessage ( s , timeout ) ;
}
2013-05-17 20:11:36 +02:00
//---------------------------------------------------------
2013-07-22 01:33:56 +02:00
// midiPanel
2013-05-17 20:11:36 +02:00
//---------------------------------------------------------
2013-07-22 01:33:56 +02:00
void MuseScore : : midiPanelOnSwitchToFile ( const QString & file )
2013-05-17 20:11:36 +02:00
{
2013-07-22 01:33:56 +02:00
bool isMidiFile = ImportMidiPanel : : isMidiFile ( file ) ;
if ( isMidiFile ) {
2013-09-25 21:53:52 +02:00
importmidiPanel - > setMidiFile ( file ) ;
2014-07-29 21:58:36 +02:00
if ( importmidiPanel - > isPreferredVisible ( ) )
2013-09-25 21:53:52 +02:00
importmidiPanel - > setVisible ( true ) ;
2013-05-17 20:11:36 +02:00
}
2013-07-22 01:33:56 +02:00
else
2013-09-25 21:53:52 +02:00
importmidiPanel - > setVisible ( false ) ;
2014-07-29 21:58:36 +02:00
importmidiShowPanel - > setVisible ( ! importmidiPanel - > isPreferredVisible ( ) & & isMidiFile ) ;
2013-07-22 01:33:56 +02:00
}
2014-11-14 11:44:48 +01:00
//---------------------------------------------------------
// midiPanelOnCloseFile
//---------------------------------------------------------
2013-07-22 01:33:56 +02:00
void MuseScore : : midiPanelOnCloseFile ( const QString & file )
{
if ( ImportMidiPanel : : isMidiFile ( file ) )
2013-09-25 21:53:52 +02:00
importmidiPanel - > excludeMidiFile ( file ) ;
2013-07-22 01:33:56 +02:00
}
2014-11-14 11:44:48 +01:00
//---------------------------------------------------------
// allowShowMidiPanel
//---------------------------------------------------------
2013-07-22 01:33:56 +02:00
void MuseScore : : allowShowMidiPanel ( const QString & file )
{
if ( ImportMidiPanel : : isMidiFile ( file ) )
2014-07-29 21:58:36 +02:00
importmidiPanel - > setPreferredVisible ( true ) ;
2013-05-17 20:11:36 +02:00
}
2014-11-14 11:44:48 +01:00
//---------------------------------------------------------
// setMidiReopenInProgress
//---------------------------------------------------------
2014-07-29 21:58:36 +02:00
void MuseScore : : setMidiReopenInProgress ( const QString & file )
2013-07-23 13:05:19 +02:00
{
if ( ImportMidiPanel : : isMidiFile ( file ) )
2014-06-21 20:50:33 +02:00
importmidiPanel - > setReopenInProgress ( ) ;
2013-09-25 21:53:52 +02:00
}
2014-11-14 11:44:48 +01:00
//---------------------------------------------------------
// showMidiImportPanel
//---------------------------------------------------------
2013-09-25 21:53:52 +02:00
void MuseScore : : showMidiImportPanel ( )
{
2014-07-29 21:58:36 +02:00
importmidiPanel - > setPreferredVisible ( true ) ;
2014-11-01 10:52:35 +01:00
QString fileName = cs ? cs - > importedFilePath ( ) : " " ;
2013-09-25 21:53:52 +02:00
if ( ImportMidiPanel : : isMidiFile ( fileName ) )
importmidiPanel - > setVisible ( true ) ;
importmidiShowPanel - > hide ( ) ;
2013-07-23 13:05:19 +02:00
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// dragEnterEvent
//---------------------------------------------------------
void MuseScore : : dragEnterEvent ( QDragEnterEvent * event )
{
const QMimeData * data = event - > mimeData ( ) ;
if ( data - > hasUrls ( ) ) {
QList < QUrl > ul = event - > mimeData ( ) - > urls ( ) ;
foreach ( const QUrl & u , ul ) {
if ( MScore : : debugMode )
2014-10-16 18:12:58 +02:00
qDebug ( " drag Url: %s scheme <%s> " , qPrintable ( u . toString ( ) ) , qPrintable ( u . scheme ( ) ) ) ;
2012-05-26 14:49:10 +02:00
if ( u . scheme ( ) = = " file " ) {
2014-10-16 18:12:58 +02:00
// QFileInfo fi(u.toLocalFile());
2012-05-26 14:49:10 +02:00
event - > acceptProposedAction ( ) ;
break ;
}
}
}
}
//---------------------------------------------------------
// dropEvent
//---------------------------------------------------------
void MuseScore : : dropEvent ( QDropEvent * event )
{
const QMimeData * data = event - > mimeData ( ) ;
if ( data - > hasUrls ( ) ) {
int view = - 1 ;
foreach ( const QUrl & u , event - > mimeData ( ) - > urls ( ) ) {
if ( u . scheme ( ) = = " file " ) {
2013-04-28 21:29:12 +02:00
QString file = u . toLocalFile ( ) ;
2016-03-11 12:18:46 +01:00
MasterScore * score = readScore ( file ) ;
2012-09-29 16:46:45 +02:00
if ( score ) {
2012-05-26 14:49:10 +02:00
view = appendScore ( score ) ;
2014-12-08 14:41:36 +01:00
addRecentScore ( score ) ;
2012-07-04 19:37:53 +02:00
}
2012-05-26 14:49:10 +02:00
}
}
2014-10-16 18:12:58 +02:00
if ( view ! = - 1 ) {
2012-05-26 14:49:10 +02:00
setCurrentScoreView ( view ) ;
2012-07-04 19:37:53 +02:00
writeSessionFile ( false ) ;
}
2012-05-26 14:49:10 +02:00
event - > acceptProposedAction ( ) ;
}
}
2016-06-30 15:34:02 +02:00
//---------------------------------------------------------
// changeEvent
//---------------------------------------------------------
2016-09-29 17:46:26 +02:00
2016-06-30 15:34:02 +02:00
void MuseScore : : changeEvent ( QEvent * e )
{
QMainWindow : : changeEvent ( e ) ;
switch ( e - > type ( ) ) {
case QEvent : : LanguageChange :
retranslate ( ) ;
break ;
default :
break ;
}
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// showPageSettings
//---------------------------------------------------------
void MuseScore : : showPageSettings ( )
{
if ( pageSettings = = 0 )
pageSettings = new PageSettings ( ) ;
2016-03-10 10:41:31 +01:00
pageSettings - > setScore ( cs - > masterScore ( ) ) ;
2012-05-26 14:49:10 +02:00
pageSettings - > show ( ) ;
pageSettings - > raise ( ) ;
}
//---------------------------------------------------------
// startDebugger
//---------------------------------------------------------
void MuseScore : : startDebugger ( )
{
if ( ! cs )
return ;
if ( debugger = = 0 )
debugger = new Debugger ( this ) ;
debugger - > updateList ( cs ) ;
debugger - > show ( ) ;
}
//---------------------------------------------------------
// showElementContext
//---------------------------------------------------------
void MuseScore : : showElementContext ( Element * el )
{
if ( el = = 0 )
return ;
startDebugger ( ) ;
debugger - > setElement ( el ) ;
}
//---------------------------------------------------------
// showPlayPanel
//---------------------------------------------------------
void MuseScore : : showPlayPanel ( bool visible )
{
2014-10-11 15:32:34 +02:00
if ( noSeq | | ! ( seq & & seq - > isRunning ( ) ) )
2012-05-26 14:49:10 +02:00
return ;
if ( playPanel = = 0 ) {
if ( ! visible )
return ;
playPanel = new PlayPanel ( this ) ;
2013-04-03 12:49:55 +02:00
connect ( playPanel , SIGNAL ( gainChange ( float ) ) , synti , SLOT ( setGain ( float ) ) ) ;
2017-03-20 12:31:22 +01:00
connect ( playPanel , SIGNAL ( metronomeGainChanged ( float ) ) , seq , SLOT ( setMetronomeGain ( float ) ) ) ;
2012-05-26 14:49:10 +02:00
connect ( playPanel , SIGNAL ( relTempoChanged ( double ) ) , seq , SLOT ( setRelTempo ( double ) ) ) ;
connect ( playPanel , SIGNAL ( posChange ( int ) ) , seq , SLOT ( seek ( int ) ) ) ;
2013-05-12 23:13:28 +02:00
connect ( playPanel , SIGNAL ( closed ( bool ) ) , playId , SLOT ( setChecked ( bool ) ) ) ;
2013-04-03 12:49:55 +02:00
connect ( synti , SIGNAL ( gainChanged ( float ) ) , playPanel , SLOT ( setGain ( float ) ) ) ;
playPanel - > setGain ( synti - > gain ( ) ) ;
2012-05-26 14:49:10 +02:00
playPanel - > setScore ( cs ) ;
2015-01-07 15:33:24 +01:00
mscore - > stackUnder ( playPanel ) ;
2012-05-26 14:49:10 +02:00
}
playPanel - > setVisible ( visible ) ;
playId - > setChecked ( visible ) ;
}
//---------------------------------------------------------
// cmdAppendMeasures
//---------------------------------------------------------
void MuseScore : : cmdAppendMeasures ( )
{
if ( cs ) {
2013-04-28 21:29:12 +02:00
if ( measuresDialog = = 0 )
2012-05-26 14:49:10 +02:00
measuresDialog = new MeasuresDialog ;
measuresDialog - > show ( ) ;
}
}
//---------------------------------------------------------
// MeasuresDialog
//---------------------------------------------------------
MeasuresDialog : : MeasuresDialog ( QWidget * parent )
: QDialog ( parent )
2013-02-07 13:10:46 +01:00
{
2012-05-26 14:49:10 +02:00
setupUi ( this ) ;
2013-02-07 13:10:46 +01:00
setWindowFlags ( this - > windowFlags ( ) & ~ Qt : : WindowContextHelpButtonHint ) ;
2013-11-28 21:39:17 +01:00
measures - > selectAll ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// accept
//---------------------------------------------------------
void MeasuresDialog : : accept ( )
2013-04-28 21:29:12 +02:00
{
int n = measures - > value ( ) ;
2012-05-26 14:49:10 +02:00
if ( mscore - > currentScore ( ) )
2017-01-18 14:16:33 +01:00
mscore - > currentScoreView ( ) - > cmdAppendMeasures ( n , ElementType : : MEASURE ) ;
2012-05-26 14:49:10 +02:00
done ( 1 ) ;
2013-04-28 21:29:12 +02:00
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// midiinToggled
//---------------------------------------------------------
void MuseScore : : midiinToggled ( bool val )
{
_midiinEnabled = val ;
}
//---------------------------------------------------------
// midiinEnabled
//---------------------------------------------------------
bool MuseScore : : midiinEnabled ( ) const
{
2017-11-29 08:21:36 +01:00
return preferences . getBool ( PREF_IO_MIDI_ENABLEINPUT ) & & _midiinEnabled ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// processMidiRemote
// return if midi remote command detected
//---------------------------------------------------------
2016-08-08 17:46:48 +02:00
bool MuseScore : : processMidiRemote ( MidiRemoteType type , int data , int value )
2012-05-26 14:49:10 +02:00
{
2017-11-29 08:21:36 +01:00
if ( ! preferences . getBool ( PREF_IO_MIDI_USEREMOTECONTROL ) )
2012-05-26 14:49:10 +02:00
return false ;
2016-08-08 17:46:48 +02:00
if ( ! value ) {
// This was a "NoteOff" or "CtrlOff" event. Most MidiRemote actions should only
// be triggered by an "On" event, so we need to check if this is one of those.
2017-11-29 08:21:36 +01:00
if ( ! preferences . getBool ( PREF_IO_MIDI_ADVANCEONRELEASE )
| | type ! = preferences . midiRemote ( RMIDI_REALTIME_ADVANCE ) . type
| | data ! = preferences . midiRemote ( RMIDI_REALTIME_ADVANCE ) . data )
2016-08-08 17:46:48 +02:00
return false ;
}
2012-05-26 14:49:10 +02:00
for ( int i = 0 ; i < MIDI_REMOTES ; + + i ) {
2017-11-29 08:21:36 +01:00
if ( preferences . midiRemote ( i ) . type = = type & & preferences . midiRemote ( i ) . data = = data ) {
2012-05-26 14:49:10 +02:00
if ( cv = = 0 )
return false ;
QAction * a = 0 ;
switch ( i ) {
case RMIDI_REWIND : a = getAction ( " rewind " ) ; break ;
case RMIDI_TOGGLE_PLAY : a = getAction ( " play " ) ; break ;
case RMIDI_PLAY :
a = getAction ( " play " ) ;
if ( a - > isChecked ( ) )
return true ;
break ;
case RMIDI_STOP :
a = getAction ( " play " ) ;
if ( ! a - > isChecked ( ) )
return true ;
break ;
case RMIDI_NOTE1 : a = getAction ( " pad-note-1 " ) ; break ;
case RMIDI_NOTE2 : a = getAction ( " pad-note-2 " ) ; break ;
case RMIDI_NOTE4 : a = getAction ( " pad-note-4 " ) ; break ;
case RMIDI_NOTE8 : a = getAction ( " pad-note-8 " ) ; break ;
case RMIDI_NOTE16 : a = getAction ( " pad-note-16 " ) ; break ;
case RMIDI_NOTE32 : a = getAction ( " pad-note-32 " ) ; break ;
case RMIDI_NOTE64 : a = getAction ( " pad-note-64 " ) ; break ;
case RMIDI_REST : a = getAction ( " rest " ) ; break ;
2014-12-08 15:14:29 +01:00
case RMIDI_DOT : a = getAction ( " pad-dot " ) ; break ;
case RMIDI_DOTDOT : a = getAction ( " pad-dotdot " ) ; break ;
2012-05-26 14:49:10 +02:00
case RMIDI_TIE : a = getAction ( " tie " ) ; break ;
2014-12-15 13:25:43 +01:00
case RMIDI_UNDO : a = getAction ( " undo " ) ; break ;
2012-05-26 14:49:10 +02:00
case RMIDI_NOTE_EDIT_MODE : a = getAction ( " note-input " ) ; break ;
2016-08-08 17:46:43 +02:00
case RMIDI_REALTIME_ADVANCE : a = getAction ( " realtime-advance " ) ; break ;
2012-05-26 14:49:10 +02:00
}
if ( a )
a - > trigger ( ) ;
return true ;
}
}
return false ;
}
//---------------------------------------------------------
// midiNoteReceived
//---------------------------------------------------------
void MuseScore : : midiNoteReceived ( int channel , int pitch , int velo )
{
2017-03-08 17:14:37 +01:00
static const int THRESHOLD_DRUMS = 5 ; // iterations required before consecutive drum notes
2012-05-26 14:49:10 +02:00
// are not considered part of a chord
static int active = 0 ;
2017-03-08 17:14:37 +01:00
static int iterDrums = 0 ;
static int activeDrums = 0 ;
2012-05-26 14:49:10 +02:00
if ( ! midiinEnabled ( ) )
return ;
// qDebug("midiNoteReceived %d %d %d", channel, pitch, velo);
if ( _midiRecordId ! = - 1 ) {
2017-11-29 08:21:36 +01:00
preferences . updateMidiRemote ( _midiRecordId , MIDI_REMOTE_TYPE_NOTEON , pitch ) ;
2012-05-26 14:49:10 +02:00
_midiRecordId = - 1 ;
if ( preferenceDialog )
preferenceDialog - > updateRemote ( ) ;
return ;
}
2012-10-29 16:37:24 +01:00
2016-08-08 17:46:48 +02:00
if ( processMidiRemote ( MIDI_REMOTE_TYPE_NOTEON , pitch , velo ) ) {
2012-05-26 14:49:10 +02:00
active = 0 ;
return ;
}
2012-10-29 16:37:24 +01:00
2012-05-26 14:49:10 +02:00
QWidget * w = QApplication : : activeModalWidget ( ) ;
if ( ! cv | | w ) {
2014-12-15 13:25:43 +01:00
active = 1 ;
2012-05-26 14:49:10 +02:00
return ;
}
if ( velo ) {
/*
* Since some drum modules do not overlap note on / off messages
* we need to take a bit of a different tactic to allow chords
* to be entered .
*
* Rather than decrement active for drums ( midi on ch10 ) ,
* we ' ll just assume that if read ( ) has been called a couple
* times in a row without a drum note , that this note is not
* part of a cord .
*/
if ( channel = = 0x09 ) {
2017-03-08 17:14:37 +01:00
if ( iterDrums > = THRESHOLD_DRUMS )
activeDrums = 0 ;
iterDrums = 0 ;
cv - > midiNoteReceived ( pitch , activeDrums > 0 , velo ) ;
}
else {
//qDebug(" midiNoteReceived %d active %d", pitch, active);
cv - > midiNoteReceived ( pitch , active > 0 , velo ) ;
+ + active ;
2012-05-26 14:49:10 +02:00
}
}
else {
2017-03-08 17:14:37 +01:00
/*
* Since a note may be assigned to a midi_remote ,
* don ' t decrease active below zero on noteoff .
*/
2014-12-15 13:25:43 +01:00
if ( ( channel ! = 0x09 ) & & ( active > 0 ) )
2012-05-26 14:49:10 +02:00
- - active ;
2017-03-08 17:14:37 +01:00
if ( ( channel = = 0x09 ) & & ( activeDrums > 0 ) )
- - activeDrums ;
2015-04-20 00:24:35 +02:00
cv - > midiNoteReceived ( pitch , false , velo ) ;
2012-05-26 14:49:10 +02:00
}
2016-08-31 03:39:41 +02:00
if ( _pianoTools & & _pianoTools - > isVisible ( ) ) {
if ( velo )
_pianoTools - > pressPitch ( pitch ) ;
else
_pianoTools - > releasePitch ( pitch ) ;
}
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// midiCtrlReceived
//---------------------------------------------------------
2014-12-15 13:24:54 +01:00
void MuseScore : : midiCtrlReceived ( int controller , int value )
2012-05-26 14:49:10 +02:00
{
if ( ! midiinEnabled ( ) )
return ;
if ( _midiRecordId ! = - 1 ) {
2017-11-29 08:21:36 +01:00
preferences . updateMidiRemote ( _midiRecordId , MIDI_REMOTE_TYPE_CTRL , controller ) ;
2012-05-26 14:49:10 +02:00
_midiRecordId = - 1 ;
if ( preferenceDialog )
preferenceDialog - > updateRemote ( ) ;
return ;
}
2014-12-15 13:24:54 +01:00
// when value is 0 (usually when a key is released ) nothing happens
2016-08-08 17:46:48 +02:00
if ( processMidiRemote ( MIDI_REMOTE_TYPE_CTRL , controller , value ) )
2012-05-26 14:49:10 +02:00
return ;
}
//---------------------------------------------------------
// removeTab
//---------------------------------------------------------
void MuseScore : : removeTab ( )
{
2016-03-11 12:18:46 +01:00
int n = scoreList . indexOf ( cs - > masterScore ( ) ) ;
2012-05-26 14:49:10 +02:00
if ( n = = - 1 ) {
qDebug ( " removeTab: %p not found " , cs ) ;
return ;
}
removeTab ( n ) ;
}
void MuseScore : : removeTab ( int i )
{
2016-03-11 12:18:46 +01:00
MasterScore * score = scoreList . value ( i ) ;
2012-09-12 16:19:03 +02:00
2012-05-26 14:49:10 +02:00
if ( score = = 0 )
return ;
2012-09-03 14:43:36 +02:00
QString tmpName = score - > tmpName ( ) ;
2012-05-26 14:49:10 +02:00
if ( checkDirty ( score ) )
return ;
2013-05-15 13:34:50 +02:00
if ( seq & & seq - > score ( ) = = score ) {
2013-02-12 11:48:50 +01:00
seq - > stopWait ( ) ;
2012-05-26 14:49:10 +02:00
seq - > setScoreView ( 0 ) ;
2013-02-07 00:19:53 +01:00
}
2012-05-26 14:49:10 +02:00
int idx1 = tab1 - > currentIndex ( ) ;
bool firstTab = tab1 - > view ( idx1 ) = = cv ;
2014-11-01 10:52:35 +01:00
midiPanelOnCloseFile ( score - > importedFilePath ( ) ) ;
2012-05-26 14:49:10 +02:00
scoreList . removeAt ( i ) ;
2013-07-22 01:33:56 +02:00
2012-05-26 14:49:10 +02:00
tab1 - > blockSignals ( true ) ;
tab1 - > removeTab ( i ) ;
tab1 - > blockSignals ( false ) ;
if ( tab2 ) {
tab2 - > blockSignals ( true ) ;
tab2 - > removeTab ( i ) ;
tab2 - > blockSignals ( false ) ;
}
cs = 0 ;
cv = 0 ;
int n = scoreList . size ( ) ;
2013-02-15 22:39:56 +01:00
if ( n = = 0 )
setCurrentScoreView ( nullptr ) ;
else
2012-05-26 14:49:10 +02:00
setCurrentScoreView ( ( firstTab ? tab1 : tab2 ) - > view ( ) ) ;
writeSessionFile ( false ) ;
2012-09-03 14:43:36 +02:00
if ( ! tmpName . isEmpty ( ) ) {
QFile f ( tmpName ) ;
2012-05-26 14:49:10 +02:00
f . remove ( ) ;
}
delete score ;
2014-05-19 13:57:37 +02:00
// Shouldn't be necessary... but fix #21841
update ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2014-08-07 10:28:13 +02:00
// loadTranslation
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2014-08-08 20:54:00 +02:00
2014-08-07 10:28:13 +02:00
void loadTranslation ( QString filename , QString localeName )
2012-05-26 14:49:10 +02:00
{
2017-02-23 11:41:53 +01:00
QString userPrefix = dataPath + " /locale/ " + filename + " _ " ;
2014-08-07 10:28:13 +02:00
QString defaultPrefix = mscoreGlobalShare + " locale/ " + filename + " _ " ;
2017-02-23 11:41:53 +01:00
QString userlp = userPrefix + localeName ;
QString defaultlp = defaultPrefix + localeName ;
QString lp = defaultlp ;
2014-08-08 20:54:00 +02:00
2013-10-29 18:14:39 +01:00
QFileInfo userFi ( userlp + " .qm " ) ;
QFileInfo defaultFi ( defaultlp + " .qm " ) ;
2014-08-08 20:54:00 +02:00
2017-02-23 11:41:53 +01:00
if ( ! defaultFi . exists ( ) ) { // try with a shorter locale name
QString shortLocaleName = localeName . left ( localeName . lastIndexOf ( " _ " ) ) ;
2013-11-14 20:06:58 +01:00
QString shortDefaultlp = defaultPrefix + shortLocaleName ;
QFileInfo shortDefaultFi ( shortDefaultlp + " .qm " ) ;
2017-02-23 11:41:53 +01:00
if ( shortDefaultFi . exists ( ) ) {
userlp = userPrefix + shortLocaleName ;
userFi = QFileInfo ( userlp + " .qm " ) ;
2013-11-14 20:06:58 +01:00
defaultFi = shortDefaultFi ;
defaultlp = shortDefaultlp ;
2014-08-07 10:28:13 +02:00
}
2014-09-06 07:52:20 +02:00
}
2014-08-08 20:54:00 +02:00
2014-08-28 14:50:17 +02:00
if ( userFi . exists ( ) ) {
if ( userFi . lastModified ( ) > defaultFi . lastModified ( ) )
lp = userlp ;
2017-02-23 11:41:53 +01:00
// else
//REVIEW QFile::remove(userlp + ".qm");
}
2014-08-08 20:54:00 +02:00
2016-07-15 01:01:51 +02:00
if ( MScore : : debugMode )
qDebug ( " load translator <%s> " , qPrintable ( lp ) ) ;
2017-02-23 11:41:53 +01:00
QTranslator * translator = new QTranslator ;
2013-09-30 18:38:05 +02:00
bool success = translator - > load ( lp ) ;
2016-07-15 01:01:51 +02:00
if ( success ) {
2014-08-07 10:28:13 +02:00
qApp - > installTranslator ( translator ) ;
translatorList . append ( translator ) ;
}
2016-07-15 01:01:51 +02:00
else {
if ( MScore : : debugMode )
qDebug ( " load translator <%s> failed " , qPrintable ( lp ) ) ;
delete translator ;
}
2014-08-07 10:28:13 +02:00
}
2014-08-08 20:54:00 +02:00
2014-08-07 10:28:13 +02:00
//---------------------------------------------------------
// setLocale
//---------------------------------------------------------
void setMscoreLocale ( QString localeName )
{
2017-02-23 11:41:53 +01:00
for ( QTranslator * t : translatorList ) {
2014-08-07 10:28:13 +02:00
qApp - > removeTranslator ( t ) ;
delete t ;
}
translatorList . clear ( ) ;
if ( MScore : : debugMode )
qDebug ( " configured localeName <%s> " , qPrintable ( localeName ) ) ;
if ( localeName . toLower ( ) = = " system " ) {
localeName = QLocale : : system ( ) . name ( ) ;
if ( MScore : : debugMode )
qDebug ( " real localeName <%s> " , qPrintable ( localeName ) ) ;
2016-06-17 11:41:41 +02:00
if ( localeName = = " en_AU " ) {
localeName = " en_GB " ; // otherwise Australia would fall back to US English
if ( MScore : : debugMode )
qDebug ( " modified localeName <%s> " , qPrintable ( localeName ) ) ;
}
2014-08-07 10:28:13 +02:00
}
2012-05-26 14:49:10 +02:00
2014-08-07 10:28:13 +02:00
// find the most recent translation file
// try to replicate QTranslator.load algorithm in our particular case
loadTranslation ( " mscore " , localeName ) ;
loadTranslation ( " instruments " , localeName ) ;
2014-08-08 20:54:00 +02:00
2012-05-26 14:49:10 +02:00
QString resourceDir ;
2013-05-16 16:12:22 +02:00
# if defined(Q_OS_MAC) || defined(Q_OS_WIN)
2012-05-26 14:49:10 +02:00
resourceDir = mscoreGlobalShare + " locale/ " ;
# else
resourceDir = QLibraryInfo : : location ( QLibraryInfo : : TranslationsPath ) ;
# endif
QTranslator * qtTranslator = new QTranslator ;
if ( MScore : : debugMode )
qDebug ( " load translator <qt_%s> from <%s> " ,
qPrintable ( localeName ) , qPrintable ( resourceDir ) ) ;
if ( ! qtTranslator - > load ( QLatin1String ( " qt_ " ) + localeName , resourceDir ) & & MScore : : debugMode )
qDebug ( " load translator <qt_%s> failed " , qPrintable ( localeName ) ) ;
else {
qApp - > installTranslator ( qtTranslator ) ;
translatorList . append ( qtTranslator ) ;
}
2015-12-18 12:50:16 +01:00
QLocale locale ( localeName ) ;
QLocale : : setDefault ( locale ) ;
qApp - > setLayoutDirection ( locale . textDirection ( ) ) ;
2012-05-26 14:49:10 +02:00
// initShortcuts();
}
//---------------------------------------------------------
// loadScores
// load scores for a new session
//---------------------------------------------------------
static void loadScores ( const QStringList & argv )
{
int currentScoreView = 0 ;
if ( argv . isEmpty ( ) ) {
if ( startWithNewScore )
mscore - > newFile ( ) ;
else {
2017-11-29 08:21:36 +01:00
switch ( preferences . sessionStart ( ) ) {
2014-07-01 14:44:45 +02:00
case SessionStart : : LAST :
2012-05-26 14:49:10 +02:00
{
QSettings settings ;
int n = settings . value ( " scores " , 0 ) . toInt ( ) ;
int c = settings . value ( " currentScore " , 0 ) . toInt ( ) ;
for ( int i = 0 ; i < n ; + + i ) {
QString s = settings . value ( QString ( " score-%1 " ) . arg ( i ) , " " ) . toString ( ) ;
2016-03-11 12:18:46 +01:00
MasterScore * score = mscore - > readScore ( s ) ;
2012-09-29 16:46:45 +02:00
if ( score ) {
2012-05-26 14:49:10 +02:00
int view = mscore - > appendScore ( score ) ;
if ( i = = c )
currentScoreView = view ;
}
}
}
break ;
2014-07-01 14:44:45 +02:00
case SessionStart : : EMPTY :
2012-05-26 14:49:10 +02:00
break ;
2014-07-01 14:44:45 +02:00
case SessionStart : : NEW :
2012-05-26 14:49:10 +02:00
mscore - > newFile ( ) ;
break ;
2014-07-01 14:44:45 +02:00
case SessionStart : : SCORE :
2012-05-26 14:49:10 +02:00
{
2017-11-29 08:21:36 +01:00
QString startScore = preferences . getString ( PREF_APP_STARTUP_STARTSCORE ) ;
MasterScore * score = mscore - > readScore ( startScore ) ;
if ( startScore . startsWith ( " :/ " ) & & score ) {
2017-03-30 15:36:32 +02:00
score - > setName ( mscore - > createDefaultName ( ) ) ;
2017-01-23 21:53:51 +01:00
// TODO score->setPageFormat(*MScore::defaultStyle().pageFormat());
2015-06-22 22:04:23 +02:00
score - > doLayout ( ) ;
2014-08-19 17:44:02 +02:00
score - > setCreated ( true ) ;
2015-03-08 03:26:44 +01:00
}
2014-08-19 17:44:02 +02:00
if ( score = = 0 ) {
2014-11-14 12:29:17 +01:00
score = mscore - > readScore ( " :/data/My_First_Score.mscz " ) ;
2015-06-22 22:04:23 +02:00
if ( score ) {
2017-03-30 15:36:32 +02:00
score - > setName ( mscore - > createDefaultName ( ) ) ;
2017-01-23 21:53:51 +01:00
// TODO score->setPageFormat(*MScore::defaultStyle().pageFormat());
2015-06-22 22:04:23 +02:00
score - > doLayout ( ) ;
score - > setCreated ( true ) ;
}
2014-08-19 17:44:02 +02:00
}
2012-09-29 16:46:45 +02:00
if ( score )
2012-05-26 14:49:10 +02:00
currentScoreView = mscore - > appendScore ( score ) ;
}
break ;
}
}
}
else {
foreach ( const QString & name , argv ) {
if ( name . isEmpty ( ) )
continue ;
2016-03-11 12:18:46 +01:00
MasterScore * score = mscore - > readScore ( name ) ;
2012-09-29 16:46:45 +02:00
if ( score ) {
2012-05-26 14:49:10 +02:00
mscore - > appendScore ( score ) ;
2014-11-20 12:49:51 +01:00
scoresOnCommandline = true ;
2014-02-28 11:14:43 +01:00
if ( ! MScore : : noGui ) {
2014-12-08 14:41:36 +01:00
mscore - > addRecentScore ( score ) ;
2012-11-25 19:15:35 +01:00
mscore - > writeSessionFile ( false ) ;
}
2012-05-26 14:49:10 +02:00
}
}
}
if ( mscore - > noScore ( ) )
currentScoreView = - 1 ;
mscore - > setCurrentView ( 0 , currentScoreView ) ;
mscore - > setCurrentView ( 1 , currentScoreView ) ;
}
//---------------------------------------------------------
2016-05-14 13:11:41 +02:00
// doConvert
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2017-04-05 18:03:34 +02:00
static bool doConvert ( Score * cs , QString fn , QString plugin = " " )
2012-05-26 14:49:10 +02:00
{
2015-07-08 08:09:14 +02:00
bool rv = true ;
2016-05-14 13:11:41 +02:00
LayoutMode layoutMode = cs - > layoutMode ( ) ;
2016-05-18 15:43:47 +02:00
cs - > setLayoutMode ( LayoutMode : : PAGE ) ;
if ( cs - > layoutMode ( ) ! = layoutMode ) {
cs - > setLayoutMode ( LayoutMode : : PAGE ) ;
cs - > doLayout ( ) ;
}
2016-05-14 13:11:41 +02:00
if ( ! styleFile . isEmpty ( ) ) {
QFile f ( styleFile ) ;
if ( f . open ( QIODevice : : ReadOnly ) )
2017-01-05 11:23:47 +01:00
cs - > style ( ) . load ( & f ) ;
2016-05-14 13:11:41 +02:00
}
2017-04-05 18:03:34 +02:00
if ( ! plugin . isEmpty ( ) ) {
mscore - > setCurrentScore ( cs ) ;
2017-05-05 18:16:50 +02:00
LayoutMode layoutMode = cs - > layoutMode ( ) ;
2017-05-06 15:33:04 +02:00
if ( layoutMode ! = LayoutMode : : PAGE ) {
cs - > setLayoutMode ( LayoutMode : : PAGE ) ;
cs - > doLayout ( ) ;
}
2017-04-05 18:03:34 +02:00
if ( mscore - > loadPlugin ( plugin ) )
mscore - > pluginTriggered ( 0 ) ;
mscore - > unloadPlugins ( ) ;
2017-05-06 15:33:04 +02:00
if ( layoutMode ! = cs - > layoutMode ( ) ) {
cs - > setLayoutMode ( layoutMode ) ;
cs - > doLayout ( ) ;
}
2017-04-05 18:03:34 +02:00
}
2016-05-14 13:11:41 +02:00
if ( fn . endsWith ( " .mscx " ) ) {
QFileInfo fi ( fn ) ;
2016-09-14 12:08:14 +02:00
if ( ! cs - > saveFile ( fi ) )
2016-05-14 13:11:41 +02:00
return false ;
return true ;
}
else if ( fn . endsWith ( " .mscz " ) ) {
QFileInfo fi ( fn ) ;
2016-09-14 12:08:14 +02:00
if ( ! cs - > saveCompressedFile ( fi , false ) )
2016-05-14 13:11:41 +02:00
return false ;
return true ;
}
2017-08-02 00:38:42 +02:00
else if ( fn . endsWith ( " .xml " ) | | fn . endsWith ( " .musicxml " ) ) {
2016-05-14 13:11:41 +02:00
rv = saveXml ( cs , fn ) ;
}
else if ( fn . endsWith ( " .mxl " ) ) {
rv = saveMxl ( cs , fn ) ;
}
else if ( fn . endsWith ( " .mid " ) )
return mscore - > saveMidi ( cs , fn ) ;
else if ( fn . endsWith ( " .pdf " ) ) {
if ( ! exportScoreParts ) {
2016-09-03 17:45:59 +02:00
rv = mscore - > savePdf ( cs , fn ) ;
2015-07-08 08:09:14 +02:00
}
2016-05-14 13:11:41 +02:00
else {
if ( cs - > excerpts ( ) . size ( ) = = 0 ) {
auto excerpts = Excerpt : : createAllExcerpt ( cs - > masterScore ( ) ) ;
for ( Excerpt * e : excerpts ) {
Score * nscore = new Score ( e - > oscore ( ) ) ;
e - > setPartScore ( nscore ) ;
2018-03-27 15:36:00 +02:00
nscore - > style ( ) . set ( Sid : : createMultiMeasureRests , true ) ;
2016-10-12 11:09:53 +02:00
Excerpt : : createExcerpt ( e ) ;
2016-10-10 18:37:28 +02:00
cs - > startCmd ( ) ;
cs - > undo ( new AddExcerpt ( e ) ) ;
2016-05-14 13:11:41 +02:00
cs - > endCmd ( ) ;
2015-05-06 09:08:20 +02:00
}
}
2016-05-14 13:11:41 +02:00
QList < Score * > scores ;
scores . append ( cs ) ;
for ( Excerpt * e : cs - > excerpts ( ) )
scores . append ( e - > partScore ( ) ) ;
return mscore - > savePdf ( scores , fn ) ;
2015-05-06 09:08:20 +02:00
}
2016-05-14 13:11:41 +02:00
}
else if ( fn . endsWith ( " .png " ) ) {
if ( ! exportScoreParts )
return mscore - > savePng ( cs , fn ) ;
else {
if ( cs - > excerpts ( ) . size ( ) = = 0 ) {
auto excerpts = Excerpt : : createAllExcerpt ( cs - > masterScore ( ) ) ;
for ( Excerpt * e : excerpts ) {
Score * nscore = new Score ( e - > oscore ( ) ) ;
e - > setPartScore ( nscore ) ;
2016-07-31 15:23:11 +02:00
nscore - > setExcerpt ( e ) ;
2016-10-10 18:37:28 +02:00
// nscore->setName(e->title()); // needed before AddExcerpt
2018-03-27 15:36:00 +02:00
nscore - > style ( ) . set ( Sid : : createMultiMeasureRests , true ) ;
2016-10-12 11:09:53 +02:00
Excerpt : : createExcerpt ( e ) ;
2016-10-10 18:37:28 +02:00
cs - > startCmd ( ) ;
cs - > undo ( new AddExcerpt ( e ) ) ;
2016-05-14 13:11:41 +02:00
cs - > endCmd ( ) ;
2016-04-01 09:32:45 +02:00
}
2016-05-14 13:11:41 +02:00
}
if ( ! mscore - > savePng ( cs , fn ) )
return false ;
int idx = 0 ;
int padding = QString ( " %1 " ) . arg ( cs - > excerpts ( ) . size ( ) ) . size ( ) ;
for ( Excerpt * e : cs - > excerpts ( ) ) {
QString suffix = QString ( " __excerpt__%1.png " ) . arg ( idx , padding , 10 , QLatin1Char ( ' 0 ' ) ) ;
QString excerptFn = fn . left ( fn . size ( ) - 4 ) + suffix ;
if ( ! mscore - > savePng ( e - > partScore ( ) , excerptFn ) )
2016-04-01 09:32:45 +02:00
return false ;
2016-05-14 13:11:41 +02:00
idx + + ;
2016-04-01 09:32:45 +02:00
}
2016-05-14 13:11:41 +02:00
return true ;
2015-07-08 08:09:14 +02:00
}
2016-05-14 13:11:41 +02:00
}
else if ( fn . endsWith ( " .svg " ) ) {
rv = mscore - > saveSvg ( cs , fn ) ;
}
2012-05-26 14:49:10 +02:00
# ifdef HAS_AUDIOFILE
2015-07-08 08:09:14 +02:00
else if ( fn . endsWith ( " .wav " ) | | fn . endsWith ( " .ogg " ) | | fn . endsWith ( " .flac " ) )
2014-11-14 11:44:48 +01:00
return mscore - > saveAudio ( cs , fn ) ;
2012-05-26 14:49:10 +02:00
# endif
2015-06-01 18:09:55 +02:00
# ifdef USE_LAME
2015-07-08 08:09:14 +02:00
else if ( fn . endsWith ( " .mp3 " ) )
2012-05-26 14:49:10 +02:00
return mscore - > saveMp3 ( cs , fn ) ;
2015-06-01 18:09:55 +02:00
# endif
2016-05-14 13:11:41 +02:00
else if ( fn . endsWith ( " .spos " ) ) {
rv = savePositions ( cs , fn , true ) ;
}
else if ( fn . endsWith ( " .mpos " ) ) {
rv = savePositions ( cs , fn , false ) ;
}
else if ( fn . endsWith ( " .mlog " ) )
return cs - > sanityCheck ( fn ) ;
2017-04-05 18:03:34 +02:00
else if ( plugin . isEmpty ( ) ) {
qDebug ( " don't know how to convert to %s " , qPrintable ( outFileName ) ) ;
2016-05-14 13:11:41 +02:00
return false ;
}
2016-05-18 15:43:47 +02:00
if ( layoutMode ! = cs - > layoutMode ( ) ) {
cs - > setLayoutMode ( layoutMode ) ;
cs - > doLayout ( ) ;
}
2016-05-14 13:11:41 +02:00
return rv ;
}
//---------------------------------------------------------
// convert
//---------------------------------------------------------
2017-04-05 18:03:34 +02:00
static bool convert ( const QString & inFile , const QString & outFile , const QString & plugin = " " )
2016-05-14 13:11:41 +02:00
{
2017-04-05 18:03:34 +02:00
if ( inFile . isEmpty ( ) | | ( outFile . isEmpty ( ) & & plugin . isEmpty ( ) ) ) {
2016-05-14 13:11:41 +02:00
fprintf ( stderr , " cannot convert <%s> to <%s> \n " , qPrintable ( inFile ) , qPrintable ( outFile ) ) ;
return false ;
}
fprintf ( stderr , " convert <%s> to <%s> \n " , qPrintable ( inFile ) , qPrintable ( outFile ) ) ;
MasterScore * score = mscore - > readScore ( inFile ) ;
if ( ! score )
return false ;
2017-04-05 18:03:34 +02:00
if ( ! doConvert ( score , outFile , plugin ) ) {
2016-05-14 13:11:41 +02:00
delete score ;
return false ;
}
delete score ;
return true ;
}
//---------------------------------------------------------
// doProcessJob
//---------------------------------------------------------
static bool doProcessJob ( QString jsonFile )
{
QFile f ( jsonFile ) ;
if ( ! f . open ( QIODevice : : ReadOnly ) ) {
fprintf ( stderr , " cannon open json file <%s> \n " , qPrintable ( jsonFile ) ) ;
return false ;
}
QJsonParseError pe ;
QJsonDocument doc = QJsonDocument : : fromJson ( f . readAll ( ) , & pe ) ;
if ( pe . error ! = QJsonParseError : : NoError ) {
fprintf ( stderr , " error reading json file <%s> at %d: %s \n " ,
qPrintable ( jsonFile ) , pe . offset , qPrintable ( pe . errorString ( ) ) ) ;
return false ;
}
if ( ! doc . isArray ( ) ) {
fprintf ( stderr , " json file <%s> is not an array \n " , qPrintable ( jsonFile ) ) ;
return false ;
}
QJsonArray a = doc . array ( ) ;
for ( const auto i : a ) {
QString inFile ;
QString outFile ;
2017-04-05 18:03:34 +02:00
QString plugin ;
2016-05-14 13:11:41 +02:00
if ( ! i . isObject ( ) ) {
fprintf ( stderr , " array value is not an object \n " ) ;
return false ;
2015-07-08 08:09:14 +02:00
}
2016-05-14 13:11:41 +02:00
QJsonObject obj = i . toObject ( ) ;
for ( const auto & key : obj . keys ( ) ) {
QString val = obj . value ( key ) . toString ( ) ;
if ( key = = " in " )
inFile = val ;
else if ( key = = " out " )
outFile = val ;
2017-04-05 18:03:34 +02:00
else if ( key = = " plugin " )
plugin = val ;
2016-05-14 13:11:41 +02:00
else {
fprintf ( stderr , " unknown key <%s> \n " , qPrintable ( key ) ) ;
return false ;
}
2015-07-08 08:09:14 +02:00
}
2017-04-05 18:03:34 +02:00
if ( ! convert ( inFile , outFile , plugin ) )
2012-05-26 14:49:10 +02:00
return false ;
2016-05-14 13:11:41 +02:00
}
return true ;
}
//---------------------------------------------------------
// processNonGui
//---------------------------------------------------------
static bool processNonGui ( const QStringList & argv )
{
if ( pluginMode ) {
loadScores ( argv ) ;
QString pn ( pluginName ) ;
bool res = false ;
if ( mscore - > loadPlugin ( pn ) ) {
Score * cs = mscore - > currentScore ( ) ;
if ( ! styleFile . isEmpty ( ) ) {
QFile f ( styleFile ) ;
if ( f . open ( QIODevice : : ReadOnly ) )
2017-01-05 11:23:47 +01:00
cs - > style ( ) . load ( & f ) ;
2016-05-14 13:11:41 +02:00
}
2016-05-18 15:43:47 +02:00
LayoutMode layoutMode = cs - > layoutMode ( ) ;
if ( layoutMode ! = LayoutMode : : PAGE ) {
cs - > setLayoutMode ( LayoutMode : : PAGE ) ;
cs - > doLayout ( ) ;
}
2016-05-14 13:11:41 +02:00
mscore - > pluginTriggered ( 0 ) ;
2016-05-18 15:43:47 +02:00
if ( layoutMode ! = cs - > layoutMode ( ) ) {
cs - > setLayoutMode ( layoutMode ) ;
cs - > doLayout ( ) ;
}
2016-05-14 13:11:41 +02:00
res = true ;
2012-05-26 14:49:10 +02:00
}
2016-05-14 13:11:41 +02:00
if ( ! converterMode )
return res ;
}
bool rv = true ;
if ( converterMode ) {
if ( processJob )
return doProcessJob ( jsonFileName ) ;
else
return convert ( argv [ 0 ] , outFileName ) ;
2012-05-26 14:49:10 +02:00
}
2015-07-08 08:09:14 +02:00
return rv ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// Message handler
//---------------------------------------------------------
2013-05-16 16:12:22 +02:00
# if defined(QT_DEBUG) && defined(Q_OS_WIN)
2014-03-04 13:06:23 +01:00
static void mscoreMessageHandler ( QtMsgType type , const QMessageLogContext & context , const QString & msg )
2012-05-26 14:49:10 +02:00
{
2014-03-04 13:06:23 +01:00
QTextStream cerr ( stderr ) ;
QByteArray localMsg = msg . toLocal8Bit ( ) ;
2014-02-28 14:25:47 +01:00
2012-05-26 14:49:10 +02:00
switch ( type ) {
2016-04-15 08:34:02 +02:00
case QtInfoMsg :
cerr < < " Info: " < < localMsg . constData ( ) < < " ( " < < context . file < < " : " < < context . line < < " , " < < context . function < < " ) " < < endl ;
break ;
2012-05-26 14:49:10 +02:00
case QtDebugMsg :
2016-04-15 08:34:02 +02:00
cerr < < " Debug: " < < localMsg . constData ( ) < < " ( " < < context . file < < " : " < < context . line < < " , " < < context . function < < " ) " < < endl ;
2012-05-26 14:49:10 +02:00
break ;
case QtWarningMsg :
2016-04-15 08:34:02 +02:00
cerr < < " Warning: " < < localMsg . constData ( ) < < " ( " < < context . file < < " : " < < context . line < < " , " < < context . function < < " ) " < < endl ;
2012-05-26 14:49:10 +02:00
break ;
2016-04-15 08:34:02 +02:00
case QtCriticalMsg : // same as QtSystemMsg
2014-03-04 13:06:23 +01:00
cerr < < " Critical: " < < localMsg . constData ( ) < < " ( " < < context . file < < " : " < < context . line < < " , " < < context . function < < " ) " < < endl ;
2012-05-26 14:49:10 +02:00
break ;
2014-03-04 13:06:23 +01:00
case QtFatalMsg : // set your breakpoint here, if you want to catch the abort
2016-04-15 08:34:02 +02:00
cerr < < " Fatal: " < < localMsg . constData ( ) < < " ( " < < context . file < < " : " < < context . line < < " , " < < context . function < < " ) " < < endl ;
2012-05-26 14:49:10 +02:00
abort ( ) ;
}
}
# endif
2013-04-02 20:46:07 +02:00
//---------------------------------------------------------
// synthesizerFactory
// create and initialize the master synthesizer
//---------------------------------------------------------
MasterSynthesizer * synthesizerFactory ( )
{
MasterSynthesizer * ms = new MasterSynthesizer ( ) ;
2013-04-03 12:13:23 +02:00
FluidS : : Fluid * fluid = new FluidS : : Fluid ( ) ;
ms - > registerSynthesizer ( fluid ) ;
2013-04-03 20:20:36 +02:00
# ifdef AEOLUS
2013-05-13 18:49:17 +02:00
ms - > registerSynthesizer ( : : createAeolus ( ) ) ;
2013-04-03 20:20:36 +02:00
# endif
# ifdef ZERBERUS
2013-04-29 15:31:22 +02:00
ms - > registerSynthesizer ( createZerberus ( ) ) ;
2013-04-03 20:20:36 +02:00
# endif
2013-04-02 20:46:07 +02:00
ms - > registerEffect ( 0 , new NoEffect ) ;
ms - > registerEffect ( 0 , new ZitaReverb ) ;
2015-09-08 15:39:04 +02:00
ms - > registerEffect ( 0 , new Compressor ) ;
2013-05-13 18:49:17 +02:00
// ms->registerEffect(0, new Freeverb);
2013-04-02 20:46:07 +02:00
ms - > registerEffect ( 1 , new NoEffect ) ;
ms - > registerEffect ( 1 , new ZitaReverb ) ;
2015-09-08 15:39:04 +02:00
ms - > registerEffect ( 1 , new Compressor ) ;
2013-05-13 18:49:17 +02:00
// ms->registerEffect(1, new Freeverb);
2013-04-03 18:11:38 +02:00
ms - > setEffect ( 0 , 1 ) ;
2013-04-02 20:46:07 +02:00
ms - > setEffect ( 1 , 0 ) ;
return ms ;
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// unstable
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
bool MuseScore : : unstable ( )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
# ifdef MSCORE_UNSTABLE
return true ;
2012-05-26 14:49:10 +02:00
# else
2013-05-13 18:49:17 +02:00
return false ;
2012-05-26 14:49:10 +02:00
# endif
2013-05-13 18:49:17 +02:00
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// MuseScoreApplication::event (mac only)
//---------------------------------------------------------
2013-04-17 14:00:26 +02:00
2015-02-19 19:55:17 +01:00
bool MuseScoreApplication : : event ( QEvent * event )
2013-05-13 18:49:17 +02:00
{
switch ( event - > type ( ) ) {
case QEvent : : FileOpen :
2013-06-24 22:07:44 +02:00
// store names of files requested to be loaded by OS X to be handled later
// this event is generated when a file is dragged onto the MuseScore icon
// in the dock and MuseScore is not running yet
2013-05-13 18:49:17 +02:00
paths . append ( static_cast < QFileOpenEvent * > ( event ) - > file ( ) ) ;
return true ;
default :
2014-07-10 14:13:37 +02:00
return QtSingleApplication : : event ( event ) ;
2013-05-08 15:27:43 +02:00
}
2013-05-13 18:49:17 +02:00
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
2015-01-29 00:19:44 +01:00
// eventFilter
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
bool MuseScore : : eventFilter ( QObject * obj , QEvent * event )
{
switch ( event - > type ( ) ) {
2015-01-29 00:19:44 +01:00
# ifdef Q_OS_MAC
2013-05-13 18:49:17 +02:00
case QEvent : : FileOpen :
2013-06-24 22:07:44 +02:00
// open files requested to be loaded by OS X
// this event is generated when a file is dragged onto the MuseScore icon
// in the dock when MuseScore is already running
2015-02-23 17:34:40 +01:00
scoresOnCommandline = true ;
2013-05-13 18:49:17 +02:00
handleMessage ( static_cast < QFileOpenEvent * > ( event ) - > file ( ) ) ;
return true ;
2015-01-29 00:19:44 +01:00
# endif
2015-02-19 19:55:17 +01:00
case QEvent : : MouseMove : {
QMouseEvent * me = static_cast < QMouseEvent * > ( event ) ;
globalX = me - > globalX ( ) ;
globalY = me - > globalY ( ) ;
return QMainWindow : : eventFilter ( obj , event ) ;
}
2015-02-20 19:34:40 +01:00
case QEvent : : StatusTip :
return true ; // prevent updates to the status bar
2015-01-29 00:19:44 +01:00
case QEvent : : KeyPress :
{
QKeyEvent * e = static_cast < QKeyEvent * > ( event ) ;
if ( obj - > isWidgetType ( ) & & e - > key ( ) = = Qt : : Key_Escape & & e - > modifiers ( ) = = Qt : : NoModifier ) {
2017-01-07 16:02:14 +01:00
// Close the search dialog when Escape is pressed:
if ( _searchDialog ! = 0 )
endSearch ( ) ;
2015-01-29 00:19:44 +01:00
if ( isActiveWindow ( ) ) {
2015-02-16 22:43:17 +01:00
obj - > event ( e ) ;
2015-01-29 00:19:44 +01:00
if ( currentScoreView ( ) )
currentScoreView ( ) - > setFocus ( ) ;
else
mscore - > setFocus ( ) ;
return true ;
}
QWidget * w = static_cast < QWidget * > ( obj ) ;
if ( getPaletteBox ( ) - > isAncestorOf ( w ) | |
2015-02-03 01:55:16 +01:00
inspector ( ) - > isAncestorOf ( w ) | |
( selectionWindow & & selectionWindow - > isAncestorOf ( w ) ) ) {
2015-01-29 00:19:44 +01:00
activateWindow ( ) ;
if ( currentScoreView ( ) )
currentScoreView ( ) - > setFocus ( ) ;
else
mscore - > setFocus ( ) ;
return true ;
}
}
2015-02-20 19:34:40 +01:00
break ;
2015-01-29 00:19:44 +01:00
}
2013-05-13 18:49:17 +02:00
default :
2014-07-10 14:13:37 +02:00
return QMainWindow : : eventFilter ( obj , event ) ;
2012-05-26 14:49:10 +02:00
}
2015-02-20 19:34:40 +01:00
return QMainWindow : : eventFilter ( obj , event ) ;
2013-05-13 18:49:17 +02:00
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// hasToCheckForUpdate
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
bool MuseScore : : hasToCheckForUpdate ( )
{
if ( ucheck )
return ucheck - > hasToCheck ( ) ;
else
return false ;
}
2013-03-01 17:14:21 +01:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// checkForUpdate
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
void MuseScore : : checkForUpdate ( )
{
if ( ucheck )
2015-03-09 17:20:23 +01:00
ucheck - > check ( version ( ) , sender ( ) ! = 0 ) ;
2013-05-13 18:49:17 +02:00
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// readLanguages
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
bool MuseScore : : readLanguages ( const QString & path )
{
2014-02-24 22:42:07 +01:00
//: The default language of the operating system. NOT a music system.
_languages . append ( LanguageItem ( " system " , tr ( " System " ) ) ) ;
2013-05-13 18:49:17 +02:00
QFile qf ( path ) ;
if ( qf . exists ( ) ) {
QDomDocument doc ;
int line , column ;
QString err ;
if ( ! doc . setContent ( & qf , false , & err , & line , & column ) ) {
QString error ;
2014-02-27 19:57:24 +01:00
error . sprintf ( qPrintable ( tr ( " Error reading language file %s at line %d column %d: %s \n " ) ) ,
2013-05-13 18:49:17 +02:00
qPrintable ( qf . fileName ( ) ) , line , column , qPrintable ( err ) ) ;
QMessageBox : : warning ( 0 ,
2017-03-28 18:54:29 +02:00
QWidget : : tr ( " Load Languages Failed: " ) ,
2013-05-13 18:49:17 +02:00
error ,
QString : : null , QWidget : : tr ( " Quit " ) , QString : : null , 0 , 1 ) ;
return false ;
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
for ( QDomElement e = doc . documentElement ( ) ; ! e . isNull ( ) ; e = e . nextSiblingElement ( ) ) {
if ( e . tagName ( ) = = " languages " ) {
for ( e = e . firstChildElement ( ) ; ! e . isNull ( ) ; e = e . nextSiblingElement ( ) ) {
if ( e . tagName ( ) = = " language " ) {
QString code = e . attribute ( QString ( " code " ) ) ;
QString name = e . attribute ( QString ( " name " ) ) ;
QString handbook = e . attribute ( QString ( " handbook " ) ) ;
_languages . append ( LanguageItem ( code , name , handbook ) ) ;
}
}
}
}
return true ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
return false ;
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// clipboardChanged
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
void MuseScore : : clipboardChanged ( )
{
#if 0
const QMimeData * ms = QApplication : : clipboard ( ) - > mimeData ( ) ;
QStringList formats = ms - > formats ( ) ;
2012-06-11 14:38:33 +02:00
2013-05-13 18:49:17 +02:00
bool flag = ms - > hasFormat ( mimeSymbolFormat )
| | ms - > hasFormat ( mimeStaffListFormat )
| | ms - > hasFormat ( mimeSymbolListFormat )
| | ms - > hasText ( ) ;
// TODO: depends on selection state
# endif
2012-06-11 14:38:33 +02:00
2013-05-13 18:49:17 +02:00
bool flag = true ;
getAction ( " paste " ) - > setEnabled ( flag ) ;
2016-04-12 14:47:44 +02:00
getAction ( " swap " ) - > setEnabled ( flag ) ;
2013-05-13 18:49:17 +02:00
}
2012-05-26 14:49:10 +02:00
2017-02-24 21:23:41 +01:00
//---------------------------------------------------------
// inputMethodLocaleChanged
//---------------------------------------------------------
void MuseScore : : inputMethodLocaleChanged ( )
{
qDebug ( " Input method QLocale::Script enum now #%d. " , QGuiApplication : : inputMethod ( ) - > locale ( ) . script ( ) ) ;
}
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// showModeText
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
void MuseScore : : showModeText ( const QString & s )
{
_modeText - > setText ( s ) ;
_modeText - > show ( ) ;
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// changeState
//---------------------------------------------------------
2013-02-21 21:57:01 +01:00
2013-05-13 18:49:17 +02:00
void MuseScore : : changeState ( ScoreState val )
{
if ( MScore : : debugMode )
qDebug ( " MuseScore::changeState: %s " , stateName ( val ) ) ;
2013-02-21 21:57:01 +01:00
2015-01-01 21:15:38 +01:00
// disallow change to edit modes if currently in play mode
if ( _sstate = = STATE_PLAY & & ( val = = STATE_EDIT | | val & STATE_ALLTEXTUAL_EDIT | | val & STATE_NOTE_ENTRY ) )
return ;
2013-05-13 18:49:17 +02:00
static const char * stdNames [ ] = {
" note-longa " , " note-breve " , " pad-note-1 " , " pad-note-2 " , " pad-note-4 " ,
2013-09-28 00:36:08 +02:00
" pad-note-8 " , " pad-note-16 " , " pad-note-32 " , " pad-note-64 " , " pad-note-128 " , " pad-rest " , " rest " } ;
2013-05-13 18:49:17 +02:00
static const char * tabNames [ ] = {
" note-longa-TAB " , " note-breve-TAB " , " pad-note-1-TAB " , " pad-note-2-TAB " , " pad-note-4-TAB " ,
2013-09-28 00:36:08 +02:00
" pad-note-8-TAB " , " pad-note-16-TAB " , " pad-note-32-TAB " , " pad-note-64-TAB " , " pad-note-128-TAB " , " pad-rest-TAB " , " rest-TAB " } ;
2016-08-08 17:45:45 +02:00
bool intoTAB = ( _sstate ! = STATE_NOTE_ENTRY_STAFF_TAB ) & & ( val = = STATE_NOTE_ENTRY_STAFF_TAB ) ;
bool fromTAB = ( _sstate = = STATE_NOTE_ENTRY_STAFF_TAB ) & & ( val ! = STATE_NOTE_ENTRY_STAFF_TAB ) ;
2013-05-13 18:49:17 +02:00
// if activating TAB note entry, swap "pad-note-...-TAB" shorctuts into "pad-note-..." actions
if ( intoTAB ) {
for ( unsigned i = 0 ; i < sizeof ( stdNames ) / sizeof ( char * ) ; + + i ) {
QAction * act = getAction ( stdNames [ i ] ) ;
2014-11-14 11:44:48 +01:00
const Shortcut * srt = Shortcut : : getShortcut ( tabNames [ i ] ) ;
2013-05-13 18:49:17 +02:00
act - > setShortcuts ( srt - > keys ( ) ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
}
// if de-ativating TAB note entry, restore shortcuts for "pad-note-..." actions
else if ( fromTAB ) {
for ( unsigned i = 0 ; i < sizeof ( stdNames ) / sizeof ( char * ) ; + + i ) {
QAction * act = getAction ( stdNames [ i ] ) ;
2014-11-14 11:44:48 +01:00
const Shortcut * srt = Shortcut : : getShortcut ( stdNames [ i ] ) ;
2013-05-13 18:49:17 +02:00
act - > setShortcuts ( srt - > keys ( ) ) ;
}
}
2013-04-02 20:46:07 +02:00
2013-10-05 14:03:34 +02:00
bool enable = ( val ! = STATE_DISABLED ) & & ( val ! = STATE_LOCK ) ;
2018-05-25 11:59:29 +02:00
for ( const Shortcut * s : Shortcut : : shortcuts ( ) ) {
2013-05-13 18:49:17 +02:00
QAction * a = s - > action ( ) ;
if ( ! a )
continue ;
2014-11-14 18:08:02 +01:00
if ( enable & & ( s - > key ( ) = = " undo " ) )
2016-03-10 10:41:31 +01:00
a - > setEnabled ( ( s - > state ( ) & val ) & & ( cs ? cs - > undoStack ( ) - > canUndo ( ) : false ) ) ;
2014-11-14 18:08:02 +01:00
else if ( enable & & ( s - > key ( ) = = " redo " ) )
2016-03-10 10:41:31 +01:00
a - > setEnabled ( ( s - > state ( ) & val ) & & ( cs ? cs - > undoStack ( ) - > canRedo ( ) : false ) ) ;
2014-11-14 18:08:02 +01:00
else if ( enable & & ( s - > key ( ) = = " cut " ) )
2014-05-26 20:21:45 +02:00
a - > setEnabled ( cs & & cs - > selection ( ) . state ( ) ! = SelState : : NONE ) ;
2014-11-14 18:08:02 +01:00
else if ( enable & & ( s - > key ( ) = = " copy " ) )
2014-11-21 12:41:13 +01:00
a - > setEnabled ( cs & & ( cs - > selection ( ) . state ( ) ! = SelState : : NONE | | val = = STATE_FOTO ) ) ;
2014-11-14 18:08:02 +01:00
else if ( enable & & ( s - > key ( ) = = " select-similar-range " ) )
2014-07-14 13:24:47 +02:00
a - > setEnabled ( cs & & cs - > selection ( ) . state ( ) = = SelState : : RANGE ) ;
2014-11-14 18:08:02 +01:00
else if ( enable & & ( s - > key ( ) = = " synth-control " ) ) {
2013-05-13 18:49:17 +02:00
Driver * driver = seq ? seq - > driver ( ) : 0 ;
// a->setEnabled(driver && driver->getSynth());
if ( MScore : : debugMode )
qDebug ( " disable synth control " ) ;
a - > setEnabled ( driver ) ;
2013-04-12 10:21:13 +02:00
}
2017-06-26 09:11:29 +02:00
else if ( s - > key ( ) = = " pad-dot " | | s - > key ( ) = = " pad-dot-dot " | | s - > key ( ) = = " delete " )
2017-06-27 16:59:07 +02:00
a - > setEnabled ( ! ( val & ( STATE_ALLTEXTUAL_EDIT | STATE_EDIT ) ) ) ;
2013-04-12 10:21:13 +02:00
else {
2014-08-26 16:38:33 +02:00
a - > setEnabled ( s - > state ( ) & val ) ;
2013-04-12 10:21:13 +02:00
}
2012-05-26 14:49:10 +02:00
}
2014-11-17 13:06:34 +01:00
2014-11-14 21:03:46 +01:00
if ( getAction ( " file-part-export " ) - > isEnabled ( ) )
2016-03-10 10:41:31 +01:00
getAction ( " file-part-export " ) - > setEnabled ( cs & & cs - > masterScore ( ) - > excerpts ( ) . size ( ) > 0 ) ;
2016-06-09 09:16:37 +02:00
if ( getAction ( " join-measures " ) - > isEnabled ( ) )
getAction ( " join-measures " ) - > setEnabled ( cs & & cs - > masterScore ( ) - > excerpts ( ) . size ( ) = = 0 ) ;
2015-03-19 18:13:02 +01:00
if ( getAction ( " split-measure " ) - > isEnabled ( ) )
2016-03-10 10:41:31 +01:00
getAction ( " split-measure " ) - > setEnabled ( cs & & cs - > masterScore ( ) - > excerpts ( ) . size ( ) = = 0 ) ;
2015-04-03 18:23:51 +02:00
2016-03-10 10:41:31 +01:00
//getAction("split-measure")->setEnabled(cs->masterScore()->excerpts().size() == 0);
2014-11-14 21:03:46 +01:00
2013-05-13 18:49:17 +02:00
// disabling top level menu entries does not
// work for MAC
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
QList < QObject * > ol = menuBar ( ) - > children ( ) ;
foreach ( QObject * o , ol ) {
QMenu * menu = qobject_cast < QMenu * > ( o ) ;
if ( ! menu )
continue ;
QString s ( menu - > objectName ( ) ) ;
2015-03-18 12:30:46 +01:00
if ( s = = " File " | | s = = " Help " | | s = = " Edit " | | s = = " Plugins " | | s = = " View " )
2013-05-13 18:49:17 +02:00
continue ;
menu - > setEnabled ( enable ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
menuWorkspaces - > setEnabled ( enable ) ;
2012-05-26 14:49:10 +02:00
2014-10-11 15:32:34 +02:00
transportTools - > setEnabled ( enable & & ! noSeq & & seq & & seq - > isRunning ( ) ) ;
2013-05-13 18:49:17 +02:00
cpitchTools - > setEnabled ( enable ) ;
mag - > setEnabled ( enable ) ;
entryTools - > setEnabled ( enable ) ;
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
if ( _sstate = = STATE_FOTO )
updateInspector ( ) ;
2018-05-18 11:46:02 +02:00
//always hide drumtools to support hiding on switching docs, switching node entry mode off, etc.
//it will be shown later if (_sstate == STATE_NOTE_ENTRY_STAFF_DRUM)
showDrumTools ( 0 , 0 ) ;
2013-03-01 17:14:21 +01:00
2017-05-02 14:17:31 +02:00
switch ( val ) {
2013-05-13 18:49:17 +02:00
case STATE_DISABLED :
2015-01-26 21:12:29 +01:00
showModeText ( tr ( " No score " ) ) ;
2013-05-13 18:49:17 +02:00
if ( debugger )
debugger - > hide ( ) ;
showPianoKeyboard ( false ) ;
break ;
case STATE_NORMAL :
_modeText - > hide ( ) ;
break ;
2016-08-08 17:45:45 +02:00
case STATE_NOTE_ENTRY :
if ( cv & & ! cv - > noteEntryMode ( ) )
2017-07-19 17:53:45 +02:00
cv - > cmd ( " note-input " ) ;
2017-06-09 13:30:29 +02:00
// fall through
2016-08-08 17:45:45 +02:00
case STATE_NOTE_ENTRY_STAFF_PITCHED :
if ( getAction ( " note-input-repitch " ) - > isChecked ( ) ) {
showModeText ( tr ( " Repitch input mode " ) ) ;
2016-08-08 17:45:49 +02:00
cs - > setNoteEntryMethod ( NoteEntryMethod : : REPITCH ) ;
2016-08-08 17:45:45 +02:00
val = STATE_NOTE_ENTRY_METHOD_REPITCH ;
}
else if ( getAction ( " note-input-rhythm " ) - > isChecked ( ) ) {
showModeText ( tr ( " Rhythm input mode " ) ) ;
2016-08-08 17:45:49 +02:00
cs - > setNoteEntryMethod ( NoteEntryMethod : : RHYTHM ) ;
2016-08-08 17:45:45 +02:00
val = STATE_NOTE_ENTRY_METHOD_RHYTHM ;
}
else if ( getAction ( " note-input-realtime-auto " ) - > isChecked ( ) ) {
showModeText ( tr ( " Realtime (automatic) note input mode " ) ) ;
2016-08-08 17:45:49 +02:00
cs - > setNoteEntryMethod ( NoteEntryMethod : : REALTIME_AUTO ) ;
2016-08-08 17:45:45 +02:00
val = STATE_NOTE_ENTRY_METHOD_REALTIME_AUTO ;
}
else if ( getAction ( " note-input-realtime-manual " ) - > isChecked ( ) ) {
showModeText ( tr ( " Realtime (manual) note input mode " ) ) ;
2016-08-08 17:45:49 +02:00
cs - > setNoteEntryMethod ( NoteEntryMethod : : REALTIME_MANUAL ) ;
2016-08-08 17:45:45 +02:00
val = STATE_NOTE_ENTRY_METHOD_REALTIME_MANUAL ;
}
else {
showModeText ( tr ( " Steptime note input mode " ) ) ;
2016-08-08 17:45:49 +02:00
cs - > setNoteEntryMethod ( NoteEntryMethod : : STEPTIME ) ;
2016-08-08 17:45:45 +02:00
val = STATE_NOTE_ENTRY_METHOD_STEPTIME ;
}
2013-05-13 18:49:17 +02:00
break ;
2016-08-08 17:45:45 +02:00
case STATE_NOTE_ENTRY_STAFF_DRUM :
2013-05-13 18:49:17 +02:00
{
2015-03-03 11:28:54 +01:00
showModeText ( tr ( " Drum input mode " ) ) ;
2013-05-13 18:49:17 +02:00
InputState & is = cs - > inputState ( ) ;
showDrumTools ( is . drumset ( ) , cs - > staff ( is . track ( ) / VOICES ) ) ;
2014-11-18 20:28:53 +01:00
if ( _drumTools )
is . setDrumNote ( _drumTools - > selectedDrumNote ( ) ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
break ;
2016-08-08 17:45:45 +02:00
case STATE_NOTE_ENTRY_STAFF_TAB :
2015-03-03 11:28:54 +01:00
showModeText ( tr ( " TAB input mode " ) ) ;
2013-05-13 18:49:17 +02:00
break ;
case STATE_EDIT :
2015-01-26 21:12:29 +01:00
showModeText ( tr ( " Edit mode " ) ) ;
2013-05-13 18:49:17 +02:00
break ;
case STATE_TEXT_EDIT :
2015-01-26 21:12:29 +01:00
showModeText ( tr ( " Text edit mode " ) ) ;
2013-05-13 18:49:17 +02:00
break ;
case STATE_LYRICS_EDIT :
2015-01-26 21:12:29 +01:00
showModeText ( tr ( " Lyrics edit mode " ) ) ;
2013-05-13 18:49:17 +02:00
break ;
case STATE_HARMONY_FIGBASS_EDIT :
2015-01-26 21:12:29 +01:00
showModeText ( tr ( " Chord symbol/figured bass edit mode " ) ) ;
2013-05-13 18:49:17 +02:00
break ;
case STATE_PLAY :
2015-01-26 21:12:29 +01:00
showModeText ( tr ( " Play " ) ) ;
2013-05-13 18:49:17 +02:00
break ;
case STATE_FOTO :
2015-03-03 11:28:54 +01:00
showModeText ( tr ( " Image capture mode " ) ) ;
2013-05-13 18:49:17 +02:00
updateInspector ( ) ;
break ;
case STATE_LOCK :
2015-01-26 21:12:29 +01:00
showModeText ( tr ( " Score locked " ) ) ;
2013-05-13 18:49:17 +02:00
break ;
default :
qFatal ( " MuseScore::changeState: illegal state %d " , val ) ;
break ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
if ( paletteBox )
paletteBox - > setDisabled ( val = = STATE_PLAY | | val = = STATE_DISABLED ) ;
2014-09-15 09:44:27 +02:00
if ( selectionWindow )
selectionWindow - > setDisabled ( val = = STATE_PLAY | | val = = STATE_DISABLED ) ;
2013-05-13 18:49:17 +02:00
QAction * a = getAction ( " note-input " ) ;
2016-08-08 17:45:45 +02:00
bool noteEntry = val & STATE_NOTE_ENTRY ;
2013-05-13 18:49:17 +02:00
a - > setChecked ( noteEntry ) ;
_sstate = val ;
2012-05-26 14:49:10 +02:00
2017-05-02 14:17:31 +02:00
Element * e = cv & & ( _sstate & STATE_ALLTEXTUAL_EDIT | | _sstate = = STATE_EDIT ) ? cv - > getEditElement ( ) : 0 ;
2013-05-13 18:49:17 +02:00
if ( ! e ) {
textTools ( ) - > hide ( ) ;
2015-09-02 12:08:31 +02:00
if ( textTools ( ) - > kbAction ( ) - > isChecked ( ) )
textTools ( ) - > kbAction ( ) - > setChecked ( false ) ;
2012-05-26 14:49:10 +02:00
}
else {
2018-05-30 14:24:28 +02:00
if ( e - > isTextBase ( ) ) {
2017-04-11 11:34:25 +02:00
textTools ( ) - > updateTools ( cv - > getEditData ( ) ) ;
2017-08-11 19:05:19 +02:00
if ( ! ( e - > isFiguredBass ( ) | | e - > isHarmony ( ) ) ) { // do not show text tools for f.b.
if ( timelineScrollArea ( ) & & timelineScrollArea ( ) - > isVisible ( ) ) {
if ( dockWidgetArea ( timelineScrollArea ( ) ) ! = dockWidgetArea ( textTools ( ) ) | | timelineScrollArea ( ) - > isFloating ( ) ) {
QSizePolicy policy ( QSizePolicy : : Maximum , QSizePolicy : : Maximum ) ;
textTools ( ) - > widget ( ) - > setSizePolicy ( policy ) ;
}
else {
QSizePolicy policy ( QSizePolicy : : Expanding , QSizePolicy : : Expanding ) ;
textTools ( ) - > widget ( ) - > setSizePolicy ( policy ) ;
}
}
else {
QSizePolicy policy ( QSizePolicy : : Maximum , QSizePolicy : : Maximum ) ;
textTools ( ) - > widget ( ) - > setSizePolicy ( policy ) ;
}
if ( timelineScrollArea ( ) )
splitDockWidget ( textTools ( ) , timelineScrollArea ( ) , Qt : : Vertical ) ;
2014-03-28 10:49:19 +01:00
textTools ( ) - > show ( ) ;
2017-08-11 19:05:19 +02:00
}
2012-07-21 16:27:31 +02:00
}
2014-08-29 19:18:39 +02:00
if ( _inspector )
2017-03-31 13:03:15 +02:00
_inspector - > update ( e - > score ( ) ) ;
2012-05-26 14:49:10 +02:00
}
}
2014-11-13 13:04:04 +01:00
//---------------------------------------------------------
// saveDialogState
//---------------------------------------------------------
void MuseScore : : saveDialogState ( const char * name , QFileDialog * d )
{
if ( d ) {
settings . beginGroup ( name ) ;
2016-07-16 19:44:28 +02:00
settings . setValue ( " geometry " , d - > saveGeometry ( ) ) ;
2014-11-13 13:04:04 +01:00
settings . setValue ( " state " , d - > saveState ( ) ) ;
settings . endGroup ( ) ;
}
}
//---------------------------------------------------------
// restoreDialogState
//---------------------------------------------------------
void MuseScore : : restoreDialogState ( const char * name , QFileDialog * d )
{
settings . beginGroup ( name ) ;
2016-07-16 19:44:28 +02:00
d - > restoreGeometry ( settings . value ( " geometry " ) . toByteArray ( ) ) ;
2014-11-13 13:04:04 +01:00
d - > restoreState ( settings . value ( " state " ) . toByteArray ( ) ) ;
settings . endGroup ( ) ;
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// writeSettings
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : writeSettings ( )
2012-05-26 14:49:10 +02:00
{
2014-11-13 13:04:04 +01:00
// save score list
for ( int i = 0 ; i < RECENT_LIST_SIZE ; + + i )
settings . setValue ( QString ( " recent-%1 " ) . arg ( i ) , _recentScores . value ( i ) ) ;
settings . setValue ( " scores " , scoreList . size ( ) ) ;
2016-04-18 10:39:19 +02:00
if ( cs ) {
int curScore = scoreList . indexOf ( cs - > masterScore ( ) ) ;
if ( curScore = = - 1 ) // cs removed if new created and not modified
curScore = 0 ;
settings . setValue ( " currentScore " , curScore ) ;
2014-11-13 13:04:04 +01:00
2016-04-18 10:39:19 +02:00
for ( int idx = 0 ; idx < scoreList . size ( ) ; + + idx )
settings . setValue ( QString ( " score-%1 " ) . arg ( idx ) , scoreList [ idx ] - > masterScore ( ) - > fileInfo ( ) - > absoluteFilePath ( ) ) ;
}
2014-11-13 13:04:04 +01:00
settings . setValue ( " lastSaveCopyDirectory " , lastSaveCopyDirectory ) ;
2015-06-19 13:18:03 +02:00
settings . setValue ( " lastSaveCopyFormat " , lastSaveCopyFormat ) ;
2014-11-13 13:04:04 +01:00
settings . setValue ( " lastSaveDirectory " , lastSaveDirectory ) ;
2016-07-31 00:36:05 +02:00
MuseScore : : saveGeometry ( this ) ;
2013-05-13 18:49:17 +02:00
settings . beginGroup ( " MainWindow " ) ;
settings . setValue ( " showPanel " , paletteBox & & paletteBox - > isVisible ( ) ) ;
2014-08-29 19:18:39 +02:00
settings . setValue ( " showInspector " , _inspector & & _inspector - > isVisible ( ) ) ;
2013-05-13 18:49:17 +02:00
settings . setValue ( " showPianoKeyboard " , _pianoTools & & _pianoTools - > isVisible ( ) ) ;
2014-09-15 09:44:27 +02:00
settings . setValue ( " showSelectionWindow " , selectionWindow & & selectionWindow - > isVisible ( ) ) ;
2013-05-13 18:49:17 +02:00
settings . setValue ( " state " , saveState ( ) ) ;
settings . setValue ( " splitScreen " , _splitScreen ) ;
settings . setValue ( " debuggerSplitter " , mainWindow - > saveState ( ) ) ;
2014-11-13 13:04:04 +01:00
settings . setValue ( " split " , _horizontalSplit ) ;
settings . setValue ( " splitter " , splitter - > saveState ( ) ) ;
2013-05-13 18:49:17 +02:00
settings . endGroup ( ) ;
2014-11-13 13:04:04 +01:00
2013-05-13 18:49:17 +02:00
Workspace : : currentWorkspace - > save ( ) ;
if ( keyEditor & & keyEditor - > dirty ( ) )
keyEditor - > save ( ) ;
if ( chordStyleEditor )
chordStyleEditor - > save ( ) ;
2014-11-12 15:01:08 +01:00
2014-11-13 13:04:04 +01:00
saveDialogState ( " loadScoreDialog " , loadScoreDialog ) ;
saveDialogState ( " saveScoreDialog " , saveScoreDialog ) ;
saveDialogState ( " loadStyleDialog " , loadStyleDialog ) ;
saveDialogState ( " saveStyleDialog " , saveStyleDialog ) ;
saveDialogState ( " saveImageDialog " , saveImageDialog ) ;
saveDialogState ( " loadChordStyleDialog " , loadChordStyleDialog ) ;
saveDialogState ( " saveChordStyleDialog " , saveChordStyleDialog ) ;
saveDialogState ( " loadScanDialog " , loadScanDialog ) ;
saveDialogState ( " loadAudioDialog " , loadAudioDialog ) ;
saveDialogState ( " loadDrumsetDialog " , loadDrumsetDialog ) ;
saveDialogState ( " saveDrumsetDialog " , saveDrumsetDialog ) ;
saveDialogState ( " loadPaletteDialog " , loadPaletteDialog ) ;
saveDialogState ( " savePaletteDialog " , savePaletteDialog ) ;
if ( debugger )
debugger - > writeSettings ( ) ;
# ifdef SCRIPT_INTERFACE
if ( _pluginCreator )
_pluginCreator - > writeSettings ( ) ;
# endif
if ( synthControl )
synthControl - > writeSettings ( ) ;
2015-09-08 17:14:02 +02:00
settings . setValue ( " synthControlVisible " , synthControl & & synthControl - > isVisible ( ) ) ;
2014-11-13 13:04:04 +01:00
if ( mixer )
mixer - > writeSettings ( ) ;
2015-09-08 17:14:02 +02:00
settings . setValue ( " mixerVisible " , mixer & & mixer - > isVisible ( ) ) ;
2014-11-13 13:04:04 +01:00
if ( seq ) {
seq - > stopWait ( ) ;
seq - > exit ( ) ;
}
if ( instrList )
instrList - > writeSettings ( ) ;
if ( pianorollEditor )
pianorollEditor - > writeSettings ( ) ;
if ( drumrollEditor )
drumrollEditor - > writeSettings ( ) ;
2016-04-19 13:55:55 +02:00
if ( startcenter )
2016-07-16 19:44:28 +02:00
startcenter - > writeSettings ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// readSettings
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : readSettings ( )
2012-05-26 14:49:10 +02:00
{
2017-03-25 12:37:24 +01:00
int margin = 100 ;
int offset = margin / 2 ;
int w = 1024 ;
int h = 768 ;
QScreen * screen = QGuiApplication : : primaryScreen ( ) ;
const QSize screenSize = screen - > availableVirtualSize ( ) ;
if ( screenSize . width ( ) - margin > w )
w = screenSize . width ( ) - margin ;
else
offset = 0 ;
if ( screenSize . height ( ) - margin > h )
h = screenSize . height ( ) - margin ;
resize ( QSize ( w , h ) ) ; //ensure default size if no geometry in settings
move ( offset , 0 ) ;
2013-05-13 18:49:17 +02:00
if ( useFactorySettings ) {
QList < int > sizes ;
sizes < < 500 < < 100 ;
mainWindow - > setSizes ( sizes ) ;
mscore - > showPalette ( true ) ;
2014-12-19 21:12:48 +01:00
mscore - > showInspector ( true ) ;
2013-05-13 18:49:17 +02:00
return ;
2012-05-26 14:49:10 +02:00
}
2016-07-31 00:36:05 +02:00
MuseScore : : restoreGeometry ( this ) ;
2013-05-13 18:49:17 +02:00
settings . beginGroup ( " MainWindow " ) ;
mainWindow - > restoreState ( settings . value ( " debuggerSplitter " ) . toByteArray ( ) ) ;
mainWindow - > setOpaqueResize ( false ) ;
2016-01-29 12:28:45 +01:00
scorePageLayoutChanged ( ) ;
2012-05-26 14:49:10 +02:00
2014-07-10 14:13:37 +02:00
//for some reason when MuseScore starts maximized the screen-reader
2016-07-31 00:36:05 +02:00
//doesn't respond to QAccessibleEvents --> so force normal mode
if ( isMaximized ( ) & & QAccessible : : isActive ( ) ) {
showNormal ( ) ;
}
2013-05-13 18:49:17 +02:00
mscore - > showPalette ( settings . value ( " showPanel " , " 1 " ) . toBool ( ) ) ;
2014-12-19 21:12:48 +01:00
mscore - > showInspector ( settings . value ( " showInspector " , " 1 " ) . toBool ( ) ) ;
2013-05-13 18:49:17 +02:00
mscore - > showPianoKeyboard ( settings . value ( " showPianoKeyboard " , " 0 " ) . toBool ( ) ) ;
2014-09-15 09:44:27 +02:00
mscore - > showSelectionWindow ( settings . value ( " showSelectionWindow " , " 0 " ) . toBool ( ) ) ;
2013-05-13 18:49:17 +02:00
restoreState ( settings . value ( " state " ) . toByteArray ( ) ) ;
2016-07-31 00:36:05 +02:00
//if we were in full screen mode, go to maximized mode
if ( isFullScreen ( ) ) {
showMaximized ( ) ;
}
2013-05-13 18:49:17 +02:00
_horizontalSplit = settings . value ( " split " , true ) . toBool ( ) ;
bool splitScreen = settings . value ( " splitScreen " , false ) . toBool ( ) ;
if ( splitScreen ) {
splitWindow ( _horizontalSplit ) ;
QAction * a = getAction ( _horizontalSplit ? " split-h " : " split-v " ) ;
a - > setChecked ( true ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
splitter - > restoreState ( settings . value ( " splitter " ) . toByteArray ( ) ) ;
settings . endGroup ( ) ;
2016-12-27 00:51:10 +01:00
QAction * a = getAction ( " toggle-fileoperations " ) ;
a - > setChecked ( ! fileTools - > isHidden ( ) ) ;
a = getAction ( " toggle-transport " ) ;
a - > setChecked ( ! transportTools - > isHidden ( ) ) ;
a = getAction ( " toggle-concertpitch " ) ;
a - > setChecked ( ! cpitchTools - > isHidden ( ) ) ;
a = getAction ( " toggle-imagecapture " ) ;
a - > setChecked ( ! fotoTools - > isHidden ( ) ) ;
2017-01-16 20:51:12 +01:00
2016-12-27 00:51:10 +01:00
a = getAction ( " toggle-noteinput " ) ;
a - > setChecked ( ! entryTools - > isHidden ( ) ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// play
// play note for preferences.defaultPlayDuration
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : play ( Element * e ) const
2012-05-26 14:49:10 +02:00
{
2017-11-29 08:21:36 +01:00
if ( noSeq | | ! ( seq & & seq - > isRunning ( ) ) | | ! preferences . getBool ( PREF_SCORE_NOTE_PLAYONCLICK ) )
2013-05-13 18:49:17 +02:00
return ;
2012-05-26 14:49:10 +02:00
2017-01-20 11:05:52 +01:00
if ( e - > isNote ( ) ) {
Note * note = toNote ( e ) ;
2013-05-13 18:49:17 +02:00
play ( e , note - > ppitch ( ) ) ;
}
2017-01-20 11:05:52 +01:00
else if ( e - > isChord ( ) ) {
2013-05-13 18:49:17 +02:00
seq - > stopNotes ( ) ;
2017-01-20 11:05:52 +01:00
Chord * c = toChord ( e ) ;
2013-05-13 18:49:17 +02:00
Part * part = c - > staff ( ) - > part ( ) ;
2017-01-20 11:05:52 +01:00
int tick = c - > segment ( ) ? c - > segment ( ) - > tick ( ) : 0 ;
2013-05-13 18:49:17 +02:00
seq - > seek ( tick ) ;
2015-03-13 11:16:43 +01:00
Instrument * instr = part - > instrument ( tick ) ;
2017-01-20 11:05:52 +01:00
for ( Note * n : c - > notes ( ) ) {
2015-03-05 16:46:37 +01:00
const Channel * channel = instr - > channel ( n - > subchannel ( ) ) ;
seq - > startNote ( channel - > channel , n - > ppitch ( ) , 80 , n - > tuning ( ) ) ;
2013-05-13 18:49:17 +02:00
}
seq - > startNoteTimer ( MScore : : defaultPlayDuration ) ;
2012-05-26 14:49:10 +02:00
}
}
2013-05-13 18:49:17 +02:00
void MuseScore : : play ( Element * e , int pitch ) const
2012-05-26 14:49:10 +02:00
{
2014-10-11 15:32:34 +02:00
if ( noSeq | | ! ( seq & & seq - > isRunning ( ) ) )
2013-10-29 09:54:53 +01:00
return ;
2017-11-29 08:21:36 +01:00
if ( preferences . getBool ( PREF_SCORE_NOTE_PLAYONCLICK ) & & e - > isNote ( ) ) {
2013-05-13 18:49:17 +02:00
Note * note = static_cast < Note * > ( e ) ;
int tick = note - > chord ( ) - > tick ( ) ;
if ( tick < 0 )
tick = 0 ;
2015-03-13 11:16:43 +01:00
Instrument * instr = note - > part ( ) - > instrument ( tick ) ;
2015-03-05 16:46:37 +01:00
const Channel * channel = instr - > channel ( note - > subchannel ( ) ) ;
seq - > startNote ( channel - > channel , pitch , 80 , MScore : : defaultPlayDuration , note - > tuning ( ) ) ;
2013-05-13 18:49:17 +02:00
}
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// reportBug
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : reportBug ( )
2012-05-26 14:49:10 +02:00
{
2015-07-01 14:17:22 +02:00
QString url = QString ( " https://musescore.org/redirect/post/bug-report?sha=%1&locale=%2 " ) . arg ( revision ( ) ) . arg ( getLocaleISOCode ( ) ) ;
QDesktopServices : : openUrl ( QUrl ( url . trimmed ( ) ) ) ;
2015-07-01 14:16:55 +02:00
}
//---------------------------------------------------------
// askForHelp
//---------------------------------------------------------
void MuseScore : : askForHelp ( )
{
2015-07-01 14:17:22 +02:00
QString url = QString ( " https://musescore.org/redirect/post/question?locale=%1 " ) . arg ( getLocaleISOCode ( ) ) ;
QDesktopServices : : openUrl ( QUrl ( url . trimmed ( ) ) ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// about
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : about ( )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
AboutBoxDialog ab ;
ab . show ( ) ;
ab . exec ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// AboutBoxDialog
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
AboutBoxDialog : : AboutBoxDialog ( )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
setupUi ( this ) ;
2016-09-29 22:27:31 +02:00
museLogo - > setPixmap ( QPixmap ( preferences . isThemeDark ( ) ?
2015-02-27 12:59:27 +01:00
" :/data/musescore-logo-transbg-m.png " : " :/data/musescore_logo_full.png " ) ) ;
2013-07-09 18:26:23 +02:00
2015-05-06 17:38:18 +02:00
if ( MuseScore : : unstable ( ) )
2016-03-25 09:06:56 +01:00
versionLabel - > setText ( tr ( " Unstable Prerelease for Version: %1 " ) . arg ( VERSION ) ) ;
2015-05-06 17:38:18 +02:00
else
2016-03-25 09:06:56 +01:00
versionLabel - > setText ( tr ( " Version: %1 " ) . arg ( VERSION ) ) ;
2013-05-13 18:49:17 +02:00
revisionLabel - > setText ( tr ( " Revision: %1 " ) . arg ( revision ) ) ;
setWindowFlags ( this - > windowFlags ( ) & ~ Qt : : WindowContextHelpButtonHint ) ;
2015-03-24 23:15:33 +01:00
2016-03-25 09:06:56 +01:00
copyrightLabel - > setText ( QString ( " <span style= \" font-size:10pt; \" >%1</span> " )
. arg ( tr ( " Visit %1www.musescore.org%2 for new versions and more information. \n "
" Support MuseScore with your %3donation%4. \n \n "
2018-02-08 14:28:57 +01:00
" Copyright © 1999-2018 Werner Schweer and Others. \n "
2016-03-25 09:06:56 +01:00
" Published under the GNU General Public License. " )
. arg ( " <a href= \" http://www.musescore.org/ \" > " )
. arg ( " </a> " )
. arg ( " <a href= \" http://www.musescore.org/donate \" > " )
. arg ( " </a> " )
. replace ( " \n " , " <br/> " ) ) ) ;
2013-05-13 18:49:17 +02:00
connect ( copyRevisionButton , SIGNAL ( clicked ( ) ) , this , SLOT ( copyRevisionToClipboard ( ) ) ) ;
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// copyRevisionToClipboard
//---------------------------------------------------------
void AboutBoxDialog : : copyRevisionToClipboard ( )
{
QClipboard * cb = QApplication : : clipboard ( ) ;
2018-02-08 10:25:16 +01:00
QString sysinfo = " OS: " ;
sysinfo + = QSysInfo : : prettyProductName ( ) ;
sysinfo + = " , Arch.: " ;
sysinfo + = QSysInfo : : currentCpuArchitecture ( ) ;
2018-02-13 18:06:05 +01:00
// endianness?
2018-02-08 10:25:16 +01:00
sysinfo + = " , MuseScore version ( " ;
sysinfo + = QSysInfo : : WordSize = = 32 ? " 32 " : " 64 " ;
sysinfo + = " -bit): " VERSION " , revision: " ;
sysinfo + = " github-musescore-musescore- " ;
sysinfo + = revision ;
cb - > setText ( sysinfo ) ;
2012-05-26 14:49:10 +02:00
}
2013-02-21 11:04:41 +01:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// AboutBoxDialog
2013-02-21 11:04:41 +01:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
AboutMusicXMLBoxDialog : : AboutMusicXMLBoxDialog ( )
2013-02-21 11:04:41 +01:00
{
2013-05-13 18:49:17 +02:00
setupUi ( this ) ;
setWindowFlags ( this - > windowFlags ( ) & ~ Qt : : WindowContextHelpButtonHint ) ;
2016-03-25 09:06:56 +01:00
label - > setText ( QString ( " <span style= \" font-size:10pt; \" >%1<br/></span> " )
. arg ( tr ( " MusicXML is an open file format for exchanging digital sheet music, \n "
2017-09-27 09:24:47 +02:00
" supported by many applications. \n "
" Copyright © 2004-2017 the Contributors to the MusicXML \n "
" Specification, published by the W3C Music Notation Community \n "
" Group under the W3C Community Contributor License Agreement \n "
" (CLA): \n %1 \n "
" A human-readable summary is available: \n %2 " )
. arg ( " \n <a href= \" https://www.w3.org/community/about/agreements/cla/ \" >https://www.w3.org/community/about/agreements/cla/</a> \n " ,
" \n <a href= \" https://www.w3.org/community/about/agreements/cla-deed/ \" >https://www.w3.org/community/about/agreements/cla-deed/</a> \n " )
2016-03-25 09:06:56 +01:00
. replace ( " \n " , " <br/> " ) ) ) ;
2013-02-21 11:04:41 +01:00
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// dirtyChanged
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : dirtyChanged ( Score * s )
2012-05-26 14:49:10 +02:00
{
2016-03-11 12:18:46 +01:00
MasterScore * score = s - > masterScore ( ) ;
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
int idx = scoreList . indexOf ( score ) ;
if ( idx = = - 1 ) {
qDebug ( " score not in list " ) ;
return ;
2013-04-15 02:04:01 +02:00
}
2016-03-18 09:29:16 +01:00
QString label ( score - > fileInfo ( ) - > completeBaseName ( ) ) ;
2013-05-13 18:49:17 +02:00
if ( score - > dirty ( ) )
label + = " * " ;
tab1 - > setTabText ( idx , label ) ;
if ( tab2 )
tab2 - > setTabText ( idx , label ) ;
2018-03-31 06:57:32 +02:00
setWindowModified ( score - > dirty ( ) ) ;
2013-05-13 18:49:17 +02:00
}
//---------------------------------------------------------
// magChanged
//---------------------------------------------------------
2015-11-23 16:02:33 +01:00
void MuseScore : : magChanged ( MagIdx idx )
2013-05-13 18:49:17 +02:00
{
if ( cv )
2015-11-23 16:02:33 +01:00
cv - > setMag ( idx , mag - > getLMag ( cv ) ) ;
2015-02-02 01:25:35 +01:00
}
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// incMag
//---------------------------------------------------------
void MuseScore : : incMag ( )
{
if ( cv ) {
2015-11-23 16:02:33 +01:00
qreal _mag = cv - > lmag ( ) * SCALE_STEP ;
if ( _mag > SCALE_MAX )
_mag = SCALE_MAX ;
2014-06-30 15:15:03 +02:00
cv - > setMag ( MagIdx : : MAG_FREE , _mag ) ;
2013-05-13 18:49:17 +02:00
setMag ( _mag ) ;
2013-04-15 02:04:01 +02:00
}
2013-05-13 18:49:17 +02:00
}
2013-04-15 02:04:01 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// decMag
//---------------------------------------------------------
void MuseScore : : decMag ( )
{
if ( cv ) {
2015-11-23 16:02:33 +01:00
qreal _mag = cv - > lmag ( ) / SCALE_STEP ;
if ( _mag < SCALE_MIN )
_mag = SCALE_MIN ;
2014-06-30 15:15:03 +02:00
cv - > setMag ( MagIdx : : MAG_FREE , _mag ) ;
2013-05-13 18:49:17 +02:00
setMag ( _mag ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// getMag
2015-11-23 16:02:33 +01:00
// return physical scale
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
double MuseScore : : getMag ( ScoreView * canvas ) const
{
return mag - > getMag ( canvas ) ;
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// setMag
2015-11-23 16:02:33 +01:00
// set logical scale
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
void MuseScore : : setMag ( double d )
{
mag - > setMag ( d ) ;
2014-06-30 15:15:03 +02:00
mag - > setMagIdx ( MagIdx : : MAG_FREE ) ;
2013-05-13 18:49:17 +02:00
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// setPos
// set position label
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
void MuseScore : : setPos ( int t )
{
if ( cs = = 0 | | t < 0 )
return ;
2012-07-12 15:35:35 +02:00
2013-05-13 18:49:17 +02:00
TimeSigMap * s = cs - > sigmap ( ) ;
int bar , beat , tick ;
s - > tickValues ( t , & bar , & beat , & tick ) ;
2013-10-24 13:32:53 +02:00
_positionLabel - > setText ( QString ( " %1:%2:%3 " )
2013-05-13 18:49:17 +02:00
. arg ( bar + 1 , 3 , 10 , QLatin1Char ( ' ' ) )
2013-10-24 13:32:53 +02:00
. arg ( beat + 1 , 2 , 10 , QLatin1Char ( ' 0 ' ) )
2013-05-13 18:49:17 +02:00
. arg ( tick , 3 , 10 , QLatin1Char ( ' 0 ' ) )
) ;
}
2013-02-15 22:39:56 +01:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
2014-12-15 13:31:59 +01:00
// undoRedo
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
2014-12-15 13:31:59 +01:00
void MuseScore : : undoRedo ( bool undo )
2012-05-26 14:49:10 +02:00
{
2017-04-11 11:34:25 +02:00
Q_ASSERT ( cv ) ;
Q_ASSERT ( cs ) ;
2017-06-30 12:27:54 +02:00
if ( _sstate & ( STATE_EDIT | STATE_HARMONY_FIGBASS_EDIT | STATE_LYRICS_EDIT ) )
2017-06-13 17:23:11 +02:00
cv - > changeState ( ViewState : : NORMAL ) ;
2017-04-11 11:34:25 +02:00
cv - > startUndoRedo ( undo ) ;
updateInputState ( cs ) ;
2013-05-13 18:49:17 +02:00
endCmd ( ) ;
2014-12-15 13:31:59 +01:00
if ( _inspector )
2017-03-31 13:03:15 +02:00
_inspector - > update ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// showProgressBar
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
QProgressBar * MuseScore : : showProgressBar ( )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( _progressBar = = 0 )
_progressBar = new QProgressBar ( this ) ;
_statusBar - > addWidget ( _progressBar ) ;
_progressBar - > show ( ) ;
return _progressBar ;
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// hideProgressBar
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
void MuseScore : : hideProgressBar ( )
{
if ( _progressBar )
_statusBar - > removeWidget ( _progressBar ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// handleMessage
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : handleMessage ( const QString & message )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( message . isEmpty ( ) )
return ;
2016-04-19 13:55:55 +02:00
if ( startcenter )
showStartcenter ( false ) ;
2013-05-13 18:49:17 +02:00
( ( QtSingleApplication * ) ( qApp ) ) - > activateWindow ( ) ;
2016-03-11 12:18:46 +01:00
MasterScore * score = readScore ( message ) ;
2013-05-13 18:49:17 +02:00
if ( score ) {
setCurrentScoreView ( appendScore ( score ) ) ;
2014-12-08 14:41:36 +01:00
addRecentScore ( score ) ;
2013-05-13 18:49:17 +02:00
writeSessionFile ( false ) ;
2012-05-26 14:49:10 +02:00
}
2012-05-30 02:12:37 +02:00
}
2012-05-30 17:12:30 +02:00
2012-05-30 02:12:37 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// editInPianoroll
2012-05-30 02:12:37 +02:00
//---------------------------------------------------------
2013-01-22 12:30:51 +01:00
2013-05-13 18:49:17 +02:00
void MuseScore : : editInPianoroll ( Staff * staff )
2012-05-30 02:12:37 +02:00
{
2013-05-13 18:49:17 +02:00
if ( pianorollEditor = = 0 )
pianorollEditor = new PianorollEditor ;
pianorollEditor - > setScore ( staff - > score ( ) ) ;
pianorollEditor - > setStaff ( staff ) ;
pianorollEditor - > show ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// editInDrumroll
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : editInDrumroll ( Staff * staff )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( drumrollEditor = = 0 )
drumrollEditor = new DrumrollEditor ;
drumrollEditor - > setStaff ( staff ) ;
drumrollEditor - > show ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// writeSessionFile
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : writeSessionFile ( bool cleanExit )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
// qDebug("write session file");
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
QDir dir ;
dir . mkpath ( dataPath ) ;
QFile f ( dataPath + " /session " ) ;
if ( ! f . open ( QIODevice : : WriteOnly ) ) {
qDebug ( " cannot create session file <%s> " , qPrintable ( f . fileName ( ) ) ) ;
2012-05-26 14:49:10 +02:00
return ;
}
2016-11-19 11:51:21 +01:00
XmlWriter xml ( 0 , & f ) ;
2013-05-13 18:49:17 +02:00
xml . header ( ) ;
xml . stag ( " museScore version= \" " MSC_VERSION " \" " ) ;
xml . tagE ( cleanExit ? " clean " : " dirty " ) ;
2016-03-11 12:18:46 +01:00
foreach ( MasterScore * score , scoreList ) {
2013-05-13 18:49:17 +02:00
xml . stag ( " Score " ) ;
xml . tag ( " created " , score - > created ( ) ) ;
xml . tag ( " dirty " , score - > dirty ( ) ) ;
2014-12-01 15:13:22 +01:00
QString path ;
if ( score - > importedFilePath ( ) . isEmpty ( ) ) {
// score was not imported from another format, e.g. MIDI file
2016-03-10 10:41:31 +01:00
path = score - > masterScore ( ) - > fileInfo ( ) - > absoluteFilePath ( ) ;
2014-12-01 15:13:22 +01:00
}
2016-03-10 10:41:31 +01:00
else if ( score - > masterScore ( ) - > fileInfo ( ) - > exists ( ) ) { // score was saved
path = score - > masterScore ( ) - > fileInfo ( ) - > absoluteFilePath ( ) ;
2014-12-01 15:13:22 +01:00
}
else { // score was imported but not saved - store original file (e.g. MIDI) path
path = score - > importedFilePath ( ) ;
}
2013-07-11 19:19:01 +02:00
if ( cleanExit | | score - > tmpName ( ) . isEmpty ( ) ) {
2014-12-01 15:13:22 +01:00
xml . tag ( " path " , path ) ;
2013-05-13 18:49:17 +02:00
}
else {
2014-12-01 15:13:22 +01:00
xml . tag ( " name " , path ) ;
2013-05-13 18:49:17 +02:00
xml . tag ( " path " , score - > tmpName ( ) ) ;
}
xml . etag ( ) ;
}
int tab = 0 ;
int idx = 0 ;
for ( int i = 0 ; i < tab1 - > count ( ) ; + + i ) {
ScoreView * v = tab1 - > view ( i ) ;
if ( v ) {
if ( v = = cv ) {
tab = 0 ;
idx = i ;
}
xml . stag ( " ScoreView " ) ;
xml . tag ( " tab " , tab ) ; // 0 instead of "tab" does not work
xml . tag ( " idx " , i ) ;
2014-06-30 15:15:03 +02:00
if ( v - > magIdx ( ) = = MagIdx : : MAG_FREE )
2015-11-18 18:09:42 +01:00
xml . tag ( " mag " , v - > lmag ( ) ) ;
2013-05-13 18:49:17 +02:00
else
2014-06-30 15:15:03 +02:00
xml . tag ( " magIdx " , int ( v - > magIdx ( ) ) ) ;
2015-11-16 14:24:47 +01:00
xml . tag ( " x " , v - > xoffset ( ) / DPMM ) ;
xml . tag ( " y " , v - > yoffset ( ) / DPMM ) ;
2013-05-13 18:49:17 +02:00
xml . etag ( ) ;
}
}
if ( splitScreen ( ) ) {
for ( int i = 0 ; i < tab2 - > count ( ) ; + + i ) {
ScoreView * v = tab2 - > view ( i ) ;
if ( v ) {
if ( v = = cv ) {
tab = 1 ;
idx = i ;
}
xml . stag ( " ScoreView " ) ;
xml . tag ( " tab " , 1 ) ;
xml . tag ( " idx " , i ) ;
2014-06-30 15:15:03 +02:00
if ( v - > magIdx ( ) = = MagIdx : : MAG_FREE )
2015-11-18 18:09:42 +01:00
xml . tag ( " mag " , v - > lmag ( ) ) ;
2013-05-13 18:49:17 +02:00
else
2014-06-30 15:15:03 +02:00
xml . tag ( " magIdx " , int ( v - > magIdx ( ) ) ) ;
2015-11-16 14:24:47 +01:00
xml . tag ( " x " , v - > xoffset ( ) / DPMM ) ;
xml . tag ( " y " , v - > yoffset ( ) / DPMM ) ;
2013-05-13 18:49:17 +02:00
xml . etag ( ) ;
}
}
}
xml . tag ( " tab " , tab ) ;
xml . tag ( " idx " , idx ) ;
xml . etag ( ) ;
f . close ( ) ;
if ( cleanExit ) {
// TODO: remove all temporary session backup files
2012-05-26 14:49:10 +02:00
}
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// removeSessionFile
// remove temp files and session file
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : removeSessionFile ( )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
QFile f ( dataPath + " /session " ) ;
if ( ! f . exists ( ) )
return ;
if ( ! f . remove ( ) ) {
qDebug ( " cannot remove session file <%s> " , qPrintable ( f . fileName ( ) ) ) ;
2012-05-26 14:49:10 +02:00
}
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// autoSaveTimerTimeout
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : autoSaveTimerTimeout ( )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
bool sessionChanged = false ;
2017-06-02 11:21:01 +02:00
for ( MasterScore * s : scoreList ) {
2013-05-13 18:49:17 +02:00
if ( s - > autosaveDirty ( ) ) {
QString tmp = s - > tmpName ( ) ;
if ( ! tmp . isEmpty ( ) ) {
QFileInfo fi ( tmp ) ;
2018-02-13 18:06:05 +01:00
// TODO: cannot catch exception here:
2014-08-26 19:31:04 +02:00
s - > saveCompressedFile ( fi , false ) ;
2013-05-13 18:49:17 +02:00
}
else {
QDir dir ;
dir . mkpath ( dataPath ) ;
QTemporaryFile tf ( dataPath + " /scXXXXXX.mscz " ) ;
tf . setAutoRemove ( false ) ;
if ( ! tf . open ( ) ) {
qDebug ( " autoSaveTimerTimeout(): create temporary file failed " ) ;
return ;
}
s - > setTmpName ( tf . fileName ( ) ) ;
QFileInfo info ( tf . fileName ( ) ) ;
2017-06-02 11:21:01 +02:00
s - > saveCompressedFile ( & tf , info , false , false ) ; // no thumbnail
2013-05-13 18:49:17 +02:00
tf . close ( ) ;
sessionChanged = true ;
}
s - > setAutosaveDirty ( false ) ;
}
}
if ( sessionChanged )
writeSessionFile ( false ) ;
2017-11-29 08:21:36 +01:00
if ( preferences . getBool ( PREF_APP_AUTOSAVE_USEAUTOSAVE ) ) {
int t = preferences . getInt ( PREF_APP_AUTOSAVE_AUTOSAVETIME ) * 60 * 1000 ;
2013-05-13 18:49:17 +02:00
autoSaveTimer - > start ( t ) ;
2012-05-26 14:49:10 +02:00
}
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// restoreSession
// Restore last session. If "always" is true, then restore
// last session even on a clean exit else only if last
// session ended abnormal.
// Return true if a session was found and restored.
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
bool MuseScore : : restoreSession ( bool always )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
QFile f ( dataPath + " /session " ) ;
if ( ! f . exists ( ) )
return false ;
if ( ! f . open ( QIODevice : : ReadOnly ) ) {
2014-02-27 19:57:24 +01:00
qDebug ( " Cannot open session file <%s> " , qPrintable ( f . fileName ( ) ) ) ;
2013-05-13 18:49:17 +02:00
return false ;
}
2018-02-21 13:30:07 +01:00
XmlReader e ( & f ) ;
2013-05-13 18:49:17 +02:00
int tab = 0 ;
int idx = - 1 ;
bool cleanExit = false ;
while ( e . readNextStartElement ( ) ) {
if ( e . name ( ) = = " museScore " ) {
/* QString version = e.attribute(QString("version"));
QStringList sl = version . split ( ' . ' ) ;
int v = sl [ 0 ] . toInt ( ) * 100 + sl [ 1 ] . toInt ( ) ;
*/
while ( e . readNextStartElement ( ) ) {
const QStringRef & tag ( e . name ( ) ) ;
if ( tag = = " clean " ) {
if ( ! always )
return false ;
cleanExit = true ;
e . readNext ( ) ;
}
else if ( tag = = " dirty " ) {
QMessageBox : : StandardButton b = QMessageBox : : question ( 0 ,
tr ( " MuseScore " ) ,
tr ( " The previous session quit unexpectedly. \n \n Restore session? " ) ,
QMessageBox : : Yes | QMessageBox : : No ,
QMessageBox : : Yes
) ;
if ( b ! = QMessageBox : : Yes )
return false ;
e . readNext ( ) ;
}
else if ( tag = = " Score " ) {
QString name ;
bool created = false ;
while ( e . readNextStartElement ( ) ) {
const QStringRef & tag ( e . name ( ) ) ;
if ( tag = = " name " )
name = e . readElementText ( ) ;
else if ( tag = = " created " )
created = e . readInt ( ) ;
else if ( tag = = " dirty " )
2015-01-30 17:03:51 +01:00
/*int dirty =*/ e . readInt ( ) ;
2013-05-13 18:49:17 +02:00
else if ( tag = = " path " ) {
2016-03-11 12:18:46 +01:00
MasterScore * score = readScore ( e . readElementText ( ) ) ;
2013-05-13 18:49:17 +02:00
if ( score ) {
2017-06-28 22:22:04 +02:00
if ( ! name . isEmpty ( ) ) {
QFileInfo * fi = score - > masterScore ( ) - > fileInfo ( ) ;
fi - > setFile ( name ) ;
// TODO: what if that path is no longer valid?
}
2013-05-13 18:49:17 +02:00
if ( cleanExit ) {
// override if last session did a clean exit
created = false ;
}
appendScore ( score ) ;
score - > setCreated ( created ) ;
}
}
else {
e . unknown ( ) ;
return false ;
}
}
}
else if ( tag = = " ScoreView " ) {
2015-11-23 16:02:33 +01:00
qreal x = .0 ;
qreal y = .0 ;
qreal vmag = 1.0 ;
2014-06-30 15:15:03 +02:00
MagIdx magIdx = MagIdx : : MAG_FREE ;
2015-11-23 16:02:33 +01:00
int tab = 0 ;
int idx = 0 ;
2013-05-13 18:49:17 +02:00
while ( e . readNextStartElement ( ) ) {
const QStringRef & tag ( e . name ( ) ) ;
if ( tag = = " tab " )
tab = e . readInt ( ) ;
else if ( tag = = " idx " )
idx = e . readInt ( ) ;
else if ( tag = = " mag " )
vmag = e . readDouble ( ) ;
else if ( tag = = " magIdx " )
2014-06-30 15:15:03 +02:00
magIdx = MagIdx ( e . readInt ( ) ) ;
2013-05-13 18:49:17 +02:00
else if ( tag = = " x " )
2015-11-16 14:24:47 +01:00
x = e . readDouble ( ) * DPMM ;
2013-05-13 18:49:17 +02:00
else if ( tag = = " y " )
2015-11-16 14:24:47 +01:00
y = e . readDouble ( ) * DPMM ;
2013-05-13 18:49:17 +02:00
else {
e . unknown ( ) ;
return false ;
}
}
( tab = = 0 ? tab1 : tab2 ) - > initScoreView ( idx , vmag , magIdx , x , y ) ;
}
else if ( tag = = " tab " )
tab = e . readInt ( ) ;
else if ( tag = = " idx " )
idx = e . readInt ( ) ;
else {
e . unknown ( ) ;
return false ;
}
}
}
else {
e . unknown ( ) ;
return false ;
}
}
setCurrentView ( tab , idx ) ;
return true ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// splitWindow
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : splitWindow ( bool horizontal )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( ! _splitScreen ) {
if ( tab2 = = 0 ) {
2014-05-28 22:35:23 +02:00
tab2 = new ScoreTab ( & scoreList , this ) ;
2013-05-13 18:49:17 +02:00
tab2 - > setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Expanding ) ;
connect ( tab2 , SIGNAL ( currentScoreViewChanged ( ScoreView * ) ) , SLOT ( setCurrentScoreView ( ScoreView * ) ) ) ;
connect ( tab2 , SIGNAL ( tabCloseRequested ( int ) ) , SLOT ( removeTab ( int ) ) ) ;
2014-06-10 23:41:30 +02:00
connect ( tab2 , SIGNAL ( actionTriggered ( QAction * ) ) , SLOT ( cmd ( QAction * ) ) ) ;
2013-05-13 18:49:17 +02:00
splitter - > addWidget ( tab2 ) ;
}
tab2 - > setVisible ( true ) ;
_splitScreen = true ;
_horizontalSplit = horizontal ;
splitter - > setOrientation ( _horizontalSplit ? Qt : : Horizontal : Qt : : Vertical ) ;
if ( ! scoreList . isEmpty ( ) ) {
tab2 - > setCurrentIndex ( 0 ) ;
2016-03-11 12:18:46 +01:00
MasterScore * s = scoreList [ 0 ] ;
2016-03-02 13:20:19 +01:00
s - > setLayoutAll ( ) ;
2016-04-18 18:11:51 +02:00
s - > update ( ) ;
2013-05-13 18:49:17 +02:00
setCurrentView ( 1 , 0 ) ;
}
}
else {
if ( _horizontalSplit = = horizontal ) {
_splitScreen = false ;
tab2 - > setVisible ( false ) ;
}
else {
_horizontalSplit = horizontal ;
QAction * a ;
if ( _horizontalSplit )
a = getAction ( " split-v " ) ;
else
a = getAction ( " split-h " ) ;
a - > setChecked ( false ) ;
splitter - > setOrientation ( _horizontalSplit ? Qt : : Horizontal : Qt : : Vertical ) ;
}
}
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// stateName
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
const char * stateName ( ScoreState s )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
switch ( s ) {
case STATE_DISABLED : return " STATE_DISABLED " ;
case STATE_NORMAL : return " STATE_NORMAL " ;
2016-08-08 17:45:45 +02:00
case STATE_NOTE_ENTRY_STAFF_PITCHED : return " STATE_NOTE_ENTRY_STAFF_PITCHED " ;
case STATE_NOTE_ENTRY_STAFF_DRUM : return " STATE_NOTE_ENTRY_STAFF_DRUM " ;
case STATE_NOTE_ENTRY_STAFF_TAB : return " STATE_NOTE_ENTRY_STAFF_TAB " ;
2013-05-13 18:49:17 +02:00
case STATE_NOTE_ENTRY : return " STATE_NOTE_ENTRY " ;
2016-08-08 17:45:45 +02:00
case STATE_NOTE_ENTRY_METHOD_STEPTIME : return " STATE_NOTE_ENTRY_METHOD_STEPTIME " ;
case STATE_NOTE_ENTRY_METHOD_REPITCH : return " STATE_NOTE_ENTRY_METHOD_REPITCH " ;
case STATE_NOTE_ENTRY_METHOD_RHYTHM : return " STATE_NOTE_ENTRY_METHOD_RHYTHM " ;
case STATE_NOTE_ENTRY_METHOD_REALTIME_AUTO : return " STATE_NOTE_ENTRY_METHOD_REALTIME_AUTO " ;
case STATE_NOTE_ENTRY_METHOD_REALTIME_MANUAL : return " STATE_NOTE_ENTRY_METHOD_REALTIME_MANUAL " ;
2013-05-13 18:49:17 +02:00
case STATE_EDIT : return " STATE_EDIT " ;
case STATE_TEXT_EDIT : return " STATE_TEXT_EDIT " ;
case STATE_LYRICS_EDIT : return " STATE_LYRICS_EDIT " ;
case STATE_HARMONY_FIGBASS_EDIT : return " STATE_HARMONY_FIGBASS_EDIT " ;
case STATE_PLAY : return " STATE_PLAY " ;
case STATE_FOTO : return " STATE_FOTO " ;
default : return " ?? " ;
2012-05-26 14:49:10 +02:00
}
}
2016-01-29 12:28:45 +01:00
//---------------------------------------------------------
// scorePageLayoutChanged
//---------------------------------------------------------
void MuseScore : : scorePageLayoutChanged ( )
{
2016-05-31 11:13:32 +02:00
if ( mainWindow ) {
mainWindow - > setOrientation ( MScore : : verticalOrientation ( ) ? Qt : : Horizontal : Qt : : Vertical ) ;
if ( navigatorScrollArea ( ) )
navigatorScrollArea ( ) - > orientationChanged ( ) ;
}
2016-01-29 12:28:45 +01:00
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// editRaster
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : editRaster ( )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( editRasterDialog = = 0 ) {
editRasterDialog = new EditRaster ( this ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
if ( editRasterDialog - > exec ( ) ) {
qDebug ( " =====accept config raster " ) ;
2012-05-26 14:49:10 +02:00
}
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// showPianoKeyboard
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : showPianoKeyboard ( bool on )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( _pianoTools = = 0 ) {
2014-12-22 09:56:39 +01:00
QAction * a = getAction ( " toggle-piano " ) ;
2013-05-13 18:49:17 +02:00
_pianoTools = new PianoTools ( this ) ;
addDockWidget ( Qt : : BottomDockWidgetArea , _pianoTools ) ;
2015-05-10 10:01:01 +02:00
connect ( _pianoTools , SIGNAL ( keyPressed ( int , bool , int ) ) , SLOT ( midiNoteReceived ( int , bool , int ) ) ) ;
connect ( _pianoTools , SIGNAL ( keyReleased ( int , bool , int ) ) , SLOT ( midiNoteReceived ( int , bool , int ) ) ) ;
2013-05-13 18:49:17 +02:00
connect ( _pianoTools , SIGNAL ( visibilityChanged ( bool ) ) , a , SLOT ( setChecked ( bool ) ) ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
if ( on ) {
_pianoTools - > show ( ) ;
2018-05-14 10:07:46 +02:00
if ( currentScore ( ) )
_pianoTools - > changeSelection ( currentScore ( ) - > selection ( ) ) ;
2018-05-21 15:04:01 +02:00
else
_pianoTools - > clearSelection ( ) ;
2013-05-13 18:49:17 +02:00
}
else {
if ( _pianoTools )
_pianoTools - > hide ( ) ;
2012-05-26 14:49:10 +02:00
}
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// showPluginCreator
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : showPluginCreator ( QAction * a )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
# ifdef SCRIPT_INTERFACE
bool on = a - > isChecked ( ) ;
if ( on ) {
2014-08-29 19:18:39 +02:00
if ( _pluginCreator = = 0 ) {
_pluginCreator = new PluginCreator ( 0 ) ;
connect ( _pluginCreator , SIGNAL ( closed ( bool ) ) , a , SLOT ( setChecked ( bool ) ) ) ;
2013-05-13 18:49:17 +02:00
}
2014-08-29 19:18:39 +02:00
_pluginCreator - > show ( ) ;
2013-05-13 18:49:17 +02:00
}
else {
2014-08-29 19:18:39 +02:00
if ( _pluginCreator )
_pluginCreator - > hide ( ) ;
2013-05-13 18:49:17 +02:00
}
# endif
2012-05-26 14:49:10 +02:00
}
2013-10-05 12:03:30 +02:00
//---------------------------------------------------------
// showPluginManager
//---------------------------------------------------------
2014-09-01 22:35:04 +02:00
void MuseScore : : showPluginManager ( )
2013-10-05 12:03:30 +02:00
{
# ifdef SCRIPT_INTERFACE
2015-03-04 14:32:38 +01:00
pluginManager - > init ( ) ;
pluginManager - > show ( ) ;
2013-10-05 12:03:30 +02:00
# endif
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// showMediaDialog
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : showMediaDialog ( )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( _mediaDialog = = 0 )
_mediaDialog = new MediaDialog ( this ) ;
_mediaDialog - > setScore ( cs ) ;
_mediaDialog - > exec ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// getPaletteBox
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
PaletteBox * MuseScore : : getPaletteBox ( )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( paletteBox = = 0 ) {
paletteBox = new PaletteBox ( this ) ;
QAction * a = getAction ( " toggle-palette " ) ;
connect ( paletteBox , SIGNAL ( visibilityChanged ( bool ) ) , a , SLOT ( setChecked ( bool ) ) ) ;
addDockWidget ( Qt : : LeftDockWidgetArea , paletteBox ) ;
}
return paletteBox ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// midiNoteReceived
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2015-05-10 10:01:01 +02:00
void MuseScore : : midiNoteReceived ( int pitch , bool ctrl , int vel )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( cv )
2015-05-10 10:01:01 +02:00
cv - > midiNoteReceived ( pitch , ctrl , vel ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// switchLayer
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : switchLayer ( const QString & s )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( cs - > switchLayer ( s ) ) {
2016-03-02 13:20:19 +01:00
cs - > setLayoutAll ( ) ;
2013-05-13 18:49:17 +02:00
cs - > update ( ) ;
2012-05-26 14:49:10 +02:00
}
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// switchPlayMode
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : switchPlayMode ( int mode )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( cs )
cs - > setPlayMode ( PlayMode ( mode ) ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// networkFinished
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : networkFinished ( QNetworkReply * reply )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( reply - > error ( ) ! = QNetworkReply : : NoError ) {
qDebug ( " Error while checking update [%s] " , qPrintable ( reply - > errorString ( ) ) ) ;
2012-05-26 14:49:10 +02:00
return ;
}
2013-05-13 18:49:17 +02:00
QByteArray ha = reply - > rawHeader ( " Content-Disposition " ) ;
QString s ( ha ) ;
QString name ;
QRegExp re ( " .*filename= \" (.*) \ " " ) ;
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
if ( ! s . isEmpty ( ) & & re . indexIn ( s ) ! = - 1 ) {
name = re . cap ( 1 ) ;
}
else {
QUrl url = reply - > url ( ) ;
QString path = url . path ( ) ;
qDebug ( " Path <%s> " , qPrintable ( path ) ) ;
QFileInfo fi ( path ) ;
name = fi . fileName ( ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
qDebug ( " header <%s> " , qPrintable ( s ) ) ;
qDebug ( " name <%s> " , qPrintable ( name ) ) ;
QByteArray data = reply - > readAll ( ) ;
QString tmpName = QDir : : tempPath ( ) + " / " + name ;
QFile f ( tmpName ) ;
f . open ( QIODevice : : WriteOnly ) ;
f . write ( data ) ;
2012-05-26 14:49:10 +02:00
f . close ( ) ;
2013-05-13 18:49:17 +02:00
2017-03-17 09:58:02 +01:00
reply - > deleteLater ( ) ;
2016-03-11 12:18:46 +01:00
MasterScore * score = readScore ( tmpName ) ;
2013-05-13 18:49:17 +02:00
if ( ! score ) {
qDebug ( " readScore failed " ) ;
return ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
score - > setCreated ( true ) ;
setCurrentScoreView ( appendScore ( score ) ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// loadFile
// load file from url
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : loadFile ( const QString & s )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
loadFile ( QUrl ( s ) ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
void MuseScore : : loadFile ( const QUrl & url )
2012-05-26 14:49:10 +02:00
{
2017-03-17 09:58:02 +01:00
QNetworkReply * nr = networkManager ( ) - > get ( QNetworkRequest ( url ) ) ;
connect ( nr , SIGNAL ( finished ( QNetworkReply * ) ) ,
2013-05-13 18:49:17 +02:00
SLOT ( networkFinished ( QNetworkReply * ) ) ) ;
2017-03-17 09:58:02 +01:00
}
//---------------------------------------------------------
// networkManager
//---------------------------------------------------------
QNetworkAccessManager * MuseScore : : networkManager ( )
{
if ( ! _networkManager )
_networkManager = new QNetworkAccessManager ( this ) ;
return _networkManager ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// selectSimilar
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : selectSimilar ( Element * e , bool sameStaff )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
Score * score = e - > score ( ) ;
2014-07-15 00:28:31 +02:00
score - > selectSimilar ( e , sameStaff ) ;
2012-05-26 14:49:10 +02:00
2013-12-24 12:31:11 +01:00
if ( score - > selectionChanged ( ) ) {
score - > setSelectionChanged ( false ) ;
SelState ss = score - > selection ( ) . state ( ) ;
selectionChanged ( ss ) ;
}
2012-05-26 14:49:10 +02:00
}
2014-07-14 13:24:47 +02:00
void MuseScore : : selectSimilarInRange ( Element * e )
{
Score * score = e - > score ( ) ;
2014-07-15 00:28:31 +02:00
score - > selectSimilarInRange ( e ) ;
2014-07-14 13:24:47 +02:00
if ( score - > selectionChanged ( ) ) {
score - > setSelectionChanged ( false ) ;
SelState ss = score - > selection ( ) . state ( ) ;
selectionChanged ( ss ) ;
}
}
2014-11-22 12:03:22 +01:00
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// selectElementDialog
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : selectElementDialog ( Element * e )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
Score * score = e - > score ( ) ;
2016-09-22 16:07:47 +02:00
if ( e - > isNote ( ) ) {
2017-11-19 11:16:39 +01:00
Note * n = toNote ( e ) ;
SelectNoteDialog sd ( n , 0 ) ;
// hide same string option if it doesn't make sense for the instrument
if ( n - > staff ( ) - > part ( ) - > instrument ( ) - > stringData ( ) - > strings ( ) = = 0 )
sd . setSameStringVisible ( false ) ;
2016-09-22 16:07:47 +02:00
if ( sd . exec ( ) ) {
NotePattern pattern ;
sd . setPattern ( & pattern ) ;
if ( sd . isInSelection ( ) )
score - > scanElementsInRange ( & pattern , Score : : collectNoteMatch ) ;
else
score - > scanElements ( & pattern , Score : : collectNoteMatch ) ;
2014-07-24 19:00:54 +02:00
2016-09-22 16:07:47 +02:00
if ( sd . doReplace ( ) ) {
score - > select ( 0 , SelectType : : SINGLE , 0 ) ;
for ( Note * ee : pattern . el )
score - > select ( ee , SelectType : : ADD , 0 ) ;
}
else if ( sd . doSubtract ( ) ) {
QList < Element * > sl ( score - > selection ( ) . elements ( ) ) ;
for ( Note * ee : pattern . el )
sl . removeOne ( ee ) ;
score - > select ( 0 , SelectType : : SINGLE , 0 ) ;
for ( Element * ee : sl )
2014-05-27 10:34:08 +02:00
score - > select ( ee , SelectType : : ADD , 0 ) ;
2013-05-13 18:49:17 +02:00
}
2016-09-22 16:07:47 +02:00
else if ( sd . doAdd ( ) ) {
QList < Element * > sl ( score - > selection ( ) . elements ( ) ) ;
for ( Note * ee : pattern . el ) {
if ( ! sl . contains ( ee ) )
score - > select ( ee , SelectType : : ADD , 0 ) ;
}
}
2012-05-26 14:49:10 +02:00
}
2016-09-22 16:07:47 +02:00
}
else {
SelectDialog sd ( e , 0 ) ;
if ( sd . exec ( ) ) {
ElementPattern pattern ;
sd . setPattern ( & pattern ) ;
if ( sd . isInSelection ( ) )
score - > scanElementsInRange ( & pattern , Score : : collectMatch ) ;
else
score - > scanElements ( & pattern , Score : : collectMatch ) ;
if ( sd . doReplace ( ) ) {
score - > select ( 0 , SelectType : : SINGLE , 0 ) ;
for ( Element * ee : pattern . el )
score - > select ( ee , SelectType : : ADD , 0 ) ;
}
else if ( sd . doSubtract ( ) ) {
QList < Element * > sl ( score - > selection ( ) . elements ( ) ) ;
for ( Element * ee : pattern . el )
sl . removeOne ( ee ) ;
score - > select ( 0 , SelectType : : SINGLE , 0 ) ;
for ( Element * ee : sl )
score - > select ( ee , SelectType : : ADD , 0 ) ;
}
else if ( sd . doAdd ( ) ) {
QList < Element * > sl ( score - > selection ( ) . elements ( ) ) ;
for ( Element * ee : pattern . el ) {
if ( ! sl . contains ( ee ) )
score - > select ( ee , SelectType : : ADD , 0 ) ;
}
}
2013-12-24 12:31:11 +01:00
}
2012-05-26 14:49:10 +02:00
}
2016-09-22 16:07:47 +02:00
if ( score - > selectionChanged ( ) ) {
score - > setSelectionChanged ( false ) ;
SelState ss = score - > selection ( ) . state ( ) ;
selectionChanged ( ss ) ;
}
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// RecordButton
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
RecordButton : : RecordButton ( QWidget * parent )
: SimpleButton ( " :/data/recordOn.svg " , " :/data/recordOff.svg " , parent )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
setCheckable ( true ) ;
defaultAction ( ) - > setCheckable ( true ) ;
2014-10-15 20:43:06 +02:00
setToolTip ( qApp - > translate ( " RecordButton " , " Record " ) ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// GreendotButton
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
GreendotButton : : GreendotButton ( QWidget * parent )
: SimpleButton ( " :/data/greendot.svg " , " :/data/darkgreendot.svg " , parent )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
setCheckable ( true ) ;
2014-10-15 20:43:06 +02:00
setToolTip ( qApp - > translate ( " GreendotButton " , " Record " ) ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// drawHandle
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
QRectF drawHandle ( QPainter & p , const QPointF & pos , bool active )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
p . save ( ) ;
2013-07-04 21:07:38 +02:00
p . setPen ( QPen ( QColor ( MScore : : selectColor [ 0 ] ) , 2.0 / p . matrix ( ) . m11 ( ) ) ) ;
2013-05-13 18:49:17 +02:00
if ( active )
2013-07-04 21:07:38 +02:00
p . setBrush ( MScore : : selectColor [ 0 ] ) ;
2013-05-13 18:49:17 +02:00
else
p . setBrush ( Qt : : NoBrush ) ;
qreal w = 8.0 / p . matrix ( ) . m11 ( ) ;
qreal h = 8.0 / p . matrix ( ) . m22 ( ) ;
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
QRectF r ( - w / 2 , - h / 2 , w , h ) ;
r . translate ( pos ) ;
p . drawRect ( r ) ;
p . restore ( ) ;
return r ;
2012-05-26 14:49:10 +02:00
}
2012-07-02 18:05:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// transpose
2012-07-02 18:05:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : transpose ( )
2012-07-02 18:05:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( cs - > last ( ) = = 0 ) // empty score?
return ;
2014-12-15 17:44:32 +01:00
bool noSelection = cs - > selection ( ) . isNone ( ) ;
2014-12-15 18:00:54 +01:00
if ( noSelection )
2014-08-08 20:54:00 +02:00
cs - > cmdSelectAll ( ) ;
2014-05-24 12:53:50 +02:00
bool rangeSelection = cs - > selection ( ) . isRange ( ) ;
2013-05-13 18:49:17 +02:00
TransposeDialog td ;
2012-07-02 18:05:10 +02:00
2014-05-26 13:21:04 +02:00
// TRANSPOSE_BY_KEY and "transpose keys" is only possible if selection state is SelState::RANGE
2013-05-13 18:49:17 +02:00
td . enableTransposeKeys ( rangeSelection ) ;
td . enableTransposeByKey ( rangeSelection ) ;
2014-12-15 17:44:32 +01:00
td . enableTransposeChordNames ( rangeSelection ) ;
2012-07-02 18:05:10 +02:00
2013-05-13 18:49:17 +02:00
int startStaffIdx = 0 ;
2015-07-06 07:01:58 +02:00
int endStaffIdx = 0 ;
2013-05-13 18:49:17 +02:00
int startTick = 0 ;
if ( rangeSelection ) {
startStaffIdx = cs - > selection ( ) . staffStart ( ) ;
2015-07-06 07:01:58 +02:00
endStaffIdx = cs - > selection ( ) . staffEnd ( ) ;
2013-05-13 18:49:17 +02:00
startTick = cs - > selection ( ) . tickStart ( ) ;
2012-05-26 14:49:10 +02:00
}
2015-07-06 07:01:58 +02:00
// find the key of the first pitched staff
Key key = Key : : C ;
for ( int i = startStaffIdx ; i < endStaffIdx ; + + i ) {
Staff * staff = cs - > staff ( i ) ;
2016-12-13 13:16:17 +01:00
if ( staff - > isPitchedStaff ( startTick ) ) {
2015-07-06 07:01:58 +02:00
key = staff - > key ( startTick ) ;
2018-03-27 15:36:00 +02:00
if ( ! cs - > styleB ( Sid : : concertPitch ) ) {
2015-07-06 07:01:58 +02:00
int diff = staff - > part ( ) - > instrument ( startTick ) - > transpose ( ) . chromatic ;
if ( diff )
key = transposeKey ( key , diff ) ;
}
break ;
}
2015-01-18 16:35:18 +01:00
}
2015-07-06 07:01:58 +02:00
2014-11-25 20:58:05 +01:00
td . setKey ( key ) ;
2013-05-13 18:49:17 +02:00
if ( ! td . exec ( ) )
return ;
2015-07-06 07:01:58 +02:00
2013-05-13 18:49:17 +02:00
cs - > transpose ( td . mode ( ) , td . direction ( ) , td . transposeKey ( ) , td . transposeInterval ( ) ,
td . getTransposeKeys ( ) , td . getTransposeChordNames ( ) , td . useDoubleSharpsFlats ( ) ) ;
2014-12-15 17:44:32 +01:00
if ( noSelection )
cs - > deselectAll ( ) ;
2012-07-02 18:05:10 +02:00
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// cmd
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : cmd ( QAction * a )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
if ( inChordEditor ) // HACK
return ;
2014-06-15 21:08:04 +02:00
2016-11-28 18:25:27 +01:00
MScore : : setError ( MS_NO_ERROR ) ;
2016-11-28 17:25:26 +01:00
2013-05-13 18:49:17 +02:00
QString cmdn ( a - > data ( ) . toString ( ) ) ;
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
if ( MScore : : debugMode )
2016-04-18 18:11:51 +02:00
qDebug ( " MuseScore::cmd <%s> " , qPrintable ( cmdn ) ) ;
2012-05-26 14:49:10 +02:00
2014-11-14 11:44:48 +01:00
const Shortcut * sc = Shortcut : : getShortcut ( cmdn . toLatin1 ( ) . data ( ) ) ;
2013-05-13 18:49:17 +02:00
if ( sc = = 0 ) {
qDebug ( " MuseScore::cmd(): unknown action <%s> " , qPrintable ( cmdn ) ) ;
2012-05-26 14:49:10 +02:00
return ;
}
2013-05-13 18:49:17 +02:00
if ( cs & & ( sc - > state ( ) & _sstate ) = = 0 ) {
2017-04-11 11:34:25 +02:00
qDebug ( " invalid state %04x %04x " , sc - > state ( ) , _sstate ) ;
2013-05-13 18:49:17 +02:00
QMessageBox : : warning ( 0 ,
2017-08-14 11:48:58 +02:00
tr ( " Invalid Command " ) ,
tr ( " Command %1 not valid in current state " ) . arg ( cmdn ) ) ;
2012-05-26 14:49:10 +02:00
return ;
}
2017-07-30 10:20:17 +02:00
if ( cmdn = = " palette-search " ) {
PaletteBox * pb = getPaletteBox ( ) ;
QLineEdit * sb = pb - > searchBox ( ) ;
sb - > setFocus ( ) ;
if ( pb - > noSelection ( ) )
pb - > setKeyboardNavigation ( false ) ;
else
pb - > setKeyboardNavigation ( true ) ;
return ;
}
if ( cmdn = = " apply-current-palette-element " ) {
PaletteBox * pb = getPaletteBox ( ) ;
for ( Palette * p : pb - > palettes ( ) ) {
if ( p - > getCurrentIdx ( ) ! = - 1 ) {
p - > applyPaletteElement ( ) ;
break ;
}
}
return ;
}
2013-05-13 18:49:17 +02:00
if ( cmdn = = " repeat-cmd " ) {
a = lastCmd ;
sc = lastShortcut ;
if ( a = = 0 )
2012-05-26 14:49:10 +02:00
return ;
2013-05-13 18:49:17 +02:00
cmdn = a - > data ( ) . toString ( ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
else {
lastCmd = a ;
lastShortcut = sc ;
2012-05-26 14:49:10 +02:00
}
2014-11-14 11:44:48 +01:00
if ( sc - > needsScore ( ) & & ! cs ) {
2013-05-13 18:49:17 +02:00
qDebug ( " no score " ) ;
return ;
}
2014-11-14 11:44:48 +01:00
if ( sc - > isCmd ( ) ) {
2013-05-13 18:49:17 +02:00
if ( ! cv - > editMode ( ) )
cs - > startCmd ( ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
cmd ( a , cmdn ) ;
2014-11-14 11:44:48 +01:00
if ( lastShortcut - > isCmd ( ) )
2013-05-13 18:49:17 +02:00
cs - > endCmd ( ) ;
endCmd ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// endCmd
2015-02-03 13:42:37 +01:00
// Called after every command action (including every
// mouse action).
// Updates the UI after a possible score change.
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : endCmd ( )
2012-05-26 14:49:10 +02:00
{
2017-07-06 07:10:27 +02:00
if ( timeline ( ) )
timeline ( ) - > updateGrid ( ) ;
2016-11-28 18:25:27 +01:00
if ( MScore : : _error ! = MS_NO_ERROR )
2016-11-28 17:25:26 +01:00
showError ( ) ;
2013-05-13 18:49:17 +02:00
if ( cs ) {
setPos ( cs - > inputState ( ) . tick ( ) ) ;
updateInputState ( cs ) ;
updateUndoRedo ( ) ;
dirtyChanged ( cs ) ;
Element * e = cs - > selection ( ) . element ( ) ;
2016-03-27 13:34:20 +02:00
// For multiple notes selected check if they all have same pitch and tuning
bool samePitch = true ;
2016-10-11 18:12:40 +02:00
int pitch = - 1 ;
2016-03-27 13:34:20 +02:00
float tuning = 0 ;
2016-10-11 18:12:40 +02:00
for ( Element * e : cs - > selection ( ) . elements ( ) ) {
if ( ! e - > isNote ( ) ) {
2016-03-27 13:34:20 +02:00
samePitch = false ;
break ;
}
2016-10-11 18:12:40 +02:00
Note * note = toNote ( e ) ;
if ( pitch = = - 1 ) {
2016-03-27 13:34:20 +02:00
pitch = note - > ppitch ( ) ;
tuning = note - > tuning ( ) ;
}
else if ( note - > ppitch ( ) ! = pitch | | fabs ( tuning - note - > tuning ( ) ) > 0.01 ) {
samePitch = false ;
break ;
}
}
2016-10-11 18:12:40 +02:00
if ( samePitch & & pitch > = 0 )
2016-03-27 13:34:20 +02:00
e = cs - > selection ( ) . elements ( ) [ 0 ] ;
2016-08-08 17:46:37 +02:00
NoteEntryMethod entryMethod = cs - > noteEntryMethod ( ) ;
if ( e & & ( cs - > playNote ( ) | | cs - > playChord ( ) )
& & entryMethod ! = NoteEntryMethod : : REALTIME_AUTO
& & entryMethod ! = NoteEntryMethod : : REALTIME_MANUAL ) {
2017-11-29 08:21:36 +01:00
if ( cs - > playChord ( ) & & preferences . getBool ( PREF_SCORE_CHORD_PLAYONADDNOTE ) & & e - > type ( ) = = ElementType : : NOTE )
2015-02-08 21:06:26 +01:00
play ( static_cast < Note * > ( e ) - > chord ( ) ) ;
else
play ( e ) ;
2013-05-13 18:49:17 +02:00
cs - > setPlayNote ( false ) ;
2015-02-08 21:06:26 +01:00
cs - > setPlayChord ( false ) ;
2012-05-26 14:49:10 +02:00
}
2016-04-18 12:20:42 +02:00
MasterScore * ms = cs - > masterScore ( ) ;
if ( ms - > excerptsChanged ( ) ) {
2016-09-29 17:46:26 +02:00
if ( tab2 ) {
// ScoreView* v = tab2->view();
// if (v && v->score() == ms) {
tab2 - > updateExcerpts ( ) ;
// }
}
if ( tab1 ) {
ScoreView * v = tab1 - > view ( ) ;
if ( v & & v - > score ( ) - > masterScore ( ) = = ms ) {
tab1 - > updateExcerpts ( ) ;
}
else if ( v = = 0 ) {
tab1 - > setExcerpt ( 0 ) ;
tab1 - > updateExcerpts ( ) ;
}
}
2016-04-18 12:20:42 +02:00
ms - > setExcerptsChanged ( false ) ;
2012-05-26 14:49:10 +02:00
}
2016-04-18 12:20:42 +02:00
if ( ms - > instrumentsChanged ( ) ) {
2015-01-26 21:10:56 +01:00
if ( ! noSeq & & ( seq & & seq - > isRunning ( ) ) )
seq - > initInstruments ( ) ;
2015-03-05 16:46:37 +01:00
instrumentChanged ( ) ; // update mixer
2016-04-18 12:20:42 +02:00
ms - > setInstrumentsChanged ( false ) ;
2012-05-26 14:49:10 +02:00
}
2013-05-13 18:49:17 +02:00
if ( cs - > selectionChanged ( ) ) {
cs - > setSelectionChanged ( false ) ;
SelState ss = cs - > selection ( ) . state ( ) ;
selectionChanged ( ss ) ;
}
2018-03-27 15:36:00 +02:00
getAction ( " concert-pitch " ) - > setChecked ( cs - > styleB ( Sid : : concertPitch ) ) ;
2012-05-26 14:49:10 +02:00
2013-10-24 12:09:00 +02:00
if ( e = = 0 & & cs - > noteEntryMode ( ) )
2013-05-13 18:49:17 +02:00
e = cs - > inputState ( ) . cr ( ) ;
2015-11-04 11:40:06 +01:00
updateViewModeCombo ( ) ;
2014-07-10 14:13:37 +02:00
ScoreAccessibility : : instance ( ) - > updateAccessibilityInfo ( ) ;
2012-05-26 14:49:10 +02:00
}
else {
2014-05-26 13:21:04 +02:00
selectionChanged ( SelState : : NONE ) ;
2012-05-26 14:49:10 +02:00
}
2017-03-31 13:03:15 +02:00
updateInspector ( ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// updateUndoRedo
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : updateUndoRedo ( )
2012-05-26 14:49:10 +02:00
{
2013-05-13 18:49:17 +02:00
QAction * a = getAction ( " undo " ) ;
2016-03-10 10:41:31 +01:00
a - > setEnabled ( cs ? cs - > undoStack ( ) - > canUndo ( ) : false ) ;
2013-05-13 18:49:17 +02:00
a = getAction ( " redo " ) ;
2016-03-10 10:41:31 +01:00
a - > setEnabled ( cs ? cs - > undoStack ( ) - > canRedo ( ) : false ) ;
2012-05-26 14:49:10 +02:00
}
2018-02-15 11:33:44 +01:00
void MuseScore : : setPlayRepeats ( bool repeat )
{
getAction ( " repeat " ) - > setChecked ( repeat ) ;
preferences . setPreference ( PREF_APP_PLAYBACK_PLAYREPEATS , repeat ) ;
MScore : : playRepeats = repeat ;
if ( cs ) {
cs - > updateRepeatList ( repeat ) ;
emit cs - > playlistChanged ( ) ;
}
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// cmd
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : cmd ( QAction * a , const QString & cmd )
2012-05-26 14:49:10 +02:00
{
if ( cmd = = " instruments " ) {
editInstrList ( ) ;
2013-04-03 12:13:23 +02:00
if ( mixer )
2016-03-11 12:18:46 +01:00
mixer - > updateAll ( cs - > masterScore ( ) ) ;
2012-05-26 14:49:10 +02:00
}
else if ( cmd = = " rewind " ) {
seq - > rewindStart ( ) ;
if ( playPanel )
2013-05-03 11:37:28 +02:00
playPanel - > heartBeat ( 0 , 0 , 0 ) ;
2012-05-26 14:49:10 +02:00
}
else if ( cmd = = " play-next-measure " )
seq - > nextMeasure ( ) ;
else if ( cmd = = " play-next-chord " )
seq - > nextChord ( ) ;
else if ( cmd = = " play-prev-measure " )
seq - > prevMeasure ( ) ;
else if ( cmd = = " play-prev-chord " )
seq - > prevChord ( ) ;
else if ( cmd = = " seek-begin " )
seq - > rewindStart ( ) ;
else if ( cmd = = " seek-end " )
seq - > seekEnd ( ) ;
else if ( cmd = = " keys " )
showKeyEditor ( ) ;
else if ( cmd = = " file-open " )
loadFiles ( ) ;
else if ( cmd = = " file-save " )
saveFile ( ) ;
2014-11-14 21:03:46 +01:00
else if ( cmd = = " file-save-online " )
showUploadScoreDialog ( ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " file-export " )
exportFile ( ) ;
else if ( cmd = = " file-part-export " )
exportParts ( ) ;
2015-03-10 19:43:22 +01:00
else if ( cmd = = " file-import-pdf " )
openExternalLink ( " https://musescore.com/import " ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " file-close " )
closeScore ( cs ) ;
2013-04-02 20:46:07 +02:00
else if ( cmd = = " file-save-as " )
2012-05-26 14:49:10 +02:00
saveAs ( cs , false ) ;
2013-04-02 20:46:07 +02:00
else if ( cmd = = " file-save-selection " )
2012-05-26 14:49:10 +02:00
saveSelection ( cs ) ;
2013-04-02 20:46:07 +02:00
else if ( cmd = = " file-save-a-copy " )
2012-05-26 14:49:10 +02:00
saveAs ( cs , true ) ;
else if ( cmd = = " file-new " )
newFile ( ) ;
2014-08-20 00:02:57 +02:00
else if ( cmd = = " quit " )
2012-05-26 14:49:10 +02:00
close ( ) ;
else if ( cmd = = " masterpalette " )
showMasterPalette ( ) ;
2014-08-20 00:02:57 +02:00
else if ( cmd = = " key-signatures " )
2016-10-25 12:32:59 +02:00
showMasterPalette ( qApp - > translate ( " Palette " , " Key Signatures " ) ) ;
2014-08-20 00:02:57 +02:00
else if ( cmd = = " time-signatures " )
2016-10-25 12:32:59 +02:00
showMasterPalette ( qApp - > translate ( " Palette " , " Time Signatures " ) ) ;
2014-08-20 00:02:57 +02:00
else if ( cmd = = " symbols " )
2016-10-25 12:32:59 +02:00
showMasterPalette ( qApp - > translate ( " MasterPalette " , " Symbols " ) ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " toggle-statusbar " ) {
2017-11-29 08:21:36 +01:00
preferences . setPreference ( PREF_UI_APP_SHOWSTATUSBAR , a - > isChecked ( ) ) ;
_statusBar - > setVisible ( a - > isChecked ( ) ) ;
2012-05-26 14:49:10 +02:00
}
else if ( cmd = = " append-measures " )
cmdAppendMeasures ( ) ;
else if ( cmd = = " insert-measures " )
cmdInsertMeasures ( ) ;
else if ( cmd = = " debugger " )
startDebugger ( ) ;
else if ( cmd = = " album " )
showAlbumManager ( ) ;
else if ( cmd = = " layer " )
showLayerManager ( ) ;
2014-01-31 10:10:21 +01:00
else if ( cmd = = " backspace " ) {
2014-12-03 16:49:28 +01:00
if ( _sstate ! = STATE_NORMAL )
2014-12-15 13:31:59 +01:00
undoRedo ( true ) ;
2014-01-31 10:10:21 +01:00
# ifdef Q_OS_MAC
2014-12-03 16:49:28 +01:00
else if ( cs ) {
cs - > startCmd ( ) ;
2014-01-31 10:10:21 +01:00
cs - > cmdDeleteSelection ( ) ;
2014-12-03 16:49:28 +01:00
cs - > endCmd ( ) ;
}
2014-01-31 10:10:21 +01:00
# endif
}
2012-05-26 14:49:10 +02:00
else if ( cmd = = " zoomin " )
incMag ( ) ;
else if ( cmd = = " zoomout " )
decMag ( ) ;
2015-07-08 15:56:05 +02:00
else if ( cmd = = " zoom100 " ) {
2015-07-08 18:02:16 +02:00
if ( cv )
2015-07-08 15:56:05 +02:00
cv - > setMag ( MagIdx : : MAG_100 , 1.0 ) ;
setMag ( 1.0 ) ;
}
2012-05-26 14:49:10 +02:00
else if ( cmd = = " midi-on " )
midiinToggled ( a - > isChecked ( ) ) ;
2014-12-15 13:31:59 +01:00
else if ( cmd = = " undo " )
undoRedo ( true ) ;
else if ( cmd = = " redo " )
undoRedo ( false ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " toggle-palette " )
showPalette ( a - > isChecked ( ) ) ;
2016-04-19 13:55:55 +02:00
else if ( cmd = = " startcenter " )
showStartcenter ( a - > isChecked ( ) ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " inspector " )
showInspector ( a - > isChecked ( ) ) ;
# ifdef OMR
else if ( cmd = = " omr " )
showOmrPanel ( a - > isChecked ( ) ) ;
# endif
else if ( cmd = = " toggle-playpanel " )
showPlayPanel ( a - > isChecked ( ) ) ;
else if ( cmd = = " toggle-navigator " )
showNavigator ( a - > isChecked ( ) ) ;
2017-07-06 07:10:27 +02:00
else if ( cmd = = " toggle-timeline " )
showTimeline ( a - > isChecked ( ) ) ;
2013-04-28 21:29:12 +02:00
else if ( cmd = = " toggle-midiimportpanel " )
2013-09-25 21:53:52 +02:00
importmidiPanel - > setVisible ( a - > isChecked ( ) ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " toggle-mixer " )
showMixer ( a - > isChecked ( ) ) ;
else if ( cmd = = " synth-control " )
2013-04-24 12:41:38 +02:00
showSynthControl ( a - > isChecked ( ) ) ;
2014-06-02 12:12:53 +02:00
else if ( cmd = = " toggle-selection-window " )
showSelectionWindow ( a - > isChecked ( ) ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " show-keys " )
;
2016-12-27 00:51:10 +01:00
else if ( cmd = = " toggle-fileoperations " )
fileTools - > setVisible ( ! fileTools - > isVisible ( ) ) ;
else if ( cmd = = " toggle-transport " )
transportTools - > setVisible ( ! transportTools - > isVisible ( ) ) ;
else if ( cmd = = " toggle-concertpitch " )
cpitchTools - > setVisible ( ! cpitchTools - > isVisible ( ) ) ;
else if ( cmd = = " toggle-imagecapture " )
fotoTools - > setVisible ( ! fotoTools - > isVisible ( ) ) ;
else if ( cmd = = " toggle-noteinput " )
entryTools - > setVisible ( ! entryTools - > isVisible ( ) ) ;
2016-08-08 11:12:32 +02:00
else if ( cmd = = " help " )
2015-02-19 19:55:17 +01:00
showContextHelp ( ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " follow " )
2017-11-29 08:21:36 +01:00
preferences . setPreference ( PREF_APP_PLAYBACK_FOLLOWSONG , a - > isChecked ( ) ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " split-h " )
splitWindow ( true ) ;
else if ( cmd = = " split-v " )
splitWindow ( false ) ;
else if ( cmd = = " edit-harmony " )
editChordStyle ( ) ;
else if ( cmd = = " parts " )
startExcerptsDialog ( ) ;
else if ( cmd = = " fullscreen " ) {
_fullscreen = a - > isChecked ( ) ;
if ( _fullscreen )
showFullScreen ( ) ;
else
showNormal ( ) ;
2013-05-16 16:12:22 +02:00
# ifdef Q_OS_MAC
2012-05-26 14:49:10 +02:00
// Qt Bug: Toolbar goes into unified mode
// after switching back from fullscreen
setUnifiedTitleAndToolBarOnMac ( false ) ;
# endif
}
else if ( cmd = = " config-raster " )
editRaster ( ) ;
else if ( cmd = = " hraster " | | cmd = = " vraster " ) // value in [hv]RasterAction already set
;
2014-12-22 09:56:39 +01:00
else if ( cmd = = " toggle-piano " )
2012-05-26 14:49:10 +02:00
showPianoKeyboard ( a - > isChecked ( ) ) ;
2012-07-02 18:05:10 +02:00
else if ( cmd = = " plugin-creator " )
showPluginCreator ( a ) ;
2013-10-05 12:03:30 +02:00
else if ( cmd = = " plugin-manager " )
2014-09-01 22:35:04 +02:00
showPluginManager ( ) ;
2013-09-30 18:38:05 +02:00
else if ( cmd = = " resource-manager " ) {
ResourceManager r ( 0 ) ;
r . exec ( ) ;
}
2012-05-26 14:49:10 +02:00
else if ( cmd = = " media " )
showMediaDialog ( ) ;
else if ( cmd = = " page-settings " )
showPageSettings ( ) ;
else if ( cmd = = " next-score " )
2012-08-20 14:34:10 +02:00
changeScore ( 1 ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " previous-score " )
2012-08-20 14:34:10 +02:00
changeScore ( 1 ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " transpose " )
transpose ( ) ;
else if ( cmd = = " save-style " ) {
QString name = getStyleFilename ( false ) ;
if ( ! name . isEmpty ( ) ) {
if ( ! cs - > saveStyle ( name ) ) {
QMessageBox : : critical ( this ,
2017-03-28 18:54:29 +02:00
tr ( " Save Style " ) , MScore : : lastError ) ;
2012-05-26 14:49:10 +02:00
}
}
}
else if ( cmd = = " load-style " ) {
QString name = mscore - > getStyleFilename ( true ) ;
if ( ! name . isEmpty ( ) ) {
cs - > startCmd ( ) ;
if ( ! cs - > loadStyle ( name ) ) {
QMessageBox : : critical ( this ,
2017-03-28 18:54:29 +02:00
tr ( " Load Style " ) , MScore : : lastError ) ;
2012-05-26 14:49:10 +02:00
}
cs - > endCmd ( ) ;
}
}
else if ( cmd = = " edit-style " ) {
EditStyle es ( cs , this ) ;
es . exec ( ) ;
}
else if ( cmd = = " edit-info " ) {
MetaEditDialog med ( cs , 0 ) ;
med . exec ( ) ;
}
else if ( cmd = = " print " )
printFile ( ) ;
2018-02-15 11:33:44 +01:00
else if ( cmd = = " repeat " )
setPlayRepeats ( a - > isChecked ( ) ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " pan " )
MScore : : panPlayback = ! MScore : : panPlayback ;
else if ( cmd = = " show-invisible " )
cs - > setShowInvisible ( a - > isChecked ( ) ) ;
else if ( cmd = = " show-unprintable " )
cs - > setShowUnprintable ( a - > isChecked ( ) ) ;
else if ( cmd = = " show-frames " )
2016-08-06 11:36:51 +02:00
cs - > setShowFrames ( a - > isChecked ( ) ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " show-pageborders " )
2016-08-06 11:36:51 +02:00
cs - > setShowPageborders ( a - > isChecked ( ) ) ;
else if ( cmd = = " mark-irregular " )
cs - > setMarkIrregularMeasures ( a - > isChecked ( ) ) ;
2012-05-26 14:49:10 +02:00
else if ( cmd = = " tempo " )
addTempo ( ) ;
2013-08-09 01:20:07 +02:00
else if ( cmd = = " loop " ) {
2013-08-23 03:32:16 +02:00
if ( loop ( ) ) {
2014-05-24 12:53:50 +02:00
if ( cs - > selection ( ) . isRange ( ) )
2013-08-22 18:29:25 +02:00
seq - > setLoopSelection ( ) ;
2013-08-19 08:53:30 +02:00
}
}
2013-08-09 01:20:07 +02:00
else if ( cmd = = " loop-in " ) {
2013-08-23 03:32:16 +02:00
seq - > setLoopIn ( ) ;
2013-10-18 12:21:01 +02:00
loopAction - > setChecked ( true ) ;
2013-08-19 08:53:30 +02:00
}
2013-08-09 01:20:07 +02:00
else if ( cmd = = " loop-out " ) {
2013-08-23 03:32:16 +02:00
seq - > setLoopOut ( ) ;
2013-10-18 12:21:01 +02:00
loopAction - > setChecked ( true ) ;
2013-08-19 08:53:30 +02:00
}
2012-05-26 14:49:10 +02:00
else if ( cmd = = " metronome " ) // no action
;
2013-10-15 09:36:17 +02:00
else if ( cmd = = " countin " ) // no action
;
2013-02-21 11:04:41 +01:00
else if ( cmd = = " lock " ) {
if ( _sstate = = STATE_LOCK )
changeState ( STATE_NORMAL ) ;
else
changeState ( STATE_LOCK ) ;
}
2013-04-23 16:20:02 +02:00
else if ( cmd = = " find " )
showSearchDialog ( ) ;
2014-02-12 14:39:44 +01:00
else if ( cmd = = " text-b " ) {
if ( _textTools )
_textTools - > toggleBold ( ) ;
}
else if ( cmd = = " text-i " ) {
if ( _textTools )
_textTools - > toggleItalic ( ) ;
}
else if ( cmd = = " text-u " ) {
if ( _textTools )
_textTools - > toggleUnderline ( ) ;
}
2016-05-31 17:44:39 +02:00
else if ( cmd = = " edit-toolbars " )
showToolbarEditor ( ) ;
2014-11-17 13:06:34 +01:00
else if ( cmd = = " viewmode " ) {
if ( cs ) {
if ( cs - > layoutMode ( ) = = LayoutMode : : PAGE )
2016-05-18 15:43:47 +02:00
switchLayoutMode ( LayoutMode : : LINE ) ;
2014-11-17 13:06:34 +01:00
else
2016-05-18 15:43:47 +02:00
switchLayoutMode ( LayoutMode : : PAGE ) ;
2014-11-17 13:06:34 +01:00
}
}
2016-06-02 12:12:40 +02:00
# ifndef NDEBUG
else if ( cmd = = " no-horizontal-stretch " ) {
MScore : : noHorizontalStretch = a - > isChecked ( ) ;
if ( cs ) {
cs - > setLayoutAll ( ) ;
cs - > update ( ) ;
}
}
else if ( cmd = = " no-vertical-stretch " ) {
MScore : : noVerticalStretch = a - > isChecked ( ) ;
if ( cs ) {
cs - > setLayoutAll ( ) ;
cs - > update ( ) ;
}
}
else if ( cmd = = " show-segment-shapes " ) {
MScore : : showSegmentShapes = a - > isChecked ( ) ;
if ( cs ) {
cs - > setLayoutAll ( ) ;
cs - > update ( ) ;
}
}
else if ( cmd = = " show-measure-shapes " ) {
MScore : : showMeasureShapes = a - > isChecked ( ) ;
if ( cs ) {
cs - > setLayoutAll ( ) ;
cs - > update ( ) ;
}
}
2016-06-03 17:54:21 +02:00
else if ( cmd = = " show-bounding-rect " ) {
MScore : : showBoundingRect = a - > isChecked ( ) ;
if ( cs ) {
cs - > setLayoutAll ( ) ;
cs - > update ( ) ;
}
}
2016-06-03 18:26:51 +02:00
else if ( cmd = = " show-corrupted-measures " ) {
MScore : : showCorruptedMeasures = a - > isChecked ( ) ;
if ( cs ) {
2017-08-16 16:56:34 +02:00
cs - > setLayoutAll ( ) ;
cs - > update ( ) ;
}
}
else if ( cmd = = " autoplace-slurs " ) {
MScore : : autoplaceSlurs = a - > isChecked ( ) ;
if ( cs ) {
2016-06-03 18:26:51 +02:00
cs - > setLayoutAll ( ) ;
cs - > update ( ) ;
}
}
2016-06-02 12:12:40 +02:00
# endif
2012-05-26 14:49:10 +02:00
else {
if ( cv ) {
2014-05-29 21:28:20 +02:00
//isAncestorOf is called to see if a widget from inspector has focus
//if so, the focus doesn't get shifted to the score, unless escape is
//pressed, or the user clicks in the score
2016-04-18 18:11:51 +02:00
if ( ! inspector ( ) - > isAncestorOf ( qApp - > focusWidget ( ) ) | | cmd = = " escape " )
2014-05-29 21:28:20 +02:00
cv - > setFocus ( ) ;
2012-05-26 14:49:10 +02:00
cv - > cmd ( a ) ;
}
else
qDebug ( " 2:unknown cmd <%s> " , qPrintable ( cmd ) ) ;
}
if ( debugger )
debugger - > reloadClicked ( ) ;
}
//---------------------------------------------------------
// openExternalLink
//---------------------------------------------------------
void MuseScore : : openExternalLink ( const QString & url )
{
QDesktopServices : : openUrl ( url ) ;
}
//---------------------------------------------------------
// navigator
//---------------------------------------------------------
Navigator * MuseScore : : navigator ( ) const
{
return _navigator ? static_cast < Navigator * > ( _navigator - > widget ( ) ) : 0 ;
}
2017-07-06 07:10:27 +02:00
//---------------------------------------------------------
// timeline
//---------------------------------------------------------
Timeline * MuseScore : : timeline ( ) const
{
if ( _timeline ) {
QSplitter * s = static_cast < QSplitter * > ( _timeline - > widget ( ) ) ;
if ( s & & s - > count ( ) > 0 )
return _timeline ? static_cast < Timeline * > ( s - > widget ( 1 ) ) : 0 ;
return 0 ;
}
return 0 ;
}
2014-08-27 21:38:00 +02:00
//---------------------------------------------------------
// getSearchDialog
//---------------------------------------------------------
2014-08-30 09:04:40 +02:00
QWidget * MuseScore : : searchDialog ( ) const
2014-08-27 21:38:00 +02:00
{
2014-08-30 09:04:40 +02:00
return _searchDialog ;
2014-08-27 21:38:00 +02:00
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// updateLayer
//---------------------------------------------------------
void MuseScore : : updateLayer ( )
{
layerSwitch - > clear ( ) ;
bool enable ;
if ( cs ) {
enable = cs - > layer ( ) . size ( ) > 1 ;
if ( enable ) {
foreach ( const Layer & l , cs - > layer ( ) )
layerSwitch - > addItem ( l . name ) ;
layerSwitch - > setCurrentIndex ( cs - > currentLayer ( ) ) ;
}
}
else
enable = false ;
layerSwitch - > setVisible ( enable ) ;
}
//---------------------------------------------------------
// updatePlayMode
//---------------------------------------------------------
void MuseScore : : updatePlayMode ( )
{
bool enable = false ;
if ( cs ) {
enable = cs - > audio ( ) ! = 0 ;
playMode - > setCurrentIndex ( int ( cs - > playMode ( ) ) ) ;
}
playMode - > setVisible ( enable ) ;
}
//---------------------------------------------------------
// closeScore
//---------------------------------------------------------
void MuseScore : : closeScore ( Score * score )
{
2014-11-29 11:09:56 +01:00
// Let's compute maximum count of ports in remaining scores
if ( seq )
seq - > recomputeMaxMidiOutPort ( ) ;
2016-03-10 10:41:31 +01:00
removeTab ( scoreList . indexOf ( score - > masterScore ( ) ) ) ;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// noteTooShortForTupletDialog
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
void MuseScore : : noteTooShortForTupletDialog ( )
{
2017-03-28 18:54:29 +02:00
QMessageBox : : warning ( this , tr ( " Warning " ) ,
2014-08-22 16:25:50 +02:00
tr ( " Cannot create tuplet: Note value is too short " )
2013-05-13 18:49:17 +02:00
) ;
}
//---------------------------------------------------------
// instrumentChanged
//---------------------------------------------------------
void MuseScore : : instrumentChanged ( )
{
if ( mixer )
2016-03-11 12:18:46 +01:00
mixer - > updateAll ( cs - > masterScore ( ) ) ;
2013-05-13 18:49:17 +02:00
}
2015-05-20 19:38:47 +02:00
//---------------------------------------------------------
// mixerPreferencesChanged
//---------------------------------------------------------
void MuseScore : : mixerPreferencesChanged ( bool showMidiControls )
{
if ( mixer )
mixer - > midiPrefsChanged ( showMidiControls ) ;
}
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
// changeScore
// switch current score
// step = 1 switch to next score
// step = -1 switch to previous score
//---------------------------------------------------------
void MuseScore : : changeScore ( int step )
{
int index = tab1 - > currentIndex ( ) ;
int n = tab1 - > count ( ) ;
if ( n = = 1 )
return ;
index + = step ;
if ( index > = n )
index = 0 ;
if ( index < 0 )
index = n - 1 ;
setCurrentScoreView ( index ) ;
}
//---------------------------------------------------------
// switchLayoutMode
2015-11-04 11:40:06 +01:00
// val is index in QComboBox viewModeCombo
2013-05-13 18:49:17 +02:00
//---------------------------------------------------------
void MuseScore : : switchLayoutMode ( int val )
{
2015-10-01 15:03:32 +02:00
if ( ! cs )
return ;
2016-05-18 15:43:47 +02:00
switchLayoutMode ( static_cast < LayoutMode > ( viewModeCombo - > itemData ( val ) . toInt ( ) ) ) ;
}
2015-10-01 15:03:32 +02:00
2016-05-18 15:43:47 +02:00
void MuseScore : : switchLayoutMode ( LayoutMode mode )
{
2015-10-01 15:03:32 +02:00
// find a measure to use as reference, if possible
QRectF view = cv - > toLogical ( QRect ( 0.0 , 0.0 , width ( ) , height ( ) ) ) ;
Measure * m = cs - > firstMeasure ( ) ;
while ( m & & ! view . intersects ( m - > canvasBoundingRect ( ) ) )
m = m - > nextMeasureMM ( ) ;
cv - > loopUpdate ( getAction ( " loop " ) - > isChecked ( ) ) ;
2016-05-18 15:43:47 +02:00
if ( mode ! = cs - > layoutMode ( ) ) {
cs - > setLayoutMode ( mode ) ;
cs - > doLayout ( ) ;
}
2015-10-01 15:03:32 +02:00
// adjustCanvasPosition often tries to preserve Y position
// but this doesn't make sense when switching modes
// also, better positioning is usually achieved if you start from the top
// and there is really no better place to position canvas if we were all the way off page previously
cv - > pageTop ( ) ;
if ( m & & m ! = cs - > firstMeasure ( ) )
cv - > adjustCanvasPosition ( m , false ) ;
2013-05-13 18:49:17 +02:00
}
//---------------------------------------------------------
// showDrumTools
//---------------------------------------------------------
2015-02-04 19:51:24 +01:00
void MuseScore : : showDrumTools ( const Drumset * drumset , Staff * staff )
2013-05-13 18:49:17 +02:00
{
if ( drumset ) {
if ( ! _drumTools ) {
_drumTools = new DrumTools ( this ) ;
addDockWidget ( Qt : : BottomDockWidgetArea , _drumTools ) ;
}
2017-08-11 19:05:19 +02:00
if ( timelineScrollArea ( ) )
splitDockWidget ( _drumTools , timelineScrollArea ( ) , Qt : : Vertical ) ;
2013-05-13 18:49:17 +02:00
_drumTools - > setDrumset ( cs , staff , drumset ) ;
_drumTools - > show ( ) ;
}
else {
if ( _drumTools )
_drumTools - > hide ( ) ;
}
}
//---------------------------------------------------------
// updateDrumTools
//---------------------------------------------------------
2015-03-17 11:50:59 +01:00
void MuseScore : : updateDrumTools ( const Drumset * ds )
2013-05-13 18:49:17 +02:00
{
if ( _drumTools )
2015-03-17 11:50:59 +01:00
_drumTools - > updateDrumset ( ds ) ;
2013-05-13 18:49:17 +02:00
}
2014-11-15 16:29:48 +01:00
//---------------------------------------------------------
// endSearch
//---------------------------------------------------------
void MuseScore : : endSearch ( )
{
_searchDialog - > hide ( ) ;
if ( cv )
cv - > setFocus ( ) ;
}
//---------------------------------------------------------
2013-05-13 18:49:17 +02:00
// showSearchDialog
//---------------------------------------------------------
void MuseScore : : showSearchDialog ( )
{
2014-08-30 09:04:40 +02:00
if ( _searchDialog = = 0 ) {
_searchDialog = new QWidget ;
_searchDialog - > setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Maximum ) ;
2013-05-13 18:49:17 +02:00
QHBoxLayout * searchDialogLayout = new QHBoxLayout ;
2014-08-30 09:04:40 +02:00
_searchDialog - > setLayout ( searchDialogLayout ) ;
layout - > insertWidget ( 2 , _searchDialog ) ;
2013-05-13 18:49:17 +02:00
QToolButton * searchExit = new QToolButton ;
2013-05-09 18:46:51 +02:00
searchExit - > setAutoRaise ( true ) ;
2014-09-18 00:12:21 +02:00
searchExit - > setIcon ( * icons [ int ( Icons : : close_ICON ) ] ) ;
2013-05-13 18:49:17 +02:00
connect ( searchExit , SIGNAL ( clicked ( ) ) , SLOT ( endSearch ( ) ) ) ;
searchDialogLayout - > addWidget ( searchExit ) ;
2013-05-09 18:46:51 +02:00
searchDialogLayout - > addSpacing ( 10 ) ;
2013-05-13 18:49:17 +02:00
searchDialogLayout - > addWidget ( new QLabel ( tr ( " Go To: " ) ) ) ;
2015-02-01 20:50:01 +01:00
searchCombo = new SearchComboBox ;
2013-05-13 18:49:17 +02:00
searchDialogLayout - > addWidget ( searchCombo ) ;
searchDialogLayout - > addStretch ( 10 ) ;
2014-08-30 09:04:40 +02:00
_searchDialog - > hide ( ) ;
2013-05-13 18:49:17 +02:00
2014-03-04 16:48:06 +01:00
qDebug ( " Line edit %p " , searchCombo - > lineEdit ( ) ) ;
2013-05-13 18:49:17 +02:00
2017-01-07 16:02:14 +01:00
connect ( searchCombo - > lineEdit ( ) , SIGNAL ( returnPressed ( ) ) , SLOT ( endSearch ( ) ) ) ;
2013-05-13 18:49:17 +02:00
}
searchCombo - > clearEditText ( ) ;
searchCombo - > setFocus ( ) ;
2014-08-30 09:04:40 +02:00
_searchDialog - > show ( ) ;
2013-05-13 18:49:17 +02:00
}
# ifndef SCRIPT_INTERFACE
void MuseScore : : pluginTriggered ( int ) { }
void MuseScore : : loadPlugins ( ) { }
bool MuseScore : : loadPlugin ( const QString & ) { return false ; }
void MuseScore : : unloadPlugins ( ) { }
# endif
2014-11-13 10:22:05 +01:00
2016-07-16 19:44:28 +02:00
void MuseScore : : saveGeometry ( QWidget const * const qw )
{
QSettings settings ;
QString objectName = qw - > objectName ( ) ;
Q_ASSERT ( ! objectName . isEmpty ( ) ) ;
settings . beginGroup ( " Geometries " ) ;
settings . setValue ( objectName , qw - > saveGeometry ( ) ) ;
settings . endGroup ( ) ;
}
void MuseScore : : restoreGeometry ( QWidget * const qw )
{
if ( ! useFactorySettings ) {
QSettings settings ;
QString objectName = qw - > objectName ( ) ;
Q_ASSERT ( ! objectName . isEmpty ( ) ) ;
settings . beginGroup ( " Geometries " ) ;
qw - > restoreGeometry ( settings . value ( objectName ) . toByteArray ( ) ) ;
settings . endGroup ( ) ;
}
}
2018-03-31 06:57:32 +02:00
void MuseScore : : updateWindowTitle ( Score * score )
{
# ifdef Q_OS_MAC
2018-04-04 19:06:21 +02:00
if ( ! cs - > isMaster ( ) )
setWindowTitle ( cs - > masterScore ( ) - > title ( ) + " - " + cs - > title ( ) ) ;
else
setWindowTitle ( cs - > title ( ) ) ;
if ( score - > masterScore ( ) - > created ( ) )
2018-03-31 06:57:32 +02:00
setWindowFilePath ( QString ( ) ) ;
2018-04-04 19:06:21 +02:00
else
2018-03-31 06:57:32 +02:00
setWindowFilePath ( score - > masterScore ( ) - > fileInfo ( ) - > absoluteFilePath ( ) ) ;
# else
2018-04-04 19:14:51 +02:00
if ( ! cs - > isMaster ( ) )
setWindowTitle ( MUSESCORE_NAME_VERSION " : " + cs - > masterScore ( ) - > title ( ) + " - " + cs - > title ( ) + " [*] " ) ;
else
setWindowTitle ( MUSESCORE_NAME_VERSION " : " + score - > title ( ) + " [*] " ) ;
2018-03-31 06:57:32 +02:00
# endif
}
2014-11-13 10:22:05 +01:00
//---------------------------------------------------------
// recentScores
2014-12-08 14:41:36 +01:00
// return a list of recent scores
// omit loaded scores
2014-11-13 10:22:05 +01:00
//---------------------------------------------------------
QFileInfoList MuseScore : : recentScores ( ) const
{
QFileInfoList fil ;
for ( const QString & s : _recentScores ) {
if ( s . isEmpty ( ) )
continue ;
QString data ( s ) ;
QFileInfo fi ( s ) ;
bool alreadyLoaded = false ;
QString fp = fi . canonicalFilePath ( ) ;
for ( Score * s : mscore - > scores ( ) ) {
2016-03-10 10:41:31 +01:00
if ( ( s - > masterScore ( ) - > fileInfo ( ) - > canonicalFilePath ( ) = = fp ) | | ( s - > importedFilePath ( ) = = fp ) ) {
2014-11-13 10:22:05 +01:00
alreadyLoaded = true ;
break ;
}
}
if ( ! alreadyLoaded & & fi . exists ( ) )
fil . append ( fi ) ;
}
return fil ;
}
2014-11-14 13:17:56 +01:00
2016-10-07 16:00:57 +02:00
//---------------------------------------------------------
2016-10-10 10:38:43 +02:00
// createPopupMenu
2016-10-07 16:00:57 +02:00
//---------------------------------------------------------
2016-10-10 10:38:43 +02:00
QMenu * MuseScore : : createPopupMenu ( )
2016-10-07 16:00:57 +02:00
{
2016-10-10 10:38:43 +02:00
QMenu * m = QMainWindow : : createPopupMenu ( ) ;
QList < QAction * > al = m - > actions ( ) ;
for ( QAction * a : al ) {
2016-10-26 18:10:21 +02:00
// textTool visibility is handled differentlyr
2016-10-10 11:39:13 +02:00
if ( _textTools & & a - > text ( ) = = _textTools - > windowTitle ( ) )
m - > removeAction ( a ) ;
2016-10-07 16:00:57 +02:00
}
2016-10-10 10:38:43 +02:00
return m ;
2016-10-07 16:00:57 +02:00
}
2017-03-17 09:39:50 +01:00
//---------------------------------------------------------
// synthesizerState
//---------------------------------------------------------
SynthesizerState MuseScore : : synthesizerState ( )
{
SynthesizerState state ;
return synti ? synti - > state ( ) : state ;
}
2017-05-16 05:01:10 +02:00
//---------------------------------------------------------
// canSaveMp3
//---------------------------------------------------------
bool MuseScore : : canSaveMp3 ( )
{
2017-06-19 16:15:53 +02:00
# ifndef USE_LAME
return false ;
# else
2017-05-16 05:01:10 +02:00
MP3Exporter exporter ;
if ( ! exporter . loadLibrary ( MP3Exporter : : AskUser : : NO ) ) {
qDebug ( " Could not open MP3 encoding library! " ) ;
return false ;
}
if ( ! exporter . validLibraryLoaded ( ) ) {
qDebug ( " Not a valid or supported MP3 encoding library! " ) ;
return false ;
}
return true ;
2017-06-19 16:15:53 +02:00
# endif
2017-05-16 05:01:10 +02:00
}
//---------------------------------------------------------
// saveMp3
//---------------------------------------------------------
bool MuseScore : : saveMp3 ( Score * score , const QString & name )
{
2017-06-19 16:15:53 +02:00
# ifndef USE_LAME
return false ;
# else
2017-05-16 05:01:10 +02:00
EventMap events ;
score - > renderMidi ( & events ) ;
if ( events . size ( ) = = 0 )
return false ;
MP3Exporter exporter ;
if ( ! exporter . loadLibrary ( MP3Exporter : : AskUser : : MAYBE ) ) {
QSettings settings ;
settings . setValue ( " /Export/lameMP3LibPath " , " " ) ;
if ( ! MScore : : noGui )
QMessageBox : : warning ( 0 ,
tr ( " Error Opening LAME library " ) ,
tr ( " Could not open MP3 encoding library! " ) ,
QString : : null , QString : : null ) ;
qDebug ( " Could not open MP3 encoding library! " ) ;
return false ;
}
if ( ! exporter . validLibraryLoaded ( ) ) {
QSettings settings ;
settings . setValue ( " /Export/lameMP3LibPath " , " " ) ;
if ( ! MScore : : noGui )
QMessageBox : : warning ( 0 ,
tr ( " Error Opening LAME library " ) ,
tr ( " Not a valid or supported MP3 encoding library! " ) ,
QString : : null , QString : : null ) ;
qDebug ( " Not a valid or supported MP3 encoding library! " ) ;
return false ;
}
// Retrieve preferences
// int highrate = 48000;
// int lowrate = 8000;
// int bitrate = 64;
// int brate = 128;
// int rmode = MODE_CBR;
// int vmode = ROUTINE_FAST;
// int cmode = CHANNEL_STEREO;
int channels = 2 ;
int oldSampleRate = MScore : : sampleRate ;
2017-11-29 08:21:36 +01:00
int sampleRate = preferences . getInt ( PREF_EXPORT_AUDIO_SAMPLERATE ) ;
exporter . setBitrate ( preferences . getInt ( PREF_EXPORT_MP3_BITRATE ) ) ;
2017-05-16 05:01:10 +02:00
int inSamples = exporter . initializeStream ( channels , sampleRate ) ;
if ( inSamples < 0 ) {
if ( ! MScore : : noGui ) {
QMessageBox : : warning ( 0 , tr ( " Encoding Error " ) ,
tr ( " Unable to initialize MP3 stream " ) ,
QString : : null , QString : : null ) ;
}
qDebug ( " Unable to initialize MP3 stream " ) ;
MScore : : sampleRate = oldSampleRate ;
return false ;
}
QFile file ( name ) ;
if ( ! file . open ( QIODevice : : WriteOnly ) ) {
if ( ! MScore : : noGui ) {
QMessageBox : : warning ( 0 ,
tr ( " Encoding Error " ) ,
tr ( " Unable to open target file for writing " ) ,
QString : : null , QString : : null ) ;
}
MScore : : sampleRate = oldSampleRate ;
return false ;
}
int bufferSize = exporter . getOutBufferSize ( ) ;
uchar * bufferOut = new uchar [ bufferSize ] ;
MasterSynthesizer * synti = synthesizerFactory ( ) ;
synti - > init ( ) ;
synti - > setSampleRate ( sampleRate ) ;
if ( MScore : : noGui ) { // use score settings if possible
bool r = synti - > setState ( score - > synthesizerState ( ) ) ;
if ( ! r )
synti - > init ( ) ;
}
else { // use current synth settings
bool r = synti - > setState ( mscore - > synthesizerState ( ) ) ;
if ( ! r )
synti - > init ( ) ;
}
MScore : : sampleRate = sampleRate ;
QProgressDialog progress ( this ) ;
progress . setWindowFlags ( Qt : : WindowFlags ( Qt : : Dialog | Qt : : FramelessWindowHint | Qt : : WindowTitleHint ) ) ;
progress . setWindowModality ( Qt : : ApplicationModal ) ;
//progress.setCancelButton(0);
progress . setCancelButtonText ( tr ( " Cancel " ) ) ;
progress . setLabelText ( tr ( " Exporting... " ) ) ;
if ( ! MScore : : noGui )
progress . show ( ) ;
static const int FRAMES = 512 ;
float bufferL [ FRAMES ] ;
float bufferR [ FRAMES ] ;
float peak = 0.0 ;
double gain = 1.0 ;
EventMap : : const_iterator endPos = events . cend ( ) ;
- - endPos ;
const int et = ( score - > utick2utime ( endPos - > first ) + 1 ) * MScore : : sampleRate ;
const int maxEndTime = ( score - > utick2utime ( endPos - > first ) + 3 ) * MScore : : sampleRate ;
progress . setRange ( 0 , et ) ;
for ( int pass = 0 ; pass < 2 ; + + pass ) {
EventMap : : const_iterator playPos ;
playPos = events . cbegin ( ) ;
synti - > allSoundsOff ( - 1 ) ;
//
// init instruments
//
foreach ( Part * part , score - > parts ( ) ) {
const InstrumentList * il = part - > instruments ( ) ;
for ( auto i = il - > begin ( ) ; i ! = il - > end ( ) ; i + + ) {
foreach ( const Channel * a , i - > second - > channel ( ) ) {
a - > updateInitList ( ) ;
foreach ( MidiCoreEvent e , a - > init ) {
if ( e . type ( ) = = ME_INVALID )
continue ;
e . setChannel ( a - > channel ) ;
int syntiIdx = synti - > index ( score - > masterScore ( ) - > midiMapping ( a - > channel ) - > articulation - > synti ) ;
synti - > play ( e , syntiIdx ) ;
}
}
}
}
int playTime = 0.0 ;
for ( ; ; ) {
unsigned frames = FRAMES ;
float max = 0 ;
//
// collect events for one segment
//
memset ( bufferL , 0 , sizeof ( float ) * FRAMES ) ;
memset ( bufferR , 0 , sizeof ( float ) * FRAMES ) ;
double endTime = playTime + frames ;
float * l = bufferL ;
float * r = bufferR ;
for ( ; playPos ! = events . cend ( ) ; + + playPos ) {
double f = score - > utick2utime ( playPos - > first ) * MScore : : sampleRate ;
if ( f > = endTime )
break ;
int n = f - playTime ;
if ( n ) {
float bu [ n * 2 ] ;
memset ( bu , 0 , sizeof ( float ) * 2 * n ) ;
synti - > process ( n , bu ) ;
float * sp = bu ;
for ( int i = 0 ; i < n ; + + i ) {
* l + + = * sp + + ;
* r + + = * sp + + ;
}
playTime + = n ;
frames - = n ;
}
const NPlayEvent & e = playPos - > second ;
if ( e . isChannelEvent ( ) ) {
int channelIdx = e . channel ( ) ;
Channel * c = score - > masterScore ( ) - > midiMapping ( channelIdx ) - > articulation ;
if ( ! c - > mute ) {
synti - > play ( e , synti - > index ( c - > synti ) ) ;
}
}
}
if ( frames ) {
float bu [ frames * 2 ] ;
memset ( bu , 0 , sizeof ( float ) * 2 * frames ) ;
synti - > process ( frames , bu ) ;
float * sp = bu ;
for ( unsigned i = 0 ; i < frames ; + + i ) {
* l + + = * sp + + ;
* r + + = * sp + + ;
}
playTime + = frames ;
}
if ( pass = = 1 ) {
for ( int i = 0 ; i < FRAMES ; + + i ) {
max = qMax ( max , qAbs ( bufferL [ i ] ) ) ;
max = qMax ( max , qAbs ( bufferR [ i ] ) ) ;
bufferL [ i ] * = gain ;
bufferR [ i ] * = gain ;
}
long bytes ;
if ( FRAMES < inSamples )
bytes = exporter . encodeRemainder ( bufferL , bufferR , FRAMES , bufferOut ) ;
else
bytes = exporter . encodeBuffer ( bufferL , bufferR , bufferOut ) ;
if ( bytes < 0 ) {
if ( MScore : : noGui )
qDebug ( " exportmp3: error from encoder: %ld " , bytes ) ;
else
QMessageBox : : warning ( 0 ,
tr ( " Encoding Error " ) ,
tr ( " Error %1 returned from MP3 encoder " ) . arg ( bytes ) ,
QString : : null , QString : : null ) ;
break ;
}
else
file . write ( ( char * ) bufferOut , bytes ) ;
}
else {
for ( int i = 0 ; i < FRAMES ; + + i ) {
max = qMax ( max , qAbs ( bufferL [ i ] ) ) ;
max = qMax ( max , qAbs ( bufferR [ i ] ) ) ;
peak = qMax ( peak , qAbs ( bufferL [ i ] ) ) ;
peak = qMax ( peak , qAbs ( bufferR [ i ] ) ) ;
}
}
playTime = endTime ;
if ( ! MScore : : noGui ) {
if ( progress . wasCanceled ( ) )
break ;
progress . setValue ( ( pass * et + playTime ) / 2 ) ;
qApp - > processEvents ( ) ;
}
if ( playTime > = et )
synti - > allNotesOff ( - 1 ) ;
// create sound until the sound decays
if ( playTime > = et & & max * peak < 0.000001 )
break ;
// hard limit
if ( playTime > maxEndTime )
break ;
}
if ( progress . wasCanceled ( ) )
break ;
if ( pass = = 0 & & peak = = 0.0 ) {
qDebug ( " song is empty " ) ;
break ;
}
gain = 0.99 / peak ;
}
long bytes = exporter . finishStream ( bufferOut ) ;
if ( bytes > 0L )
file . write ( ( char * ) bufferOut , bytes ) ;
bool wasCanceled = progress . wasCanceled ( ) ;
progress . close ( ) ;
delete synti ;
delete [ ] bufferOut ;
file . close ( ) ;
if ( wasCanceled )
file . remove ( ) ;
MScore : : sampleRate = oldSampleRate ;
return true ;
2017-06-19 16:15:53 +02:00
# endif
2017-05-16 05:01:10 +02:00
}
2018-02-15 11:33:44 +01:00
void MuseScore : : updateUiStyleAndTheme ( )
{
// set UI Theme
QApplication : : setStyle ( QStyleFactory : : create ( " Fusion " ) ) ;
QString wd = QString ( " %1/%2 " ) . arg ( QStandardPaths : : writableLocation ( QStandardPaths : : DocumentsLocation ) ) . arg ( QCoreApplication : : applicationName ( ) ) ;
// set UI Color Palette
QPalette p ( QApplication : : palette ( ) ) ;
QString jsonPaletteFilename = preferences . isThemeDark ( ) ? " palette_dark_fusion.json " : " palette_light_fusion.json " ; ;
QFile jsonPalette ( QString ( " :/themes/%1 " ) . arg ( jsonPaletteFilename ) ) ;
// read from Documents TODO: remove this
if ( QFile : : exists ( QString ( " %1/%2 " ) . arg ( wd , " ms_palette.json " ) ) )
jsonPalette . setFileName ( QString ( " %1/%2 " ) . arg ( wd , " ms_palette.json " ) ) ;
if ( jsonPalette . open ( QFile : : ReadOnly | QFile : : Text ) ) {
QJsonDocument d = QJsonDocument : : fromJson ( jsonPalette . readAll ( ) ) ;
QJsonObject o = d . object ( ) ;
QMetaEnum metaEnum = QMetaEnum : : fromType < QPalette : : ColorRole > ( ) ;
for ( int i = 0 ; i < metaEnum . keyCount ( ) ; + + i ) {
QJsonValue v = o . value ( metaEnum . valueToKey ( i ) ) ;
if ( ! v . isUndefined ( ) )
p . setColor ( static_cast < QPalette : : ColorRole > ( metaEnum . value ( i ) ) , QColor ( v . toString ( ) ) ) ;
}
}
QApplication : : setPalette ( p ) ;
// set UI Style
QString css ;
QString styleFilename = preferences . isThemeDark ( ) ? " style_dark_fusion.css " : " style_light_fusion.css " ;
QFile fstyle ( QString ( " :/themes/%1 " ) . arg ( styleFilename ) ) ;
// read from Documents TODO: remove this
if ( QFile : : exists ( QString ( " %1/%2 " ) . arg ( wd , " ms_style.css " ) ) )
fstyle . setFileName ( QString ( " %1/%2 " ) . arg ( wd , " ms_style.css " ) ) ;
if ( fstyle . open ( QFile : : ReadOnly | QFile : : Text ) ) {
QTextStream in ( & fstyle ) ;
css = in . readAll ( ) ;
}
css . replace ( " $voice1-bgcolor " , MScore : : selectColor [ 0 ] . name ( QColor : : HexRgb ) ) ;
css . replace ( " $voice2-bgcolor " , MScore : : selectColor [ 1 ] . name ( QColor : : HexRgb ) ) ;
css . replace ( " $voice3-bgcolor " , MScore : : selectColor [ 2 ] . name ( QColor : : HexRgb ) ) ;
css . replace ( " $voice4-bgcolor " , MScore : : selectColor [ 3 ] . name ( QColor : : HexRgb ) ) ;
qApp - > setStyleSheet ( css ) ;
genIcons ( ) ;
Shortcut : : refreshIcons ( ) ;
}
2013-05-13 18:49:17 +02:00
}
using namespace Ms ;
//---------------------------------------------------------
// main
//---------------------------------------------------------
int main ( int argc , char * av [ ] )
{
2016-02-04 11:27:47 +01:00
# ifndef NDEBUG
2016-03-23 12:23:02 +01:00
qSetMessagePattern ( " %{file}:%{function}: %{message} " ) ;
2017-01-16 20:51:12 +01:00
Ms : : checkStyles ( ) ;
2016-02-04 11:27:47 +01:00
# endif
2015-01-07 17:16:58 +01:00
QApplication : : setDesktopSettingsAware ( true ) ;
2017-09-20 17:38:32 +02:00
QApplication : : setAttribute ( Qt : : AA_UseHighDpiPixmaps ) ;
QApplication : : setAttribute ( Qt : : AA_EnableHighDpiScaling ) ;
2013-05-16 16:12:22 +02:00
# if defined(QT_DEBUG) && defined(Q_OS_WIN)
2014-03-04 13:06:23 +01:00
qInstallMessageHandler ( mscoreMessageHandler ) ;
2013-05-13 18:49:17 +02:00
# endif
2017-11-29 08:21:36 +01:00
qRegisterMetaTypeStreamOperators < SessionStart > ( " SessionStart " ) ;
qRegisterMetaTypeStreamOperators < MusicxmlExportBreaks > ( " MusicxmlExportBreaks " ) ;
qRegisterMetaTypeStreamOperators < MuseScoreStyleType > ( " MuseScoreStyleType " ) ;
2013-05-13 18:49:17 +02:00
QFile f ( " :/revision.h " ) ;
f . open ( QIODevice : : ReadOnly ) ;
revision = QString ( f . readAll ( ) ) . trimmed ( ) ;
f . close ( ) ;
2017-05-02 14:17:31 +02:00
const char * appName ;
const char * appName2 ;
2015-05-06 17:38:18 +02:00
if ( MuseScore : : unstable ( ) ) {
2017-05-02 14:17:31 +02:00
appName2 = " mscore-dev3 " ;
appName = " MuseScoreDevelopment " ;
2015-05-06 17:38:18 +02:00
}
else {
2017-05-02 14:17:31 +02:00
appName2 = " mscore3 " ;
appName = " MuseScore3 " ;
2015-05-06 17:38:18 +02:00
}
2017-11-27 09:56:41 +01:00
2017-05-02 14:17:31 +02:00
MuseScoreApplication * app = new MuseScoreApplication ( appName2 , argc , av ) ;
QCoreApplication : : setApplicationName ( appName ) ;
2013-05-13 18:49:17 +02:00
QCoreApplication : : setOrganizationName ( " MuseScore " ) ;
QCoreApplication : : setOrganizationDomain ( " musescore.org " ) ;
2015-03-09 17:20:23 +01:00
QCoreApplication : : setApplicationVersion ( VERSION ) ;
2017-05-02 14:17:31 +02:00
2014-07-10 14:13:37 +02:00
QAccessible : : installFactory ( AccessibleScoreView : : ScoreViewFactory ) ;
2015-02-01 20:50:01 +01:00
QAccessible : : installFactory ( AccessibleSearchBox : : SearchBoxFactory ) ;
2014-11-24 20:23:01 +01:00
QAccessible : : installFactory ( Awl : : AccessibleAbstractSlider : : AbstractSliderFactory ) ;
2013-05-13 18:49:17 +02:00
Q_INIT_RESOURCE ( zita ) ;
2013-05-16 16:12:22 +02:00
# ifndef Q_OS_MAC
2013-05-13 18:49:17 +02:00
QSettings : : setDefaultFormat ( QSettings : : IniFormat ) ;
# endif
2015-05-06 17:38:18 +02:00
QCommandLineParser parser ;
parser . addHelpOption ( ) ; // -?, -h, --help
parser . addVersionOption ( ) ; // -v, --version
2015-05-06 09:08:20 +02:00
2015-05-06 19:31:32 +02:00
//parser.addOption(QCommandLineOption({"v", "version"}, "Print version")); // see above
parser . addOption ( QCommandLineOption ( " long-version " , " Print detailed version information " ) ) ;
parser . addOption ( QCommandLineOption ( { " d " , " debug " } , " Debug mode " ) ) ;
2017-05-18 23:29:14 +02:00
parser . addOption ( QCommandLineOption ( { " L " , " layout-debug " } , " Layout debug mode " ) ) ;
2015-05-06 19:31:32 +02:00
parser . addOption ( QCommandLineOption ( { " s " , " no-synthesizer " } , " No internal synthesizer " ) ) ;
2017-05-18 23:29:14 +02:00
parser . addOption ( QCommandLineOption ( { " m " , " no-midi " } , " No MIDI " ) ) ;
2015-05-06 19:31:32 +02:00
parser . addOption ( QCommandLineOption ( { " a " , " use-audio " } , " Use audio driver: jack, alsa, pulse, or portaudio " , " driver " ) ) ;
parser . addOption ( QCommandLineOption ( { " n " , " new-score " } , " Start with new score " ) ) ;
parser . addOption ( QCommandLineOption ( { " I " , " dump-midi-in " } , " Dump midi input " ) ) ;
parser . addOption ( QCommandLineOption ( { " O " , " dump-midi-out " } , " Dump midi output " ) ) ;
2017-05-18 23:29:14 +02:00
parser . addOption ( QCommandLineOption ( { " o " , " export-to " } , " Export to 'file'. Format depends on file's extension " , " file " ) ) ;
parser . addOption ( QCommandLineOption ( { " r " , " image-resolution " } , " Used with '-o <file>.png'. Set output resolution for image export " , " DPI " ) ) ;
parser . addOption ( QCommandLineOption ( { " T " , " trim-image " } , " Used with '-o <file>.png' and '-o <file.svg>'. Trim exported image with specified margin (in pixels) " , " margin " ) ) ;
2015-05-06 19:31:32 +02:00
parser . addOption ( QCommandLineOption ( { " x " , " gui-scaling " } , " Set scaling factor for GUI elements " , " factor " ) ) ;
2017-05-18 23:29:14 +02:00
parser . addOption ( QCommandLineOption ( { " D " , " monitor-resolution " } , " Specify monitor resolution " , " DPI " ) ) ;
2015-05-06 19:31:32 +02:00
parser . addOption ( QCommandLineOption ( { " S " , " style " } , " Load style file " , " style " ) ) ;
2017-01-18 20:56:41 +01:00
parser . addOption ( QCommandLineOption ( { " p " , " plugin " } , " Execute named plugin " , " name " ) ) ;
2015-05-06 19:31:32 +02:00
parser . addOption ( QCommandLineOption ( " template-mode " , " Save template mode, no page size " ) ) ;
parser . addOption ( QCommandLineOption ( { " F " , " factory-settings " } , " Use factory settings " ) ) ;
parser . addOption ( QCommandLineOption ( { " R " , " revert-settings " } , " Revert to default preferences " ) ) ;
parser . addOption ( QCommandLineOption ( { " i " , " load-icons " } , " Load icons from INSTALLPATH/icons " ) ) ;
2017-05-18 23:29:14 +02:00
parser . addOption ( QCommandLineOption ( { " j " , " job " } , " Process a conversion job " , " file " ) ) ;
2015-05-06 19:31:32 +02:00
parser . addOption ( QCommandLineOption ( { " e " , " experimental " } , " Enable experimental features " ) ) ;
2017-05-18 23:29:14 +02:00
parser . addOption ( QCommandLineOption ( { " c " , " config-folder " } , " Override configuration and settings folder " , " dir " ) ) ;
parser . addOption ( QCommandLineOption ( { " t " , " test-mode " } , " Set test mode flag for all files " ) ) ;
2015-05-06 19:31:32 +02:00
parser . addOption ( QCommandLineOption ( { " M " , " midi-operations " } , " Specify MIDI import operations file " , " file " ) ) ;
parser . addOption ( QCommandLineOption ( { " w " , " no-webview " } , " No web view in start center " ) ) ;
2017-05-18 23:29:14 +02:00
parser . addOption ( QCommandLineOption ( { " P " , " export-score-parts " } , " Used with '-o <file>.pdf', export score and parts " ) ) ;
parser . addOption ( QCommandLineOption ( " no-fallback-font " , " Don't use Bravura as fallback musical font " ) ) ;
parser . addOption ( QCommandLineOption ( { " f " , " force " } , " Used with '-o <file>', ignore warnings reg. score being corrupted or from wrong version " ) ) ;
2018-05-05 15:30:35 +02:00
parser . addOption ( QCommandLineOption ( { " b " , " bitrate " } , " Used with '-o <file>.mp3', sets bitrate, in kbps " , " bitrate " ) ) ;
2015-05-06 09:08:20 +02:00
2015-05-06 17:38:18 +02:00
parser . addPositionalArgument ( " scorefiles " , " The files to open " , " [scorefile...] " ) ;
parser . process ( QCoreApplication : : arguments ( ) ) ;
//if (parser.isSet("v")) parser.showVersion(); // a) needs Qt >= 5.4 , b) instead we use addVersionOption()
if ( parser . isSet ( " long-version " ) ) {
printVersion ( " MuseScore " ) ;
return EXIT_SUCCESS ;
}
MScore : : debugMode = parser . isSet ( " d " ) ;
2016-06-02 12:12:40 +02:00
MScore : : noHorizontalStretch = MScore : : noVerticalStretch = parser . isSet ( " L " ) ;
2015-05-06 17:38:18 +02:00
noSeq = parser . isSet ( " s " ) ;
noMidi = parser . isSet ( " m " ) ;
if ( parser . isSet ( " a " ) ) {
audioDriver = parser . value ( " a " ) ;
if ( audioDriver . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
}
startWithNewScore = parser . isSet ( " n " ) ;
externalIcons = parser . isSet ( " i " ) ;
midiInputTrace = parser . isSet ( " I " ) ;
midiOutputTrace = parser . isSet ( " O " ) ;
2016-10-07 13:21:05 +02:00
MScore : : useFallbackFont = ! parser . isSet ( " no-fallback-font " ) ;
2016-05-14 13:11:41 +02:00
2015-05-06 17:38:18 +02:00
if ( ( converterMode = parser . isSet ( " o " ) ) ) {
MScore : : noGui = true ;
outFileName = parser . value ( " o " ) ;
if ( outFileName . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
}
2016-05-14 13:11:41 +02:00
if ( ( processJob = parser . isSet ( " j " ) ) ) {
MScore : : noGui = true ;
converterMode = true ;
jsonFileName = parser . value ( " j " ) ;
if ( jsonFileName . isEmpty ( ) ) {
fprintf ( stderr , " json file name missing \n " ) ;
parser . showHelp ( EXIT_FAILURE ) ;
}
}
2015-05-06 17:38:18 +02:00
if ( ( pluginMode = parser . isSet ( " p " ) ) ) {
MScore : : noGui = true ;
pluginName = parser . value ( " p " ) ;
if ( pluginName . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
}
MScore : : saveTemplateMode = parser . isSet ( " template-mode " ) ;
if ( parser . isSet ( " r " ) ) {
QString temp = parser . value ( " r " ) ;
if ( temp . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
2018-05-05 15:30:35 +02:00
bool ok = false ;
double res = temp . toDouble ( & ok ) ;
if ( ok )
preferences . setTemporaryPreference ( PREF_EXPORT_PNG_RESOLUTION , res ) ;
else
fprintf ( stderr , " PNG resolution value '%s' not recognized, using default setting from preferences instead. \n " , qPrintable ( temp ) ) ;
2015-05-06 17:38:18 +02:00
}
if ( parser . isSet ( " T " ) ) {
QString temp = parser . value ( " T " ) ;
if ( temp . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
2016-05-28 22:56:06 +02:00
bool ok = false ;
trimMargin = temp . toInt ( & ok ) ;
2018-05-05 15:30:35 +02:00
if ( ! ok ) {
fprintf ( stderr , " Trim margin value '%s' not recognized, so no trimming will be done. \n " , qPrintable ( temp ) ) ;
2016-05-28 22:56:06 +02:00
trimMargin = - 1 ;
2018-05-05 15:30:35 +02:00
}
2015-05-06 17:38:18 +02:00
}
if ( parser . isSet ( " x " ) ) {
QString temp = parser . value ( " x " ) ;
if ( temp . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
2016-05-28 22:56:06 +02:00
bool ok = false ;
guiScaling = temp . toDouble ( & ok ) ;
2018-05-05 15:30:35 +02:00
if ( ! ok ) {
fprintf ( stderr , " GUI scaling value '%s' not recognized, so the values detected by Qt are taken. \n " , qPrintable ( temp ) ) ;
2016-05-28 22:56:06 +02:00
guiScaling = 0.0 ;
2018-05-05 15:30:35 +02:00
}
2016-05-28 22:56:06 +02:00
}
if ( parser . isSet ( " D " ) ) {
QString temp = parser . value ( " D " ) ;
if ( temp . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
2018-05-05 15:30:35 +02:00
bool ok = false ;
2016-05-28 22:56:06 +02:00
userDPI = temp . toDouble ( & ok ) ;
2018-05-05 15:30:35 +02:00
if ( ! ok ) {
fprintf ( stderr , " DPI value '%s' not recognized, so the values detected by Qt are taken. \n " , qPrintable ( temp ) ) ;
2016-05-28 22:56:06 +02:00
userDPI = 0.0 ;
2018-05-05 15:30:35 +02:00
}
2015-05-06 17:38:18 +02:00
}
if ( parser . isSet ( " S " ) ) {
styleFile = parser . value ( " S " ) ;
if ( styleFile . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
}
useFactorySettings = parser . isSet ( " F " ) ;
deletePreferences = ( useFactorySettings | | parser . isSet ( " R " ) ) ;
enableExperimental = parser . isSet ( " e " ) ;
if ( parser . isSet ( " c " ) ) {
QString path = parser . value ( " c " ) ;
if ( path . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
QDir dir ;
if ( dir . exists ( path ) ) {
QSettings : : setPath ( QSettings : : IniFormat , QSettings : : UserScope , path ) ;
QSettings : : setPath ( QSettings : : IniFormat , QSettings : : SystemScope , path ) ;
dataPath = path ;
2013-05-13 18:49:17 +02:00
}
2013-02-21 11:04:41 +01:00
}
2017-03-31 13:03:15 +02:00
MScore : : testMode = parser . isSet ( " t " ) ;
2015-05-06 17:38:18 +02:00
if ( parser . isSet ( " M " ) ) {
QString temp = parser . value ( " M " ) ;
if ( temp . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
2017-11-29 08:21:36 +01:00
midiImportOperations . setOperationsFile ( temp ) ;
2015-05-06 17:38:18 +02:00
}
noWebView = parser . isSet ( " w " ) ;
2015-05-06 09:08:20 +02:00
exportScoreParts = parser . isSet ( " export-score-parts " ) ;
if ( exportScoreParts & & ! converterMode )
parser . showHelp ( EXIT_FAILURE ) ;
2016-05-03 14:23:09 +02:00
ignoreWarnings = parser . isSet ( " f " ) ;
2017-02-17 17:51:17 +01:00
if ( parser . isSet ( " b " ) ) {
QString temp = parser . value ( " b " ) ;
if ( temp . isEmpty ( ) )
parser . showHelp ( EXIT_FAILURE ) ;
bool ok = false ;
2017-11-29 08:21:36 +01:00
int rate = temp . toInt ( & ok ) ;
if ( ok )
preferences . setTemporaryPreference ( PREF_EXPORT_MP3_BITRATE , rate ) ;
2018-05-05 15:30:35 +02:00
else
fprintf ( stderr , " MP3 bitrate value '%s' not recognized, using default setting from preferences instead. \n " , qPrintable ( temp ) ) ;
2017-02-17 17:51:17 +01:00
}
2015-05-06 17:38:18 +02:00
QStringList argv = parser . positionalArguments ( ) ;
2013-05-13 18:49:17 +02:00
mscoreGlobalShare = getSharePath ( ) ;
2013-07-05 18:54:11 +02:00
iconPath = externalIcons ? mscoreGlobalShare + QString ( " icons/ " ) : QString ( " :/data/icons/ " ) ;
2013-05-13 18:49:17 +02:00
2015-03-04 16:44:03 +01:00
if ( ! converterMode & & ! pluginMode ) {
2013-05-13 18:49:17 +02:00
if ( ! argv . isEmpty ( ) ) {
int ok = true ;
2016-05-14 13:11:41 +02:00
for ( const QString & message : argv ) {
2013-05-13 18:49:17 +02:00
QFileInfo fi ( message ) ;
if ( ! app - > sendMessage ( fi . absoluteFilePath ( ) ) ) {
ok = false ;
break ;
}
2017-11-27 09:56:41 +01:00
2013-05-13 18:49:17 +02:00
}
if ( ok )
return 0 ;
2012-05-26 14:49:10 +02:00
}
else
2015-01-07 13:47:03 +01:00
if ( app - > sendMessage ( QString ( " " ) ) )
2013-05-13 18:49:17 +02:00
return 0 ;
2012-05-26 14:49:10 +02:00
}
2017-11-27 09:56:41 +01:00
2013-05-13 18:49:17 +02:00
if ( dataPath . isEmpty ( ) )
2016-04-18 19:23:45 +02:00
dataPath = QStandardPaths : : writableLocation ( QStandardPaths : : DataLocation ) ;
2014-06-03 15:28:10 +02:00
2014-05-13 14:47:18 +02:00
if ( deletePreferences ) {
QDir ( dataPath ) . removeRecursively ( ) ;
QSettings settings ;
2015-08-31 03:57:31 +02:00
QFile : : remove ( settings . fileName ( ) + " .lock " ) ; //forcibly remove lock
2014-05-13 14:47:18 +02:00
QFile : : remove ( settings . fileName ( ) ) ;
2016-02-03 19:20:45 +01:00
settings . clear ( ) ;
2014-05-13 14:47:18 +02:00
}
2014-06-03 15:28:10 +02:00
2013-05-13 18:49:17 +02:00
// create local plugin directory
// if not already there:
2015-01-07 13:47:03 +01:00
QDir ( ) . mkpath ( dataPath + " /plugins " ) ;
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
if ( MScore : : debugMode )
qDebug ( " global share: <%s> " , qPrintable ( mscoreGlobalShare ) ) ;
2012-05-26 14:49:10 +02:00
2017-11-29 08:21:36 +01:00
// set translator before Shortcut are initialized to get translations for all shortcuts
// can not use preferences to retrieve these values as it needs to be initialized after translator is set
2013-05-13 18:49:17 +02:00
if ( useFactorySettings )
localeName = " system " ;
2012-05-26 14:49:10 +02:00
else {
2013-05-13 18:49:17 +02:00
QSettings s ;
2017-11-29 08:21:36 +01:00
localeName = s . value ( PREF_UI_APP_LANGUAGE , " system " ) . toString ( ) ;
2012-05-26 14:49:10 +02:00
}
2014-06-03 15:28:10 +02:00
2013-05-13 18:49:17 +02:00
setMscoreLocale ( localeName ) ;
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
Shortcut : : init ( ) ;
preferences . init ( ) ;
2012-05-26 14:49:10 +02:00
2013-10-02 10:05:54 +02:00
QNetworkProxyFactory : : setUseSystemConfiguration ( true ) ;
2017-03-09 13:37:40 +01:00
MScore : : init ( ) ; // initialize libmscore
2017-11-29 08:21:36 +01:00
updateExternalValuesFromPreferences ( ) ;
2017-03-09 13:37:40 +01:00
// initialize current page size from default printer
2017-03-21 11:30:46 +01:00
# ifndef QT_NO_PRINTER
2017-05-02 14:17:31 +02:00
if ( ! MScore : : testMode ) {
2017-03-09 13:37:40 +01:00
QPrinter p ;
if ( p . isValid ( ) ) {
2018-04-09 11:51:35 +02:00
// qDebug("set paper size from default printer");
2017-03-09 13:37:40 +01:00
QRectF psf = p . paperRect ( QPrinter : : Inch ) ;
2018-03-27 15:36:00 +02:00
MScore : : defaultStyle ( ) . set ( Sid : : pageWidth , psf . width ( ) ) ;
MScore : : defaultStyle ( ) . set ( Sid : : pageHeight , psf . height ( ) ) ;
MScore : : defaultStyle ( ) . set ( Sid : : pagePrintableWidth , psf . width ( ) - 20.0 / INCH ) ;
2017-03-09 13:37:40 +01:00
}
2014-05-19 15:19:36 +02:00
}
2017-05-02 14:17:31 +02:00
# endif
2012-05-26 14:49:10 +02:00
2014-04-25 19:26:22 +02:00
# ifdef SCRIPT_INTERFACE
2017-06-28 15:18:59 +02:00
if ( - 1 = = qmlRegisterType < QmlPlugin > ( " MuseScore " , 3 , 0 , " MuseScore " ) )
qDebug ( " qmlRegisterType failed: MuseScore " ) ;
2014-04-25 19:26:22 +02:00
# endif
2013-10-30 09:42:08 +01:00
if ( MScore : : debugMode ) {
2015-11-16 14:24:47 +01:00
qDebug ( " DPI %f " , DPI ) ;
2012-05-26 14:49:10 +02:00
2015-11-16 14:24:47 +01:00
QScreen * screen = QGuiApplication : : primaryScreen ( ) ;
2013-10-30 09:42:08 +01:00
qDebug ( ) < < " Information for screen: " < < screen - > name ( ) ;
qDebug ( ) < < " Available geometry: " < < screen - > availableGeometry ( ) . x ( ) < < screen - > availableGeometry ( ) . y ( ) < < screen - > availableGeometry ( ) . width ( ) < < " x " < < screen - > availableGeometry ( ) . height ( ) ;
qDebug ( ) < < " Available size: " < < screen - > availableSize ( ) . width ( ) < < " x " < < screen - > availableSize ( ) . height ( ) ;
qDebug ( ) < < " Available virtual geometry: " < < screen - > availableVirtualGeometry ( ) . x ( ) < < screen - > availableVirtualGeometry ( ) . y ( ) < < screen - > availableVirtualGeometry ( ) . width ( ) < < " x " < < screen - > availableVirtualGeometry ( ) . height ( ) ;
qDebug ( ) < < " Available virtual size: " < < screen - > availableVirtualSize ( ) . width ( ) < < " x " < < screen - > availableVirtualSize ( ) . height ( ) ;
qDebug ( ) < < " Depth: " < < screen - > depth ( ) < < " bits " ;
qDebug ( ) < < " Geometry: " < < screen - > geometry ( ) . x ( ) < < screen - > geometry ( ) . y ( ) < < screen - > geometry ( ) . width ( ) < < " x " < < screen - > geometry ( ) . height ( ) ;
qDebug ( ) < < " Logical DPI: " < < screen - > logicalDotsPerInch ( ) ;
qDebug ( ) < < " Logical DPI X: " < < screen - > logicalDotsPerInchX ( ) ;
qDebug ( ) < < " Logical DPI Y: " < < screen - > logicalDotsPerInchY ( ) ;
qDebug ( ) < < " Physical DPI: " < < screen - > physicalDotsPerInch ( ) ;
qDebug ( ) < < " Physical DPI X: " < < screen - > physicalDotsPerInchX ( ) ;
qDebug ( ) < < " Physical DPI Y: " < < screen - > physicalDotsPerInchY ( ) ;
qDebug ( ) < < " Physical size: " < < screen - > physicalSize ( ) . width ( ) < < " x " < < screen - > physicalSize ( ) . height ( ) < < " mm " ;
qDebug ( ) < < " Refresh rate: " < < screen - > refreshRate ( ) < < " Hz " ;
qDebug ( ) < < " Size: " < < screen - > size ( ) . width ( ) < < " x " < < screen - > size ( ) . height ( ) ;
qDebug ( ) < < " Virtual geometry: " < < screen - > virtualGeometry ( ) . x ( ) < < screen - > virtualGeometry ( ) . y ( ) < < screen - > virtualGeometry ( ) . width ( ) < < " x " < < screen - > virtualGeometry ( ) . height ( ) ;
qDebug ( ) < < " Virtual size: " < < screen - > virtualSize ( ) . width ( ) < < " x " < < screen - > virtualSize ( ) . height ( ) ;
}
2013-10-08 20:03:34 +02:00
2017-03-31 13:03:15 +02:00
if ( ! MScore : : testMode )
2017-11-29 08:21:36 +01:00
MScore : : readDefaultStyle ( preferences . getString ( PREF_SCORE_STYLE_DEFAULTSTYLEFILE ) ) ;
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
QSplashScreen * sc = 0 ;
2014-11-10 10:05:25 +01:00
QTimer * stimer = 0 ;
2017-11-29 08:21:36 +01:00
if ( ! MScore : : noGui & & preferences . getBool ( PREF_UI_APP_STARTUP_SHOWSPLASHSCREEN ) ) {
2014-12-18 21:02:04 +01:00
QPixmap pm ( " :/data/splash.png " ) ;
2013-05-13 18:49:17 +02:00
sc = new QSplashScreen ( pm ) ;
sc - > setWindowTitle ( QString ( " MuseScore Startup " ) ) ;
2014-05-12 15:58:57 +02:00
# ifdef Q_OS_MAC // to have session dialog on top of splashscreen on mac
sc - > setWindowFlags ( Qt : : FramelessWindowHint ) ;
# endif
2014-11-14 11:44:48 +01:00
// show splash screen for 5 sec
2014-11-10 10:05:25 +01:00
stimer = new QTimer ( 0 ) ;
qApp - > connect ( stimer , SIGNAL ( timeout ( ) ) , sc , SLOT ( close ( ) ) ) ;
stimer - > start ( 5000 ) ;
2013-05-13 18:49:17 +02:00
sc - > show ( ) ;
qApp - > processEvents ( ) ;
2012-05-26 14:49:10 +02:00
}
2015-03-04 15:54:50 +01:00
if ( ! converterMode & & ! pluginMode ) {
2018-02-15 11:33:44 +01:00
MuseScore : : updateUiStyleAndTheme ( ) ;
2014-10-17 19:22:58 +02:00
}
else
noSeq = true ;
2013-07-16 18:16:16 +02:00
2015-11-03 23:05:59 +01:00
genIcons ( ) ;
2014-10-17 19:22:58 +02:00
// Do not create sequencer and audio drivers if run with '-s'
if ( ! noSeq ) {
2013-05-13 18:49:17 +02:00
seq = new Seq ( ) ;
MScore : : seq = seq ;
Driver * driver = driverFactory ( seq , audioDriver ) ;
2014-10-17 19:22:58 +02:00
synti = synthesizerFactory ( ) ;
2013-05-13 18:49:17 +02:00
if ( driver ) {
MScore : : sampleRate = driver - > sampleRate ( ) ;
synti - > setSampleRate ( MScore : : sampleRate ) ;
synti - > init ( ) ;
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
seq - > setDriver ( driver ) ;
}
else {
2014-10-11 15:32:34 +02:00
// Do not delete the sequencer If we can't load driver.
// Allow user to select the working driver later.
MScore : : sampleRate = 44100 ; // Would be changed when user changes driver
synti - > setSampleRate ( MScore : : sampleRate ) ;
synti - > init ( ) ;
2013-05-13 18:49:17 +02:00
}
2014-10-11 15:32:34 +02:00
seq - > setMasterSynthesizer ( synti ) ;
2013-05-13 18:49:17 +02:00
}
2014-10-17 19:22:58 +02:00
else {
seq = 0 ;
MScore : : seq = 0 ;
}
2017-05-02 14:17:31 +02:00
//---
2013-05-13 18:49:17 +02:00
//
// avoid font problems by overriding the environment
// fall back to "C" locale
//
2012-05-26 14:49:10 +02:00
2013-10-08 19:25:04 +02:00
//#ifndef Q_OS_WIN
//setenv("LANG", "C", 1);
//#endif
//QLocale::setDefault(QLocale(QLocale::C));
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
if ( MScore : : debugMode ) {
QStringList sl ( QCoreApplication : : libraryPaths ( ) ) ;
foreach ( const QString & s , sl )
qDebug ( " LibraryPath: <%s> " , qPrintable ( s ) ) ;
}
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
// rastral size of font is 20pt = 20/72 inch = 20*DPI/72 dots
// staff has 5 lines = 4 * _spatium
2015-11-16 14:24:47 +01:00
// _spatium = SPATIUM20; // 20.0 / 72.0 * DPI / 4.0;
2012-05-26 14:49:10 +02:00
2014-11-18 16:17:28 +01:00
if ( ! MScore : : noGui ) {
2015-02-10 16:15:56 +01:00
# ifndef Q_OS_MAC
2014-06-02 18:13:14 +02:00
qApp - > setWindowIcon ( * icons [ int ( Icons : : window_ICON ) ] ) ;
2015-02-10 16:15:56 +01:00
# endif
2014-11-18 16:17:28 +01:00
Workspace : : initWorkspace ( ) ;
}
2013-05-13 18:49:17 +02:00
mscore = new MuseScore ( ) ;
2014-07-23 17:08:48 +02:00
// create a score for internal use
2017-01-05 11:23:47 +01:00
gscore = new MasterScore ( ) ;
gscore - > setMovements ( new Movements ( ) ) ;
gscore - > setStyle ( MScore : : baseStyle ( ) ) ;
2018-03-27 15:36:00 +02:00
gscore - > style ( ) . set ( Sid : : MusicalTextFont , QString ( " Bravura Text " ) ) ;
2014-03-20 20:02:17 +01:00
ScoreFont * scoreFont = ScoreFont : : fontFactory ( " Bravura " ) ;
gscore - > setScoreFont ( scoreFont ) ;
2015-11-16 14:24:47 +01:00
gscore - > setNoteHeadWidth ( scoreFont - > width ( SymId : : noteheadBlack , gscore - > spatium ( ) ) / SPATIUM20 ) ;
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
if ( ! noSeq ) {
2014-10-11 15:32:34 +02:00
if ( ! seq - > init ( ) )
2013-05-13 18:49:17 +02:00
qDebug ( " sequencer init failed " ) ;
2012-08-15 17:43:31 +02:00
}
2013-05-13 18:49:17 +02:00
//read languages list
mscore - > readLanguages ( mscoreGlobalShare + " locale/languages.xml " ) ;
2013-04-23 16:20:02 +02:00
2017-07-18 09:45:00 +02:00
if ( ! MScore : : noGui ) {
QSettings s ;
if ( ! s . contains ( " firstStart " ) ) {
StartupWizard * sw = new StartupWizard ;
sw - > exec ( ) ;
s . setValue ( " firstStart " , false ) ;
s . setValue ( " keyboardLayout " , sw - > keyboardLayout ( ) ) ;
2017-11-29 08:21:36 +01:00
preferences . setPreference ( PREF_UI_APP_LANGUAGE , sw - > language ( ) ) ;
2017-07-18 09:45:00 +02:00
setMscoreLocale ( sw - > language ( ) ) ;
for ( auto ws : Workspace : : workspaces ( ) ) {
if ( ws - > name ( ) . compare ( sw - > workspace ( ) ) = = 0 ) {
mscore - > changeWorkspace ( ws ) ;
2017-11-29 08:21:36 +01:00
preferences . setPreference ( PREF_APP_WORKSPACE , ws - > name ( ) ) ;
2017-07-18 09:45:00 +02:00
mscore - > getPaletteBox ( ) - > updateWorkspaces ( ) ;
2017-08-01 10:52:35 +02:00
}
2017-07-18 09:45:00 +02:00
}
delete sw ;
}
QString keyboardLayout = s . value ( " keyboardLayout " ) . toString ( ) ;
StartupWizard : : autoSelectShortcuts ( keyboardLayout ) ;
}
2013-05-13 18:49:17 +02:00
QApplication : : instance ( ) - > installEventFilter ( mscore ) ;
2015-01-29 00:19:44 +01:00
2013-05-13 18:49:17 +02:00
mscore - > setRevision ( revision ) ;
int files = 0 ;
2015-02-23 14:48:26 +01:00
bool restoredSession = false ;
2014-02-28 11:14:43 +01:00
if ( MScore : : noGui ) {
2014-08-17 12:43:16 +02:00
# ifdef Q_OS_MAC
// see issue #28706: Hangup in converter mode with MusicXML source
qApp - > processEvents ( ) ;
# endif
2016-05-14 13:11:41 +02:00
exit ( processNonGui ( argv ) ? 0 : EXIT_FAILURE ) ;
2013-05-13 18:49:17 +02:00
}
else {
mscore - > readSettings ( ) ;
QObject : : connect ( qApp , SIGNAL ( messageReceived ( const QString & ) ) ,
mscore , SLOT ( handleMessage ( const QString & ) ) ) ;
2013-04-23 16:20:02 +02:00
2013-07-10 17:00:21 +02:00
static_cast < QtSingleApplication * > ( qApp ) - > setActivationWindow ( mscore , false ) ;
2013-06-24 22:07:44 +02:00
// count filenames specified on the command line
// these are the non-empty strings remaining in argv
2013-05-13 18:49:17 +02:00
foreach ( const QString & name , argv ) {
if ( ! name . isEmpty ( ) )
+ + files ;
}
2018-02-12 11:34:54 +01:00
# ifdef Q_OS_MAC
2013-06-24 22:07:44 +02:00
// app->paths contains files requested to be loaded by OS X
// append these to argv and update file count
foreach ( const QString & name , app - > paths ) {
if ( ! name . isEmpty ( ) ) {
argv < < name ;
+ + files ;
}
2013-05-13 18:49:17 +02:00
}
2013-06-24 22:07:44 +02:00
# endif
2013-05-13 18:49:17 +02:00
//
// TODO: delete old session backups
//
2017-11-29 08:21:36 +01:00
restoredSession = mscore - > restoreSession ( ( preferences . sessionStart ( ) = = SessionStart : : LAST & & ( files = = 0 ) ) ) ;
2015-02-23 14:48:26 +01:00
if ( ! restoredSession | | files )
2013-05-13 18:49:17 +02:00
loadScores ( argv ) ;
}
2017-05-02 14:17:31 +02:00
2013-07-17 14:36:34 +02:00
errorMessage = new QErrorMessage ( mscore ) ;
2017-11-29 08:21:36 +01:00
mscore - > getPluginManager ( ) - > readPluginList ( ) ;
2013-05-13 18:49:17 +02:00
mscore - > loadPlugins ( ) ;
mscore - > writeSessionFile ( false ) ;
2013-04-23 16:20:02 +02:00
2013-05-16 16:12:22 +02:00
# ifdef Q_OS_MAC
2013-05-13 18:49:17 +02:00
// there's a bug in Qt showing the toolbar unified after switching showFullScreen(), showMaximized(),
// showNormal()...
mscore - > setUnifiedTitleAndToolBarOnMac ( false ) ;
2018-02-12 11:34:54 +01:00
// don't let macOS add "Show Tab Bar" to "View" Menu
CocoaBridge : : setAllowsAutomaticWindowTabbing ( false ) ;
2013-05-13 18:49:17 +02:00
# endif
2013-04-23 16:20:02 +02:00
2013-05-13 18:49:17 +02:00
mscore - > changeState ( mscore - > noScore ( ) ? STATE_DISABLED : STATE_NORMAL ) ;
mscore - > show ( ) ;
2013-04-23 16:20:02 +02:00
2013-05-13 18:49:17 +02:00
if ( mscore - > hasToCheckForUpdate ( ) )
mscore - > checkForUpdate ( ) ;
2014-11-14 11:44:48 +01:00
2017-11-29 08:21:36 +01:00
if ( ! scoresOnCommandline & & preferences . getBool ( PREF_UI_APP_STARTUP_SHOWSTARTCENTER ) & & ( ! restoredSession | | mscore - > scores ( ) . size ( ) = = 0 ) ) {
2015-02-23 17:34:40 +01:00
# ifdef Q_OS_MAC
// ugly, but on mac we get an event when a file is open.
// We can't get the event when the startcenter is shown.
// So we let the event loop run a bit before showing the start center.
2015-02-23 18:11:14 +01:00
QTimer * timer = new QTimer ( ) ;
timer - > setSingleShot ( true ) ;
QObject : : connect ( timer , & QTimer : : timeout , [ = ] ( ) {
2015-02-23 17:34:40 +01:00
if ( ! scoresOnCommandline ) {
getAction ( " startcenter " ) - > setChecked ( true ) ;
mscore - > showStartcenter ( true ) ;
}
2015-02-23 18:11:14 +01:00
timer - > deleteLater ( ) ;
} ) ;
timer - > start ( 500 ) ;
2015-02-23 17:34:40 +01:00
# else
2015-02-26 14:34:07 +01:00
2014-11-10 12:30:53 +01:00
getAction ( " startcenter " ) - > setChecked ( true ) ;
2014-11-10 10:05:25 +01:00
mscore - > showStartcenter ( true ) ;
2015-02-23 17:34:40 +01:00
# endif
2014-11-10 12:30:53 +01:00
}
2015-02-23 17:34:40 +01:00
2017-11-29 08:21:36 +01:00
mscore - > showPlayPanel ( preferences . getBool ( PREF_UI_APP_STARTUP_SHOWPLAYPANEL ) ) ;
2015-09-08 17:14:02 +02:00
QSettings settings ;
if ( settings . value ( " synthControlVisible " , false ) . toBool ( ) )
mscore - > showSynthControl ( true ) ;
if ( settings . value ( " mixerVisible " , false ) . toBool ( ) )
mscore - > showMixer ( true ) ;
2015-02-23 17:34:40 +01:00
2013-05-13 18:49:17 +02:00
return qApp - > exec ( ) ;
2013-04-23 16:20:02 +02:00
}