+ ActionCollection *coll = QtUi::actionCollection("General");
+
+ QAction *toggleSearchBar = coll->action("ToggleSearchBar");
+ connect(toggleSearchBar, &QAction::toggled, this, &QWidget::setVisible);
+
+ auto *hideSearchBar = new Action{{}, this, toggleSearchBar, &QAction::setChecked};
+ hideSearchBar->setShortcut(Qt::Key_Escape);
+ hideSearchBar->setShortcutConfigurable(false);
+ coll->addAction("HideSearchBar", hideSearchBar);
+
+ connect(ui.hideButton, &QAbstractButton::clicked, toggleSearchBar, &QAction::toggle);
+ connect(ui.searchEditLine, &QLineEdit::textChanged, this, &ChatViewSearchBar::delaySearch);
+ connect(&_searchDelayTimer, &QTimer::timeout, this, &ChatViewSearchBar::search);
+}
+
+
+void ChatViewSearchBar::setVisible(bool visible)
+{
+ // clearing the search field also removes the highlight items from the scene
+ // this should be done before the SearchBar is hidden, as the hiding triggers
+ // a resize event which can lead to strange side effects.
+ ui.searchEditLine->clear();
+ QWidget::setVisible(visible);
+ if (visible)
+ ui.searchEditLine->setFocus();
+ else
+ emit hidden();