]> git.lyx.org Git - lyx.git/commitdiff
make Ctrl+mousewheel change the display font sizes (pretty similar to
authorAndré Pönitz <poenitz@gmx.net>
Sat, 8 Mar 2008 16:15:10 +0000 (16:15 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 8 Mar 2008 16:15:10 +0000 (16:15 +0000)
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
src/frontends/qt4/GuiWorkArea.cpp

index 968829131d8cf9fc899068b56ea79a1bb0f5cf2d..6b50910fb27f792a3776f23dac0828cb9b91dc97 100644 (file)
@@ -793,6 +793,7 @@ void PrefColors::update(LyXRC const & /*rc*/)
        change_lyxObjects_selection();
 }
 
+
 void PrefColors::change_color()
 {
        int const row = lyxObjectsLW->currentRow();
index 81aad47b293c35e820cd39e9d901891632cc9e31..2618f830ba3493f94b10abe83c47b351e5d7dac8 100644 (file)
@@ -53,6 +53,7 @@
 #include <QMenu>
 #include <QPainter>
 #include <QPalette>
+#include <QPixmapCache>
 #include <QScrollBar>
 #include <QTabBar>
 #include <QTimer>
@@ -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();
 }