mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03: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
Notes:
sideshowbarker
2024-07-16 23:52:22 +09:00
Author: https://github.com/adamjoer Commit: https://github.com/SerenityOS/serenity/commit/d6796d5123 Pull-request: https://github.com/SerenityOS/serenity/pull/21166
@ -25,6 +25,7 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QInputDialog>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QShortcut>
|
||||
#include <QTabBar>
|
||||
|
||||
namespace Ladybird {
|
||||
@ -406,6 +407,22 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
|
||||
m_go_forward_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()) {
|
||||
bool is_first_tab = true;
|
||||
for (auto const& url : initial_urls) {
|
||||
|
Loading…
Reference in New Issue
Block a user