Skip to content

Commit

Permalink
fix #38811
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Nov 17, 2014
1 parent f53ca60 commit 9509480
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 24 deletions.
12 changes: 12 additions & 0 deletions libmscore/undo.cpp
Expand Up @@ -3841,4 +3841,16 @@ void ChangeStartEndSpanner::flip()
end = e;
}

//---------------------------------------------------------
// ChangeLayoutMode::flip
//---------------------------------------------------------

void ChangeLayoutMode::flip()
{
LayoutMode lm = score->layoutMode();
score->setLayoutMode(layoutMode);
layoutMode = lm;
score->setLayoutAll(true);
}

}
17 changes: 17 additions & 0 deletions libmscore/undo.h
Expand Up @@ -87,6 +87,8 @@ enum class PlayEventType : char;
#define UNDO_NAME(a)
#endif

enum class LayoutMode : char;

//---------------------------------------------------------
// UndoCommand
//---------------------------------------------------------
Expand Down Expand Up @@ -1425,6 +1427,21 @@ class ChangeStartEndSpanner : public UndoCommand {
UNDO_NAME("ChangeStartEndSpanner")
};

//---------------------------------------------------------
// ChangeLayoutMode
//---------------------------------------------------------

class ChangeLayoutMode : public UndoCommand {
Score* score;
LayoutMode layoutMode;

void flip();

public:
ChangeLayoutMode(Score* s, LayoutMode m) : score(s), layoutMode(m) {}
UNDO_NAME("ChangeLayoutMode")
};


} // namespace Ms
#endif
Expand Down
44 changes: 22 additions & 22 deletions mscore/musescore.cpp
Expand Up @@ -260,7 +260,7 @@ void MuseScore::closeEvent(QCloseEvent* ev)
}

writeSettings();

_loginManager->save();

ev->accept();
Expand Down Expand Up @@ -2412,7 +2412,7 @@ void MuseScore::changeState(ScoreState val)
a->setEnabled(s->state() & val);
}
}

if (getAction("file-part-export")->isEnabled())
getAction("file-part-export")->setEnabled(cs->rootScore()->excerpts().size() > 0);

Expand Down Expand Up @@ -3850,6 +3850,11 @@ void MuseScore::endCmd()

if (e == 0 && cs->noteEntryMode())
e = cs->inputState().cr();
if (cs->layoutMode() == LayoutMode::PAGE)
viewModeCombo->setCurrentIndex(0);
else
viewModeCombo->setCurrentIndex(1);

cs->end();
ScoreAccessibility::instance()->updateAccessibilityInfo();
}
Expand Down Expand Up @@ -4120,20 +4125,6 @@ void MuseScore::cmd(QAction* a, const QString& cmd)
;
else if (cmd == "countin") // no action
;
else if (cmd == "viewmode") {
if (cs) {
if (cs->layoutMode() == LayoutMode::PAGE) {
cs->setLayoutMode(LayoutMode::LINE);
viewModeCombo->setCurrentIndex(1);
}
else {
cs->setLayoutMode(LayoutMode::PAGE);
viewModeCombo->setCurrentIndex(0);
}
cs->doLayout();
cs->setUpdateAll(true);
}
}
else if (cmd == "lock") {
if (_sstate == STATE_LOCK)
changeState(STATE_NORMAL);
Expand All @@ -4154,7 +4145,14 @@ void MuseScore::cmd(QAction* a, const QString& cmd)
if (_textTools)
_textTools->toggleUnderline();
}

else if (cmd == "viewmode") {
if (cs) {
if (cs->layoutMode() == LayoutMode::PAGE)
switchLayoutMode(1);
else
switchLayoutMode(0);
}
}
else {
if (cv) {
//isAncestorOf is called to see if a widget from inspector has focus
Expand Down Expand Up @@ -4302,14 +4300,16 @@ void MuseScore::changeScore(int step)
void MuseScore::switchLayoutMode(int val)
{
if (cs) {
cs->startCmd();
LayoutMode mode;
if (val == 0)
cs->setLayoutMode(LayoutMode::PAGE);
mode = LayoutMode::PAGE;
else
cs->setLayoutMode(LayoutMode::LINE);
cs->doLayout();
cs->setUpdateAll(true);
cv->update();
mode = LayoutMode::LINE;
cs->undo(new ChangeLayoutMode(cs, mode));
cv->loopUpdate(getAction("loop")->isChecked());
cs->endCmd();
endCmd();
}
}

Expand Down
9 changes: 7 additions & 2 deletions mscore/shortcut.cpp
Expand Up @@ -58,7 +58,7 @@ Shortcut Shortcut::_sc[] = {
QT_TRANSLATE_NOOP("action","Save score to file"),
Icons::fileSave_ICON
},
{
{
MsWidget::MAIN_WINDOW,
STATE_NORMAL | STATE_NOTE_ENTRY | STATE_EDIT | STATE_LYRICS_EDIT | STATE_PLAY,
"file-save-online",
Expand Down Expand Up @@ -2681,7 +2681,12 @@ Shortcut Shortcut::_sc[] = {
MsWidget::MAIN_WINDOW,
STATE_NORMAL,
"viewmode",
QT_TRANSLATE_NOOP("action","Toggle View Mode")
QT_TRANSLATE_NOOP("action","Toggle View Mode"),
0,
0,
Icons::Invalid_ICON,
Qt::WindowShortcut,
ShortcutFlags::A_SCORE
},
{
MsWidget::SCORE_TAB,
Expand Down

0 comments on commit 9509480

Please sign in to comment.