mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
Ladybird: Add URL and 'open in background' parameters to new_tab()
This will avoid loading starting about:blank page in places when we know exactly what we want to load. The opening in background part might be useful for future things like file drops and right-click open in new tab.
This commit is contained in:
parent
194ddca24f
commit
731fec525e
2 changed files with 16 additions and 8 deletions
|
@ -304,7 +304,9 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive
|
||||||
debug_request("same-origin-policy", state ? "on" : "off");
|
debug_request("same-origin-policy", state ? "on" : "off");
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(new_tab_action, &QAction::triggered, this, &BrowserWindow::new_tab);
|
QObject::connect(new_tab_action, &QAction::triggered, this, [this] {
|
||||||
|
new_tab("about:blank", Activate::Yes);
|
||||||
|
});
|
||||||
QObject::connect(settings_action, &QAction::triggered, this, [this] {
|
QObject::connect(settings_action, &QAction::triggered, this, [this] {
|
||||||
new SettingsDialog(this);
|
new SettingsDialog(this);
|
||||||
});
|
});
|
||||||
|
@ -317,7 +319,8 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive
|
||||||
QObject::connect(m_tabs_container, &QTabWidget::tabCloseRequested, this, &BrowserWindow::close_tab);
|
QObject::connect(m_tabs_container, &QTabWidget::tabCloseRequested, this, &BrowserWindow::close_tab);
|
||||||
QObject::connect(close_current_tab_action, &QAction::triggered, this, &BrowserWindow::close_current_tab);
|
QObject::connect(close_current_tab_action, &QAction::triggered, this, &BrowserWindow::close_current_tab);
|
||||||
|
|
||||||
new_tab();
|
// We need to load *something* to make the JS console usable.
|
||||||
|
new_tab("about:blank", Activate::Yes);
|
||||||
|
|
||||||
setCentralWidget(m_tabs_container);
|
setCentralWidget(m_tabs_container);
|
||||||
}
|
}
|
||||||
|
@ -329,7 +332,7 @@ void BrowserWindow::debug_request(DeprecatedString const& request, DeprecatedStr
|
||||||
m_current_tab->debug_request(request, argument);
|
m_current_tab->debug_request(request, argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::new_tab()
|
void BrowserWindow::new_tab(QString const& url, Activate activate)
|
||||||
{
|
{
|
||||||
auto tab = make<Tab>(this, m_webdriver_content_ipc_path);
|
auto tab = make<Tab>(this, m_webdriver_content_ipc_path);
|
||||||
auto tab_ptr = tab.ptr();
|
auto tab_ptr = tab.ptr();
|
||||||
|
@ -340,6 +343,7 @@ void BrowserWindow::new_tab()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tabs_container->addTab(tab_ptr, "New Tab");
|
m_tabs_container->addTab(tab_ptr, "New Tab");
|
||||||
|
if (activate == Activate::Yes)
|
||||||
m_tabs_container->setCurrentWidget(tab_ptr);
|
m_tabs_container->setCurrentWidget(tab_ptr);
|
||||||
|
|
||||||
QObject::connect(tab_ptr, &Tab::title_changed, this, &BrowserWindow::tab_title_changed);
|
QObject::connect(tab_ptr, &Tab::title_changed, this, &BrowserWindow::tab_title_changed);
|
||||||
|
@ -367,12 +371,11 @@ void BrowserWindow::new_tab()
|
||||||
|
|
||||||
tab_ptr->focus_location_editor();
|
tab_ptr->focus_location_editor();
|
||||||
|
|
||||||
// This is a hack to make the JS console usable in new windows.
|
// We *don't* load the initial page if we are connected to a WebDriver, as the Set URL command may come in very
|
||||||
// Note we *don't* load the initial page if we are connected to a WebDriver, as the Set URL command may come in very
|
|
||||||
// quickly, and become replaced by this load.
|
// quickly, and become replaced by this load.
|
||||||
if (m_webdriver_content_ipc_path.is_empty()) {
|
if (m_webdriver_content_ipc_path.is_empty()) {
|
||||||
// We make it HistoryNavigation so that the initial page doesn't get added to the history.
|
// We make it HistoryNavigation so that the initial page doesn't get added to the history.
|
||||||
tab_ptr->navigate("about:blank", Tab::LoadType::HistoryNavigation);
|
tab_ptr->navigate(url, Tab::LoadType::HistoryNavigation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,15 @@ public:
|
||||||
|
|
||||||
int tab_index(Tab*);
|
int tab_index(Tab*);
|
||||||
|
|
||||||
|
enum class Activate {
|
||||||
|
Yes,
|
||||||
|
No,
|
||||||
|
};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void tab_title_changed(int index, QString const&);
|
void tab_title_changed(int index, QString const&);
|
||||||
void tab_favicon_changed(int index, QIcon icon);
|
void tab_favicon_changed(int index, QIcon icon);
|
||||||
void new_tab();
|
void new_tab(QString const&, Activate);
|
||||||
void close_tab(int index);
|
void close_tab(int index);
|
||||||
void close_current_tab();
|
void close_current_tab();
|
||||||
void open_next_tab();
|
void open_next_tab();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue