From e159548fc99d2c611da98d930e8c7885e97d11ed Mon Sep 17 00:00:00 2001 From: nixo Date: Sat, 31 Oct 2020 16:29:46 +0100 Subject: Switch between tabs with Alt-N --- src/mainwindow.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ee79efa..706394e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -73,6 +73,22 @@ MainWindow::MainWindow(QApplication * app, QWidget *parent) : connect(sc, &QShortcut::activated, this, &MainWindow::on_focus_inputbar); } + { + std::string prefix = "Alt+"; + for (char tab = '0'; tab <= '9'; ++tab) { + std::string shortcut = prefix + tab; + QShortcut * sc = new QShortcut(QKeySequence(shortcut.c_str()), this); + connect(sc, &QShortcut::activated, this, + [this, tab](){ + // 1-9 goes from the first to the n-th tab, 0 goes to the last one + this->ui->browser_tabs-> + setCurrentIndex((tab == '0' ? + this->ui->browser_tabs->count() + : tab-'0') - 1); + }); + } + } + this->ui->favourites_view->setContextMenuPolicy(Qt::CustomContextMenu); this->ui->history_view->setContextMenuPolicy(Qt::CustomContextMenu); } -- cgit v1.2.3