Skip to content

Commit

Permalink
fix #295257: Implement page-width shortcut with previous zoom-level t…
Browse files Browse the repository at this point in the history
…oggle

Manually merged #5564 to 3.x
  • Loading branch information
worldwideweary authored and anatoly-os committed Jun 6, 2020
1 parent 11655e0 commit a29de17
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions mscore/scoreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "libmscore/mscoreview.h"
#include "libmscore/pos.h"
#include "libmscore/harmony.h"
#include "mscore/magbox.h"

namespace Ms {

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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*);
Expand Down Expand Up @@ -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<Element*> elementsNear(QPointF);
void editArticulationProperties(Articulation*);
Expand Down
7 changes: 7 additions & 0 deletions mscore/shortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a29de17

Please sign in to comment.