From: Scott Kostyshak Date: Sat, 8 Oct 2016 03:18:54 +0000 (-0400) Subject: Factor out magic zoom minimum to a const member X-Git-Tag: 2.3.0alpha1~911 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=168d3557;p=features.git Factor out magic zoom minimum to a const member The limit of 10% is used in both getStatus() and dispatch() to set a minimum zoom level. Having it centralized makes the code more readable and makes changing the minimum less error-prone. --- diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index b8a0777644..c8afd2b5df 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2034,8 +2034,10 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) bool const neg_zoom = convert(cmd.argument()) < 0 || (cmd.action() == LFUN_BUFFER_ZOOM_OUT && cmd.argument().empty()); - if (lyxrc.zoom <= 10 && neg_zoom) { - flag.message(_("Zoom level cannot be less than 10%.")); + if (lyxrc.zoom <= zoom_min && neg_zoom) { + docstring const msg = + bformat(_("Zoom level cannot be less than %1$d%."), zoom_min); + flag.message(msg); enable = false; } else enable = doc_buffer; @@ -3979,8 +3981,8 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) } else zoom += convert(cmd.argument()); - if (zoom < 10) - zoom = 10; + if (zoom < static_cast(zoom_min)) + zoom = zoom_min; lyxrc.zoom = zoom; dr.setMessage(bformat(_("Zoom level is now %1$d%"), lyxrc.zoom)); diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index c7c2699ace..c55d60bc08 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -461,6 +461,9 @@ private: /// Statusbar widget that shows version control status QLabel * version_control_; + /// Minimum zoom percentage + unsigned int const zoom_min = 10; + }; } // namespace frontend