From a63df75361a3468c62a03ef55e6442d37603d381 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Sun, 16 Oct 2022 16:16:59 +0300 Subject: [PATCH] Konsole Part: Ctrl+Mouse Scroll to change font size Konsole: Move biggerFont() and smallerFont() into TEWidget Signed-off-by: Mavridis Philippe Additional changes. Signed-off-by: Michele Calgaro --- konsole/konsole/TEWidget.cpp | 24 ++++++++++++++++++++++++ konsole/konsole/TEWidget.h | 4 ++++ konsole/konsole/konsole.cpp | 11 ++--------- konsole/konsole/konsole_part.cpp | 11 ++--------- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/konsole/konsole/TEWidget.cpp b/konsole/konsole/TEWidget.cpp index 52cd1236b..026ee2df8 100644 --- a/konsole/konsole/TEWidget.cpp +++ b/konsole/konsole/TEWidget.cpp @@ -308,6 +308,19 @@ void TEWidget::fontChange(const TQFont &) update(); } +void TEWidget::biggerFont(void) { + TQFont f = getVTFont(); + f.setPointSize( f.pointSize() + 1 ); + setVTFont( f ); +} + +void TEWidget::smallerFont(void) { + TQFont f = getVTFont(); + if ( f.pointSize() < 6 ) return; // A minimum size + f.setPointSize( f.pointSize() - 1 ); + setVTFont( f ); +} + void TEWidget::setVTFont(const TQFont& f) { TQFont font = f; @@ -1695,6 +1708,17 @@ void TEWidget::wheelEvent( TQWheelEvent* ev ) if (ev->orientation() != Qt::Vertical) return; + if (ev->state() & ControlButton) { + if (ev->delta() > 0) { + biggerFont(); + } + else { + smallerFont(); + } + ev->accept(); + return; + } + if ( mouse_marks ) { if (!screen || screen->hasScroll() || (scrollbar->maxValue() == 0 && screen_num == 0)) diff --git a/konsole/konsole/TEWidget.h b/konsole/konsole/TEWidget.h index 967896082..32c1ce9d5 100644 --- a/konsole/konsole/TEWidget.h +++ b/konsole/konsole/TEWidget.h @@ -126,6 +126,10 @@ public: */ void setVTFont(const TQFont& font); + /** Changes font size by 1 point */ + void biggerFont(); + void smallerFont(); + void setMouseMarks(bool on); static void setAntialias( bool enable ) { s_antialias = enable; } static bool antialias() { return s_antialias; } diff --git a/konsole/konsole/konsole.cpp b/konsole/konsole/konsole.cpp index 4faef5239..11fae96d1 100644 --- a/konsole/konsole/konsole.cpp +++ b/konsole/konsole/konsole.cpp @@ -4387,20 +4387,13 @@ void Konsole::slotFontChanged() void Konsole::biggerFont(void) { if ( !se ) return; - - TQFont f = te->getVTFont(); - f.setPointSize( f.pointSize() + 1 ); - te->setVTFont( f ); + te->biggerFont(); activateSession(); } void Konsole::smallerFont(void) { if ( !se ) return; - - TQFont f = te->getVTFont(); - if ( f.pointSize() < 6 ) return; // A minimum size - f.setPointSize( f.pointSize() - 1 ); - te->setVTFont( f ); + te->smallerFont(); activateSession(); } diff --git a/konsole/konsole/konsole_part.cpp b/konsole/konsole/konsole_part.cpp index 64fdfb700..5e1379a4e 100644 --- a/konsole/konsole/konsole_part.cpp +++ b/konsole/konsole/konsole_part.cpp @@ -705,19 +705,12 @@ void konsolePart::slotSelectFont() { void konsolePart::biggerFont(void) { if ( !se ) return; - - TQFont f = te->getVTFont(); - f.setPointSize( f.pointSize() + 1 ); - te->setVTFont( f ); + te->biggerFont(); } void konsolePart::smallerFont(void) { if ( !se ) return; - - TQFont f = te->getVTFont(); - if ( f.pointSize() < 6 ) return; // A minimum size - f.setPointSize( f.pointSize() - 1 ); - te->setVTFont( f ); + te->smallerFont(); } void konsolePart::updateKeytabMenu()