From: Vincent van Ravesteijn Date: Sat, 4 Apr 2009 09:14:38 +0000 (+0000) Subject: Fix bug #3038: wish for lfuns for zoom-in and zoom-out X-Git-Tag: 2.0.0~6949 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6b5ce8a999028cefcf47a127ec5e8384f24d13dd;p=features.git Fix bug #3038: wish for lfuns for zoom-in and zoom-out git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29077 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/FuncCode.h b/src/FuncCode.h index 5365c4df28..e83c8bbc25 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -423,6 +423,8 @@ enum FuncCode LFUN_INSET_BEGIN_SELECT, // JMarc, 20090316 LFUN_INSET_END_SELECT, // JMarc, 20090316 LFUN_SCREEN_SHOW_CURSOR, // vfr, 20090325 + LFUN_BUFFER_ZOOM_IN, // vfr, 20090330 + LFUN_BUFFER_ZOOM_OUT, // vfr, 20090330 LFUN_LASTACTION // end of the table diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index ecd6b6f3e0..e70d5a8195 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -3204,6 +3204,24 @@ void LyXAction::init() */ { LFUN_COPY_LABEL_AS_REF, "copy-label-as-reference", ReadOnly | NoUpdate, Edit }, +/*! + * \var lyx::FuncCode lyx::LFUN_BUFFER_ZOOM_IN + * \li Action: Increases the zoom of the screen fonts. + * \li Syntax: buffer-zoom-in + * \li Origin: vfr, 30 Mar 2009 + * \endvar + */ + { LFUN_BUFFER_ZOOM_IN, "buffer-zoom-in", ReadOnly, Buffer }, + +/*! + * \var lyx::FuncCode lyx::LFUN_BUFFER_ZOOM_OUT + * \li Action: Decreases the zoom of the screen fonts. + * \li Syntax: buffer-zoom-out + * \li Origin: vfr, 30 Mar 2009 + * \endvar + */ + { LFUN_BUFFER_ZOOM_OUT, "buffer-zoom-out", ReadOnly, Buffer }, + { LFUN_NOACTION, "", Noop, Hidden } #ifndef DOXYGEN_SHOULD_SKIP_THIS }; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 02f143ce7d..402f39c379 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -17,6 +17,7 @@ #include "Dialog.h" #include "FileDialog.h" +#include "FontLoader.h" #include "GuiApplication.h" #include "GuiCommandBuffer.h" #include "GuiCompleter.h" @@ -55,13 +56,14 @@ #include "Toolbars.h" #include "version.h" -#include "support/lassert.h" +#include "support/convert.h" #include "support/debug.h" #include "support/ExceptionMessage.h" #include "support/FileName.h" #include "support/filetools.h" #include "support/gettext.h" #include "support/ForkedCalls.h" +#include "support/lassert.h" #include "support/lstrings.h" #include "support/os.h" #include "support/Package.h" @@ -1326,13 +1328,21 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) enable = false; break; - case LFUN_COMPLETION_CANCEL: + case LFUN_COMPLETION_CANCEL: if (!d.current_work_area_ || (!d.current_work_area_->completer().popupVisible() && !d.current_work_area_->completer().inlineVisible())) enable = false; break; + case LFUN_BUFFER_ZOOM_OUT: + enable = buf && lyxrc.zoom > 10; + break; + + case LFUN_BUFFER_ZOOM_IN: + enable = buf; + break; + default: return false; } @@ -2202,6 +2212,25 @@ bool GuiView::dispatch(FuncRequest const & cmd) d.current_work_area_->completer().activate(); break; + case LFUN_BUFFER_ZOOM_IN: + case LFUN_BUFFER_ZOOM_OUT: + if (cmd.argument().empty()) { + if (cmd.action == LFUN_BUFFER_ZOOM_IN) + lyxrc.zoom += 20; + else + lyxrc.zoom -= 20; + } else + lyxrc.zoom += convert(cmd.argument()); + + 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)); + break; default: dispatched = false; diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 344b63044c..2d379462d7 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -43,6 +43,7 @@ #include "graphics/GraphicsImage.h" #include "graphics/GraphicsLoader.h" +#include "support/convert.h" #include "support/debug.h" #include "support/gettext.h" #include "support/FileName.h" @@ -810,15 +811,8 @@ void GuiWorkArea::wheelEvent(QWheelEvent * ev) // documentation of QWheelEvent) int const 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(); - ev->accept(); - lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE)); + docstring arg = convert(5 * delta); + lyx::dispatch(FuncRequest(LFUN_BUFFER_ZOOM_IN, arg)); return; }