mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-18 19:48:23 -05:00
Improvements for working in the SQL Execution area using keyboard
This addresses two issued mentioned in #2215 # It's possible to focus out of the SQL Editor using Ctrl+PgDown (not used by QScintilla) # Ctrl+Tab and Ctrl+Shift+Tab works in all the widgets in the area and provides the same functionality that the one provided by QTabWidget (switch for- and backwards through the tabs)
This commit is contained in:
@@ -221,6 +221,28 @@ void MainWindow::init()
|
||||
closeSqlTab(ui->tabSqlAreas->currentIndex());
|
||||
});
|
||||
|
||||
// Shortcuts for advancing and going back in the SQL Execution area tabs, independently of the widget which has focus.
|
||||
// This emulates the shortcuts provided by QTabWidget.
|
||||
QShortcut* shortcutNextTab = new QShortcut(QKeySequence(tr("Ctrl+Tab")), ui->tabSqlAreas, nullptr, nullptr, Qt::WidgetWithChildrenShortcut);
|
||||
connect(shortcutNextTab, &QShortcut::activated, this, [this]() {
|
||||
if(ui->tabSqlAreas->currentIndex() == ui->tabSqlAreas->count() - 1)
|
||||
ui->tabSqlAreas->setCurrentIndex(0);
|
||||
else
|
||||
ui->tabSqlAreas->setCurrentIndex(ui->tabSqlAreas->currentIndex() + 1);
|
||||
SqlExecutionArea* sqlWidget = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->currentWidget());
|
||||
sqlWidget->getEditor()->setFocus();
|
||||
});
|
||||
|
||||
QShortcut* shortcutPreviousTab = new QShortcut(QKeySequence(tr("Ctrl+Shift+Tab")), ui->tabSqlAreas, nullptr, nullptr, Qt::WidgetWithChildrenShortcut);
|
||||
connect(shortcutPreviousTab, &QShortcut::activated, this, [this]() {
|
||||
if(ui->tabSqlAreas->currentIndex() == 0)
|
||||
ui->tabSqlAreas->setCurrentIndex(ui->tabSqlAreas->count() - 1);
|
||||
else
|
||||
ui->tabSqlAreas->setCurrentIndex(ui->tabSqlAreas->currentIndex() - 1);
|
||||
SqlExecutionArea* sqlWidget = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->currentWidget());
|
||||
sqlWidget->getEditor()->setFocus();
|
||||
});
|
||||
|
||||
// Create the actions for the recently opened dbs list
|
||||
for(int i = 0; i < MaxRecentFiles; ++i) {
|
||||
recentFileActs[i] = new QAction(this);
|
||||
|
||||
@@ -41,6 +41,9 @@ SqlTextEdit::SqlTextEdit(QWidget* parent) :
|
||||
QShortcut* shortcutToggleComment = new QShortcut(QKeySequence(tr("Ctrl+/")), this, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
connect(shortcutToggleComment, &QShortcut::activated, this, &SqlTextEdit::toggleBlockComment);
|
||||
|
||||
QShortcut* shortcutFocusOut = new QShortcut(QKeySequence(tr("Ctrl+PgDown")), this, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
connect(shortcutFocusOut, &QShortcut::activated, this, &SqlTextEdit::transferFocus);
|
||||
|
||||
// Do rest of initialisation
|
||||
reloadSettings();
|
||||
}
|
||||
@@ -133,3 +136,9 @@ void SqlTextEdit::toggleBlockComment()
|
||||
}
|
||||
endUndoAction();
|
||||
}
|
||||
|
||||
void SqlTextEdit::transferFocus()
|
||||
{
|
||||
// We need two jumps to get to the Table Results widget
|
||||
nextInFocusChain()->nextInFocusChain()->setFocus();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ public:
|
||||
|
||||
static SqlUiLexer* sqlLexer;
|
||||
|
||||
private:
|
||||
void transferFocus();
|
||||
|
||||
public slots:
|
||||
void reloadSettings();
|
||||
void toggleBlockComment();
|
||||
|
||||
Reference in New Issue
Block a user