From c1c1ad867882b0bb74212c5327535bd42b078a8a Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 2 Apr 2024 12:52:03 -0400 Subject: [PATCH] Ladybird/Qt: Prevent adding multiple audio state buttons If the left-hand side of the tab is already occupied with an audio state button, we would add a second button to the right-hand side. Prevent that by checking if the occupant is our audio state button. --- Ladybird/Qt/BrowserWindow.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Ladybird/Qt/BrowserWindow.cpp b/Ladybird/Qt/BrowserWindow.cpp index c7f50edd11f..56ec17bdd8b 100644 --- a/Ladybird/Qt/BrowserWindow.cpp +++ b/Ladybird/Qt/BrowserWindow.cpp @@ -671,6 +671,7 @@ void BrowserWindow::tab_audio_play_state_changed(int index, Web::HTML::AudioPlay case Web::HTML::AudioPlayState::Playing: auto* button = new QPushButton(icon_for_page_mute_state(*tab), {}); button->setToolTip(tool_tip_for_page_mute_state(*tab)); + button->setObjectName("LadybirdAudioState"); button->setFlat(true); button->resize({ 20, 20 }); @@ -721,8 +722,11 @@ QString BrowserWindow::tool_tip_for_page_mute_state(Tab& tab) const QTabBar::ButtonPosition BrowserWindow::audio_button_position_for_tab(int tab_index) const { - if (m_tabs_container->tabBar()->tabButton(tab_index, QTabBar::LeftSide)) - return QTabBar::RightSide; + if (auto* button = m_tabs_container->tabBar()->tabButton(tab_index, QTabBar::LeftSide)) { + if (button->objectName() != "LadybirdAudioState") + return QTabBar::RightSide; + } + return QTabBar::LeftSide; }