gui: mainwindow: Add CTRL(+Shift+)Tab shortcut to switch between tabs

This commit is contained in:
Albert S. 2022-08-14 16:18:15 +02:00
parent 166c051cfb
commit 47c19d121a

Vedi File

@ -343,6 +343,24 @@ bool MainWindow::indexerTabActive()
void MainWindow::processShortcut(int key) void MainWindow::processShortcut(int key)
{ {
if(key == Qt::Key_Tab || key == Qt::Key_Backtab)
{
int tabIndex = ui->tabWidget->currentIndex();
if(key == Qt::Key_Tab)
{
++tabIndex;
}
if(key == Qt::Key_Backtab)
{
--tabIndex;
}
tabIndex = tabIndex % ui->tabWidget->count();
if(tabIndex < 0)
{
tabIndex = ui->tabWidget->count() - 1;
}
ui->tabWidget->setCurrentIndex(tabIndex);
}
if(key == Qt::Key_L) if(key == Qt::Key_L)
{ {
ui->txtSearch->setFocus(); ui->txtSearch->setFocus();
@ -376,7 +394,6 @@ void MainWindow::processShortcut(int key)
{ {
ui->txtSearch->clear(); ui->txtSearch->clear();
} }
return;
} }
if(key == Qt::Key_F) if(key == Qt::Key_F)
{ {
@ -427,12 +444,15 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
if(quit) if(quit)
{ {
qApp->quit(); qApp->quit();
return;
} }
if(event->modifiers() & Qt::ControlModifier) if(event->modifiers() & Qt::ControlModifier)
{ {
processShortcut(event->key()); processShortcut(event->key());
return;
} }
QWidget::keyPressEvent(event); QWidget::keyPressEvent(event);
} }