Skip to content

Commit

Permalink
Add hotkey for search-help
Browse files Browse the repository at this point in the history
Add a new hotkey (CTRL+J) for toggling on/off
the search-help when you are in the search field
Fixes: #4100
  • Loading branch information
0xdeadbeer committed Apr 15, 2024
1 parent 6481ecc commit d4312f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/gui/SearchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <QKeyEvent>
#include <QMenu>
#include <QShortcut>
#include <QToolButton>

#include "core/SignalMultiplexer.h"
Expand All @@ -43,6 +44,8 @@ SearchWidget::SearchWidget(QWidget* parent)
m_searchTimer->setSingleShot(true);
m_clearSearchTimer->setSingleShot(true);

new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_J), this, SLOT(toggleHelpShortcut()));

connect(m_ui->searchEdit, SIGNAL(textChanged(QString)), SLOT(startSearchTimer()));
connect(m_ui->helpIcon, SIGNAL(triggered()), SLOT(toggleHelp()));
connect(m_ui->searchIcon, SIGNAL(triggered()), SLOT(showSearchMenu()));
Expand Down Expand Up @@ -217,6 +220,17 @@ void SearchWidget::clearSearch()
emit searchCanceled();
}

void SearchWidget::toggleHelpShortcut()
{
if (m_helpWidget->isVisible()) {
toggleHelp();
}

if (m_ui->searchEdit->hasFocus()) {
toggleHelp();
}
}

void SearchWidget::toggleHelp()
{
if (m_helpWidget->isVisible()) {
Expand Down
1 change: 1 addition & 0 deletions src/gui/SearchWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private slots:
void updateCaseSensitive();
void updateLimitGroup();
void toggleHelp();
void toggleHelpShortcut();
void showSearchMenu();
void resetSearchClearTimer();

Expand Down

0 comments on commit d4312f9

Please sign in to comment.