diff options
Diffstat (limited to 'src/widgets/widgets/qplaintextedit.cpp')
-rw-r--r-- | src/widgets/widgets/qplaintextedit.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 95271adeb0..5a8da45a88 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -2223,11 +2223,57 @@ void QPlainTextEdit::changeEvent(QEvent *e) #ifndef QT_NO_WHEELEVENT void QPlainTextEdit::wheelEvent(QWheelEvent *e) { + Q_D(QPlainTextEdit); + if (!(d->control->textInteractionFlags() & Qt::TextEditable)) { + if (e->modifiers() & Qt::ControlModifier) { + const int delta = e->delta(); + if (delta < 0) + zoomOut(); + else if (delta > 0) + zoomIn(); + return; + } + } QAbstractScrollArea::wheelEvent(e); updateMicroFocus(); } #endif +/*! + \fn QPlainTextEdit::zoomIn(int range) + + Zooms in on the text by making the base font size \a range + points larger and recalculating all font sizes to be the new size. + This does not change the size of any images. + + \sa zoomOut() +*/ +void QPlainTextEdit::zoomIn(int range) +{ + QFont f = font(); + const int newSize = f.pointSize() + range; + if (newSize <= 0) + return; + f.setPointSize(newSize); + setFont(f); +} + +/*! + \fn QPlainTextEdit::zoomOut(int range) + + \overload + + Zooms out on the text by making the base font size \a range points + smaller and recalculating all font sizes to be the new size. This + does not change the size of any images. + + \sa zoomIn() +*/ +void QPlainTextEdit::zoomOut(int range) +{ + zoomIn(-range); +} + #ifndef QT_NO_CONTEXTMENU /*! This function creates the standard context menu which is shown when the user clicks on the line edit with the right mouse |