Skip to content

Commit

Permalink
Fix #307121: Revert default zoom type to “100%”
Browse files Browse the repository at this point in the history
Reverted the default zoom type to “100%” (as it was prior to #5623).
  • Loading branch information
Spire42 committed Jun 24, 2020
1 parent 670af1f commit 1804d68
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
2 changes: 1 addition & 1 deletion mscore/preferences.h
Expand Up @@ -76,7 +76,7 @@ enum class MusicxmlExportBreaks : char {

// Default-zoom-type options
enum class ZoomType : int {
PAGE_WIDTH = 0, WHOLE_PAGE, TWO_PAGES, PERCENTAGE
PERCENTAGE = 0, PAGE_WIDTH, WHOLE_PAGE, TWO_PAGES,
};

class PreferenceVisitor;
Expand Down
8 changes: 4 additions & 4 deletions mscore/prefsdialog.cpp
Expand Up @@ -150,10 +150,10 @@ PreferenceDialog::PreferenceDialog(QWidget* parent)
connect(bgColorButton, &QRadioButton::toggled, this, &PreferenceDialog::updateBgView);

zoomDefaultType->clear();
zoomDefaultType->addItem(tr("Page Width"), 0);
zoomDefaultType->addItem(tr("Whole Page"), 1);
zoomDefaultType->addItem(tr("Two Pages"), 2);
zoomDefaultType->addItem(tr("Percentage"), 3);
zoomDefaultType->addItem(tr("Percentage"), 0);
zoomDefaultType->addItem(tr("Page Width"), 1);
zoomDefaultType->addItem(tr("Whole Page"), 2);
zoomDefaultType->addItem(tr("Two Pages"), 3);

zoomPrecisionKeyboard->setRange(ZOOM_PRECISION_MIN, ZOOM_PRECISION_MAX);
zoomPrecisionMouse->setRange(ZOOM_PRECISION_MIN, ZOOM_PRECISION_MAX);
Expand Down
8 changes: 4 additions & 4 deletions mscore/prefsdialog.ui
Expand Up @@ -1158,22 +1158,22 @@
</property>
<item>
<property name="text">
<string notr="true" extracomment="Dummy values. Used for clarity in the Designer. Translated elsewhere.">Page Width</string>
<string notr="true" extracomment="Dummy values. Used for clarity in the Designer. Translated elsewhere.">Percentage</string>
</property>
</item>
<item>
<property name="text">
<string notr="true" extracomment="Dummy values. Used for clarity in the Designer. Translated elsewhere.">Whole Page</string>
<string notr="true" extracomment="Dummy values. Used for clarity in the Designer. Translated elsewhere.">Page Width</string>
</property>
</item>
<item>
<property name="text">
<string notr="true" extracomment="Dummy values. Used for clarity in the Designer. Translated elsewhere.">Two Pages</string>
<string notr="true" extracomment="Dummy values. Used for clarity in the Designer. Translated elsewhere.">Whole Page</string>
</property>
</item>
<item>
<property name="text">
<string notr="true" extracomment="Dummy values. Used for clarity in the Designer. Translated elsewhere.">Percentage</string>
<string notr="true" extracomment="Dummy values. Used for clarity in the Designer. Translated elsewhere.">Two Pages</string>
</property>
</item>
</widget>
Expand Down
45 changes: 19 additions & 26 deletions mscore/zoombox.cpp
Expand Up @@ -47,37 +47,35 @@ const std::array<ZoomEntry, 13> zoomEntries { {
{ ZoomIndex::ZOOM_FREE, 0, "" },
} };

static constexpr ZoomIndex startZoomIndex = ZoomIndex::ZOOM_PAGE_WIDTH;

ZoomState ZoomBox::getDefaultLogicalZoom()
{
ZoomIndex index = startZoomIndex;
qreal logicalLevel = 1.0;
ZoomState result { ZoomIndex::ZOOM_100, 1.0 };

// Convert the default-zoom preferences into a usable zoom index and logical zoom level.
switch (static_cast<ZoomType>(preferences.getInt(PREF_UI_CANVAS_ZOOM_DEFAULT_TYPE))) {
case ZoomType::WHOLE_PAGE:
index = ZoomIndex::ZOOM_WHOLE_PAGE;
break;
case ZoomType::TWO_PAGES:
index = ZoomIndex::ZOOM_TWO_PAGES;
break;
case ZoomType::PERCENTAGE: {
// Select a numeric preset zoom entry if the percentage corresponds to one; otherwise, select free zoom.
const auto logicalLevelPercentage = preferences.getInt(PREF_UI_CANVAS_ZOOM_DEFAULT_LEVEL);
const auto i = std::find(zoomEntries.cbegin(), zoomEntries.cend(), logicalLevelPercentage);
index = ((i != zoomEntries.cend()) && i->isNumericPreset()) ? i->index : ZoomIndex::ZOOM_FREE;
logicalLevel = logicalLevelPercentage / 100.0;
result.index = ((i != zoomEntries.cend()) && i->isNumericPreset()) ? i->index : ZoomIndex::ZOOM_FREE;
result.level = logicalLevelPercentage / 100.0;
}
break;
case ZoomType::PAGE_WIDTH:
Q_FALLTHROUGH();
result.index = ZoomIndex::ZOOM_PAGE_WIDTH;
break;
case ZoomType::WHOLE_PAGE:
result.index = ZoomIndex::ZOOM_WHOLE_PAGE;
break;
case ZoomType::TWO_PAGES:
result.index = ZoomIndex::ZOOM_TWO_PAGES;
break;
default:
index = ZoomIndex::ZOOM_PAGE_WIDTH;
Q_ASSERT(false);
break;
}

return { index, logicalLevel };
return result;
}

//---------------------------------------------------------
Expand All @@ -86,29 +84,24 @@ ZoomState ZoomBox::getDefaultLogicalZoom()

ZoomBox::ZoomBox(QWidget* parent)
: QComboBox(parent)
, _previousLogicalLevel(1.0)
, _previousLogicalLevel(0.0)
, _previousScoreView(nullptr)
{
setEditable(true);
setInsertPolicy(QComboBox::InsertAtBottom);
setToolTip(tr("Zoom"));
setWhatsThis(tr("Zoom"));
setAccessibleName(tr("Zoom"));
setValidator(new ZoomValidator(this));
setAutoCompletion(false);

int i = 0;
setFocusPolicy(Qt::StrongFocus);
setFixedHeight(preferences.getInt(PREF_UI_THEME_ICONHEIGHT) + 8); // hack
setMaxCount(static_cast<int>(zoomEntries.size()));
setMaxVisibleItems(static_cast<int>(zoomEntries.size()));
for (const ZoomEntry& e : zoomEntries) {
QString ts(QCoreApplication::translate("magTable", e.txt));
addItem(ts, QVariant::fromValue(e.index));
if (e.index == startZoomIndex)
setCurrentIndex(i);
++i;
}
setMaxCount(i);
setFocusPolicy(Qt::StrongFocus);
setAccessibleName(tr("Zoom"));
setMaxVisibleItems(static_cast<int>(zoomEntries.size()));
setFixedHeight(preferences.getInt(PREF_UI_THEME_ICONHEIGHT) + 8); // hack
resetToDefaultLogicalZoom();
connect(this, SIGNAL(currentIndexChanged(int)), SLOT(indexChanged(int)));
connect(lineEdit(), SIGNAL(returnPressed()), SLOT(textChanged()));
Expand Down

0 comments on commit 1804d68

Please sign in to comment.