Skip to content
This repository has been archived by the owner on Dec 25, 2022. It is now read-only.

Laydibird/UI: select location when you change tab #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ BrowserWindow::BrowserWindow(int webdriver_fd_passing_socket)
setWindowTitle(QString("%1 - Ladybird").arg(m_tabs_container->tabText(index)));
setWindowIcon(m_tabs_container->tabIcon(index));
m_current_tab = verify_cast<Tab>(m_tabs_container->widget(index));
m_current_tab->select_location();
});
QObject::connect(m_tabs_container, &QTabWidget::tabCloseRequested, this, &BrowserWindow::close_tab);
QObject::connect(close_current_tab_action, &QAction::triggered, this, &BrowserWindow::close_current_tab);
Expand Down Expand Up @@ -356,8 +357,11 @@ void BrowserWindow::tab_title_changed(int index, QString const& title)
{
if (title.isEmpty()) {
m_tabs_container->setTabText(index, "...");
if (m_tabs_container->currentIndex() == index)
if (m_tabs_container->currentIndex() == index) {
setWindowTitle("Ladybird");
if (m_current_tab->current_location() == "about:blank")
m_current_tab->select_location();
}
} else {
m_tabs_container->setTabText(index, title);
if (m_tabs_container->currentIndex() == index)
Expand Down
2 changes: 2 additions & 0 deletions Tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Tab final : public QWidget {
void navigate(QString);

void debug_request(String const& request, String const& argument);
const QString current_location()const { return m_location_edit->text(); }

public slots:
void focus_location_editor();
Expand All @@ -39,6 +40,7 @@ public slots:
void forward();
void home();
void reload();
void select_location(){ m_location_edit->selectAll(); }

signals:
void title_changed(int id, QString);
Expand Down