Add Ctrl+K shortcut for focusing search text

This commit is contained in:
Christoffer Klang 2013-08-11 00:47:41 +02:00
parent 22cfff3e69
commit a4125be39f
2 changed files with 13 additions and 0 deletions

View File

@ -108,6 +108,9 @@ MainWindow::MainWindow(QWidget *parent) :
// initialise ui
ui->setupUi(this);
setupShortcuts();
restoreGeometry(settings.value("geometry").toByteArray());
ui->splitter->restoreState(settings.value("splitter").toByteArray());
connect(ui->splitter, &QSplitter::splitterMoved, [=](int, int) {
@ -434,6 +437,15 @@ void MainWindow::bringToFront(bool withHack)
#endif
}
void MainWindow::setupShortcuts()
{
QShortcut* focusSearch = new QShortcut(QKeySequence("Ctrl+K"), this);
focusSearch->setContext(Qt::ApplicationShortcut);
connect(focusSearch, &QShortcut::activated, [=]() {
ui->lineEdit->setFocus();
});
}
void MainWindow::setHotKey(const QKeySequence& hotKey_) {
// platform-specific code for global key grabbing
#ifdef WIN32

View File

@ -51,6 +51,7 @@ protected:
settings.setValue("geometry", saveGeometry());
QMainWindow::closeEvent(event);
}
void setupShortcuts();
};
#endif // MAINWINDOW_H