diff --git a/Ladybird/Icons/close.tvg b/Ladybird/Icons/close.tvg new file mode 100644 index 00000000000..b8c7d45c8fb Binary files /dev/null and b/Ladybird/Icons/close.tvg differ diff --git a/Ladybird/Qt/BrowserWindow.cpp b/Ladybird/Qt/BrowserWindow.cpp index 5a7c042025d..08b1d7d1714 100644 --- a/Ladybird/Qt/BrowserWindow.cpp +++ b/Ladybird/Qt/BrowserWindow.cpp @@ -604,6 +604,7 @@ void BrowserWindow::initialize_tab(Tab* tab) }; m_tabs_container->setTabIcon(m_tabs_container->indexOf(tab), tab->favicon()); + create_close_button_for_tab(tab); tab->focus_location_editor(); } @@ -658,6 +659,22 @@ void BrowserWindow::tab_favicon_changed(int index, QIcon const& icon) m_tabs_container->setTabIcon(index, icon); } +void BrowserWindow::create_close_button_for_tab(Tab* tab) +{ + auto index = m_tabs_container->indexOf(tab); + m_tabs_container->setTabIcon(index, tab->favicon()); + + auto* button = new TabBarButton(create_tvg_icon_with_theme_colors("close", palette())); + auto position = audio_button_position_for_tab(index) == QTabBar::LeftSide ? QTabBar::RightSide : QTabBar::LeftSide; + + connect(button, &QPushButton::clicked, this, [this, tab]() { + auto index = m_tabs_container->indexOf(tab); + close_tab(index); + }); + + m_tabs_container->tabBar()->setTabButton(index, position, button); +} + void BrowserWindow::tab_audio_play_state_changed(int index, Web::HTML::AudioPlayState play_state) { auto* tab = verify_cast(m_tabs_container->widget(index)); diff --git a/Ladybird/Qt/BrowserWindow.h b/Ladybird/Qt/BrowserWindow.h index a5a651abe89..e4caab42ba3 100644 --- a/Ladybird/Qt/BrowserWindow.h +++ b/Ladybird/Qt/BrowserWindow.h @@ -129,6 +129,8 @@ private: } } + void create_close_button_for_tab(Tab*); + QIcon icon_for_page_mute_state(Tab&) const; QString tool_tip_for_page_mute_state(Tab&) const; QTabBar::ButtonPosition audio_button_position_for_tab(int tab_index) const; diff --git a/Ladybird/Qt/ladybird.qrc b/Ladybird/Qt/ladybird.qrc index 65b5ec87889..b4c17459bf1 100644 --- a/Ladybird/Qt/ladybird.qrc +++ b/Ladybird/Qt/ladybird.qrc @@ -2,6 +2,7 @@ ../Icons/ladybird.png ../Icons/back.tvg + ../Icons/close.tvg ../Icons/forward.tvg ../Icons/reload.tvg