diff options
author | Marius Kintel <marius@kintel.net> | 2012-07-24 02:43:43 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2012-07-24 02:43:43 (GMT) |
commit | f1634d545dafecb745f32fa786d351e95b545280 (patch) | |
tree | 36342df7c93328f4db71988466e21c10b429a0ef /src/editor.cc | |
parent | ec01e7f492cb750221464dc09d8d3e3d18607d18 (diff) | |
parent | dcb8c201199d45c082992377bcabda92574abd83 (diff) |
Merge branch 'master' of github.com:openscad/openscad
Conflicts:
scripts/linux-build-dependencies.sh
Diffstat (limited to 'src/editor.cc')
-rw-r--r-- | src/editor.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/editor.cc b/src/editor.cc index 4482558..bba8d4f 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -1,4 +1,5 @@ #include "editor.h" +#include "Preferences.h" #ifndef _QCODE_EDIT_ void Editor::indentSelection() @@ -70,4 +71,40 @@ void Editor::uncommentSelection() cursor.setPosition(p2, QTextCursor::KeepAnchor); setTextCursor(cursor); } + +void Editor::zoomIn() +{ + // See also QT's implementation in QEditor.cpp + QSettings settings; + QFont tmp_font = this->font() ; + if ( font().pointSize() >= 1 ) + tmp_font.setPointSize( 1 + font().pointSize() ); + else + tmp_font.setPointSize( 1 ); + settings.setValue("editor/fontsize", tmp_font.pointSize()); + this->setFont( tmp_font ); +} + +void Editor::zoomOut() +{ + QSettings settings; + QFont tmp_font = this->font(); + if ( font().pointSize() >= 2 ) + tmp_font.setPointSize( -1 + font().pointSize() ); + else + tmp_font.setPointSize( 1 ); + settings.setValue("editor/fontsize", tmp_font.pointSize()); + this->setFont( tmp_font ); +} + +void Editor::wheelEvent ( QWheelEvent * event ) +{ + if (event->modifiers() == Qt::ControlModifier) { + if (event->delta() > 0 ) + zoomIn(); + else if (event->delta() < 0 ) + zoomOut(); + } +} + #endif |