From 5b3ab4759d78eb2c5a9fe53c37bcd5c2cb371b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Br=C3=A6strup=20Sayoc?= Date: Sun, 6 Oct 2024 20:45:49 +0200 Subject: [PATCH] [Gui] TextEdit, zoom on Ctrl + wheel Fixes #13861 --- src/Gui/TextEdit.cpp | 11 +++++++++++ src/Gui/TextEdit.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/Gui/TextEdit.cpp b/src/Gui/TextEdit.cpp index 21feb89c9e..79acc46729 100644 --- a/src/Gui/TextEdit.cpp +++ b/src/Gui/TextEdit.cpp @@ -96,6 +96,17 @@ void TextEdit::keyPressEvent(QKeyEvent* e) } } +void TextEdit::wheelEvent(QWheelEvent* e) +{ + // Reimplement from QPlainText::wheelEvent as zoom is only allowed natively if !isReadOnly + if (e->modifiers() & Qt::ControlModifier) { + float delta = e->angleDelta().y() / 120.f; + zoomInF(delta); + return; + } + QPlainTextEdit::wheelEvent(e); +} + /** * Completes the word. */ diff --git a/src/Gui/TextEdit.h b/src/Gui/TextEdit.h index 8e1f7d9fb0..c1ceb49a10 100644 --- a/src/Gui/TextEdit.h +++ b/src/Gui/TextEdit.h @@ -70,6 +70,7 @@ Q_SIGNALS: protected: void keyPressEvent(QKeyEvent *) override; + void wheelEvent(QWheelEvent* e) override; private: void createListBox();