Skip to content

Commit

Permalink
Issue zealdocs#1033: Deduplicate search bar focus code.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcomella committed Nov 11, 2018
1 parent 1062848 commit 2279a93
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/libs/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ MainWindow::MainWindow(Core::Application *app, QWidget *parent) :

// Setup application wide shortcuts.
// Focus search bar.
QShortcut *shortcut = new QShortcut(QStringLiteral("Ctrl+K"), this);
connect(shortcut, &QShortcut::activated,
ui->lineEdit, static_cast<void (SearchEdit::*)()>(&SearchEdit::setFocus));

shortcut = new QShortcut(QStringLiteral("Ctrl+L"), this);
connect(shortcut, &QShortcut::activated,
ui->lineEdit, static_cast<void (SearchEdit::*)()>(&SearchEdit::setFocus));
QShortcut *shortcut;
QStringList searchBarFocusShortcuts;
searchBarFocusShortcuts << "Ctrl+K" << "Ctrl+L";
for (auto it = searchBarFocusShortcuts.begin(); it != searchBarFocusShortcuts.end(); ++it) {
shortcut = new QShortcut(*it, this);
connect(shortcut, &QShortcut::activated,
ui->lineEdit, static_cast<void (SearchEdit::*)()>(&SearchEdit::setFocus));
}

// Duplicate current tab.
shortcut = new QShortcut(QStringLiteral("Ctrl+Alt+T"), this);
Expand Down

0 comments on commit 2279a93

Please sign in to comment.