mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
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.
This commit is contained in:
parent
6a0e5571c5
commit
168d355721
@ -2034,8 +2034,10 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
|||||||
bool const neg_zoom =
|
bool const neg_zoom =
|
||||||
convert<int>(cmd.argument()) < 0 ||
|
convert<int>(cmd.argument()) < 0 ||
|
||||||
(cmd.action() == LFUN_BUFFER_ZOOM_OUT && cmd.argument().empty());
|
(cmd.action() == LFUN_BUFFER_ZOOM_OUT && cmd.argument().empty());
|
||||||
if (lyxrc.zoom <= 10 && neg_zoom) {
|
if (lyxrc.zoom <= zoom_min && neg_zoom) {
|
||||||
flag.message(_("Zoom level cannot be less than 10%."));
|
docstring const msg =
|
||||||
|
bformat(_("Zoom level cannot be less than %1$d%."), zoom_min);
|
||||||
|
flag.message(msg);
|
||||||
enable = false;
|
enable = false;
|
||||||
} else
|
} else
|
||||||
enable = doc_buffer;
|
enable = doc_buffer;
|
||||||
@ -3979,8 +3981,8 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
} else
|
} else
|
||||||
zoom += convert<int>(cmd.argument());
|
zoom += convert<int>(cmd.argument());
|
||||||
|
|
||||||
if (zoom < 10)
|
if (zoom < static_cast<int>(zoom_min))
|
||||||
zoom = 10;
|
zoom = zoom_min;
|
||||||
lyxrc.zoom = zoom;
|
lyxrc.zoom = zoom;
|
||||||
|
|
||||||
dr.setMessage(bformat(_("Zoom level is now %1$d%"), lyxrc.zoom));
|
dr.setMessage(bformat(_("Zoom level is now %1$d%"), lyxrc.zoom));
|
||||||
|
@ -461,6 +461,9 @@ private:
|
|||||||
/// Statusbar widget that shows version control status
|
/// Statusbar widget that shows version control status
|
||||||
QLabel * version_control_;
|
QLabel * version_control_;
|
||||||
|
|
||||||
|
/// Minimum zoom percentage
|
||||||
|
unsigned int const zoom_min = 10;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
Loading…
Reference in New Issue
Block a user