Close search popup window on Escape pressed

This commit is contained in:
Alexandr Kondratev 2019-05-05 20:19:47 +03:00 committed by pajlada
parent a3f6d2b773
commit 14eb302c3d
2 changed files with 21 additions and 8 deletions

View file

@ -17,6 +17,24 @@ SearchPopup::SearchPopup()
this->resize(400, 600); this->resize(400, 600);
} }
void SearchPopup::setChannel(ChannelPtr channel)
{
this->snapshot_ = channel->getMessageSnapshot();
this->performSearch();
this->setWindowTitle("Searching in " + channel->getName() + "s history");
}
void SearchPopup::keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Escape) {
this->close();
return;
}
BaseWidget::keyPressEvent(e);
}
void SearchPopup::initLayout() void SearchPopup::initLayout()
{ {
// VBOX // VBOX
@ -60,14 +78,6 @@ void SearchPopup::initLayout()
} }
} }
void SearchPopup::setChannel(ChannelPtr channel)
{
this->snapshot_ = channel->getMessageSnapshot();
this->performSearch();
this->setWindowTitle("Searching in " + channel->getName() + "s history");
}
void SearchPopup::performSearch() void SearchPopup::performSearch()
{ {
QString text = searchInput_->text(); QString text = searchInput_->text();

View file

@ -22,6 +22,9 @@ public:
void setChannel(std::shared_ptr<Channel> channel); void setChannel(std::shared_ptr<Channel> channel);
protected:
void keyPressEvent(QKeyEvent *e) override;
private: private:
void initLayout(); void initLayout();
void performSearch(); void performSearch();