gui: handle ESC (to quit) and CTRL+L (focus on searchbar and select content)

此提交包含在:
2018-12-29 20:21:13 +01:00
父節點 5081f559df
當前提交 4b3b862e11
共有 3 個檔案被更改,包括 25 行新增3 行删除

查看文件

@ -58,6 +58,26 @@ bool MainWindow::pdfTabActive()
return ui->tabWidget->currentIndex() == 1;
}
void MainWindow::keyPressEvent(QKeyEvent *event)
{
bool quit = ((event->modifiers() & Qt::ControlModifier && event->key() == Qt::Key_Q) || event->key() == Qt::Key_Escape);
if(quit)
{
qApp->quit();
}
if(event->modifiers() & Qt::ControlModifier)
{
if(event->key() == Qt::Key_L)
{
ui->txtSearch->setFocus();
ui->txtSearch->selectAll();
}
}
QWidget::keyPressEvent(event);
}
void MainWindow::tabChanged()
{
if(pdfTabActive())