diff --git a/CHANGELOG.md b/CHANGELOG.md index 439dbda1ce6..f9ecf75431c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - Bugfix: Fixed support for Windows 11 Snap layouts. (#4994) - Bugfix: Fixed some windows appearing between screens. (#4797) - Bugfix: Fixed a bug on Wayland where tooltips would spawn as separate windows instead of behaving like tooltips. (#4998) +- Bugfix: Fixes to section deletion in text input fields. (#5013) - Bugfix: Show user text input within watch streak notices. (#5029) - Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978) - Dev: Change clang-format from v14 to v16. (#4929) diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index 97251a28774..0c9aebe309c 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -227,6 +227,7 @@ EmotePopup::EmotePopup(QWidget *parent) this->search_->setClearButtonEnabled(true); this->search_->findChild()->setIcon( QPixmap(":/buttons/clearSearch.png")); + this->search_->installEventFilter(this); layout2->addWidget(this->search_); layout->addLayout(layout2); @@ -448,6 +449,21 @@ void EmotePopup::loadChannel(ChannelPtr channel) } } +bool EmotePopup::eventFilter(QObject *object, QEvent *event) +{ + if (object == this->search_ && event->type() == QEvent::KeyPress) + { + auto *keyEvent = dynamic_cast(event); + if (keyEvent == QKeySequence::DeleteStartOfWord && + this->search_->selectionLength() > 0) + { + this->search_->backspace(); + return true; + } + } + return false; +} + void EmotePopup::filterTwitchEmotes(std::shared_ptr searchChannel, const QString &searchText) { diff --git a/src/widgets/dialogs/EmotePopup.hpp b/src/widgets/dialogs/EmotePopup.hpp index 71a20a0a863..43dbb45c626 100644 --- a/src/widgets/dialogs/EmotePopup.hpp +++ b/src/widgets/dialogs/EmotePopup.hpp @@ -46,6 +46,7 @@ class EmotePopup : public BasePopup const QString &searchText); void filterEmotes(const QString &text); void addShortcuts() override; + bool eventFilter(QObject *object, QEvent *event) override; }; } // namespace chatterino diff --git a/src/widgets/dialogs/SelectChannelDialog.cpp b/src/widgets/dialogs/SelectChannelDialog.cpp index 391c85457e9..65aefe8aaf2 100644 --- a/src/widgets/dialogs/SelectChannelDialog.cpp +++ b/src/widgets/dialogs/SelectChannelDialog.cpp @@ -497,6 +497,12 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, widget->previousInFocusChain()->setFocus(); return true; } + else if (event_key == QKeySequence::DeleteStartOfWord && + this->dialog->ui_.twitch.channelName->selectionLength() > 0) + { + this->dialog->ui_.twitch.channelName->backspace(); + return true; + } else { return false; diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index 2fcfa31665d..9d98913e8bd 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -113,6 +113,7 @@ void SettingsDialog::initUi() edit->setClearButtonEnabled(true); edit->findChild()->setIcon( QPixmap(":/buttons/clearSearch.png")); + this->ui_.search->installEventFilter(this); QObject::connect(edit.getElement(), &QLineEdit::textChanged, this, &SettingsDialog::filterElements); @@ -206,6 +207,21 @@ void SettingsDialog::setElementFilter(const QString &query) this->ui_.search->setText(query); } +bool SettingsDialog::eventFilter(QObject *object, QEvent *event) +{ + if (object == this->ui_.search && event->type() == QEvent::KeyPress) + { + auto *keyEvent = dynamic_cast(event); + if (keyEvent == QKeySequence::DeleteStartOfWord && + this->ui_.search->selectionLength() > 0) + { + this->ui_.search->backspace(); + return true; + } + } + return false; +} + void SettingsDialog::addTabs() { this->ui_.tabContainer->setSpacing(0); diff --git a/src/widgets/dialogs/SettingsDialog.hpp b/src/widgets/dialogs/SettingsDialog.hpp index 38b113d261c..9e574b68899 100644 --- a/src/widgets/dialogs/SettingsDialog.hpp +++ b/src/widgets/dialogs/SettingsDialog.hpp @@ -59,6 +59,7 @@ class SettingsDialog : public BaseWindow void selectTab(SettingsTabId id); void filterElements(const QString &query); void setElementFilter(const QString &query); + bool eventFilter(QObject *object, QEvent *event) override; void onOkClicked(); void onCancelClicked(); diff --git a/src/widgets/helper/SearchPopup.cpp b/src/widgets/helper/SearchPopup.cpp index b3446930805..2ca8b41bc5e 100644 --- a/src/widgets/helper/SearchPopup.cpp +++ b/src/widgets/helper/SearchPopup.cpp @@ -202,11 +202,10 @@ 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()) + if (keyEvent == QKeySequence::DeleteStartOfWord && + this->searchInput_->selectionLength() > 0) { - this->searchInput_->clear(); + this->searchInput_->backspace(); return true; } }