diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index 06cfdd1d83c0b..38e8713691752 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -6226,6 +6226,25 @@ void MuseScore::cmd(QAction* a, const QString& cmd) cv->setMag(MagIdx::MAG_100, 1.0); setMag(1.0); } + else if (cmd == "zoom-page-width") { + if (cv) { + MagIdx currentMagIdx = cv->magIdx(); + if (currentMagIdx != MagIdx::MAG_PAGE_WIDTH) { + // Save current zoom state for toggle + cv->previousMagIdx(currentMagIdx); + // Update zoom drop-down list + mag->setMagIdx(MagIdx::MAG_PAGE_WIDTH); + // Update the actual score's zoom-level + mag->magChanged(MagIdx::MAG_PAGE_WIDTH); + } + // If current zoom-level is page-width, + // switch to previous zoom-level + else { + mag->setMagIdx(cv->previousMagIdx()); + mag->magChanged(cv->previousMagIdx()); + } + } + } else if (cmd == "midi-on") midiinToggled(a->isChecked()); else if (cmd == "undo") diff --git a/mscore/scoreview.h b/mscore/scoreview.h index 027bdfb9c17eb..ead9639b74ff5 100644 --- a/mscore/scoreview.h +++ b/mscore/scoreview.h @@ -21,6 +21,7 @@ #include "libmscore/mscoreview.h" #include "libmscore/pos.h" #include "libmscore/harmony.h" +#include "mscore/magbox.h" namespace Ms { @@ -148,6 +149,7 @@ class ScoreView : public QWidget, public MuseScoreView { QTransform _matrix, imatrix; MagIdx _magIdx; + MagIdx _previousMagIdx { MagIdx::MAG_PAGE_WIDTH }; // for magnification zoom-level toggling QFocusFrame* focusFrame; @@ -368,6 +370,7 @@ class ScoreView : public QWidget, public MuseScoreView { virtual void removeScore() { _score = 0; } void setMag(qreal m); + bool navigatorVisible() const; void cmd(const QAction*); void cmd(const char*); @@ -474,6 +477,9 @@ class ScoreView : public QWidget, public MuseScoreView { Element* getEditElement(); void onElementDestruction(Element*) override; + MagIdx previousMagIdx() const { return _previousMagIdx; } + void previousMagIdx(MagIdx id) { _previousMagIdx = id; } + virtual Element* elementNear(QPointF); QList elementsNear(QPointF); void editArticulationProperties(Articulation*); diff --git a/mscore/shortcut.cpp b/mscore/shortcut.cpp index f16a454939252..b3c2357dc205d 100644 --- a/mscore/shortcut.cpp +++ b/mscore/shortcut.cpp @@ -2676,6 +2676,13 @@ Shortcut Shortcut::_sc[] = { QT_TRANSLATE_NOOP("action","Zoom to 100%"), QT_TRANSLATE_NOOP("action","Zoom to 100%") }, + { + MsWidget::MAIN_WINDOW, + STATE_NORMAL | STATE_NOTE_ENTRY | STATE_EDIT | STATE_PLAY, + "zoom-page-width", + QT_TRANSLATE_NOOP("action","Zoom to Page Width or Previous Magnification Level"), + QT_TRANSLATE_NOOP("action","Zoom to page-width / previous magnification level") + }, { MsWidget::SCORE_TAB, STATE_NORMAL | STATE_NOTE_ENTRY,