From 420384ad0b00d2277b3b4604826cf53ea39f2ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Mon, 23 Oct 2023 14:58:22 +0100 Subject: [PATCH 1/5] Use "new" signal/slot syntax --- lib/Emulation.cpp | 20 ++++++++++---------- lib/Vt102Emulation.cpp | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/Emulation.cpp b/lib/Emulation.cpp index 723f5d20..511e7f15 100644 --- a/lib/Emulation.cpp +++ b/lib/Emulation.cpp @@ -63,14 +63,14 @@ Emulation::Emulation() : _screen[1] = new Screen(40,80); _currentScreen = _screen[0]; - QObject::connect(&_bulkTimer1, SIGNAL(timeout()), this, SLOT(showBulk()) ); - QObject::connect(&_bulkTimer2, SIGNAL(timeout()), this, SLOT(showBulk()) ); + QObject::connect(&_bulkTimer1, &QTimer::timeout, this, &Konsole::Emulation::showBulk); + QObject::connect(&_bulkTimer2, &QTimer::timeout, this, &Konsole::Emulation::showBulk); // listen for mouse status changes - connect(this , SIGNAL(programUsesMouseChanged(bool)) , - SLOT(usesMouseChanged(bool))); - connect(this , SIGNAL(programBracketedPasteModeChanged(bool)) , - SLOT(bracketedPasteModeChanged(bool))); + connect(this, &Konsole::Emulation::programUsesMouseChanged, + this, &Konsole::Emulation::usesMouseChanged); + connect(this, &Konsole::Emulation::programBracketedPasteModeChanged, + this, &Konsole::Emulation::bracketedPasteModeChanged); connect(this, &Emulation::cursorChanged, this, [this] (KeyboardCursorShape cursorShape, bool blinkingCursorEnabled) { emit titleChanged( 50, QString(QLatin1String("CursorShape=%1;BlinkingCursorEnabled=%2")) @@ -104,11 +104,11 @@ ScreenWindow* Emulation::createWindow() window->setScreen(_currentScreen); _windows << window; - connect(window , SIGNAL(selectionChanged()), - this , SLOT(bufferedUpdate())); + connect(window, &Konsole::ScreenWindow::selectionChanged, + this, &Konsole::Emulation::bufferedUpdate); - connect(this , SIGNAL(outputChanged()), - window , SLOT(notifyOutputChanged()) ); + connect(this, &Konsole::Emulation::outputChanged, + window, &Konsole::ScreenWindow::notifyOutputChanged); connect(this, &Emulation::handleCommandFromKeyboard, window, &ScreenWindow::handleCommandFromKeyboard); diff --git a/lib/Vt102Emulation.cpp b/lib/Vt102Emulation.cpp index e74f8821..9db198af 100644 --- a/lib/Vt102Emulation.cpp +++ b/lib/Vt102Emulation.cpp @@ -66,7 +66,8 @@ Vt102Emulation::Vt102Emulation() _reportFocusEvents(false) { _titleUpdateTimer->setSingleShot(true); - QObject::connect(_titleUpdateTimer , SIGNAL(timeout()) , this , SLOT(updateTitle())); + QObject::connect(_titleUpdateTimer, &QTimer::timeout, + this, &Konsole::Vt102Emulation::updateTitle); initTokenizer(); reset(); From b2608f2776859330337c15cf632600295601e006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Mon, 23 Oct 2023 15:22:46 +0100 Subject: [PATCH 2/5] Drop defines for bulk timeouts #defines are much more error prone. --- lib/Emulation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Emulation.cpp b/lib/Emulation.cpp index 511e7f15..1c543357 100644 --- a/lib/Emulation.cpp +++ b/lib/Emulation.cpp @@ -332,9 +332,6 @@ int Emulation::lineCount() const return _currentScreen->getLines() + _currentScreen->getHistLines(); } -#define BULK_TIMEOUT1 10 -#define BULK_TIMEOUT2 40 - void Emulation::showBulk() { _bulkTimer1.stop(); @@ -348,6 +345,9 @@ void Emulation::showBulk() void Emulation::bufferedUpdate() { + static const int BULK_TIMEOUT1 = 10; + static const int BULK_TIMEOUT2 = 40; + _bulkTimer1.setSingleShot(true); _bulkTimer1.start(BULK_TIMEOUT1); if (!_bulkTimer2.isActive()) From 7bc912c5cb9e900177dd76ebd9cb155cf8df451a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Mon, 23 Oct 2023 18:27:43 +0100 Subject: [PATCH 3/5] Remove KDE includes --- lib/Emulation.cpp | 3 --- lib/Vt102Emulation.cpp | 4 ---- 2 files changed, 7 deletions(-) diff --git a/lib/Emulation.cpp b/lib/Emulation.cpp index 1c543357..08267d26 100644 --- a/lib/Emulation.cpp +++ b/lib/Emulation.cpp @@ -39,9 +39,6 @@ #include -// KDE -//#include - // Konsole #include "KeyboardTranslator.h" #include "Screen.h" diff --git a/lib/Vt102Emulation.cpp b/lib/Vt102Emulation.cpp index 9db198af..0f773b95 100644 --- a/lib/Vt102Emulation.cpp +++ b/lib/Vt102Emulation.cpp @@ -48,10 +48,6 @@ #include #include -// KDE -//#include -//#include - // Konsole #include "KeyboardTranslator.h" #include "Screen.h" From 092ce1f16618fa69c7998a2638038c3207b33ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Mon, 23 Oct 2023 18:31:32 +0100 Subject: [PATCH 4/5] Drop XKB related conditional compilation Not used. Artifacts from Konsole. --- lib/Vt102Emulation.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib/Vt102Emulation.cpp b/lib/Vt102Emulation.cpp index 0f773b95..2a9aa131 100644 --- a/lib/Vt102Emulation.cpp +++ b/lib/Vt102Emulation.cpp @@ -24,20 +24,6 @@ #include "Vt102Emulation.h" #include "tools.h" -// XKB -//#include - -// this allows konsole to be compiled without XKB and XTEST extensions -// even though it might be available on a particular system. -#if defined(AVOID_XKB) - #undef HAVE_XKB -#endif - -#if defined(HAVE_XKB) - void scrolllock_set_off(); - void scrolllock_set_on(); -#endif - // Standard #include #include From 4f158c2ce55c9c0883392b64ebc028be23c6d849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Wed, 25 Oct 2023 12:49:09 +0100 Subject: [PATCH 5/5] Assign bulkTimers a parent The parent/child relationship is not used to manage memory. It's only used to keep the objects together when moving them between threads (so that the entire subtree is moved by moveToThread). That's not the case here, but it's good practice. Reference: https://www.kdab.com/qobject_ownership_propagate_const/ --- lib/Emulation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Emulation.h b/lib/Emulation.h index 7d2263b5..1217386e 100644 --- a/lib/Emulation.h +++ b/lib/Emulation.h @@ -510,8 +510,8 @@ private slots: private: bool _usesMouse; bool _bracketedPasteMode; - QTimer _bulkTimer1; - QTimer _bulkTimer2; + QTimer _bulkTimer1{this}; + QTimer _bulkTimer2{this}; };