Fixes to ctrl+backspace behavior (#5013)

This commit is contained in:
Herman Stornes
2023-12-16 14:40:05 +01:00
committed by GitHub
parent 918b8ca4bd
commit b78b57b454
7 changed files with 44 additions and 4 deletions
+16
View File
@@ -227,6 +227,7 @@ EmotePopup::EmotePopup(QWidget *parent)
this->search_->setClearButtonEnabled(true);
this->search_->findChild<QAbstractButton *>()->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<QKeyEvent *>(event);
if (keyEvent == QKeySequence::DeleteStartOfWord &&
this->search_->selectionLength() > 0)
{
this->search_->backspace();
return true;
}
}
return false;
}
void EmotePopup::filterTwitchEmotes(std::shared_ptr<Channel> searchChannel,
const QString &searchText)
{
+1
View File
@@ -46,6 +46,7 @@ private:
const QString &searchText);
void filterEmotes(const QString &text);
void addShortcuts() override;
bool eventFilter(QObject *object, QEvent *event) override;
};
} // namespace chatterino
@@ -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;
+16
View File
@@ -113,6 +113,7 @@ void SettingsDialog::initUi()
edit->setClearButtonEnabled(true);
edit->findChild<QAbstractButton *>()->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<QKeyEvent *>(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);
+1
View File
@@ -59,6 +59,7 @@ private:
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();