mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
Ladybird: Add keyboard shortcuts for jumping to a specific tab
It's now possible to open a specific tab by using Ctrl/Command plus the number key corresponding to its position in the tab row.
This commit is contained in:
parent
f2f98b7938
commit
d6796d5123
1 changed files with 17 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <QShortcut>
|
||||||
#include <QTabBar>
|
#include <QTabBar>
|
||||||
|
|
||||||
namespace Ladybird {
|
namespace Ladybird {
|
||||||
|
@ -406,6 +407,22 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
|
||||||
m_go_forward_action->setEnabled(false);
|
m_go_forward_action->setEnabled(false);
|
||||||
m_reload_action->setEnabled(false);
|
m_reload_action->setEnabled(false);
|
||||||
|
|
||||||
|
for (int i = 0; i <= 7; ++i) {
|
||||||
|
new QShortcut(QKeySequence(Qt::CTRL | static_cast<Qt::Key>(Qt::Key_1 + i)), this, [this, i] {
|
||||||
|
if (m_tabs_container->count() <= 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_tabs_container->setCurrentIndex(min(i, m_tabs_container->count() - 1));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_9), this, [this] {
|
||||||
|
if (m_tabs_container->count() <= 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_tabs_container->setCurrentIndex(m_tabs_container->count() - 1);
|
||||||
|
});
|
||||||
|
|
||||||
if (!initial_urls.is_empty()) {
|
if (!initial_urls.is_empty()) {
|
||||||
bool is_first_tab = true;
|
bool is_first_tab = true;
|
||||||
for (auto const& url : initial_urls) {
|
for (auto const& url : initial_urls) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue