Skip to content

Commit

Permalink
Merge pull request #4085 from dmitrio95/277616-reset-positions
Browse files Browse the repository at this point in the history
fix #277616: ask for resetting positions when importing old scores
  • Loading branch information
anatoly-os committed Oct 31, 2018
2 parents 18a900b + 3f7b825 commit 77b832b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
26 changes: 26 additions & 0 deletions libmscore/cmd.cpp
Expand Up @@ -1900,6 +1900,32 @@ void Score::cmdResetNoteAndRestGroupings()
endCmd();
}

//---------------------------------------------------------
// resetElementShapePosition
// For use with Score::scanElements.
// Reset positions and autoplacement for the given
// element.
//---------------------------------------------------------

static void resetElementPosition(void*, Element* e)
{
e->undoResetProperty(Pid::AUTOPLACE);
e->undoResetProperty(Pid::OFFSET);
if (e->isSpanner())
e->undoResetProperty(Pid::OFFSET2);
}

//---------------------------------------------------------
// cmdResetAllPositions
//---------------------------------------------------------

void Score::cmdResetAllPositions()
{
startCmd();
scanElements(nullptr, resetElementPosition);
endCmd();
}

//---------------------------------------------------------
// processMidiInput
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/score.h
Expand Up @@ -586,6 +586,7 @@ class Score : public QObject, public ScoreElement {
void cmdAddOttava(OttavaType);
void cmdAddStretch(qreal);
void cmdResetNoteAndRestGroupings();
void cmdResetAllPositions();
void cmdDoubleDuration() { cmdIncDecDuration(-1, 0); }
void cmdHalfDuration() { cmdIncDecDuration( 1, 0); }
void cmdIncDurationDotted() { cmdIncDecDuration(-1, 1); }
Expand Down
1 change: 1 addition & 0 deletions mscore/file.cpp
Expand Up @@ -370,6 +370,7 @@ MasterScore* MuseScore::readScore(const QString& name)
allowShowMidiPanel(name);
if (score)
addRecentScore(score);

return score;
}

Expand Down
37 changes: 34 additions & 3 deletions mscore/musescore.cpp
Expand Up @@ -371,8 +371,10 @@ void MuseScore::closeEvent(QCloseEvent* ev)

// remove all new created/not save score so they are
// note saved as session data
for (MasterScore* score : removeList)
for (MasterScore* score : removeList) {
scoreList.removeAll(score);
scoreWasShown.remove(score);
}

writeSessionFile(true);
for (MasterScore* score : scoreList) {
Expand Down Expand Up @@ -2115,6 +2117,7 @@ int MuseScore::appendScore(MasterScore* score)
}
}
scoreList.insert(index, score);
scoreWasShown[score] = false;
tab1->insertTab(score);
if (tab2)
tab2->insertTab(score);
Expand Down Expand Up @@ -2235,6 +2238,27 @@ void MuseScore::reloadInstrumentTemplates()
}
}

//---------------------------------------------------------
// askResetOldScorePositions
//---------------------------------------------------------

void MuseScore::askResetOldScorePositions(Score* score)
{
if (score->mscVersion() < 300 && score->mscVersion() > 114) {
QMessageBox msgBox;
QString question = tr("Reset all elements positions?");
msgBox.setWindowTitle(question);
msgBox.setText(tr("This score was created in older versions of MuseScore. For a better experience of using MuseScore 3.0 it is recommended to reset elements positions to their default values.") + "\n\n" + question);
msgBox.setIcon(QMessageBox::Question);
msgBox.setStandardButtons(
QMessageBox::Yes | QMessageBox::No
);

if (msgBox.exec() == QMessageBox::Yes)
score->cmdResetAllPositions();
}
}

//---------------------------------------------------------
// setCurrentView
//---------------------------------------------------------
Expand Down Expand Up @@ -2382,6 +2406,11 @@ void MuseScore::setCurrentScoreView(ScoreView* view)
timeline()->setScoreView(view);
}
ScoreAccessibility::instance()->updateAccessibilityInfo();

if (!scoreWasShown[cs]) {
scoreWasShown[cs] = true;
askResetOldScorePositions(cs);
}
}

//---------------------------------------------------------
Expand Down Expand Up @@ -2885,6 +2914,7 @@ void MuseScore::removeTab(int i)

midiPanelOnCloseFile(score->importedFilePath());
scoreList.removeAt(i);
scoreWasShown.remove(score);

tab1->removeTab(i, /* noCurrentChangedSignals */ true);
if (tab2)
Expand Down Expand Up @@ -7075,8 +7105,6 @@ int main(int argc, char* av[])
// TODO: delete old session backups
//
restoredSession = mscore->restoreSession((preferences.sessionStart() == SessionStart::LAST && (files == 0)));
if (!restoredSession || files)
loadScores(argv);
}

errorMessage = new QErrorMessage(mscore);
Expand All @@ -7096,6 +7124,9 @@ int main(int argc, char* av[])
mscore->changeState(mscore->noScore() ? STATE_DISABLED : STATE_NORMAL);
mscore->show();

if (!restoredSession || files)
loadScores(argv);

#ifndef MSCORE_NO_UPDATE_CHECKER
if (mscore->hasToCheckForUpdate())
mscore->checkForUpdate();
Expand Down
2 changes: 2 additions & 0 deletions mscore/musescore.h
Expand Up @@ -221,6 +221,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {

QSettings settings;
ScoreView* cv { 0 };
QMap<Score*, bool> scoreWasShown; // whether each score in scoreList has ever been shown
ScoreState _sstate;
UpdateChecker* ucheck;
ExtensionsUpdateChecker* packUChecker = nullptr;
Expand Down Expand Up @@ -471,6 +472,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
void setPlayRepeats(bool repeat);

ScoreTab* createScoreTab();
void askResetOldScorePositions(Score* score);

QString getUtmParameters(QString medium) const;

Expand Down

0 comments on commit 77b832b

Please sign in to comment.