From 68f14d3425b56366d651591626927e5cf8f3cd76 Mon Sep 17 00:00:00 2001 From: Van Huynh <73868785+vchuynh@users.noreply.github.com> Date: Sun, 7 May 2023 17:10:22 -0400 Subject: [PATCH] Fix Ctrl+Backspace bug after Select All in chat search popup (#4536) --- CHANGELOG.md | 1 + src/widgets/helper/SearchPopup.cpp | 17 +++++++++++++++++ src/widgets/helper/SearchPopup.hpp | 1 + 3 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb27834a3..2f7defb8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Bugfix: Fixed link tooltips not showing unless the thumbnail setting was enabled. (#4597) - Bugfix: Domains starting with `http` are now parsed as links again. (#4598) - Bugfix: Fixed click effects on buttons not being antialiased. (#4473) +- Bugfix: Fixed Ctrl+Backspace not working after Select All in chat search popup. (#4461) - Dev: Added the ability to control the `followRedirect` mode for requests. (#4594) ## 2.4.3 diff --git a/src/widgets/helper/SearchPopup.cpp b/src/widgets/helper/SearchPopup.cpp index 75f80e231..7879e3b92 100644 --- a/src/widgets/helper/SearchPopup.cpp +++ b/src/widgets/helper/SearchPopup.cpp @@ -185,6 +185,22 @@ void SearchPopup::showEvent(QShowEvent *) this->search(); } +bool SearchPopup::eventFilter(QObject *object, QEvent *event) +{ + if (object == this->searchInput_ && event->type() == QEvent::KeyPress) + { + QKeyEvent *keyEvent = static_cast(event); + if (keyEvent->key() == Qt::Key_Backspace && + keyEvent->modifiers() == Qt::ControlModifier && + this->searchInput_->text() == this->searchInput_->selectedText()) + { + this->searchInput_->clear(); + return true; + } + } + return false; +} + void SearchPopup::search() { if (this->snapshot_.size() == 0) @@ -279,6 +295,7 @@ void SearchPopup::initLayout() QPixmap(":/buttons/clearSearch.png")); QObject::connect(this->searchInput_, &QLineEdit::textChanged, this, &SearchPopup::search); + this->searchInput_->installEventFilter(this); } layout1->addLayout(layout2); diff --git a/src/widgets/helper/SearchPopup.hpp b/src/widgets/helper/SearchPopup.hpp index d7caab885..780f9472a 100644 --- a/src/widgets/helper/SearchPopup.hpp +++ b/src/widgets/helper/SearchPopup.hpp @@ -31,6 +31,7 @@ public: protected: virtual void updateWindowTitle(); void showEvent(QShowEvent *event) override; + bool eventFilter(QObject *object, QEvent *event) override; private: void initLayout();