mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Make the session zoom relative to the default zoom
Also rename lyxrc.zoom to lyxrc.defaultZoom Fixes: #10455
This commit is contained in:
parent
eb51d60571
commit
858a9a0465
@ -892,7 +892,8 @@ void LyXAction::init()
|
||||
* \var lyx::FuncCode lyx::LFUN_BUFFER_ZOOM
|
||||
* \li Action: Sets the zoom of the screen fonts.
|
||||
* \li Syntax: buffer-zoom [<ZOOM>]
|
||||
* \li Params: <ZOOM>: The zoom in % points (neg. or pos.), the default is to reset to zoom savd in preferences.
|
||||
* \li Params: <ZOOM>: The target zoom value in %;
|
||||
* the default is the default zoom as saved in preferences.
|
||||
* \li Origin: daniel, 28 Oct 2016
|
||||
* \endvar
|
||||
*/
|
||||
@ -902,7 +903,8 @@ void LyXAction::init()
|
||||
* \var lyx::FuncCode lyx::LFUN_BUFFER_ZOOM_IN
|
||||
* \li Action: Increases the zoom of the screen fonts.
|
||||
* \li Syntax: buffer-zoom-in [<ZOOM>]
|
||||
* \li Params: <ZOOM>: The zoom in % points (neg. or pos.), the default is 20.
|
||||
* \li Params: <ZOOM>: The zoom value addition in % (neg. or pos.);
|
||||
* the default is 10% of the default zoom as saved in preferences.
|
||||
* \li Origin: vfr, 30 Mar 2009
|
||||
* \endvar
|
||||
*/
|
||||
@ -913,7 +915,8 @@ void LyXAction::init()
|
||||
* \var lyx::FuncCode lyx::LFUN_BUFFER_ZOOM_OUT
|
||||
* \li Action: Decreases the zoom of the screen fonts.
|
||||
* \li Syntax: buffer-zoom-out [<ZOOM>]
|
||||
* \li Params: <ZOOM>: The zoom in % points (neg. or pos.), the default is -20.
|
||||
* \li Params: <ZOOM>: The zoom value abstraction in % (neg. or pos.);
|
||||
* the default is 10% of the default zoom as saved in preferences.
|
||||
* \li Origin: vfr, 30 Mar 2009
|
||||
* \endvar
|
||||
*/
|
||||
|
@ -245,8 +245,8 @@ void LyXRC::setDefaults()
|
||||
pygmentize_command = string();
|
||||
dpi = 75;
|
||||
// Because a screen is typically wider than a piece of paper:
|
||||
zoom = 150;
|
||||
currentZoom = zoom;
|
||||
defaultZoom = 150;
|
||||
currentZoom = defaultZoom;
|
||||
allow_geometry_session = true;
|
||||
// Default LaTeX font size:
|
||||
font_sizes[FONT_SIZE_TINY] = "5.0";
|
||||
@ -624,9 +624,9 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
|
||||
break;
|
||||
|
||||
case RC_SCREEN_ZOOM:
|
||||
lexrc >> zoom;
|
||||
if (zoom < 10)
|
||||
zoom = 10;
|
||||
lexrc >> defaultZoom;
|
||||
if (defaultZoom < 10)
|
||||
defaultZoom = 10;
|
||||
break;
|
||||
|
||||
case RC_GEOMETRY_SESSION:
|
||||
@ -1724,8 +1724,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
// fall through
|
||||
case RC_SCREEN_ZOOM:
|
||||
if (ignore_system_lyxrc ||
|
||||
zoom != system_lyxrc.zoom) {
|
||||
os << "\\screen_zoom " << zoom << '\n';
|
||||
defaultZoom != system_lyxrc.defaultZoom) {
|
||||
os << "\\screen_zoom " << defaultZoom << '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
|
@ -295,9 +295,10 @@ public:
|
||||
bool allow_geometry_session;
|
||||
/// Scrolling speed of the mouse wheel
|
||||
double mouse_wheel_speed;
|
||||
/// Zoom factor for screen fonts
|
||||
int zoom;
|
||||
/// Current zoom factor for screen fonts
|
||||
/// Default zoom factor for screen fonts
|
||||
int defaultZoom;
|
||||
/// Actual zoom factor for screen fonts
|
||||
/// (default zoom plus buffer zoom factor)
|
||||
int currentZoom;
|
||||
/// Screen font sizes in points for each font size
|
||||
std::string font_sizes[10];
|
||||
|
@ -1089,7 +1089,7 @@ void PrefScreenFonts::applyRC(LyXRC & rc) const
|
||||
parseFontName(screenTypewriterCO->currentText(),
|
||||
rc.typewriter_font_name, rc.typewriter_font_foundry);
|
||||
|
||||
rc.zoom = screenZoomSB->value();
|
||||
rc.defaultZoom = screenZoomSB->value();
|
||||
rc.font_sizes[FONT_SIZE_TINY] = widgetToDoubleStr(screenTinyED);
|
||||
rc.font_sizes[FONT_SIZE_SCRIPT] = widgetToDoubleStr(screenSmallestED);
|
||||
rc.font_sizes[FONT_SIZE_FOOTNOTE] = widgetToDoubleStr(screenSmallerED);
|
||||
@ -1106,7 +1106,7 @@ void PrefScreenFonts::applyRC(LyXRC & rc) const
|
||||
|| rc.roman_font_name != oldrc.roman_font_name
|
||||
|| rc.sans_font_name != oldrc.sans_font_name
|
||||
|| rc.typewriter_font_name != oldrc.typewriter_font_name
|
||||
|| rc.zoom != oldrc.zoom) {
|
||||
|| rc.defaultZoom != oldrc.defaultZoom) {
|
||||
// The global QPixmapCache is used in GuiPainter to cache text
|
||||
// painting so we must reset it in case any of the above
|
||||
// parameter is changed.
|
||||
@ -1130,7 +1130,7 @@ void PrefScreenFonts::updateRC(LyXRC const & rc)
|
||||
selectSans(screenSansCO->currentText());
|
||||
selectTypewriter(screenTypewriterCO->currentText());
|
||||
|
||||
screenZoomSB->setValue(rc.zoom);
|
||||
screenZoomSB->setValue(rc.defaultZoom);
|
||||
updateScreenFontSizes(rc);
|
||||
|
||||
pixmapCacheCB->setChecked(rc.use_pixmap_cache);
|
||||
|
@ -741,7 +741,7 @@ void GuiView::autoSaveThreadFinished()
|
||||
void GuiView::saveLayout() const
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("zoom", lyxrc.currentZoom);
|
||||
settings.setValue("zoom_ratio", zoom_ratio_);
|
||||
settings.setValue("devel_mode", devel_mode_);
|
||||
settings.beginGroup("views");
|
||||
settings.beginGroup(QString::number(id_));
|
||||
@ -772,7 +772,12 @@ void GuiView::saveUISettings() const
|
||||
bool GuiView::restoreLayout()
|
||||
{
|
||||
QSettings settings;
|
||||
lyxrc.currentZoom = settings.value("zoom", lyxrc.zoom).toInt();
|
||||
zoom_ratio_ = settings.value("zoom_ratio", 1.0).toDouble();
|
||||
// Actual zoom value: default zoom + fractional offset
|
||||
int zoom = lyxrc.defaultZoom * zoom_ratio_;
|
||||
if (zoom < static_cast<int>(zoom_min_))
|
||||
zoom = zoom_min_;
|
||||
lyxrc.currentZoom = zoom;
|
||||
devel_mode_ = settings.value("devel_mode", devel_mode_).toBool();
|
||||
settings.beginGroup("views");
|
||||
settings.beginGroup(QString::number(id_));
|
||||
@ -4114,30 +4119,31 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
case LFUN_BUFFER_ZOOM_IN:
|
||||
case LFUN_BUFFER_ZOOM_OUT:
|
||||
case LFUN_BUFFER_ZOOM: {
|
||||
// use a signed temp to avoid overflow
|
||||
int zoom = lyxrc.currentZoom;
|
||||
if (cmd.argument().empty()) {
|
||||
if (cmd.action() == LFUN_BUFFER_ZOOM)
|
||||
zoom = lyxrc.zoom;
|
||||
zoom_ratio_ = 1.0;
|
||||
else if (cmd.action() == LFUN_BUFFER_ZOOM_IN)
|
||||
zoom += 20;
|
||||
zoom_ratio_ += 0.1;
|
||||
else
|
||||
zoom -= 20;
|
||||
zoom_ratio_ -= 0.1;
|
||||
} else {
|
||||
if (cmd.action() == LFUN_BUFFER_ZOOM)
|
||||
zoom = convert<int>(cmd.argument());
|
||||
zoom_ratio_ = convert<int>(cmd.argument()) / double(lyxrc.defaultZoom);
|
||||
else if (cmd.action() == LFUN_BUFFER_ZOOM_IN)
|
||||
zoom += convert<int>(cmd.argument());
|
||||
zoom_ratio_ += convert<int>(cmd.argument()) / 100.0;
|
||||
else
|
||||
zoom -= convert<int>(cmd.argument());
|
||||
zoom_ratio_ -= convert<int>(cmd.argument()) / 100.0;
|
||||
}
|
||||
|
||||
// Actual zoom value: default zoom + fractional extra value
|
||||
int zoom = lyxrc.defaultZoom * zoom_ratio_;
|
||||
if (zoom < static_cast<int>(zoom_min_))
|
||||
zoom = zoom_min_;
|
||||
|
||||
lyxrc.currentZoom = zoom;
|
||||
|
||||
dr.setMessage(bformat(_("Zoom level is now %1$d%"), lyxrc.currentZoom));
|
||||
dr.setMessage(bformat(_("Zoom level is now %1$d% (default value: %2$d%)"),
|
||||
lyxrc.currentZoom, lyxrc.defaultZoom));
|
||||
|
||||
// The global QPixmapCache is used in GuiPainter to cache text
|
||||
// painting so we must reset it.
|
||||
|
@ -470,6 +470,9 @@ private:
|
||||
/// Statusbar widget that shows version control status
|
||||
QLabel * version_control_;
|
||||
|
||||
/// The rate from which the actual zoom value is calculated
|
||||
/// from the default zoom pref
|
||||
double zoom_ratio_ = 1.0;
|
||||
/// Minimum zoom percentage
|
||||
static int const zoom_min_ = 10;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user