summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-04-27 14:04:13 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-04-27 14:04:13 +0300
commit2c6192d08f8f609c32adfb56c628dc86b43c8c54 (patch)
treea2375f2d6193ebb7404d2e0b8555a25418da9fff /src
parentImprove room searching (diff)
downloadnheko-2c6192d08f8f609c32adfb56c628dc86b43c8c54.tar.xz
Fix clicking on room list suggestions
Diffstat (limited to 'src')
-rw-r--r--src/QuickSwitcher.cc11
-rw-r--r--src/SuggestionsPopup.cpp30
2 files changed, 25 insertions, 16 deletions
diff --git a/src/QuickSwitcher.cc b/src/QuickSwitcher.cc

index d406a6de..3596a8c4 100644 --- a/src/QuickSwitcher.cc +++ b/src/QuickSwitcher.cc
@@ -103,11 +103,13 @@ QuickSwitcher::QuickSwitcher(QSharedPointer<Cache> cache, QWidget *parent) &RoomSearchInput::selectPreviousCompletion, &popup_, &SuggestionsPopup::selectPreviousSuggestion); - connect(&popup_, &SuggestionsPopup::itemSelected, this, &QuickSwitcher::roomSelected); + connect(&popup_, &SuggestionsPopup::itemSelected, this, [this](const QString &room_id) { + reset(); + emit roomSelected(room_id); + }); connect(roomSearch_, &RoomSearchInput::hiding, this, [this]() { popup_.hide(); }); connect(roomSearch_, &QLineEdit::returnPressed, this, [this]() { - emit closing(); - roomSearch_->clear(); + reset(); popup_.selectHoveredSuggestion<RoomItem>(); }); } @@ -125,8 +127,7 @@ void QuickSwitcher::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Escape) { - roomSearch_->clear(); event->accept(); - emit closing(); + reset(); } } diff --git a/src/SuggestionsPopup.cpp b/src/SuggestionsPopup.cpp
index cb569ddf..86586c92 100644 --- a/src/SuggestionsPopup.cpp +++ b/src/SuggestionsPopup.cpp
@@ -38,17 +38,6 @@ PopupItem::paintEvent(QPaintEvent *) p.fillRect(rect(), hoverColor_); } -void -PopupItem::mousePressEvent(QMouseEvent *event) -{ - if (event->buttons() != Qt::RightButton) - // TODO: should be abstracted. - emit clicked( - Cache::displayName(ChatPage::instance()->currentRoom(), selectedText())); - - QWidget::mousePressEvent(event); -} - UserItem::UserItem(QWidget *parent, const QString &user_id) : PopupItem(parent) , userId_{user_id} @@ -77,6 +66,16 @@ UserItem::UserItem(QWidget *parent, const QString &user_id) [this](const QImage &img) { avatar_->setImage(img); }); } +void +UserItem::mousePressEvent(QMouseEvent *event) +{ + if (event->buttons() != Qt::RightButton) + emit clicked( + Cache::displayName(ChatPage::instance()->currentRoom(), selectedText())); + + QWidget::mousePressEvent(event); +} + RoomItem::RoomItem(QWidget *parent, const RoomSearchResult &res) : PopupItem(parent) , roomId_{QString::fromStdString(res.room_id)} @@ -97,6 +96,15 @@ RoomItem::RoomItem(QWidget *parent, const RoomSearchResult &res) avatar_->setImage(res.img); } +void +RoomItem::mousePressEvent(QMouseEvent *event) +{ + if (event->buttons() != Qt::RightButton) + emit clicked(selectedText()); + + QWidget::mousePressEvent(event); +} + SuggestionsPopup::SuggestionsPopup(QWidget *parent) : QWidget(parent) {