mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
UI/Qt: Don't hide the location bar URL when creating a tab from a URL
The location bar URL is no longer hidden when creating a new tab or opening a new window that has an associated URL. Conversely, the location bar is now always focused and the URL hidden when creating a window or tab without an associated URL. The location bar is focused when: * Opening the browser from the command line with no URL arguments * Opening a new tab (Ctrl+T) * Opening a new window (Ctrl+N) The location bar is not focused when: * Opening the browser from the command line with one or more URLs * Opening hyperlinks in a new tab * Clicking a hyperlink with `target="_blank"` This matches the behavior of other major browsers.
This commit is contained in:
parent
8a3dc5ea0a
commit
efce3d9671
Notes:
sideshowbarker
2024-07-17 01:23:08 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/efce3d9671 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/228 Issue: https://github.com/LadybirdBrowser/ladybird/issues/227
@ -67,6 +67,13 @@ BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, Web
|
|||||||
auto* window = new BrowserWindow(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path, allow_popups, parent_tab, move(page_index));
|
auto* window = new BrowserWindow(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path, allow_popups, parent_tab, move(page_index));
|
||||||
set_active_window(*window);
|
set_active_window(*window);
|
||||||
window->show();
|
window->show();
|
||||||
|
if (initial_urls.is_empty()) {
|
||||||
|
auto* tab = window->current_tab();
|
||||||
|
if (tab) {
|
||||||
|
tab->set_url_is_hidden(true);
|
||||||
|
tab->focus_location_editor();
|
||||||
|
}
|
||||||
|
}
|
||||||
window->activateWindow();
|
window->activateWindow();
|
||||||
window->raise();
|
window->raise();
|
||||||
return *window;
|
return *window;
|
||||||
|
@ -544,11 +544,12 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::Cook
|
|||||||
QObject::connect(quit_action, &QAction::triggered, this, &QMainWindow::close);
|
QObject::connect(quit_action, &QAction::triggered, this, &QMainWindow::close);
|
||||||
|
|
||||||
QObject::connect(m_new_tab_action, &QAction::triggered, this, [this] {
|
QObject::connect(m_new_tab_action, &QAction::triggered, this, [this] {
|
||||||
new_tab_from_url(ak_url_from_qstring(Settings::the()->new_tab_page()), Web::HTML::ActivateTab::Yes);
|
auto& tab = new_tab_from_url(ak_url_from_qstring(Settings::the()->new_tab_page()), Web::HTML::ActivateTab::Yes);
|
||||||
|
tab.set_url_is_hidden(true);
|
||||||
|
tab.focus_location_editor();
|
||||||
});
|
});
|
||||||
QObject::connect(m_new_window_action, &QAction::triggered, this, [this] {
|
QObject::connect(m_new_window_action, &QAction::triggered, this, [this] {
|
||||||
auto initial_urls = Vector<URL::URL> { ak_url_from_qstring(Settings::the()->new_tab_page()) };
|
(void)static_cast<Ladybird::Application*>(QApplication::instance())->new_window({}, m_cookie_jar, m_web_content_options, m_webdriver_content_ipc_path, m_allow_popups);
|
||||||
(void)static_cast<Ladybird::Application*>(QApplication::instance())->new_window(initial_urls, m_cookie_jar, m_web_content_options, m_webdriver_content_ipc_path, m_allow_popups);
|
|
||||||
});
|
});
|
||||||
QObject::connect(open_file_action, &QAction::triggered, this, &BrowserWindow::open_file);
|
QObject::connect(open_file_action, &QAction::triggered, this, &BrowserWindow::open_file);
|
||||||
QObject::connect(settings_action, &QAction::triggered, this, [this] {
|
QObject::connect(settings_action, &QAction::triggered, this, [this] {
|
||||||
@ -616,8 +617,12 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::Cook
|
|||||||
if (parent_tab) {
|
if (parent_tab) {
|
||||||
new_child_tab(Web::HTML::ActivateTab::Yes, *parent_tab, AK::move(page_index));
|
new_child_tab(Web::HTML::ActivateTab::Yes, *parent_tab, AK::move(page_index));
|
||||||
} else {
|
} else {
|
||||||
for (size_t i = 0; i < initial_urls.size(); ++i) {
|
if (initial_urls.is_empty()) {
|
||||||
new_tab_from_url(initial_urls[i], (i == 0) ? Web::HTML::ActivateTab::Yes : Web::HTML::ActivateTab::No);
|
new_tab_from_url(ak_url_from_qstring(Settings::the()->new_tab_page()), Web::HTML::ActivateTab::Yes);
|
||||||
|
} else {
|
||||||
|
for (size_t i = 0; i < initial_urls.size(); ++i) {
|
||||||
|
new_tab_from_url(initial_urls[i], (i == 0) ? Web::HTML::ActivateTab::Yes : Web::HTML::ActivateTab::No);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,11 +678,9 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab, Tab& par
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_tabs_container->addTab(tab, "New Tab");
|
m_tabs_container->addTab(tab, "New Tab");
|
||||||
if (activate_tab == Web::HTML::ActivateTab::Yes) {
|
if (activate_tab == Web::HTML::ActivateTab::Yes)
|
||||||
m_tabs_container->setCurrentWidget(tab);
|
m_tabs_container->setCurrentWidget(tab);
|
||||||
if (m_tabs_container->count() != 1)
|
|
||||||
tab->set_url_is_hidden(true);
|
|
||||||
}
|
|
||||||
initialize_tab(tab);
|
initialize_tab(tab);
|
||||||
return *tab;
|
return *tab;
|
||||||
}
|
}
|
||||||
@ -691,11 +694,9 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_tabs_container->addTab(tab, "New Tab");
|
m_tabs_container->addTab(tab, "New Tab");
|
||||||
if (activate_tab == Web::HTML::ActivateTab::Yes) {
|
if (activate_tab == Web::HTML::ActivateTab::Yes)
|
||||||
m_tabs_container->setCurrentWidget(tab);
|
m_tabs_container->setCurrentWidget(tab);
|
||||||
if (m_tabs_container->count() != 1)
|
|
||||||
tab->set_url_is_hidden(true);
|
|
||||||
}
|
|
||||||
initialize_tab(tab);
|
initialize_tab(tab);
|
||||||
|
|
||||||
return *tab;
|
return *tab;
|
||||||
@ -770,8 +771,6 @@ void BrowserWindow::initialize_tab(Tab* tab)
|
|||||||
m_tabs_container->setTabIcon(m_tabs_container->indexOf(tab), tab->favicon());
|
m_tabs_container->setTabIcon(m_tabs_container->indexOf(tab), tab->favicon());
|
||||||
create_close_button_for_tab(tab);
|
create_close_button_for_tab(tab);
|
||||||
|
|
||||||
tab->focus_location_editor();
|
|
||||||
|
|
||||||
tab->set_line_box_borders(m_show_line_box_borders_action->isChecked());
|
tab->set_line_box_borders(m_show_line_box_borders_action->isChecked());
|
||||||
tab->set_scripting(m_enable_scripting_action->isChecked());
|
tab->set_scripting(m_enable_scripting_action->isChecked());
|
||||||
tab->set_block_popups(m_block_pop_ups_action->isChecked());
|
tab->set_block_popups(m_block_pop_ups_action->isChecked());
|
||||||
|
@ -66,11 +66,6 @@ static Vector<URL::URL> sanitize_urls(Vector<ByteString> const& raw_urls)
|
|||||||
if (auto url = WebView::sanitize_url(raw_url); url.has_value())
|
if (auto url = WebView::sanitize_url(raw_url); url.has_value())
|
||||||
sanitized_urls.append(url.release_value());
|
sanitized_urls.append(url.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sanitized_urls.is_empty()) {
|
|
||||||
auto new_tab_page = Ladybird::Settings::the()->new_tab_page();
|
|
||||||
sanitized_urls.append(ak_string_from_qstring(new_tab_page));
|
|
||||||
}
|
|
||||||
return sanitized_urls;
|
return sanitized_urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user