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
This commit is contained in:
André Pönitz 2008-03-08 16:15:10 +00:00
parent 300977b597
commit 69bfaf01a2
2 changed files with 22 additions and 10 deletions

View File

@ -793,6 +793,7 @@ void PrefColors::update(LyXRC const & /*rc*/)
change_lyxObjects_selection();
}
void PrefColors::change_color()
{
int const row = lyxObjectsLW->currentRow();

View 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();
}