From 69bfaf01a241b4a6b42c040a18e823dac5e4ce8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sat, 8 Mar 2008 16:15:10 +0000 Subject: [PATCH] make Ctrl+mousewheel change the display font sizes (pretty similar to what firefox does) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23564 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiPrefs.cpp | 1 + src/frontends/qt4/GuiWorkArea.cpp | 31 +++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 968829131d..6b50910fb2 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -793,6 +793,7 @@ void PrefColors::update(LyXRC const & /*rc*/) change_lyxObjects_selection(); } + void PrefColors::change_color() { int const row = lyxObjectsLW->currentRow(); diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 81aad47b29..2618f830ba 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -743,19 +744,29 @@ void GuiWorkArea::mouseMoveEvent(QMouseEvent * e) } -void GuiWorkArea::wheelEvent(QWheelEvent * e) +void GuiWorkArea::wheelEvent(QWheelEvent * ev) { // Wheel rotation by one notch results in a delta() of 120 (see // documentation of QWheelEvent) - double const lines = qApp->wheelScrollLines() - * lyxrc.mouse_wheel_speed - * e->delta() / 120.0; - LYXERR(Debug::SCROLLING, "wheelScrollLines = " << qApp->wheelScrollLines() - << " delta = " << e->delta() - << " lines = " << lines); - verticalScrollBar()->setValue(verticalScrollBar()->value() - - int(lines * verticalScrollBar()->singleStep())); - e->accept(); + int delta = ev->delta() / 120; + if (ev->modifiers() & Qt::ControlModifier) { + lyxrc.zoom -= 5 * delta; + if (lyxrc.zoom < 10) + lyxrc.zoom = 10; + // The global QPixmapCache is used in GuiPainter to cache text + // painting so we must reset it. + QPixmapCache::clear(); + guiApp->fontLoader().update(); + lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE)); + } else { + double const lines = qApp->wheelScrollLines() + * lyxrc.mouse_wheel_speed * delta; + LYXERR(Debug::SCROLLING, "wheelScrollLines = " << qApp->wheelScrollLines() + << " delta = " << ev->delta() << " lines = " << lines); + verticalScrollBar()->setValue(verticalScrollBar()->value() - + int(lines * verticalScrollBar()->singleStep())); + } + ev->accept(); } -- 2.39.5